diff --git a/rest/index.php b/rest/index.php index 6cd90df7a9796d6b365b7658abd44098221d6de2..7db6f2220d83de7d53832a5fe5dac4b33edeb864 100755 --- a/rest/index.php +++ b/rest/index.php @@ -394,6 +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}/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 8acee7bc2e9b6be7dcd46faa0c664092f0382a4e..31851fd86b423c72dd0cd3e14883a4f6b90fc460 100755 --- a/src/app/action/controllers/PreProcessActionController.php +++ b/src/app/action/controllers/PreProcessActionController.php @@ -985,6 +985,66 @@ class PreProcessActionController return $response->withJson(['resourcesInformations' => $resourcesInformations]); } + public function checkInterruptRejectResetVisa(Request $request, Response $response, array $args) + { + $body = $request->getParsedBody(); + + if (!Validator::arrayType()->notEmpty()->validate($body['resources'])) { + return $response->withStatus(400)->withJson(['errors' => 'Body resources is empty or not an array']); + } + + $errors = ResourceListController::listControl(['groupId' => $args['groupId'], 'userId' => $args['userId'], 'basketId' => $args['basketId'], 'currentUserId' => $GLOBALS['id']]); + if (!empty($errors['errors'])) { + return $response->withStatus($errors['code'])->withJson(['errors' => $errors['errors']]); + } + + $body['resources'] = array_slice($body['resources'], 0, 500); + if (!ResController::hasRightByResId(['resId' => $body['resources'], 'userId' => $GLOBALS['id']])) { + return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); + } + + $signableAttachmentsTypes = []; + $attachmentsTypes = AttachmentModel::getAttachmentsTypesByXML(); + foreach ($attachmentsTypes as $key => $type) { + if ($type['sign']) { + $signableAttachmentsTypes[] = $key; + } + } + + $resourcesInformation = []; + foreach ($body['resources'] as $resId) { + $resource = ResModel::getById(['resId' => $resId, 'select' => ['alt_identifier']]); + if (empty($resource['alt_identifier'])) { + $resource['alt_identifier'] = _UNDEFINED; + } + + $isSignatory = ListInstanceModel::get(['select' => ['signatory', 'requested_signature'], 'where' => ['res_id = ?', 'difflist_type = ?', 'process_date is null'], 'data' => [$resId, 'VISA_CIRCUIT'], 'orderBy' => ['listinstance_id'], 'limit' => 1]); + if (empty($isSignatory[0])) { + $hasCircuit = ListInstanceModel::get(['select' => [1], 'where' => ['res_id = ?', 'difflist_type = ?'], 'data' => [$resId, 'VISA_CIRCUIT']]); + if (!empty($hasCircuit)) { + $resourcesInformation['error'][] = ['alt_identifier' => $resource['alt_identifier'], 'res_id' => $resId, 'reason' => 'endedCircuit']; + } else { + $resourcesInformation['error'][] = ['alt_identifier' => $resource['alt_identifier'], 'res_id' => $resId, 'reason' => 'noCircuitAvailable']; + } + } else { + $hasPrevious = ListInstanceModel::get([ + 'select' => [1], + 'where' => ['res_id = ?', 'difflist_type = ?', 'process_date is not null'], + 'data' => [$resId, 'VISA_CIRCUIT'], + 'orderBy' => ['listinstance_id'], + 'limit' => 1 + ]); + 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' => 'circuitNotStarted']; + } + } + } + + return $response->withJson(['resourcesInformations' => $resourcesInformation]); + } + public function checkValidateParallelOpinion(Request $request, Response $response, array $args) { $body = $request->getParsedBody(); @@ -1175,67 +1235,6 @@ class PreProcessActionController return $response->withJson(['resourcesInformations' => $resourcesInformation]); } - public function checkValidateParallelOpinionDiffusion(Request $request, Response $response, array $args) - { - $body = $request->getParsedBody(); - - if (!Validator::arrayType()->notEmpty()->validate($body['resources'])) { - return $response->withStatus(400)->withJson(['errors' => 'Body resources is empty or not an array']); - } - - $errors = ResourceListController::listControl(['groupId' => $args['groupId'], 'userId' => $args['userId'], 'basketId' => $args['basketId'], 'currentUserId' => $GLOBALS['id']]); - if (!empty($errors['errors'])) { - return $response->withStatus($errors['code'])->withJson(['errors' => $errors['errors']]); - } - - $body['resources'] = array_slice($body['resources'], 0, 500); - if (!ResController::hasRightByResId(['resId' => $body['resources'], 'userId' => $GLOBALS['id']])) { - return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); - } - - $resourcesInformation = []; - foreach ($body['resources'] as $resId) { - $resource = ResModel::getById(['resId' => $resId, 'select' => ['alt_identifier', 'opinion_limit_date']]); - - if (empty($resource['alt_identifier'])) { - $resource['alt_identifier'] = _UNDEFINED; - } - - if (empty($resource['opinion_limit_date'])) { - return $response->withStatus(400)->withJson(['errors' => 'No opinion limit date for resource ' . $resource['alt_identifier']]); - } - - $opinionNote = NoteModel::get([ - 'where' => ['identifier = ?', "note_text ilike '[" . _TO_AVIS . "]%'"], - 'data' => [$resId] - ]); - - if (empty($opinionNote)) { - return $response->withStatus(400)->withJson(['errors' => 'No opinion note for resource ' . $resource['alt_identifier']]); - } - - $isSignatory = ListInstanceModel::get([ - 'select' => [1], - 'where' => ['res_id = ?', 'difflist_type = ?', 'process_date is null', 'item_mode in (?)'], - 'data' => [$resId, 'entity_id', ['avis', 'avis_copy', 'avis_info']], - 'orderBy' => ['listinstance_id'], - 'limit' => 1 - ]); - if (empty($isSignatory[0])) { - $hasCircuit = ListInstanceModel::get(['select' => [1], 'where' => ['res_id = ?', 'difflist_type = ?'], 'data' => [$resId, 'entity_id']]); - if (!empty($hasCircuit)) { - $resourcesInformation['error'][] = ['alt_identifier' => $resource['alt_identifier'], 'res_id' => $resId, 'reason' => 'endedCircuit']; - } else { - $resourcesInformation['error'][] = ['alt_identifier' => $resource['alt_identifier'], 'res_id' => $resId, 'reason' => 'noCircuitAvailable']; - } - } else { - $resourcesInformation['success'][] = ['alt_identifier' => $resource['alt_identifier'], 'res_id' => $resId]; - } - } - - return $response->withJson(['resourcesInformations' => $resourcesInformation]); - } - public function isDestinationChanging(Request $request, Response $response, array $args) { if (!ResController::hasRightByResId(['resId' => [$args['resId']], 'userId' => $GLOBALS['id']])) { diff --git a/src/app/search/controllers/SearchController.php b/src/app/search/controllers/SearchController.php index 3583383767df47e0edbadb869b68974687e2cb8e..5105a763463a1db2f2c43101164432c80c1f3a10 100644 --- a/src/app/search/controllers/SearchController.php +++ b/src/app/search/controllers/SearchController.php @@ -127,6 +127,13 @@ class SearchController } } + $nonSearchableStatuses = StatusModel::get(['select' => ['id'], 'where' => ['can_be_searched = ?'], 'data' => ['N']]); + if (!empty($nonSearchableStatuses)) { + $nonSearchableStatuses = array_column($nonSearchableStatuses, 'id'); + $searchWhere[] = 'status not in (?)'; + $searchData[] = $nonSearchableStatuses; + } + $limit = 25; if (!empty($queryParams['limit']) && is_numeric($queryParams['limit'])) { $limit = (int)$queryParams['limit']; diff --git a/src/app/status/models/StatusModelAbstract.php b/src/app/status/models/StatusModelAbstract.php index 51600bd30d0765de262add1e43c959a7fdc11f1a..1b91e475d86b45d5b9744c586e1c24edcacaf6e4 100755 --- a/src/app/status/models/StatusModelAbstract.php +++ b/src/app/status/models/StatusModelAbstract.php @@ -19,17 +19,19 @@ use SrcCore\models\DatabaseModel; abstract class StatusModelAbstract { - public static function get(array $aArgs = []) + public static function get(array $args = []) { - ValidatorModel::arrayType($aArgs, ['select']); + ValidatorModel::arrayType($args, ['select', 'where', 'data']); - $aReturn = DatabaseModel::select([ - 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], + $statuses = DatabaseModel::select([ + 'select' => empty($args['select']) ? ['*'] : $args['select'], 'table' => ['status'], + 'where' => $args['where'] ?? [], + 'data' => $args['data'] ?? [], 'order_by' => ['label_status'] ]); - return $aReturn; + return $statuses; } public static function getById(array $aArgs) 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.html b/src/frontend/app/actions/visa-reject-back-to-previous-action/reject-visa-back-to-previous-action.component.html index 2a1b9b13dfdbf623b0f18355ddad50dd0cb8dfb0..e1ec516307fccaf7181fb2a57bead5fd88e4c53e 100644 --- a/src/frontend/app/actions/visa-reject-back-to-previous-action/reject-visa-back-to-previous-action.component.html +++ b/src/frontend/app/actions/visa-reject-back-to-previous-action/reject-visa-back-to-previous-action.component.html @@ -11,6 +11,25 @@ {{lang.elements}}</b> ? <div *ngIf="data.resIds.length > 1" class="alert-message alert-message-info" role="alert" style="margin-top: 30px;" [innerHTML]="lang.rejectVisaBack"></div> <div *ngIf="data.resIds.length == 1 && appVisaWorkflow !== undefined && appVisaWorkflow.getLastVisaUser() !== ''" class="alert-message alert-message-info" role="alert" style="margin-top: 30px;" [innerHTML]="lang.rejectVisaBackUser + ' <b>' + appVisaWorkflow.getLastVisaUser().labelToDisplay + '</b>'"></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> @@ -20,7 +39,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-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 f6bdcb4fcd9997a99b87ee87a67dd7ae056ca2ef..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 @@ -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: "reject-visa-back-to-previous-action.component.html", @@ -18,6 +19,11 @@ export class RejectVisaBackToPrevousActionComponent 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; @@ -25,10 +31,37 @@ export class RejectVisaBackToPrevousActionComponent implements OnInit { public http: HttpClient, private notify: NotificationService, public dialogRef: MatDialogRef<RejectVisaBackToPrevousActionComponent>, - @Inject(MAT_DIALOG_DATA) public data: any + @Inject(MAT_DIALOG_DATA) public data: any, + public functions: FunctionsService ) { } - ngOnInit() { } + async ngOnInit() { + this.loading = true; + await this.checkRejectVisaBackToPrevious(); + this.loading = false; + } + + checkRejectVisaBackToPrevious() { + 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; @@ -47,4 +80,8 @@ export class RejectVisaBackToPrevousActionComponent implements OnInit { }) ).subscribe(); } + + isValidAction() { + return !this.noResourceToProcess; + } } 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 514869bfe42442d8e6dc170fd1255d67edc22e57..3193f1e5abc533f0e058a34d34a15137aab00994 100755 --- a/src/frontend/lang/lang-en.ts +++ b/src/frontend/lang/lang-en.ts @@ -1436,4 +1436,5 @@ export const LANG_EN = { "validateAvisParallel": "Your are validating an opinion request", "validateAvisParallelSingle": "Your are validating an opinion request of", "displayWebserviceAccount": "Display webservice account", + "circuitNotStarted": "The workflow has not yet started", }; diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts index 79d0f0d6d3c677ccc4e4781c180a20adfddfc1d5..8ba4360f496da3d229f1203bdab6550bafcdc7f7 100755 --- a/src/frontend/lang/lang-fr.ts +++ b/src/frontend/lang/lang-fr.ts @@ -1476,4 +1476,5 @@ export const LANG_FR = { "validateAvisParallel": "Vous allez valider des demandes d'avis", "validateAvisParallelSingle": "Vous allez valider la demande d'avis de", "displayWebserviceAccount": "Afficher les comptes de webservice", + "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 f2ccb637f88aa83d271b75e81cde3965581b2ce1..b7b25406b6c288158d1473cde86cd95eb5672cce 100755 --- a/src/frontend/lang/lang-nl.ts +++ b/src/frontend/lang/lang-nl.ts @@ -1461,4 +1461,5 @@ export const LANG_NL = { "validateAvisParallel": "Your are validating an opinion request", //_TO_TRANSLATE "validateAvisParallelSingle": "Your are validating an opinion request of", //_TO_TRANSLATE "displayWebserviceAccount": "Display webservice account", //_TO_TRANSLATE + "circuitNotStarted": "The workflow has not yet started", //_TO_TRANSLATE };