diff --git a/src/frontend/app/actions/avis-workflow-send-action/send-avis-workflow-action.component.html b/src/frontend/app/actions/avis-workflow-send-action/send-avis-workflow-action.component.html index 54c812860cdc59b608b8fe43eece04178de4eee0..8f3a8cf5e1bfd0cc7340065d253fac789f2f165a 100644 --- a/src/frontend/app/actions/avis-workflow-send-action/send-avis-workflow-action.component.html +++ b/src/frontend/app/actions/avis-workflow-send-action/send-avis-workflow-action.component.html @@ -22,11 +22,23 @@ </li> </ul> </div> - <app-avis-workflow *ngIf="data.resIds.length == 1 || (!noResourceToProcess && data.resIds.length > 1)" [adminMode]="true" #appAvisWorkflow> + <mat-form-field (click)="picker.open()" appearance="outline" style="cursor:pointer;margin-top: 10px;"> + <mat-label>Date limite de l'avis</mat-label> + <input matInput [(ngModel)]="opinionLimitDate" [matDatepicker]="picker" [placeholder]="lang.chooseDate" + [min]="today" readonly style="cursor:pointer;" required> + <mat-datepicker-toggle matSuffix [for]="picker" *ngIf="!opinionLimitDate"> + </mat-datepicker-toggle> + <mat-datepicker #picker></mat-datepicker> + <button mat-button color="warn" matSuffix mat-icon-button *ngIf="opinionLimitDate" + (click)="$event.stopPropagation();opinionLimitDate = null;" [title]="lang.eraseValue"> + <mat-icon color="warn" class="fa fa-calendar-times"> + </mat-icon> + </button> + </mat-form-field> + <app-note-editor #noteEditor [title]="lang.addOpinionReason" [resIds]="data.resIds"></app-note-editor> + <app-avis-workflow *ngIf="data.resIds.length == 1 || (!noResourceToProcess && data.resIds.length > 1)" + [adminMode]="true" #appAvisWorkflow> </app-avis-workflow> - <div style="padding-top: 10px;"> - <app-note-editor #noteEditor [resIds]="data.resIds"></app-note-editor> - </div> </mat-sidenav-content> </mat-sidenav-container> </div> diff --git a/src/frontend/app/actions/avis-workflow-send-action/send-avis-workflow-action.component.ts b/src/frontend/app/actions/avis-workflow-send-action/send-avis-workflow-action.component.ts index a0239883639ac90af1496c67ac8fa8ade4745d5f..56ef6800876d90ab18c671a939bc972c1579e04a 100644 --- a/src/frontend/app/actions/avis-workflow-send-action/send-avis-workflow-action.component.ts +++ b/src/frontend/app/actions/avis-workflow-send-action/send-avis-workflow-action.component.ts @@ -22,6 +22,10 @@ export class SendAvisWorkflowComponent implements OnInit { noResourceToProcess: boolean = null; + opinionLimitDate: Date = null; + + today: Date = new Date(); + @ViewChild('noteEditor', { static: true }) noteEditor: NoteEditorComponent; @ViewChild('appAvisWorkflow', { static: false }) appAvisWorkflow: AvisWorkflowComponent; @@ -32,7 +36,7 @@ export class SendAvisWorkflowComponent implements OnInit { @Inject(MAT_DIALOG_DATA) public data: any, public functions: FunctionsService) { } - async ngOnInit(): Promise<void> { + async ngOnInit(): Promise<void> { if (this.data.resIds.length > 0) { this.loading = true; await this.checkAvisWorkflow(); @@ -103,8 +107,8 @@ export class SendAvisWorkflowComponent implements OnInit { } executeAction(realResSelected: number[]) { - - this.http.put(this.data.processActionRoute, { resources: realResSelected, note: this.noteEditor.getNoteContent() }).pipe( + const noteContent: string = `[POUR AVIS] ${this.noteEditor.getNoteContent()}`; + this.http.put(this.data.processActionRoute, { resources: realResSelected, note: noteContent, data: { opinionLimitDate: this.functions.formatDateObjectToFrenchDateString(this.opinionLimitDate, true) } }).pipe( tap((data: any) => { if (!data) { this.dialogRef.close('success'); @@ -122,7 +126,7 @@ export class SendAvisWorkflowComponent implements OnInit { } isValidAction() { - if (!this.noResourceToProcess && this.appAvisWorkflow !== undefined && !this.appAvisWorkflow.emptyWorkflow() && !this.appAvisWorkflow.workflowEnd()) { + if (!this.noResourceToProcess && this.appAvisWorkflow !== undefined && !this.appAvisWorkflow.emptyWorkflow() && !this.appAvisWorkflow.workflowEnd() && !this.functions.empty(this.noteEditor.getNoteContent()) && !this.functions.empty(this.functions.formatDateObjectToFrenchDateString(this.opinionLimitDate))) { return true; } else { return false; diff --git a/src/frontend/app/notes/note-editor.component.html b/src/frontend/app/notes/note-editor.component.html index dba19614f015c2f9d7b3f599cd43676180321ccd..e9e1a410d9a77c3b13047742a844083dde359597 100644 --- a/src/frontend/app/notes/note-editor.component.html +++ b/src/frontend/app/notes/note-editor.component.html @@ -1,5 +1,5 @@ <mat-form-field appearance="outline" class="noteEditorContent"> - <textarea matInput placeholder="{{lang.addNote}}" [(ngModel)]="content"></textarea> + <textarea matInput placeholder="{{title}}" [(ngModel)]="content"></textarea> <button matSuffix color="primary" mat-icon-button title="{{lang.noteTemplates}}" [matMenuTriggerFor]="menu" (click)="getTemplatesNote()"> <mat-icon fontSet="fas" fontIcon="fa-file-alt fa-2x"></mat-icon> diff --git a/src/frontend/app/notes/note-editor.component.ts b/src/frontend/app/notes/note-editor.component.ts index b2a28eaa35df405abc653c8e76f5f66a57c0e592..064070dc6947da002582837da71b4317691dd377 100644 --- a/src/frontend/app/notes/note-editor.component.ts +++ b/src/frontend/app/notes/note-editor.component.ts @@ -18,6 +18,7 @@ export class NoteEditorComponent implements AfterViewInit { content: string = ''; + @Input('title') title: string = this.lang.addNote; @Input('resIds') resIds: any[]; @Input('addMode') addMode: boolean; @Output('refreshNotes') refreshNotes = new EventEmitter<string>(); diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts index fedc794c793038336cae2195c3e08573f5f0ddd7..45a5093ad428fc00bbbaa8ef41f3aed26f733ce6 100755 --- a/src/frontend/lang/lang-en.ts +++ b/src/frontend/lang/lang-en.ts @@ -1419,4 +1419,5 @@ export const LANG_EN = { "userHasntSigned": "The assignee hasn't signed any document", "noCircuitAvailable": "No workflow defined", "interrupted": "Interrupted", + "addOpinionReason": "Please fill the opinion reason", }; diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts index 646077465b7a20cac8727dc33362480e316892ea..a5ae9593b4f2e57e19f846ed2a538c34f5346503 100755 --- a/src/frontend/lang/lang-fr.ts +++ b/src/frontend/lang/lang-fr.ts @@ -1459,4 +1459,5 @@ export const LANG_FR = { "userHasntSigned": "Le signataire n'a pas signé de document", "noCircuitAvailable": "Aucun circuit défini", "interrupted": "Interrompu", + "addOpinionReason": "Veuillez renseigner le motif de l'avis", }; diff --git a/src/frontend/lang/lang-nl.ts b/src/frontend/lang/lang-nl.ts index c08f33ac01caab0ca0889ac795c173338fd2b066..e0ceed6e24b0b16c9be9ab1df9f571d27793bac6 100755 --- a/src/frontend/lang/lang-nl.ts +++ b/src/frontend/lang/lang-nl.ts @@ -1444,4 +1444,5 @@ export const LANG_NL = { "userHasntSigned": "The assignee hasn't signed any document", //_TO_TRANSLATE "noCircuitAvailable": "No workflow defined", //_TO_TRANSLATE "interrupted": "Interrupted", //_TO_TRANSLATE + "addOpinionReason": "Please fill the opinion reason", //_TO_TRANSLATE }; diff --git a/src/frontend/service/functions.service.ts b/src/frontend/service/functions.service.ts index 12a3ebe634f70fe9f0b1e7e52abe933b1d442ca9..dfdfdc5014a4a0068f82b072e9786412526396c5 100644 --- a/src/frontend/service/functions.service.ts +++ b/src/frontend/service/functions.service.ts @@ -8,7 +8,7 @@ export class FunctionsService { constructor() { } - empty(value: string) { + empty(value: any) { if (value === null || value === undefined) { return true; @@ -40,14 +40,17 @@ export class FunctionsService { } formatDateObjectToFrenchDateString(date: Date, limitMode: boolean = false) { - - let day = date.getDate(); - let month = date.getMonth() + 1; - let year = date.getFullYear(); - let limit = ''; - if (limitMode) { - limit = ' 23:59:59'; + if (date !== null) { + let day = date.getDate(); + let month = date.getMonth() + 1; + let year = date.getFullYear(); + let limit = ''; + if (limitMode) { + limit = ' 23:59:59'; + } + return `${('00' + day).slice(-2)}-${('00' + month).slice(-2)}-${year}${limit}`; + } else { + return date; } - return `${('00' + day).slice(-2)}-${('00' + month).slice(-2)}-${year}${limit}`; } }