Skip to content
Snippets Groups Projects
Commit f088929a authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #14837 TIME 0:45 init action multigest front

parent 6370d9cd
No related branches found
No related tags found
No related merge requests found
......@@ -45,6 +45,7 @@ import { SendToRecordManagementComponent } from './send-to-record-management-act
import { CheckReplyRecordManagementComponent } from './check-reply-record-management-action/check-reply-record-management.component';
import { ResetRecordManagementComponent } from './reset-record-management-action/reset-record-management.component';
import { CheckAcknowledgmentRecordManagementComponent } from './check-acknowledgment-record-management-action/check-acknowledgment-record-management.component';
import { SendMultigestActionComponent } from './send-multigest-action/send-multigest-action.component';
@Injectable()
export class ActionsService implements OnDestroy {
......@@ -1203,6 +1204,30 @@ export class ActionsService implements OnDestroy {
).subscribe();
}
sendMultigestAction(options: any = null) {
const dialogRef = this.dialog.open(SendMultigestActionComponent, {
panelClass: 'maarch-modal',
autoFocus: false,
disableClose: true,
data: this.setDatasActionToSend()
});
dialogRef.afterClosed().pipe(
tap((data: any) => {
this.unlockResourceAfterActionModal(data);
}),
filter((data: string) => data === 'success'),
tap((result: any) => {
this.endAction(result);
}),
finalize(() => this.loading = false),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
}
getUserOtpIcon(id: string): Promise<string> {
return new Promise((resolve) => {
this.http.get(`assets/${id}.png`, { responseType: 'blob' }).pipe(
......
<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" style="margin: 0;">
<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>
<br />
<div *ngIf="resourcesErrors.length > 0" class="alert-message alert-message-danger mailList" role="alert">
<p>
{{'lang.canNotMakeAction' | translate}} :
</p>
<ul>
<li *ngFor="let ressource of resourcesErrors">
<b>{{ressource.alt_identifier}}</b> : {{'lang.' + ressource.reason | translate}}
</li>
</ul>
</div>
<div style="clear: both;">
<mat-form-field class="smallInput" appearance="outline" floatLabel="never">
<mat-icon color="primary" class="fa fa-search" matPrefix></mat-icon>
<input type="text" id="autoCompleteInput" #autoCompleteInput [placeholder]="'Recherche un dossier'"
matInput [formControl]="searchFolder">
</mat-form-field>
<app-maaarch-tree #maarchTree *ngIf="multigestFolders.length > 0"
[childrenRoute]="'../rest/multigest/folders/__node/children'" [rawData]="multigestFolders"
(afterSelectNode)="selectFolder($event)"></app-maaarch-tree>
<div id="jstreeMultigest"></div>
</div>
<div class="col-md-12" style="padding-top: 10px;">
<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 || !isValidAction()"
(click)="onSubmit()">{{'lang.validate' | translate}}</button>
<button mat-raised-button mat-button [disabled]="loading" [mat-dialog-close]="">{{'lang.cancel' | translate}}</button>
</div>
</div>
\ No newline at end of file
.loading {
display: flex;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #ffffffb3;
z-index: 2;
overflow: hidden;
}
.smallInput {
font-size: 9px;
padding-left: 20px;
padding-right: 20px;
::ng-deep.mat-form-field-flex {
display: flex;
align-items: center;
}
.mat-icon {
height: auto;
}
}
\ No newline at end of file
import { Component, OnInit, Inject, ViewChild } from '@angular/core';
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, finalize, catchError, debounceTime, filter, switchMap } from 'rxjs/operators';
import { FormControl } from '@angular/forms';
import { FunctionsService } from '@service/functions.service';
import { MaarchTreeComponent } from '@plugins/tree/maarch-tree.component';
import { of } from 'rxjs';
@Component({
templateUrl: 'send-multigest-action.component.html',
styleUrls: ['send-multigest-action.component.scss'],
})
export class SendMultigestActionComponent implements OnInit {
@ViewChild('noteEditor', { static: true }) noteEditor: NoteEditorComponent;
@ViewChild('maarchTree', { static: false }) maarchTree: MaarchTreeComponent;
loading: boolean = false;
errors: any;
multigestFolders: any[] = [];
searchFolder = new FormControl();
selectedFolder: number = null;
selectedFolderName: string = null;
resourcesErrors: any[] = [];
noResourceToProcess: boolean = null;
constructor(
public translate: TranslateService,
public http: HttpClient,
private notify: NotificationService,
public dialogRef: MatDialogRef<SendMultigestActionComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
public functions: FunctionsService
) { }
async ngOnInit(): Promise<void> {
this.loading = true;
await this.checkMultigest();
this.loading = false;
this.getRootFolders();
this.searchFolder.valueChanges
.pipe(
debounceTime(300),
tap(async (value: any) => {
this.selectedFolder = null;
this.selectedFolderName = null;
if (value.length === 0) {
await this.getRootFolders();
this.refreshTree();
}
}),
filter(value => value.length > 2),
switchMap(data => this.http.get('../rest/multigest/autocomplete/folders', { params: { 'search': data } })),
tap((data: any) => {
this.multigestFolders = data;
this.refreshTree();
})
).subscribe();
}
checkMultigest() {
this.resourcesErrors = [];
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 + '/checkSendMultigest', { resources: this.data.resIds })
.subscribe((data: any) => {
if (!this.functions.empty(data.fatalError)) {
this.notify.error(this.translate.instant('lang.' + data.reason));
this.dialogRef.close();
} else 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);
this.dialogRef.close();
});
});
}
refreshTree() {
const tmpData = this.multigestFolders;
this.multigestFolders = [];
setTimeout(() => {
this.multigestFolders = tmpData;
}, 200);
}
getRootFolders() {
return new Promise((resolve, reject) => {
this.http.get('../rest/multigest/rootFolders').pipe(
tap((data: any) => {
this.multigestFolders = data;
resolve(true);
}),
catchError((err: any) => {
this.notify.handleSoftErrors(err);
return of(false);
})
).subscribe();
});
}
selectFolder(folder: any) {
this.selectedFolder = folder.id;
this.selectedFolderName = this.getNameWithParents(folder.text, folder.parent);
}
onSubmit() {
this.loading = true;
if (this.data.resIds.length > 0) {
this.executeAction();
}
}
executeAction() {
const realResSelected: number[] = this.data.resIds.filter((resId: any) => this.resourcesErrors.map(resErr => resErr.res_id).indexOf(resId) === -1);
this.http.put(this.data.processActionRoute, { resources: realResSelected, note: this.noteEditor.getNoteContent(), data: { folderId: this.selectedFolder, folderName: this.selectedFolderName } }).pipe(
tap((data: any) => {
if (!data) {
this.dialogRef.close('success');
}
if (data && data.errors != null) {
this.notify.error(data.errors);
}
}),
finalize(() => this.loading = false),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
}
isValidAction() {
return this.selectedFolder !== null && !this.noResourceToProcess;
}
getNameWithParents(name: string, parentId: string) {
if (parentId === '#') {
return name;
}
this.maarchTree.getTreeData().forEach((folder: any) => {
if (folder.id == parentId) {
name = folder.text + '/' + name;
if (folder.parent !== '#') {
name = this.getNameWithParents(name, folder.parent);
}
}
});
return name;
}
}
......@@ -83,6 +83,8 @@ import { SendToRecordManagementComponent } from './actions/send-to-record-manage
import { CheckReplyRecordManagementComponent } from './actions/check-reply-record-management-action/check-reply-record-management.component';
import { ResetRecordManagementComponent } from './actions/reset-record-management-action/reset-record-management.component';
import { CheckAcknowledgmentRecordManagementComponent } from './actions/check-acknowledgment-record-management-action/check-acknowledgment-record-management.component';
import { SendMultigestActionComponent } from './actions/send-multigest-action/send-multigest-action.component';
// PROCESS
import { ProcessComponent } from './process/process.component';
......@@ -275,6 +277,7 @@ export class MyHammerConfig extends HammerGestureConfig {
GiveAvisParallelActionComponent,
ValidateAvisParallelComponent,
SendAlfrescoActionComponent,
SendMultigestActionComponent,
SaveRegisteredMailActionComponent,
SaveAndPrintRegisteredMailActionComponent,
SaveAndIndexRegisteredMailActionComponent,
......@@ -349,6 +352,7 @@ export class MyHammerConfig extends HammerGestureConfig {
closeMailWithAttachmentsOrNotesActionComponent,
SendSignatureBookActionComponent,
SendAlfrescoActionComponent,
SendMultigestActionComponent,
SaveRegisteredMailActionComponent,
SaveAndPrintRegisteredMailActionComponent,
SaveAndIndexRegisteredMailActionComponent,
......
......@@ -6,7 +6,7 @@ interface actionPages {
'label': string; // title
'name': string; // name
'component': string; // action service component
'category': 'application' | 'acknowledgementReceipt' | 'externalSignatoryBook' | 'visa' | 'avis' | 'maileva' | 'alfresco' | 'registeredMail' | 'recordManagement'; // category
'category': 'application' | 'acknowledgementReceipt' | 'externalSignatoryBook' | 'visa' | 'avis' | 'maileva' | 'alfresco' | 'registeredMail' | 'recordManagement' | 'multigest'; // category
'description': string; // description
}
......@@ -309,7 +309,15 @@ export class ActionPagesService {
'component': 'resetRecordManagementAction',
'category': 'recordManagement',
'description': this.translate.instant('lang.resetRecordManagement')
}
},
{
'id': 'send_multigest',
'label': this.translate.instant('lang.sendMultigest'),
'name': 'send_multigest',
'component': 'sendMultigestAction',
'category': 'multigest',
'description': this.translate.instant('lang.sendMultigest')
},
];
......
......@@ -2542,5 +2542,11 @@
"switchSae": "Configurer Maarch RM",
"configSaeInfo": "Pour plus d'informations sur la configuration d'un système d'archivage électronique. Consulter la documentation : <a href=\"{{url}}\" target=\"_blank\" class=\"link\">Configurer un SAE</a>",
"delegatedOpinion": "Avis donné à la place de",
"requestedOpinion": "Avis demandé à la place de"
"requestedOpinion": "Avis demandé à la place de",
"multigest": "Multigest",
"multigestUrl": "Adresse de l'API Multigest",
"multigestCreation": "Création d'un compte Multigest",
"multigestModification": "Modification d'un compte Multigest",
"multigestAccount": "Compte Multigest",
"sendMultigest": "Envoyer vers Multigest"
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment