diff --git a/core/xml/actions_pages.xml b/core/xml/actions_pages.xml index 253a1ae4f62dff3c5e4444d331581c40a9a40ce7..9d1a0efff252610aeb3bc985857e98f0e8479286 100755 --- a/core/xml/actions_pages.xml +++ b/core/xml/actions_pages.xml @@ -416,4 +416,34 @@ An action page is described in a ACTIONPAGE tag : <MODULE></MODULE> <FLAG_CREATE>false</FLAG_CREATE> </ACTIONPAGE> + <ACTIONPAGE> + <ID>saveRegisteredMail</ID> + <LABEL>_SAVE_REGISTERED_MAIL</LABEL> + <NAME>saveRegisteredMail</NAME> + <DESC>_SAVE_REGISTERED_MAIL</DESC> + <component>saveRegisteredMailAction</component> + <ORIGIN>apps</ORIGIN> + <MODULE></MODULE> + <FLAG_CREATE>false</FLAG_CREATE> + </ACTIONPAGE> + <ACTIONPAGE> + <ID>saveAndPrintRegisteredMail</ID> + <LABEL>_SAVE_PRINT_REGISTERED_MAIL</LABEL> + <NAME>saveAndPrintRegisteredMail</NAME> + <DESC>_SAVE_PRINT_REGISTERED_MAIL</DESC> + <component>saveAndPrintRegisteredMailAction</component> + <ORIGIN>apps</ORIGIN> + <MODULE></MODULE> + <FLAG_CREATE>false</FLAG_CREATE> + </ACTIONPAGE> + <ACTIONPAGE> + <ID>printRegisteredMail</ID> + <LABEL>_PRINT_REGISTERED_MAIL</LABEL> + <NAME>printRegisteredMail</NAME> + <DESC>_PRINT_REGISTERED_MAIL</DESC> + <component>printRegisteredMailAction</component> + <ORIGIN>apps</ORIGIN> + <MODULE></MODULE> + <FLAG_CREATE>false</FLAG_CREATE> + </ACTIONPAGE> </ROOT> diff --git a/package.json b/package.json index acdbe236d9ed327938ac3fb443404a39f754dd45..63bb3a80abe5ab00895cc8d00be80f099e887071 100755 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@types/jquery.nicescroll": "^3.7.1", "@types/jstree": "^3.3.40", "@types/tooltipster": "0.0.29", - "ajv": "^6.12.2", + "ajv": "^6.12.4", "bootstrap": "^3.4.1", "chosen-js": "^1.8.7", "codelyzer": "^5.2.2", @@ -71,7 +71,7 @@ "photoswipe": "^4.1.3", "protractor": "^5.4.4", "rxjs": "^6.5.5", - "tinymce": "^5.3.1", + "tinymce": "^5.4.2", "tinymce-i18n": "^19.9.17", "tooltipster": "^4.2.8", "tslib": "^1.13.0", diff --git a/src/app/action/controllers/ActionMethodController.php b/src/app/action/controllers/ActionMethodController.php index 0659bcc0489a879d0aaeca23b73178ef6e280fc8..949b19bca09bde51cefaa403a3a1361c13c3167f 100644 --- a/src/app/action/controllers/ActionMethodController.php +++ b/src/app/action/controllers/ActionMethodController.php @@ -81,6 +81,9 @@ class ActionMethodController 'validateParallelOpinionDiffusionAction' => 'validateParallelOpinionDiffusion', 'reconcileAction' => 'reconcile', 'sendAlfrescoAction' => 'sendResourceAlfresco', + 'saveRegisteredMailAction' => 'saveRegisteredMail', + 'saveAndPrintRegisteredMailAction' => 'saveAndPrintRegisteredMail', + 'printRegisteredMailAction' => 'printRegisteredMail', 'noConfirmAction' => null ]; diff --git a/src/app/group/controllers/GroupController.php b/src/app/group/controllers/GroupController.php index 31f63c779b303a37b131c8676189fe12c448014d..ec079c26edf2d008c3d10cf952ea926d076a6ec0 100755 --- a/src/app/group/controllers/GroupController.php +++ b/src/app/group/controllers/GroupController.php @@ -19,7 +19,7 @@ use User\models\UserModel; class GroupController { - const INDEXING_ACTIONS = ['confirmAction', 'noConfirmAction', 'closeMailAction', 'sendSignatureBookAction', 'closeAndIndexAction']; + const INDEXING_ACTIONS = ['confirmAction', 'noConfirmAction', 'closeMailAction', 'sendSignatureBookAction', 'closeAndIndexAction', 'saveRegisteredMailAction', 'saveAndPrintRegisteredMailAction']; public function get(Request $request, Response $response) { diff --git a/src/app/registeredMail/controllers/RegisteredMailTrait.php b/src/app/registeredMail/controllers/RegisteredMailTrait.php index 9057040f319ec83d4bbd9a03c3de8921bbf78af5..485d845d3428456dd3393e9fdf0139c4f4b24a50 100644 --- a/src/app/registeredMail/controllers/RegisteredMailTrait.php +++ b/src/app/registeredMail/controllers/RegisteredMailTrait.php @@ -54,11 +54,11 @@ trait RegisteredMailTrait return ['errors' => ['No range found']]; } - $status = $range['current_number'] + 1 > $range['range_end'] ? 'DEL' : 'OK'; + $status = $range[0]['current_number'] + 1 > $range[0]['range_end'] ? 'DEL' : 'OK'; RegisteredNumberRangeModel::update([ - 'set' => ['current_number' => $range['current_number'] + 1, 'status' => $status], + 'set' => ['current_number' => $range[0]['current_number'] + 1, 'status' => $status], 'where' => ['id = ?'], - 'data' => [$range['id']] + 'data' => [$range[0]['id']] ]); $date = new \DateTime($resource['departure_date']); @@ -71,7 +71,7 @@ trait RegisteredMailTrait 'warranty' => $args['data']['warranty'], 'letter' => empty($args['letter']) ? 'false' : 'true', 'recipient' => json_encode($args['data']['recipient']), - 'number' => $range['current_number'], + 'number' => $range[0]['current_number'], 'reference' => "{$date} - {$args['data']['reference']}", 'generated' => 'false', ]); @@ -112,11 +112,11 @@ trait RegisteredMailTrait return ['errors' => ['No range found']]; } - $status = $range['current_number'] + 1 > $range['range_end'] ? 'DEL' : 'OK'; + $status = $range[0]['current_number'] + 1 > $range[0]['range_end'] ? 'DEL' : 'OK'; RegisteredNumberRangeModel::update([ - 'set' => ['current_number' => $range['current_number'] + 1, 'status' => $status], + 'set' => ['current_number' => $range[0]['current_number'] + 1, 'status' => $status], 'where' => ['id = ?'], - 'data' => [$range['id']] + 'data' => [$range[0]['id']] ]); $date = new \DateTime($resource['departure_date']); @@ -129,7 +129,7 @@ trait RegisteredMailTrait 'warranty' => $args['data']['warranty'], 'letter' => empty($args['letter']) ? 'false' : 'true', 'recipient' => json_encode($args['data']['recipient']), - 'number' => $range['current_number'], + 'number' => $range[0]['current_number'], 'reference' => "{$date} - {$args['data']['reference']}", 'generated' => 'true', ]); @@ -139,9 +139,8 @@ trait RegisteredMailTrait public static function printRegisteredMail(array $args) { - ValidatorModel::notEmpty($args, ['resId', 'data']); + ValidatorModel::notEmpty($args, ['resId']); ValidatorModel::intVal($args, ['resId']); - ValidatorModel::arrayType($args, ['data']); $registeredMail = RegisteredMailModel::getByResId(['select' => ['issuing_site', 'type', 'number', 'warranty', 'letter', 'recipient'], 'resId' => $args['resId']]); if (empty($registeredMail)) { @@ -175,6 +174,6 @@ trait RegisteredMailTrait 'sender' => $sender ]); - return ['encodedFileContent' => $encodedFileContent]; + return ['data' => $encodedFileContent]; } } diff --git a/src/core/lang/lang-en.php b/src/core/lang/lang-en.php index aec3c45ff90d0b41d3a0b27d04e9f40fa2608355..4af7864b6248dcac8c6a1624aee930a3c22401f7 100755 --- a/src/core/lang/lang-en.php +++ b/src/core/lang/lang-en.php @@ -470,3 +470,7 @@ define("_ISSUING_SITE_DELETED", "Issuing site deleted"); define("_REGISTERED_NUMBER_RANGE_CREATED", "Registered number range created"); define("_REGISTERED_NUMBER_RANGE_UPDATED", "Registered number range updated"); define("_REGISTERED_NUMBER_RANGE_DELETED", "Registered number range deleted"); + +define('_SAVE_REGISTERED_MAIL', 'Save registered mail'); +define('_SAVE_PRINT_REGISTERED_MAIL', 'Save and print registered mail'); +define('_PRINT_REGISTERED_MAIL', 'Print registered mail'); diff --git a/src/core/lang/lang-fr.php b/src/core/lang/lang-fr.php index fc221502667aa2ea46e59231f393d6d14407a446..a6c89b4e4bbc036a02c74644925b586e12a5bbff 100755 --- a/src/core/lang/lang-fr.php +++ b/src/core/lang/lang-fr.php @@ -470,3 +470,7 @@ define("_ISSUING_SITE_DELETED", "Site émetteur supprimé"); define("_REGISTERED_NUMBER_RANGE_CREATED", "Plage de recommandé créé"); define("_REGISTERED_NUMBER_RANGE_UPDATED", "Plage de recommandé modifié"); define("_REGISTERED_NUMBER_RANGE_DELETED", "Plage de recommandé supprimé"); + +define('_SAVE_REGISTERED_MAIL', 'Enregistrer le recommandé'); +define('_SAVE_PRINT_REGISTERED_MAIL', 'Enregistrer et imprimer le recommandé'); +define('_PRINT_REGISTERED_MAIL', 'Imprimer le recommandé'); diff --git a/src/frontend/app/actions/actions.module.ts b/src/frontend/app/actions/actions.module.ts index 4a5e6de5dec16ef8486f6a28f0f9edb32d03c7fd..60b8dae8dc123db999d1645ccc62958ab6f58034 100644 --- a/src/frontend/app/actions/actions.module.ts +++ b/src/frontend/app/actions/actions.module.ts @@ -39,6 +39,9 @@ import { GiveAvisParallelActionComponent } from './avis-give-parallel-action/giv import { ValidateAvisParallelComponent } from './avis-parallel-validate-action/validate-avis-parallel-action.component'; import { ReconcileActionComponent } from './reconciliation-action/reconcile-action.component'; import { SendAlfrescoActionComponent } from './send-alfresco-action/send-alfresco-action.component'; +import { SaveRegisteredMailActionComponent } from './save-registered-mail-action/save-registered-mail-action.component'; +import { SaveAndPrintRegisteredMailActionComponent } from './save-and-print-registered-mail-action/save-and-print-registered-mail-action.component'; +import { PrintRegisteredMailActionComponent } from './print-registered-mail-action/print-registered-mail-action.component'; import { InternationalizationModule } from '../../service/translate/internationalization.module'; import { TranslateService } from '@ngx-translate/core'; @@ -84,6 +87,9 @@ import { TranslateService } from '@ngx-translate/core'; GiveAvisParallelActionComponent, ValidateAvisParallelComponent, SendAlfrescoActionComponent, + SaveRegisteredMailActionComponent, + SaveAndPrintRegisteredMailActionComponent, + PrintRegisteredMailActionComponent, ReconcileActionComponent, ], exports: [ @@ -121,6 +127,9 @@ import { TranslateService } from '@ngx-translate/core'; GiveAvisParallelActionComponent, ValidateAvisParallelComponent, SendAlfrescoActionComponent, + SaveRegisteredMailActionComponent, + SaveAndPrintRegisteredMailActionComponent, + PrintRegisteredMailActionComponent, ReconcileActionComponent, DocumentViewerModule ], @@ -151,6 +160,9 @@ import { TranslateService } from '@ngx-translate/core'; closeMailWithAttachmentsOrNotesActionComponent, SendSignatureBookActionComponent, SendAlfrescoActionComponent, + SaveRegisteredMailActionComponent, + SaveAndPrintRegisteredMailActionComponent, + PrintRegisteredMailActionComponent, ViewDocActionComponent, ReconcileActionComponent, ] diff --git a/src/frontend/app/actions/actions.service.ts b/src/frontend/app/actions/actions.service.ts index ac0cca6c3ae066848573145bb804ecb0517b8077..2bc8dcbd1457d2de9285ed45ac4d13ad317f2fd5 100644 --- a/src/frontend/app/actions/actions.service.ts +++ b/src/frontend/app/actions/actions.service.ts @@ -37,6 +37,9 @@ import { HeaderService } from '../../service/header.service'; import { FunctionsService } from '../../service/functions.service'; import { ReconcileActionComponent } from './reconciliation-action/reconcile-action.component'; import { SendAlfrescoActionComponent } from './send-alfresco-action/send-alfresco-action.component'; +import { SaveRegisteredMailActionComponent } from './save-registered-mail-action/save-registered-mail-action.component'; +import { SaveAndPrintRegisteredMailActionComponent } from './save-and-print-registered-mail-action/save-and-print-registered-mail-action.component'; +import { PrintRegisteredMailActionComponent } from './print-registered-mail-action/print-registered-mail-action.component'; @Injectable() export class ActionsService implements OnDestroy { @@ -968,4 +971,79 @@ export class ActionsService implements OnDestroy { }) ).subscribe(); } + + saveRegisteredMailAction(options: any = null) { + + const dialogRef = this.dialog.open(SaveRegisteredMailActionComponent, { + panelClass: 'maarch-modal', + disableClose: true, + width: '500px', + data: this.setDatasActionToSend() + }); + + dialogRef.afterClosed().pipe( + tap((resIds: any) => { + this.unlockResourceAfterActionModal(resIds); + }), + filter((resIds: any) => !this.functions.empty(resIds)), + tap((resIds: any) => { + this.endAction(resIds); + }), + finalize(() => this.loading = false), + catchError((err: any) => { + this.notify.handleErrors(err); + return of(false); + }) + ).subscribe(); + } + + saveAndPrintRegisteredMailAction(options: any = null) { + + const dialogRef = this.dialog.open(SaveAndPrintRegisteredMailActionComponent, { + panelClass: 'maarch-modal', + disableClose: true, + width: '500px', + data: this.setDatasActionToSend() + }); + + dialogRef.afterClosed().pipe( + tap((resIds: any) => { + this.unlockResourceAfterActionModal(resIds); + }), + filter((resIds: any) => !this.functions.empty(resIds)), + tap((resIds: any) => { + this.endAction(resIds); + }), + finalize(() => this.loading = false), + catchError((err: any) => { + this.notify.handleErrors(err); + return of(false); + }) + ).subscribe(); + } + + printRegisteredMailAction(options: any = null) { + + const dialogRef = this.dialog.open(PrintRegisteredMailActionComponent, { + panelClass: 'maarch-modal', + disableClose: true, + width: '500px', + data: this.setDatasActionToSend() + }); + + dialogRef.afterClosed().pipe( + tap((resIds: any) => { + this.unlockResourceAfterActionModal(resIds); + }), + filter((resIds: any) => !this.functions.empty(resIds)), + tap((resIds: any) => { + this.endAction(resIds); + }), + finalize(() => this.loading = false), + catchError((err: any) => { + this.notify.handleErrors(err); + return of(false); + }) + ).subscribe(); + } } diff --git a/src/frontend/app/actions/print-registered-mail-action/print-registered-mail-action.component.html b/src/frontend/app/actions/print-registered-mail-action/print-registered-mail-action.component.html new file mode 100755 index 0000000000000000000000000000000000000000..c60eb7ac35010913cf3b827bf3d925aecdcdb8c3 --- /dev/null +++ b/src/frontend/app/actions/print-registered-mail-action/print-registered-mail-action.component.html @@ -0,0 +1,25 @@ +<div class="mat-dialog-content-container"> + <h1 mat-dialog-title>{{data.action.label}}</h1> + <div mat-dialog-content> + <div *ngIf="loading" class="loading" style="display:flex;height:100%;"> + <mat-spinner style="margin:auto;"></mat-spinner> + </div> + <div class="row"> + <div class="col-md-12"> + {{'lang.makeActionOn' | translate}} + <b *ngIf="data.resIds.length === 0" color="primary" class="highlight">{{'lang.currentIndexingMail' | translate}}</b> + <b *ngIf="data.resIds.length == 1" color="primary" class="highlight">{{data.resource.chrono}}</b> + <b *ngIf="data.resIds.length > 1" color="primary" class="highlight">{{data.resIds.length}} {{'lang.elements' | translate}}</b> ? + </div> + <div class="col-md-12"> + <app-note-editor #noteEditor [resIds]="data.resIds"></app-note-editor> + </div> + </div> + </div> + <span class="divider-modal"></span> + <div mat-dialog-actions class="actions"> + <button mat-raised-button mat-button color="primary" [disabled]="loading" (click)="onSubmit()">{{'lang.validate' | translate}}</button> + <button mat-raised-button mat-button [disabled]="loading" [mat-dialog-close]="">{{'lang.cancel' | translate}}</button> + </div> +</div> + diff --git a/src/frontend/app/actions/print-registered-mail-action/print-registered-mail-action.component.scss b/src/frontend/app/actions/print-registered-mail-action/print-registered-mail-action.component.scss new file mode 100755 index 0000000000000000000000000000000000000000..9b9e92da03cafc37dc94c66e97855987df4aeea3 --- /dev/null +++ b/src/frontend/app/actions/print-registered-mail-action/print-registered-mail-action.component.scss @@ -0,0 +1,15 @@ +.highlight { + font-size: 110%; +} + +.loading { + display:flex; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: #ffffffb3; + z-index: 1; + overflow: hidden; +} \ No newline at end of file diff --git a/src/frontend/app/actions/print-registered-mail-action/print-registered-mail-action.component.ts b/src/frontend/app/actions/print-registered-mail-action/print-registered-mail-action.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..a9effdf285a5b487043ceb1076f0cc908b351983 --- /dev/null +++ b/src/frontend/app/actions/print-registered-mail-action/print-registered-mail-action.component.ts @@ -0,0 +1,54 @@ +import { Component, OnInit, Inject, ViewChild } from '@angular/core'; +import { LANG } from '../../translate.component'; +import { TranslateService } from '@ngx-translate/core'; +import { NotificationService } from '../../../service/notification/notification.service'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { HttpClient } from '@angular/common/http'; +import { NoteEditorComponent } from '../../notes/note-editor.component'; +import { tap, exhaustMap, catchError, finalize } from 'rxjs/operators'; +import { of } from 'rxjs'; + +@Component({ + templateUrl: "print-registered-mail-action.component.html", + styleUrls: ['print-registered-mail-action.component.scss'], +}) +export class PrintRegisteredMailActionComponent implements OnInit { + + lang: any = LANG; + loading: boolean = false; + + @ViewChild('noteEditor', { static: true }) noteEditor: NoteEditorComponent; + + constructor( + private translate: TranslateService, + public http: HttpClient, + private notify: NotificationService, + public dialogRef: MatDialogRef<PrintRegisteredMailActionComponent>, + @Inject(MAT_DIALOG_DATA) public data: any + ) { } + + ngOnInit(): void { } + + onSubmit() { + this.loading = true; + this.executeAction(); + } + + executeAction() { + const downloadLink = document.createElement('a'); + this.http.put(this.data.processActionRoute, { resources: this.data.resIds, note: this.noteEditor.getNote() }).pipe( + tap((data: any) => { + downloadLink.href = `data:application/pdf;base64,${data.data.encodedFileContent}`; + downloadLink.setAttribute('download', 'recommande.pdf'); + document.body.appendChild(downloadLink); + downloadLink.click(); + this.dialogRef.close(this.data.resIds); + }), + finalize(() => this.loading = false), + catchError((err: any) => { + this.notify.handleSoftErrors(err); + return of(false); + }) + ).subscribe(); + } +} diff --git a/src/frontend/app/actions/save-and-print-registered-mail-action/save-and-print-registered-mail-action.component.html b/src/frontend/app/actions/save-and-print-registered-mail-action/save-and-print-registered-mail-action.component.html new file mode 100755 index 0000000000000000000000000000000000000000..c60eb7ac35010913cf3b827bf3d925aecdcdb8c3 --- /dev/null +++ b/src/frontend/app/actions/save-and-print-registered-mail-action/save-and-print-registered-mail-action.component.html @@ -0,0 +1,25 @@ +<div class="mat-dialog-content-container"> + <h1 mat-dialog-title>{{data.action.label}}</h1> + <div mat-dialog-content> + <div *ngIf="loading" class="loading" style="display:flex;height:100%;"> + <mat-spinner style="margin:auto;"></mat-spinner> + </div> + <div class="row"> + <div class="col-md-12"> + {{'lang.makeActionOn' | translate}} + <b *ngIf="data.resIds.length === 0" color="primary" class="highlight">{{'lang.currentIndexingMail' | translate}}</b> + <b *ngIf="data.resIds.length == 1" color="primary" class="highlight">{{data.resource.chrono}}</b> + <b *ngIf="data.resIds.length > 1" color="primary" class="highlight">{{data.resIds.length}} {{'lang.elements' | translate}}</b> ? + </div> + <div class="col-md-12"> + <app-note-editor #noteEditor [resIds]="data.resIds"></app-note-editor> + </div> + </div> + </div> + <span class="divider-modal"></span> + <div mat-dialog-actions class="actions"> + <button mat-raised-button mat-button color="primary" [disabled]="loading" (click)="onSubmit()">{{'lang.validate' | translate}}</button> + <button mat-raised-button mat-button [disabled]="loading" [mat-dialog-close]="">{{'lang.cancel' | translate}}</button> + </div> +</div> + diff --git a/src/frontend/app/actions/save-and-print-registered-mail-action/save-and-print-registered-mail-action.component.scss b/src/frontend/app/actions/save-and-print-registered-mail-action/save-and-print-registered-mail-action.component.scss new file mode 100755 index 0000000000000000000000000000000000000000..9b9e92da03cafc37dc94c66e97855987df4aeea3 --- /dev/null +++ b/src/frontend/app/actions/save-and-print-registered-mail-action/save-and-print-registered-mail-action.component.scss @@ -0,0 +1,15 @@ +.highlight { + font-size: 110%; +} + +.loading { + display:flex; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: #ffffffb3; + z-index: 1; + overflow: hidden; +} \ No newline at end of file diff --git a/src/frontend/app/actions/save-and-print-registered-mail-action/save-and-print-registered-mail-action.component.ts b/src/frontend/app/actions/save-and-print-registered-mail-action/save-and-print-registered-mail-action.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..6a5e8c46372404d62d65bdcf6c6378d01a9ed114 --- /dev/null +++ b/src/frontend/app/actions/save-and-print-registered-mail-action/save-and-print-registered-mail-action.component.ts @@ -0,0 +1,79 @@ +import { Component, OnInit, Inject, ViewChild } from '@angular/core'; +import { LANG } from '../../translate.component'; +import { TranslateService } from '@ngx-translate/core'; +import { NotificationService } from '../../../service/notification/notification.service'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { HttpClient } from '@angular/common/http'; +import { NoteEditorComponent } from '../../notes/note-editor.component'; +import { tap, exhaustMap, catchError, finalize } from 'rxjs/operators'; +import { of } from 'rxjs'; + +@Component({ + templateUrl: "save-and-print-registered-mail-action.component.html", + styleUrls: ['save-and-print-registered-mail-action.component.scss'], +}) +export class SaveAndPrintRegisteredMailActionComponent implements OnInit { + + lang: any = LANG; + loading: boolean = false; + + @ViewChild('noteEditor', { static: true }) noteEditor: NoteEditorComponent; + + constructor( + private translate: TranslateService, + public http: HttpClient, + private notify: NotificationService, + public dialogRef: MatDialogRef<SaveAndPrintRegisteredMailActionComponent>, + @Inject(MAT_DIALOG_DATA) public data: any + ) { } + + ngOnInit(): void { } + + onSubmit() { + this.loading = true; + if (this.data.resIds.length === 0) { + this.indexDocumentAndExecuteAction(); + } else { + this.executeAction(); + } + } + + indexDocumentAndExecuteAction() { + this.http.post('../rest/resources', this.data.resource).pipe( + tap((data: any) => { + this.data.resIds = [data.resId]; + }), + exhaustMap(() => this.http.put(this.data.indexActionRoute, { resource: this.data.resIds[0], note: this.noteEditor.getNote(), + data: { + type: this.data.resource.registeredMail_type, + warranty: this.data.resource.registeredMail_warranty, + issuingSiteId: this.data.resource.registeredMail_issuingSite, + recipient: this.data.resource.registeredMail_recipient, + reference: this.data.resource.registeredMail_reference + } + }) + ), + tap(() => { + this.dialogRef.close(this.data.resIds); + }), + finalize(() => this.loading = false), + catchError((err: any) => { + this.notify.handleSoftErrors(err); + return of(false); + }) + ).subscribe() + } + + executeAction() { + this.http.put(this.data.processActionRoute, { resources: this.data.resIds, note: this.noteEditor.getNote() }).pipe( + tap(() => { + this.dialogRef.close(this.data.resIds); + }), + finalize(() => this.loading = false), + catchError((err: any) => { + this.notify.handleSoftErrors(err); + return of(false); + }) + ).subscribe(); + } +} diff --git a/src/frontend/app/actions/save-registered-mail-action/save-registered-mail-action.component.html b/src/frontend/app/actions/save-registered-mail-action/save-registered-mail-action.component.html new file mode 100755 index 0000000000000000000000000000000000000000..c60eb7ac35010913cf3b827bf3d925aecdcdb8c3 --- /dev/null +++ b/src/frontend/app/actions/save-registered-mail-action/save-registered-mail-action.component.html @@ -0,0 +1,25 @@ +<div class="mat-dialog-content-container"> + <h1 mat-dialog-title>{{data.action.label}}</h1> + <div mat-dialog-content> + <div *ngIf="loading" class="loading" style="display:flex;height:100%;"> + <mat-spinner style="margin:auto;"></mat-spinner> + </div> + <div class="row"> + <div class="col-md-12"> + {{'lang.makeActionOn' | translate}} + <b *ngIf="data.resIds.length === 0" color="primary" class="highlight">{{'lang.currentIndexingMail' | translate}}</b> + <b *ngIf="data.resIds.length == 1" color="primary" class="highlight">{{data.resource.chrono}}</b> + <b *ngIf="data.resIds.length > 1" color="primary" class="highlight">{{data.resIds.length}} {{'lang.elements' | translate}}</b> ? + </div> + <div class="col-md-12"> + <app-note-editor #noteEditor [resIds]="data.resIds"></app-note-editor> + </div> + </div> + </div> + <span class="divider-modal"></span> + <div mat-dialog-actions class="actions"> + <button mat-raised-button mat-button color="primary" [disabled]="loading" (click)="onSubmit()">{{'lang.validate' | translate}}</button> + <button mat-raised-button mat-button [disabled]="loading" [mat-dialog-close]="">{{'lang.cancel' | translate}}</button> + </div> +</div> + diff --git a/src/frontend/app/actions/save-registered-mail-action/save-registered-mail-action.component.scss b/src/frontend/app/actions/save-registered-mail-action/save-registered-mail-action.component.scss new file mode 100755 index 0000000000000000000000000000000000000000..9b9e92da03cafc37dc94c66e97855987df4aeea3 --- /dev/null +++ b/src/frontend/app/actions/save-registered-mail-action/save-registered-mail-action.component.scss @@ -0,0 +1,15 @@ +.highlight { + font-size: 110%; +} + +.loading { + display:flex; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: #ffffffb3; + z-index: 1; + overflow: hidden; +} \ No newline at end of file diff --git a/src/frontend/app/actions/save-registered-mail-action/save-registered-mail-action.component.ts b/src/frontend/app/actions/save-registered-mail-action/save-registered-mail-action.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..206e0e43afa6c3235a93bb1008e68141fdaa24a5 --- /dev/null +++ b/src/frontend/app/actions/save-registered-mail-action/save-registered-mail-action.component.ts @@ -0,0 +1,79 @@ +import { Component, OnInit, Inject, ViewChild } from '@angular/core'; +import { LANG } from '../../translate.component'; +import { TranslateService } from '@ngx-translate/core'; +import { NotificationService } from '../../../service/notification/notification.service'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { HttpClient } from '@angular/common/http'; +import { NoteEditorComponent } from '../../notes/note-editor.component'; +import { tap, exhaustMap, catchError, finalize } from 'rxjs/operators'; +import { of } from 'rxjs'; + +@Component({ + templateUrl: "save-registered-mail-action.component.html", + styleUrls: ['save-registered-mail-action.component.scss'], +}) +export class SaveRegisteredMailActionComponent implements OnInit { + + lang: any = LANG; + loading: boolean = false; + + @ViewChild('noteEditor', { static: true }) noteEditor: NoteEditorComponent; + + constructor( + private translate: TranslateService, + public http: HttpClient, + private notify: NotificationService, + public dialogRef: MatDialogRef<SaveRegisteredMailActionComponent>, + @Inject(MAT_DIALOG_DATA) public data: any + ) { } + + ngOnInit(): void { } + + onSubmit() { + this.loading = true; + if (this.data.resIds.length === 0) { + this.indexDocumentAndExecuteAction(); + } else { + this.executeAction(); + } + } + + indexDocumentAndExecuteAction() { + this.http.post('../rest/resources', this.data.resource).pipe( + tap((data: any) => { + this.data.resIds = [data.resId]; + }), + exhaustMap(() => this.http.put(this.data.indexActionRoute, { resource: this.data.resIds[0], note: this.noteEditor.getNote(), + data: { + type: this.data.resource.registeredMail_type, + warranty: this.data.resource.registeredMail_warranty, + issuingSiteId: this.data.resource.registeredMail_issuingSite, + recipient: this.data.resource.registeredMail_recipient, + reference: this.data.resource.registeredMail_reference + } + }) + ), + tap(() => { + this.dialogRef.close(this.data.resIds); + }), + finalize(() => this.loading = false), + catchError((err: any) => { + this.notify.handleSoftErrors(err); + return of(false); + }) + ).subscribe() + } + + executeAction() { + this.http.put(this.data.processActionRoute, { resources: this.data.resIds, note: this.noteEditor.getNote() }).pipe( + tap(() => { + this.dialogRef.close(this.data.resIds); + }), + finalize(() => this.loading = false), + catchError((err: any) => { + this.notify.handleSoftErrors(err); + return of(false); + }) + ).subscribe(); + } +} diff --git a/src/frontend/app/administration/registered-mail/registered-mail-list.component.ts b/src/frontend/app/administration/registered-mail/registered-mail-list.component.ts index 4c05152dcc20aedec5b45a003c1fe36c2bd32981..9809b22812eecf646ad16a4a2d2729a1550f5657 100644 --- a/src/frontend/app/administration/registered-mail/registered-mail-list.component.ts +++ b/src/frontend/app/administration/registered-mail/registered-mail-list.component.ts @@ -98,7 +98,7 @@ export class RegisteredMailListComponent implements OnInit { const dataTosend = JSON.parse(JSON.stringify(row)); dataTosend.status = 'OK'; - const dialogRef = this.dialog.open(ConfirmComponent, { panelClass: 'maarch-modal', autoFocus: false, disableClose: true, data: { title: this.translate.instant('lang.activate'), msg: 'En activant cette plage, cela clôtura la plage actuelle utilisée pour ce type de recommandé.' } }); + const dialogRef = this.dialog.open(ConfirmComponent, { panelClass: 'maarch-modal', autoFocus: false, disableClose: true, data: { title: this.translate.instant('lang.activate'), msg: 'En activant cette plage, cela clôturera la plage actuelle utilisée pour ce type de recommandé.' } }); dialogRef.afterClosed().pipe( filter((data: string) => data === 'ok'),