Skip to content
Snippets Groups Projects
Commit 0cba5e7b authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #10633 TIME 0:35 add opinion limit date + reason

parent bdf48fb8
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
......@@ -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;
......
<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>
......
......@@ -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>();
......
......@@ -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",
};
......@@ -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",
};
......@@ -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
};
......@@ -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}`;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment