diff --git a/rest/index.php b/rest/index.php index 0c5c3cad65a7699b1571f70921a60544c3fc8e1b..7db6f2220d83de7d53832a5fe5dac4b33edeb864 100755 --- a/rest/index.php +++ b/rest/index.php @@ -394,7 +394,7 @@ $app->post('/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}/ac $app->post('/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}/actions/{actionId}/checkContinueOpinionCircuit', \Action\controllers\PreProcessActionController::class . ':checkContinueOpinionCircuit'); $app->post('/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}/actions/{actionId}/checkGiveParallelOpinion', \Action\controllers\PreProcessActionController::class . ':checkGiveParallelOpinion'); $app->post('/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}/actions/{actionId}/checkValidateParallelOpinionDiffusion', \Action\controllers\PreProcessActionController::class . ':checkValidateParallelOpinionDiffusion'); -$app->post('/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}/actions/{actionId}/checkRejectVisaBackToPrevious', \Action\controllers\PreProcessActionController::class . ':checkRejectVisaBackToPrevious'); +$app->post('/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}/actions/{actionId}/checkInterruptRejectResetVisa', \Action\controllers\PreProcessActionController::class . ':checkInterruptRejectResetVisa'); //Search $app->get('/search', \Search\controllers\SearchController::class . ':get'); diff --git a/src/app/action/controllers/PreProcessActionController.php b/src/app/action/controllers/PreProcessActionController.php index 6954695eca1e143859ff18cb479bbba2d174cf07..d68599e74a765f5db58e5322d8a4d964f63ab080 100755 --- a/src/app/action/controllers/PreProcessActionController.php +++ b/src/app/action/controllers/PreProcessActionController.php @@ -985,7 +985,7 @@ class PreProcessActionController return $response->withJson(['resourcesInformations' => $resourcesInformations]); } - public function checkRejectVisaBackToPrevious(Request $request, Response $response, array $args) + public function checkInterruptRejectResetVisa(Request $request, Response $response, array $args) { $body = $request->getParsedBody(); @@ -1026,8 +1026,6 @@ class PreProcessActionController } else { $resourcesInformation['error'][] = ['alt_identifier' => $resource['alt_identifier'], 'res_id' => $resId, 'reason' => 'noCircuitAvailable']; } - } elseif ($isSignatory[0]['requested_signature'] && !$isSignatory[0]['signatory']) { - $resourcesInformation['warning'][] = ['alt_identifier' => $resource['alt_identifier'], 'res_id' => $resId, 'reason' => 'userHasntSigned']; } else { $hasPrevious = ListInstanceModel::get([ 'select' => [1], @@ -1039,7 +1037,7 @@ class PreProcessActionController if (!empty($hasPrevious)) { $resourcesInformation['success'][] = ['alt_identifier' => $resource['alt_identifier'], 'res_id' => $resId]; } else { - $resourcesInformation['error'][] = ['alt_identifier' => $resource['alt_identifier'], 'res_id' => $resId, 'reason' => 'noPreviousAvailable']; + $resourcesInformation['error'][] = ['alt_identifier' => $resource['alt_identifier'], 'res_id' => $resId, 'reason' => 'circuitNotStarted']; } } } diff --git a/src/frontend/app/actions/visa-interrupt-action/interrupt-visa-action.component.html b/src/frontend/app/actions/visa-interrupt-action/interrupt-visa-action.component.html index 842a678f0ae72aaf07f1896ebbab6c0399e83740..1fa9c8fd1febb1f238427f109a33506cbd58d753 100644 --- a/src/frontend/app/actions/visa-interrupt-action/interrupt-visa-action.component.html +++ b/src/frontend/app/actions/visa-interrupt-action/interrupt-visa-action.component.html @@ -11,6 +11,25 @@ {{lang.elements}}</b> ? <div class="alert-message alert-message-info" role="alert" style="margin-top: 30px;" [innerHTML]="lang.interruptVisaWorkflow"></div> + + <div *ngIf="resourcesErrors.length > 0" class="alert-message alert-message-danger mailList" role="alert"> + <p> + {{lang.canNotMakeAction}} : + </p> + <ul> + <li *ngFor="let ressource of resourcesErrors"> + <b>{{ressource.alt_identifier}}</b> : {{lang[ressource.reason]}} + </li> + </ul> + </div> + <div *ngIf="resourcesWarnings.length > 0" class="alert-message alert-message-info mailList" role="alert"> + <ul style="margin: 0;padding-bottom: 0px;"> + <li *ngFor="let ressource of resourcesWarnings"> + <b>{{ressource.alt_identifier}}</b> : {{lang[ressource.reason]}} + </li> + </ul> + </div> + <app-visa-workflow *ngIf="data.resIds.length == 1" [adminMode]="false" [resId]="data.resIds[0]" #appVisaWorkflow> </app-visa-workflow> @@ -21,7 +40,7 @@ </div> </div> <div mat-dialog-actions class="actions"> - <button mat-raised-button mat-button color="primary" [disabled]="loading" + <button mat-raised-button mat-button color="primary" [disabled]="loading || !isValidAction()" (click)="onSubmit()">{{lang.validate}}</button> <button mat-raised-button mat-button [disabled]="loading" [mat-dialog-close]="">{{lang.cancel}}</button> -</div> \ No newline at end of file +</div> diff --git a/src/frontend/app/actions/visa-interrupt-action/interrupt-visa-action.component.ts b/src/frontend/app/actions/visa-interrupt-action/interrupt-visa-action.component.ts index eceb3a4a2fb4d881034dc61d4def4649d0f11885..f5ea201140fff904241debb7345e750d70b8149e 100644 --- a/src/frontend/app/actions/visa-interrupt-action/interrupt-visa-action.component.ts +++ b/src/frontend/app/actions/visa-interrupt-action/interrupt-visa-action.component.ts @@ -6,6 +6,7 @@ import { HttpClient } from '@angular/common/http'; import { NoteEditorComponent } from '../../notes/note-editor.component'; import { tap, finalize, catchError } from 'rxjs/operators'; import { of } from 'rxjs'; +import {FunctionsService} from "../../../service/functions.service"; @Component({ templateUrl: "interrupt-visa-action.component.html", @@ -17,16 +18,48 @@ export class InterruptVisaActionComponent implements OnInit { lang: any = LANG; loading: boolean = false; + resourcesWarnings: any[] = []; + resourcesErrors: any[] = []; + + noResourceToProcess: boolean = null; + @ViewChild('noteEditor', { static: true }) noteEditor: NoteEditorComponent; constructor( public http: HttpClient, private notify: NotificationService, public dialogRef: MatDialogRef<InterruptVisaActionComponent>, - @Inject(MAT_DIALOG_DATA) public data: any + @Inject(MAT_DIALOG_DATA) public data: any, + public functions: FunctionsService ) { } - ngOnInit(): void { } + async ngOnInit() { + this.loading = true; + await this.checkInterruptVisa(); + this.loading = false; + } + + checkInterruptVisa() { + this.resourcesErrors = []; + this.resourcesWarnings = []; + + return new Promise((resolve, reject) => { + this.http.post('../../rest/resourcesList/users/' + this.data.userId + '/groups/' + this.data.groupId + '/baskets/' + this.data.basketId + '/actions/' + this.data.action.id + '/checkInterruptRejectResetVisa', { resources: this.data.resIds }) + .subscribe((data: any) => { + if (!this.functions.empty(data.resourcesInformations.warning)) { + this.resourcesWarnings = data.resourcesInformations.warning; + } + + if(!this.functions.empty(data.resourcesInformations.error)) { + this.resourcesErrors = data.resourcesInformations.error; + this.noResourceToProcess = this.resourcesErrors.length === this.data.resIds.length; + } + resolve(true); + }, (err: any) => { + this.notify.handleSoftErrors(err); + }); + }); + } onSubmit() { this.loading = true; @@ -45,4 +78,8 @@ export class InterruptVisaActionComponent implements OnInit { }) ).subscribe(); } + + isValidAction() { + return !this.noResourceToProcess; + } } diff --git a/src/frontend/app/actions/visa-reject-back-to-previous-action/reject-visa-back-to-previous-action.component.ts b/src/frontend/app/actions/visa-reject-back-to-previous-action/reject-visa-back-to-previous-action.component.ts index 54b418baa2b60a990998f980fe774206a1d5ee6d..c43cba03b8e240460c938aeec0d74dfcd98c038f 100644 --- a/src/frontend/app/actions/visa-reject-back-to-previous-action/reject-visa-back-to-previous-action.component.ts +++ b/src/frontend/app/actions/visa-reject-back-to-previous-action/reject-visa-back-to-previous-action.component.ts @@ -46,7 +46,7 @@ export class RejectVisaBackToPrevousActionComponent implements OnInit { this.resourcesWarnings = []; return new Promise((resolve, reject) => { - this.http.post('../../rest/resourcesList/users/' + this.data.userId + '/groups/' + this.data.groupId + '/baskets/' + this.data.basketId + '/actions/' + this.data.action.id + '/checkRejectVisaBackToPrevious', { resources: this.data.resIds }) + this.http.post('../../rest/resourcesList/users/' + this.data.userId + '/groups/' + this.data.groupId + '/baskets/' + this.data.basketId + '/actions/' + this.data.action.id + '/checkInterruptRejectResetVisa', { resources: this.data.resIds }) .subscribe((data: any) => { if (!this.functions.empty(data.resourcesInformations.warning)) { this.resourcesWarnings = data.resourcesInformations.warning; diff --git a/src/frontend/app/actions/visa-reset-action/reset-visa-action.component.html b/src/frontend/app/actions/visa-reset-action/reset-visa-action.component.html index 80131ffd6e2e6ee5d8fa4e7f6b0d84e48e114741..fef6bfd807f14055c498e1d5f49c619c5d576cc8 100644 --- a/src/frontend/app/actions/visa-reset-action/reset-visa-action.component.html +++ b/src/frontend/app/actions/visa-reset-action/reset-visa-action.component.html @@ -13,6 +13,25 @@ [innerHTML]="lang.resetVisaWorkflowUser + ' <b>' + appVisaWorkflow.getFirstVisaUser().labelToDisplay + '</b>'"></div> <div *ngIf="data.resIds.length > 1" class="alert-message alert-message-info" role="alert" style="margin-top: 30px;" [innerHTML]="lang.resetVisaWorkflow"></div> + + <div *ngIf="resourcesErrors.length > 0" class="alert-message alert-message-danger mailList" role="alert"> + <p> + {{lang.canNotMakeAction}} : + </p> + <ul> + <li *ngFor="let ressource of resourcesErrors"> + <b>{{ressource.alt_identifier}}</b> : {{lang[ressource.reason]}} + </li> + </ul> + </div> + <div *ngIf="resourcesWarnings.length > 0" class="alert-message alert-message-info mailList" role="alert"> + <ul style="margin: 0;padding-bottom: 0px;"> + <li *ngFor="let ressource of resourcesWarnings"> + <b>{{ressource.alt_identifier}}</b> : {{lang[ressource.reason]}} + </li> + </ul> + </div> + <app-visa-workflow *ngIf="data.resIds.length == 1" [adminMode]="false" [resId]="data.resIds[0]" #appVisaWorkflow> </app-visa-workflow> </div> @@ -22,7 +41,7 @@ </div> </div> <div mat-dialog-actions class="actions"> - <button mat-raised-button mat-button color="primary" [disabled]="loading" + <button mat-raised-button mat-button color="primary" [disabled]="loading || !isValidAction()" (click)="onSubmit()">{{lang.validate}}</button> <button mat-raised-button mat-button [disabled]="loading" [mat-dialog-close]="">{{lang.cancel}}</button> -</div> \ No newline at end of file +</div> diff --git a/src/frontend/app/actions/visa-reset-action/reset-visa-action.component.ts b/src/frontend/app/actions/visa-reset-action/reset-visa-action.component.ts index 0476fc8194c819986cf3bf861937ccefee854814..1046030de4246b8f80023315d4a4857acba75652 100644 --- a/src/frontend/app/actions/visa-reset-action/reset-visa-action.component.ts +++ b/src/frontend/app/actions/visa-reset-action/reset-visa-action.component.ts @@ -7,6 +7,7 @@ import { NoteEditorComponent } from '../../notes/note-editor.component'; import { tap, finalize, catchError } from 'rxjs/operators'; import { of } from 'rxjs'; import { VisaWorkflowComponent } from '../../visa/visa-workflow.component'; +import {FunctionsService} from "../../../service/functions.service"; @Component({ templateUrl: "reset-visa-action.component.html", @@ -17,6 +18,11 @@ export class ResetVisaActionComponent implements OnInit { lang: any = LANG; loading: boolean = false; + resourcesWarnings: any[] = []; + resourcesErrors: any[] = []; + + noResourceToProcess: boolean = null; + @ViewChild('noteEditor', { static: true }) noteEditor: NoteEditorComponent; @ViewChild('appVisaWorkflow', { static: false }) appVisaWorkflow: VisaWorkflowComponent; @@ -24,10 +30,37 @@ export class ResetVisaActionComponent implements OnInit { public http: HttpClient, private notify: NotificationService, public dialogRef: MatDialogRef<ResetVisaActionComponent>, - @Inject(MAT_DIALOG_DATA) public data: any + @Inject(MAT_DIALOG_DATA) public data: any, + public functions: FunctionsService ) { } - ngOnInit(): void { } + async ngOnInit() { + this.loading = true; + await this.checkResetVisa(); + this.loading = false; + } + + checkResetVisa() { + this.resourcesErrors = []; + this.resourcesWarnings = []; + + return new Promise((resolve, reject) => { + this.http.post('../../rest/resourcesList/users/' + this.data.userId + '/groups/' + this.data.groupId + '/baskets/' + this.data.basketId + '/actions/' + this.data.action.id + '/checkInterruptRejectResetVisa', { resources: this.data.resIds }) + .subscribe((data: any) => { + if (!this.functions.empty(data.resourcesInformations.warning)) { + this.resourcesWarnings = data.resourcesInformations.warning; + } + + if(!this.functions.empty(data.resourcesInformations.error)) { + this.resourcesErrors = data.resourcesInformations.error; + this.noResourceToProcess = this.resourcesErrors.length === this.data.resIds.length; + } + resolve(true); + }, (err: any) => { + this.notify.handleSoftErrors(err); + }); + }); + } onSubmit() { this.loading = true; @@ -46,4 +79,8 @@ export class ResetVisaActionComponent implements OnInit { }) ).subscribe(); } + + isValidAction() { + return !this.noResourceToProcess; + } } diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts index f750cb54e51b410f2aa7a2d467aa89dde8e52001..86568f70d0a8981452e9a177c6a9d3590086fa74 100755 --- a/src/frontend/lang/lang-en.ts +++ b/src/frontend/lang/lang-en.ts @@ -1435,5 +1435,5 @@ export const LANG_EN = { "validateBy": "Validate by", "validateAvisParallel": "Your are validating an opinion request", "validateAvisParallelSingle": "Your are validating an opinion request of", - "noPreviousAvailable": "No previous signatories or visa available", + "circuitNotStarted": "The workflow has not yet started", }; diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts index 1a7728cd64a6efe49e1d24ed4b368b50e3c1d1d2..2d229311dfe8f8f0e40951e8e657e3fefe39545d 100755 --- a/src/frontend/lang/lang-fr.ts +++ b/src/frontend/lang/lang-fr.ts @@ -1475,5 +1475,5 @@ export const LANG_FR = { "validateBy": "Validé par", "validateAvisParallel": "Vous allez valider des demandes d'avis", "validateAvisParallelSingle": "Vous allez valider la demande d'avis de", - "noPreviousAvailable": "Aucun précédent signataire ou viseur disponible", + "circuitNotStarted": "Le circuit n'a pas encore commencé", }; diff --git a/src/frontend/lang/lang-nl.ts b/src/frontend/lang/lang-nl.ts index 03ddfc5eba344f24a6bef7c9dbb66fe06bc26edb..994f92b604199d4f44ec1bd663499b2c8b25089a 100755 --- a/src/frontend/lang/lang-nl.ts +++ b/src/frontend/lang/lang-nl.ts @@ -1460,5 +1460,5 @@ export const LANG_NL = { "validateBy": "Validate by", //_TO_TRANSLATE "validateAvisParallel": "Your are validating an opinion request", //_TO_TRANSLATE "validateAvisParallelSingle": "Your are validating an opinion request of", //_TO_TRANSLATE - "noPreviousAvailable": "No previous signatories or visa available", //_TO_TRANSLATE + "circuitNotStarted": "The workflow has not yet started", //_TO_TRANSLATE };