diff --git a/src/frontend/app/actions/send-signature-book-action/send-signature-book-action.component.html b/src/frontend/app/actions/send-signature-book-action/send-signature-book-action.component.html index b377fc59812460b9e170bb9ca2552b6bcfb391c1..75aa68fced55f8bb797ed336927ce0c81005624b 100644 --- a/src/frontend/app/actions/send-signature-book-action/send-signature-book-action.component.html +++ b/src/frontend/app/actions/send-signature-book-action/send-signature-book-action.component.html @@ -22,15 +22,15 @@ </li> </ul> </div> - <app-visa-workflow *ngIf="data.resIds.length == 1 || (!noResourceToProcess && data.resIds.length > 1)" [adminMode]="true" #appVisaWorkflow [resId]="data.resIds[0]"> + <app-visa-workflow *ngIf="data.resIds.length == 1 || (!noResourceToProcess && data.resIds.length > 1)" [adminMode]="true" #appVisaWorkflow> </app-visa-workflow> <div style="padding-top: 10px;"> <app-note-editor #noteEditor [resIds]="data.resIds"></app-note-editor> </div> </mat-sidenav-content> - <mat-sidenav position='end' *ngIf="data.resIds.length === 1" opened mode="side" style="overflow-x:hidden;" + <mat-sidenav position='end' [opened]="data.resIds.length === 1 && noResourceToProcess" mode="side" style="overflow-x:hidden;" autoFocus="false" [ngStyle]="{'width': '400px'}"> - <app-attachments-list [resId]="data.resIds[0]" (afterActionAttachment)="checkSignatureBook()"></app-attachments-list> + <app-attachments-list *ngIf="data.resIds.length === 1 && noResourceToProcess" [resId]="data.resIds[0]" (afterActionAttachment)="checkSignatureBook()"></app-attachments-list> </mat-sidenav> </mat-sidenav-container> </div> diff --git a/src/frontend/app/actions/send-signature-book-action/send-signature-book-action.component.ts b/src/frontend/app/actions/send-signature-book-action/send-signature-book-action.component.ts index 37c26ade6c3c3152c2654e06ac7990e27d6ddacd..2e0bb00af9dcbf546af814c741a20d10d85d8475 100644 --- a/src/frontend/app/actions/send-signature-book-action/send-signature-book-action.component.ts +++ b/src/frontend/app/actions/send-signature-book-action/send-signature-book-action.component.ts @@ -20,7 +20,7 @@ export class SendSignatureBookActionComponent implements OnInit { resourcesError: any[] = []; - noResourceToProcess: boolean = false; + noResourceToProcess: boolean = null; @ViewChild('noteEditor', { static: true }) noteEditor: NoteEditorComponent; @ViewChild('appVisaWorkflow', { static: false }) appVisaWorkflow: VisaWorkflowComponent; @@ -36,6 +36,10 @@ export class SendSignatureBookActionComponent implements OnInit { this.loading = true; await this.checkSignatureBook(); this.loading = false; + await this.appVisaWorkflow.loadWorkflow(this.data.resIds[0]); + if (this.appVisaWorkflow.emptyWorkflow()) { + this.appVisaWorkflow.loadDefaultWorkflow(this.data.resIds[0]); + } } checkSignatureBook() { @@ -60,10 +64,12 @@ export class SendSignatureBookActionComponent implements OnInit { if ( this.data.resIds.length === 0) { // this.indexDocumentAndExecuteAction(); } else { - const res = await this.appVisaWorkflow.saveVisaWorkflow(); + const realResSelected: number[] = this.data.resIds.filter((resId: any) => this.resourcesError.map(resErr => resErr.res_id).indexOf(resId) === -1); + + const res = await this.appVisaWorkflow.saveVisaWorkflow(realResSelected); if (res) { - this.executeAction(); + this.executeAction(realResSelected); } } this.loading = false; @@ -87,12 +93,8 @@ export class SendSignatureBookActionComponent implements OnInit { ).subscribe() } */ - executeAction() { - let realResSelected: string[]; - let datas: any; + executeAction(realResSelected: number[]) { - realResSelected = this.data.resIds.filter((resId: any) => this.resourcesError.map(resErr => resErr.res_id).indexOf(resId) === -1); - this.http.put(this.data.processActionRoute, {resources : realResSelected, note : this.noteEditor.getNoteContent()}).pipe( tap((data: any) => { if (!data) { @@ -111,7 +113,7 @@ export class SendSignatureBookActionComponent implements OnInit { } isValidAction() { - if (!this.noResourceToProcess) { + if (!this.noResourceToProcess && !this.appVisaWorkflow.emptyWorkflow()) { return true; } else { return false; 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 13914b226fb1131ae150be7db355129461414157..d3d80fd176b2a166001fbd23f60bbe1be9431f10 100644 --- a/src/frontend/app/indexation/indexing-form/indexing-form.component.ts +++ b/src/frontend/app/indexation/indexing-form/indexing-form.component.ts @@ -654,12 +654,10 @@ export class IndexingFormComponent implements OnInit { fieldValue = data[elem.identifier]; } - if (elem.type === 'date' && !this.functions.empty(fieldValue)) { - fieldValue = new Date(fieldValue); - } - if (elem.identifier === 'priority') { this.setPriorityColor(null, fieldValue); + } else if (elem.identifier === 'processLimitDate' && !this.functions.empty(fieldValue)) { + elem.startDate = ''; } else if (elem.identifier === 'destination') { if (this.mode === 'process') { this.arrFormControl[elem.identifier].disable(); @@ -668,6 +666,10 @@ export class IndexingFormComponent implements OnInit { } else if (elem.identifier === 'initiator' && elem.values.filter((val: any) => val.id === fieldValue).length === 0 && !this.functions.empty(fieldValue)) { await this.getCurrentInitiator(elem, fieldValue); } + + if (elem.type === 'date' && !this.functions.empty(fieldValue)) { + fieldValue = new Date(fieldValue); + } this.arrFormControl[elem.identifier].setValue(fieldValue); } if (!this.canEdit) { diff --git a/src/frontend/app/visa/visa-workflow.component.ts b/src/frontend/app/visa/visa-workflow.component.ts index 5a8a02bdd368abfb7beb1922d66ba66b74af93b4..d582ec9f34835858fd1d0fd8665bf8d4fefd23d3 100644 --- a/src/frontend/app/visa/visa-workflow.component.ts +++ b/src/frontend/app/visa/visa-workflow.component.ts @@ -215,6 +215,29 @@ export class VisaWorkflowComponent implements OnInit { } loadWorkflow(resId: number) { + this.resId = resId; + this.loading = true; + this.visaWorkflow.items = []; + return new Promise((resolve, reject) => { + this.http.get("../../rest/resources/" + resId + "/visaCircuit") + .subscribe((data: any) => { + data.forEach((element: any) => { + this.visaWorkflow.items.push( + { + ...element, + difflist_type: 'VISA_CIRCUIT' + }); + }); + this.visaWorkflowClone = JSON.parse(JSON.stringify(this.visaWorkflow.items)) + this.loading = false; + resolve(true); + }, (err: any) => { + this.notify.handleErrors(err); + }); + }); + } + + loadDefaultWorkflow(resId: number) { this.loading = true; this.visaWorkflow.items = []; this.http.get("../../rest/resources/" + resId + "/visaCircuit") @@ -280,10 +303,10 @@ export class VisaWorkflowComponent implements OnInit { return this.visaWorkflow.items.filter((item: any) => this.functions.empty(item.externalId)).map((item: any) => item.labelToDisplay); } - saveVisaWorkflow() { + saveVisaWorkflow(resIds: number[] = [this.resId]) { return new Promise((resolve, reject) => { if (this.visaWorkflow.items.length === 0) { - this.http.delete(`../../rest/resources/${this.resId}/circuits/visaCircuit`).pipe( + this.http.delete(`../../rest/resources/${resIds[0]}/circuits/visaCircuit`).pipe( tap(() => { this.visaWorkflowClone = JSON.parse(JSON.stringify(this.visaWorkflow.items)); this.notify.success(this.lang.visaWorkflowDeleted); @@ -295,7 +318,13 @@ export class VisaWorkflowComponent implements OnInit { }) ).subscribe(); } else if (this.isValidWorkflow()) { - this.http.put(`../../rest/listinstances`, [{ resId: this.resId, listInstances: this.visaWorkflow.items }]).pipe( + const arrVisa = resIds.map(resId => { + return { + resId : resId, + listInstances : this.visaWorkflow.items + } + }); + this.http.put(`../../rest/listinstances`, arrVisa).pipe( tap((data: any) => { this.visaWorkflowClone = JSON.parse(JSON.stringify(this.visaWorkflow.items)); this.notify.success(this.lang.visaWorkflowUpdated); @@ -376,6 +405,14 @@ export class VisaWorkflowComponent implements OnInit { } } + emptyWorkflow() { + if (this.visaWorkflow.items.length === 0) { + return true; + } else { + return false; + } + } + openPromptSaveModel() { const dialogRef = this.dialog.open(AddVisaModelModalComponent, { data: { visaWorkflow: this.visaWorkflow.items } });