diff --git a/core/xml/actions_pages.xml b/core/xml/actions_pages.xml index 9d1a0efff252610aeb3bc985857e98f0e8479286..00c3e39101528eba3e706a005782ffa2c04bd770 100755 --- a/core/xml/actions_pages.xml +++ b/core/xml/actions_pages.xml @@ -436,6 +436,16 @@ An action page is described in a ACTIONPAGE tag : <MODULE></MODULE> <FLAG_CREATE>false</FLAG_CREATE> </ACTIONPAGE> + <ACTIONPAGE> + <ID>saveAndIndexRegisteredMail</ID> + <LABEL>_SAVE_INDEX_REGISTERED_MAIL</LABEL> + <NAME>saveAndIndexRegisteredMail</NAME> + <DESC>_SAVE_INDEX_REGISTERED_MAIL</DESC> + <component>saveAndIndexRegisteredMailAction</component> + <ORIGIN>apps</ORIGIN> + <MODULE></MODULE> + <FLAG_CREATE>false</FLAG_CREATE> + </ACTIONPAGE> <ACTIONPAGE> <ID>printRegisteredMail</ID> <LABEL>_PRINT_REGISTERED_MAIL</LABEL> diff --git a/src/app/action/controllers/ActionMethodController.php b/src/app/action/controllers/ActionMethodController.php index 949b19bca09bde51cefaa403a3a1361c13c3167f..4777a37281a0aac881215b72a0d74ed26b7d4f95 100644 --- a/src/app/action/controllers/ActionMethodController.php +++ b/src/app/action/controllers/ActionMethodController.php @@ -83,6 +83,7 @@ class ActionMethodController 'sendAlfrescoAction' => 'sendResourceAlfresco', 'saveRegisteredMailAction' => 'saveRegisteredMail', 'saveAndPrintRegisteredMailAction' => 'saveAndPrintRegisteredMail', + 'saveAndIndexRegisteredMailAction' => 'saveRegisteredMail', 'printRegisteredMailAction' => 'printRegisteredMail', 'noConfirmAction' => null ]; diff --git a/src/app/group/controllers/GroupController.php b/src/app/group/controllers/GroupController.php index ec079c26edf2d008c3d10cf952ea926d076a6ec0..d13d5dead3641917f0ed247ee60de12d526baf9e 100755 --- a/src/app/group/controllers/GroupController.php +++ b/src/app/group/controllers/GroupController.php @@ -19,7 +19,8 @@ use User\models\UserModel; class GroupController { - const INDEXING_ACTIONS = ['confirmAction', 'noConfirmAction', 'closeMailAction', 'sendSignatureBookAction', 'closeAndIndexAction', 'saveRegisteredMailAction', 'saveAndPrintRegisteredMailAction']; + const INDEXING_ACTIONS = ['confirmAction', 'noConfirmAction', 'closeMailAction', 'sendSignatureBookAction', 'closeAndIndexAction', + 'saveRegisteredMailAction', 'saveAndPrintRegisteredMailAction', 'saveAndIndexRegisteredMailAction']; public function get(Request $request, Response $response) { diff --git a/src/core/lang/lang-en.php b/src/core/lang/lang-en.php index 4af7864b6248dcac8c6a1624aee930a3c22401f7..7109cb9d179f556091720b42e0c610bef0a3e729 100755 --- a/src/core/lang/lang-en.php +++ b/src/core/lang/lang-en.php @@ -473,4 +473,5 @@ 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('_SAVE_INDEX_REGISTERED_MAIL', 'Save registered mail and start indexing'); define('_PRINT_REGISTERED_MAIL', 'Print registered mail'); diff --git a/src/core/lang/lang-fr.php b/src/core/lang/lang-fr.php index a6c89b4e4bbc036a02c74644925b586e12a5bbff..f882f7aa93a740028996719648afb75a17ef9756 100755 --- a/src/core/lang/lang-fr.php +++ b/src/core/lang/lang-fr.php @@ -473,4 +473,5 @@ 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('_SAVE_INDEX_REGISTERED_MAIL', 'Enregistrer le recommandé et lancer l\'indexation'); 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 60b8dae8dc123db999d1645ccc62958ab6f58034..72537a09b3d1dfa4e5c59cbfdb6ff44a48801373 100644 --- a/src/frontend/app/actions/actions.module.ts +++ b/src/frontend/app/actions/actions.module.ts @@ -40,6 +40,7 @@ import { ValidateAvisParallelComponent } from './avis-parallel-validate-action/v 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 { SaveAndIndexRegisteredMailActionComponent } from './save-and-index-registered-mail-action/save-and-index-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'; @@ -89,6 +90,7 @@ import { TranslateService } from '@ngx-translate/core'; SendAlfrescoActionComponent, SaveRegisteredMailActionComponent, SaveAndPrintRegisteredMailActionComponent, + SaveAndIndexRegisteredMailActionComponent, PrintRegisteredMailActionComponent, ReconcileActionComponent, ], @@ -129,6 +131,7 @@ import { TranslateService } from '@ngx-translate/core'; SendAlfrescoActionComponent, SaveRegisteredMailActionComponent, SaveAndPrintRegisteredMailActionComponent, + SaveAndIndexRegisteredMailActionComponent, PrintRegisteredMailActionComponent, ReconcileActionComponent, DocumentViewerModule @@ -162,6 +165,7 @@ import { TranslateService } from '@ngx-translate/core'; SendAlfrescoActionComponent, SaveRegisteredMailActionComponent, SaveAndPrintRegisteredMailActionComponent, + SaveAndIndexRegisteredMailActionComponent, PrintRegisteredMailActionComponent, ViewDocActionComponent, ReconcileActionComponent, diff --git a/src/frontend/app/actions/actions.service.ts b/src/frontend/app/actions/actions.service.ts index d46dc9494e5527b3ce5fd34245a094cd07a1d7ce..3ca1dc35597c3f2192eb65d2302d5689f490e13c 100644 --- a/src/frontend/app/actions/actions.service.ts +++ b/src/frontend/app/actions/actions.service.ts @@ -39,6 +39,7 @@ import { ReconcileActionComponent } from './reconciliation-action/reconcile-acti 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 { SaveAndIndexRegisteredMailActionComponent } from './save-and-index-registered-mail-action/save-and-index-registered-mail-action.component'; import { PrintRegisteredMailActionComponent } from './print-registered-mail-action/print-registered-mail-action.component'; @Injectable() @@ -1022,6 +1023,29 @@ export class ActionsService implements OnDestroy { ).subscribe(); } + saveAndIndexRegisteredMailAction(options: any = null) { + const dialogRef = this.dialog.open(SaveAndIndexRegisteredMailActionComponent, { + 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, { diff --git a/src/frontend/app/actions/save-and-index-registered-mail-action/save-and-index-registered-mail-action.component.html b/src/frontend/app/actions/save-and-index-registered-mail-action/save-and-index-registered-mail-action.component.html new file mode 100755 index 0000000000000000000000000000000000000000..c60eb7ac35010913cf3b827bf3d925aecdcdb8c3 --- /dev/null +++ b/src/frontend/app/actions/save-and-index-registered-mail-action/save-and-index-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-index-registered-mail-action/save-and-index-registered-mail-action.component.scss b/src/frontend/app/actions/save-and-index-registered-mail-action/save-and-index-registered-mail-action.component.scss new file mode 100755 index 0000000000000000000000000000000000000000..9b9e92da03cafc37dc94c66e97855987df4aeea3 --- /dev/null +++ b/src/frontend/app/actions/save-and-index-registered-mail-action/save-and-index-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-index-registered-mail-action/save-and-index-registered-mail-action.component.ts b/src/frontend/app/actions/save-and-index-registered-mail-action/save-and-index-registered-mail-action.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..62ba0cd4a2cc3a83fbdd5278d4aabd11d801f22c --- /dev/null +++ b/src/frontend/app/actions/save-and-index-registered-mail-action/save-and-index-registered-mail-action.component.ts @@ -0,0 +1,80 @@ +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-index-registered-mail-action.component.html", + styleUrls: ['save-and-index-registered-mail-action.component.scss'], +}) +export class SaveAndIndexRegisteredMailActionComponent implements OnInit { + + lang: any = LANG; + loading: boolean = false; + + @ViewChild('noteEditor', { static: true }) noteEditor: NoteEditorComponent; + + constructor( + public translate: TranslateService, + public http: HttpClient, + private notify: NotificationService, + public dialogRef: MatDialogRef<SaveAndIndexRegisteredMailActionComponent>, + @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, + letter: this.data.resource.registeredMail_letter, + 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/indexation/indexation.component.ts b/src/frontend/app/indexation/indexation.component.ts index 84e8e54045595891d8987094cc512e1243d97266..4256c49562fbecbb8fe09a0c81340644ce2c1097 100644 --- a/src/frontend/app/indexation/indexation.component.ts +++ b/src/frontend/app/indexation/indexation.component.ts @@ -86,7 +86,7 @@ export class IndexationComponent implements OnInit { // Event after process action this.subscription = this.actionService.catchAction().subscribe(resIds => { - if (this.selectedAction.component === 'closeAndIndexAction') { + if (['closeAndIndexAction', 'saveAndIndexRegisteredMailAction'].indexOf(this.selectedAction.component) > -1) { this.appDocumentViewer.templateListForm.reset(); this.appDocumentViewer.file = { name: '',