diff --git a/src/frontend/app/avis/avis-workflow.component.ts b/src/frontend/app/avis/avis-workflow.component.ts index 7d5d5ca7829147f7b84c2d2430d4fce5b272a370..2af2852be81bdee928cae15009b4aa8f3fc8052c 100644 --- a/src/frontend/app/avis/avis-workflow.component.ts +++ b/src/frontend/app/avis/avis-workflow.component.ts @@ -236,30 +236,33 @@ export class AvisWorkflowComponent implements OnInit { } saveAvisWorkflow() { - if (this.avisWorkflow.items.length === 0) { - this.http.delete(`../../rest/resources/${this.resId}/circuits/opinionCircuit`).pipe( - tap(() => { - this.avisWorkflowClone = JSON.parse(JSON.stringify(this.avisWorkflow.items)); - this.notify.success(this.lang.avisWorkflowDeleted); - }), - catchError((err: any) => { - this.notify.handleSoftErrors(err); - return of(false); - }) - ).subscribe(); - } else { - this.http.put(`../../rest/listinstances`, [{ resId: this.resId, listInstances: this.avisWorkflow.items }]).pipe( - tap((data: any) => { - this.avisWorkflowClone = JSON.parse(JSON.stringify(this.avisWorkflow.items)); - this.notify.success(this.lang.avisWorkflowUpdated); - }), - catchError((err: any) => { - this.notify.handleSoftErrors(err); - return of(false); - }) - ).subscribe(); - } - + return new Promise((resolve, reject) => { + if (this.avisWorkflow.items.length === 0) { + this.http.delete(`../../rest/resources/${this.resId}/circuits/opinionCircuit`).pipe( + tap(() => { + this.avisWorkflowClone = JSON.parse(JSON.stringify(this.avisWorkflow.items)); + this.notify.success(this.lang.avisWorkflowDeleted); + resolve(true); + }), + catchError((err: any) => { + this.notify.handleSoftErrors(err); + return of(false); + }) + ).subscribe(); + } else { + this.http.put(`../../rest/listinstances`, [{ resId: this.resId, listInstances: this.avisWorkflow.items }]).pipe( + tap((data: any) => { + this.avisWorkflowClone = JSON.parse(JSON.stringify(this.avisWorkflow.items)); + this.notify.success(this.lang.avisWorkflowUpdated); + resolve(true); + }), + catchError((err: any) => { + this.notify.handleSoftErrors(err); + return of(false); + }) + ).subscribe(); + } + }); } addItemToWorkflow(item: any) { diff --git a/src/frontend/app/diffusions/diffusions-list.component.ts b/src/frontend/app/diffusions/diffusions-list.component.ts index 117d7275711e3f2d5c0d0e173805e41e09011eef..3dea60c99bc7d6009b12a4888a872aa270eccf96 100644 --- a/src/frontend/app/diffusions/diffusions-list.component.ts +++ b/src/frontend/app/diffusions/diffusions-list.component.ts @@ -294,26 +294,29 @@ export class DiffusionsListComponent implements OnInit { } saveListinstance() { - const listInstance: any[] = [ - { - resId: this.resId, - listInstances: this.getCurrentListinstance() - } - ]; - this.http.put('../../rest/listinstances', listInstance).pipe( - tap((data: any) => { - if (data && data.errors != null) { - this.notify.error(data.errors); - } else { - this.diffListClone = JSON.parse(JSON.stringify(this.getCurrentListinstance())); - this.notify.success(this.lang.diffusionListUpdated); + return new Promise((resolve, reject) => { + const listInstance: any[] = [ + { + resId: this.resId, + listInstances: this.getCurrentListinstance() } - }), - catchError((err: any) => { - this.notify.handleErrors(err); - return of(false); - }) - ).subscribe(); + ]; + this.http.put('../../rest/listinstances', listInstance).pipe( + tap((data: any) => { + if (data && data.errors != null) { + this.notify.error(data.errors); + } else { + this.diffListClone = JSON.parse(JSON.stringify(this.getCurrentListinstance())); + this.notify.success(this.lang.diffusionListUpdated); + resolve(true); + } + }), + catchError((err: any) => { + this.notify.handleErrors(err); + return of(false); + }) + ).subscribe(); + }); } initRoles() { diff --git a/src/frontend/app/indexation/indexing-form/indexing-form.component.ts b/src/frontend/app/indexation/indexing-form/indexing-form.component.ts index dba9611a78575c92b35c8273b2f2ebea4c742045..ef0873dd9169ae0dce449062f789aa66ed83b8be 100644 --- a/src/frontend/app/indexation/indexing-form/indexing-form.component.ts +++ b/src/frontend/app/indexation/indexing-form/indexing-form.component.ts @@ -299,7 +299,7 @@ export class IndexingFormComponent implements OnInit { } else { element.default_value = '_TODAY'; } - } else { + } else { if (element.identifier === 'processLimitDate') { element.default_value = this.functions.formatDateObjectToFrenchDateString(this.arrFormControl[element.identifier].value, true); } else { @@ -337,24 +337,28 @@ export class IndexingFormComponent implements OnInit { } saveData(userId: number, groupId: number, basketId: number) { - if (this.isValidForm()) { - const formatdatas = this.formatDatas(this.getDatas()); + return new Promise((resolve, reject) => { + if (this.isValidForm()) { + const formatdatas = this.formatDatas(this.getDatas()); + + this.http.put(`../../rest/resources/${this.resId}?userId=${userId}&groupId=${groupId}&basketId=${basketId}`, formatdatas).pipe( + tap(() => { + this.currentResourceValues = JSON.parse(JSON.stringify(this.getDatas(false)));; + this.notify.success(this.lang.dataUpdated); + resolve(true); + }), + catchError((err: any) => { + this.notify.handleErrors(err); + return of(false); + }) + ).subscribe(); + return true; + } else { + this.notify.error(this.lang.mustFixErrors); + return false; + } + }); - this.http.put(`../../rest/resources/${this.resId}?userId=${userId}&groupId=${groupId}&basketId=${basketId}`, formatdatas).pipe( - tap(() => { - this.currentResourceValues = JSON.parse(JSON.stringify(this.getDatas(false)));; - this.notify.success(this.lang.dataUpdated); - }), - catchError((err: any) => { - this.notify.handleErrors(err); - return of(false); - }) - ).subscribe(); - return true; - } else { - this.notify.error(this.lang.mustFixErrors); - return false; - } } formatDatas(datas: any) { @@ -634,10 +638,10 @@ export class IndexingFormComponent implements OnInit { tap(async (data: any) => { await Promise.all(this.fieldCategories.map(async (element: any) => { - //this.fieldCategories.forEach(async element => { + //this.fieldCategories.forEach(async element => { await Promise.all(this['indexingModels_' + element].map(async (elem: any) => { - //this['indexingModels_' + element].forEach((elem: any) => { + //this['indexingModels_' + element].forEach((elem: any) => { const customId: any = Object.keys(data.customFields).filter(index => index === elem.identifier.split('indexingCustomField_')[1])[0]; if (Object.keys(data).indexOf(elem.identifier) > -1 || customId !== undefined) { @@ -685,12 +689,12 @@ export class IndexingFormComponent implements OnInit { getCurrentInitiator(field: any, initiatorId: number) { return new Promise((resolve, reject) => { this.http.get(`../../rest/entities/${initiatorId}`).pipe( - tap((data: any) => { + tap((data: any) => { field.values.unshift({ id: data.id, label: data.entity_label }); - resolve(true); + resolve(true); }) ).subscribe(); }); diff --git a/src/frontend/app/process/process.component.ts b/src/frontend/app/process/process.component.ts index c4aa27ac1d87e988f97bad8652da53cdb6db2d80..fe21410da0746bd28dcaebbac8de57fe99b60623 100755 --- a/src/frontend/app/process/process.component.ts +++ b/src/frontend/app/process/process.component.ts @@ -517,15 +517,15 @@ export class ProcessComponent implements OnInit { }, 0); } - saveTool() { + async saveTool() { if (this.currentTool === 'info' && this.indexingForm !== undefined) { - this.indexingForm.saveData(this.currentUserId, this.currentGroupId, this.currentBasketId); + await this.indexingForm.saveData(this.currentUserId, this.currentGroupId, this.currentBasketId); } else if (this.currentTool === 'diffusionList' && this.appDiffusionsList !== undefined) { - this.appDiffusionsList.saveListinstance(); + await this.appDiffusionsList.saveListinstance(); } else if (this.currentTool === 'visaCircuit' && this.appVisaWorkflow !== undefined) { - this.appVisaWorkflow.saveVisaWorkflow(); + await this.appVisaWorkflow.saveVisaWorkflow(); } else if (this.currentTool === 'opinionCircuit' && this.appAvisWorkflow !== undefined) { - this.appAvisWorkflow.saveAvisWorkflow(); + await this.appAvisWorkflow.saveAvisWorkflow(); } this.loadResource(); } diff --git a/src/frontend/app/visa/visa-workflow.component.ts b/src/frontend/app/visa/visa-workflow.component.ts index 8d884b874b03f6afff111c4586187ec6c87d692b..f5814daff9ce7648f8f62193e468056050307ca7 100644 --- a/src/frontend/app/visa/visa-workflow.component.ts +++ b/src/frontend/app/visa/visa-workflow.component.ts @@ -281,31 +281,35 @@ export class VisaWorkflowComponent implements OnInit { } saveVisaWorkflow() { - if (this.visaWorkflow.items.length === 0) { - this.http.delete(`../../rest/resources/${this.resId}/circuits/visaCircuit`).pipe( - tap(() => { - this.visaWorkflowClone = JSON.parse(JSON.stringify(this.visaWorkflow.items)); - this.notify.success(this.lang.visaWorkflowDeleted); - }), - catchError((err: any) => { - this.notify.handleSoftErrors(err); - return of(false); - }) - ).subscribe(); - } else if (this.isValidWorkflow()) { - this.http.put(`../../rest/listinstances`, [{ resId: this.resId, listInstances: this.visaWorkflow.items }]).pipe( - tap((data: any) => { - this.visaWorkflowClone = JSON.parse(JSON.stringify(this.visaWorkflow.items)); - this.notify.success(this.lang.visaWorkflowUpdated); - }), - catchError((err: any) => { - this.notify.handleSoftErrors(err); - return of(false); - }) - ).subscribe(); - } else { - this.notify.error(this.lang.signUserRequired); - } + return new Promise((resolve, reject) => { + if (this.visaWorkflow.items.length === 0) { + this.http.delete(`../../rest/resources/${this.resId}/circuits/visaCircuit`).pipe( + tap(() => { + this.visaWorkflowClone = JSON.parse(JSON.stringify(this.visaWorkflow.items)); + this.notify.success(this.lang.visaWorkflowDeleted); + resolve(true); + }), + catchError((err: any) => { + this.notify.handleSoftErrors(err); + return of(false); + }) + ).subscribe(); + } else if (this.isValidWorkflow()) { + this.http.put(`../../rest/listinstances`, [{ resId: this.resId, listInstances: this.visaWorkflow.items }]).pipe( + tap((data: any) => { + this.visaWorkflowClone = JSON.parse(JSON.stringify(this.visaWorkflow.items)); + this.notify.success(this.lang.visaWorkflowUpdated); + resolve(true); + }), + catchError((err: any) => { + this.notify.handleSoftErrors(err); + return of(false); + }) + ).subscribe(); + } else { + this.notify.error(this.lang.signUserRequired); + } + }); } addItemToWorkflow(item: any, maarchParapheurMode = false) {