diff --git a/src/app/resource/controllers/IndexingController.php b/src/app/resource/controllers/IndexingController.php index fc4d01bb1cbf1f77c35b4b19b7f58edc5cae7f8f..7c0f108a733b04e1c43fadd04ede16664d06a4d2 100755 --- a/src/app/resource/controllers/IndexingController.php +++ b/src/app/resource/controllers/IndexingController.php @@ -244,6 +244,8 @@ class IndexingController { $queryParams = $request->getQueryParams(); + // if delay is 0, then the process limit date is today + $delay = 0; if (!empty($queryParams['doctype'])) { $doctype = DoctypeModel::getById(['id' => $queryParams['doctype'], 'select' => ['process_delay']]); if (empty($doctype)) { @@ -258,6 +260,9 @@ class IndexingController } $delay = $priority['delays']; } + if (!empty($queryParams['today'])) { + $delay = 0; + } if (!Validator::intVal()->validate($delay)) { return $response->withStatus(400)->withJson(['errors' => 'Delay is not a numeric value']); } 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 b0f54260bea6cef46b7e2de8da1c83fb7f8190a3..1b9b9948132f67a6142fde20a955af31ce1758cc 100755 --- a/src/frontend/app/indexation/indexing-form/indexing-form.component.ts +++ b/src/frontend/app/indexation/indexing-form/indexing-form.component.ts @@ -266,6 +266,8 @@ export class IndexingFormComponent implements OnInit { indexingModelClone: any; resDataClone: any; + isProcessLimitDateToday: boolean = false; + constructor( public translate: TranslateService, public http: HttpClient, @@ -997,7 +999,16 @@ export class IndexingFormComponent implements OnInit { this.indexingModelClone = JSON.parse(JSON.stringify(data.indexingModel)); } - await this.initElemForm(saveResourceState); + await this.initElemForm(saveResourceState).then(() => { + // check if clock is active + if (!this.functions.empty(this['indexingModels_process'])) { + const processLimitDate = this['indexingModels_process'].find((element: any) => element.identifier === 'processLimitDate'); + if (!this.functions.empty(processLimitDate.today)) { + this.isProcessLimitDateToday = true; + this.calcLimitDateToday(); + } + } + }); this.createForm(); }), @@ -1187,7 +1198,8 @@ export class IndexingFormComponent implements OnInit { let limitDate: any = null; const objToSend: any = { doctype: value, - priority: this.arrFormControl['priority'].value + priority: this.arrFormControl['priority'].value, + today: this.isProcessLimitDateToday }; if (this.functions.empty(this.arrFormControl['priority'].value)) { delete objToSend.priority; @@ -1212,11 +1224,41 @@ export class IndexingFormComponent implements OnInit { } } + /** + * @description calculate the limit date if the clock is active + * @returns void + */ + calcLimitDateToday() { + let limitDate: any = null; + const objToSend: any = { + today: true + }; + if (this.arrFormControl['processLimitDate'] !== undefined) { + this.http.get('../rest/indexing/processLimitDate', { params: objToSend }).pipe( + tap((data: any) => { + limitDate = data.processLimitDate !== null ? new Date(data.processLimitDate) : ''; + this.arrFormControl['processLimitDate'].setValue(limitDate); + }), + filter((data) => this.arrFormControl['priority'] !== undefined && data.processLimitDate !== null), + exhaustMap(() => this.http.get('../rest/indexing/priority', { params: { 'processLimitDate': limitDate.toDateString() } })), + tap((data: any) => { + this.arrFormControl['priority'].setValue(data.priority); + this.setPriorityColor(null, data.priority); + }), + catchError((err: any) => { + this.notify.handleErrors(err); + return of(false); + }) + ).subscribe(); + } + } + calcLimitDateByPriority(field: any, value: any) { let limitDate: any = null; const objToSend: any = { priority: value, - doctype: this.arrFormControl['doctype'].value + doctype: this.arrFormControl['doctype'].value, + today: this.isProcessLimitDateToday }; if (this.functions.empty(this.arrFormControl['doctype'].value)) { delete objToSend.doctype;