diff --git a/src/frontend/app/administration/indexingModel/indexing-models-administration.component.ts b/src/frontend/app/administration/indexingModel/indexing-models-administration.component.ts index 82d1557d053521d3f68523bcc7256a5aa9ab8c2b..b4d1042e2ce744d81b207530c2564fa2d4e37ef6 100644 --- a/src/frontend/app/administration/indexingModel/indexing-models-administration.component.ts +++ b/src/frontend/app/administration/indexingModel/indexing-models-administration.component.ts @@ -115,6 +115,24 @@ export class IndexingModelsAdministrationComponent implements OnInit { ).subscribe(); } else { this.dialogRef = this.dialog.open(RedirectIndexingModelComponent, { panelClass: 'maarch-modal', autoFocus: false, disableClose: true, data: { title: this.lang.delete, msg: this.lang.confirmAction, indexingModel: indexingModel } }); + + this.dialogRef.afterClosed().pipe( + filter((data: string) => data === 'ok'), + tap(() => { + for (const i in this.indexingModels) { + if (this.indexingModels[i].id === indexingModel.id) { + this.indexingModels.splice(Number(i), 1); + } + } + this.dataSource = new MatTableDataSource(this.indexingModels); + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + }), + catchError((err: any) => { + this.notify.handleSoftErrors(err); + return of(false); + }) + ).subscribe(); } } diff --git a/src/frontend/app/administration/indexingModel/redirectIndexingModel/redirect-indexing-model.component.html b/src/frontend/app/administration/indexingModel/redirectIndexingModel/redirect-indexing-model.component.html index bbcf62c7879334f6ccefc06986ef36fc7fce5c73..647b0b0d07cd9ffc5cddc03fc80fb60635d49d87 100644 --- a/src/frontend/app/administration/indexingModel/redirectIndexingModel/redirect-indexing-model.component.html +++ b/src/frontend/app/administration/indexingModel/redirectIndexingModel/redirect-indexing-model.component.html @@ -1,28 +1,30 @@ <div class="mat-dialog-content-container"> - <h1 mat-dialog-title>Réaffection du modèle d'enregistrement</h1> + <h1 mat-dialog-title>{{lang.indexingModelReassign}}</h1> <div mat-dialog-content> <div class="alert-message alert-message-info"> - Ce modèle est déjà utilisé par : + {{lang.indexingModelUsedBy}} <ul> <li *ngFor="let usage of mainIndexingModel.used"> - <b>{{usage.count}}</b> courrier(s) avec le statut <b>{{usage.status}}</b> + <b>{{usage.count}}</b> {{lang.mailsWithStatus}} <b>{{usage.status}}</b> </li> </ul> - Pour le supprimer vous devez le remplacer par autre modèle. + {{lang.indexingModelReplaceToDelete}} </div> <div *ngIf="!loading"> - <mat-select name="model" [(ngModel)]="modelIds" style="padding: 10px; margin: 10px" - [placeholder]="lang.indexingModel" required (selectionChange)="changeModel($event)"> - <mat-option *ngFor="let model of indexingModels;let i=index" [value]="model.id" [disabled]="model.id === mainIndexingModel.id"> - {{model.label}} - </mat-option> - </mat-select> + <mat-form-field style="padding: 10px; margin-top: 15px"> + <mat-select name="model" [(ngModel)]="modelIds" + [placeholder]="lang.indexingModel" required (selectionChange)="changeModel($event)"> + <mat-option *ngFor="let model of indexingModels;let i=index" [value]="model.id" [disabled]="model.id === mainIndexingModel.id"> + {{model.label}} + </mat-option> + </mat-select> + </mat-form-field> </div> <div class="alert-message alert-message-danger" *ngIf="resetFields.length !== 0"> - Les champs suivants ne sont pas dans le modèle sélectionné et seront réinitialisé pour tous les courriers : + {{lang.indexingModelFieldsReset}} <ul> <li *ngFor="let field of resetFields"> - {{field.identifier}} + {{field.label}} </li> </ul> @@ -31,7 +33,7 @@ <span class="divider-modal"></span> <div mat-dialog-actions> <button class="actions" color="primary" mat-raised-button [disabled]="selectedModelId === undefined" - (click)="onSubmit()">{{this.lang.ok}}</button> + (click)="onSubmit()">{{this.lang.validate}}</button> <button class="actions" color="" mat-raised-button (click)="this.dialogRef.close('');">{{this.lang.cancel}}</button> </div> </div> diff --git a/src/frontend/app/administration/indexingModel/redirectIndexingModel/redirect-indexing-model.component.ts b/src/frontend/app/administration/indexingModel/redirectIndexingModel/redirect-indexing-model.component.ts index 94d787631385e0a6cf5ae54bd56e862bf3f746ab..5834c2b157a492966947bef111badd572053ffbe 100644 --- a/src/frontend/app/administration/indexingModel/redirectIndexingModel/redirect-indexing-model.component.ts +++ b/src/frontend/app/administration/indexingModel/redirectIndexingModel/redirect-indexing-model.component.ts @@ -5,10 +5,13 @@ import {catchError, finalize, map, tap} from 'rxjs/operators'; import {of} from 'rxjs/internal/observable/of'; import {HttpClient} from '@angular/common/http'; import {NotificationService} from '../../../notification.service'; +import {SortPipe} from '../../../../plugins/sorting.pipe'; +import {AppService} from '../../../../service/app.service'; @Component({ templateUrl: 'redirect-indexing-model.component.html', - styleUrls: ['redirect-indexing-model.component.scss'] + styleUrls: ['redirect-indexing-model.component.scss'], + providers: [AppService, SortPipe] }) export class RedirectIndexingModelComponent implements OnInit { @@ -26,6 +29,66 @@ export class RedirectIndexingModelComponent implements OnInit { resetFields: any[] = []; statuses: any[] = []; + customFields: any[] = []; + + availableFields: any[] = [ + { + identifier: 'doctype', + label: this.lang.doctype + }, + { + identifier: 'subject', + label: this.lang.subject + }, + { + identifier: 'recipients', + label: this.lang.getRecipients + }, + { + identifier: 'priority', + label: this.lang.priority + }, + { + identifier: 'confidentiality', + label: this.lang.confidential + }, + { + identifier: 'initiator', + label: this.lang.initiatorEntityAlt + }, + { + identifier: 'departureDate', + label: this.lang.departureDate + }, + { + identifier: 'processLimitDate', + label: this.lang.processLimitDate + }, + { + identifier: 'tags', + label: this.lang.tags + }, + { + identifier: 'senders', + label: this.lang.getSenders + }, + { + identifier: 'destination', + label: this.lang.destination + }, + { + identifier: 'folders', + label: this.lang.folders + }, + { + identifier: 'documentDate', + label: this.lang.docDate + }, + { + identifier: 'arrivalDate', + label: this.lang.arrivalDate + }, + ]; loading: boolean = false; @@ -33,18 +96,19 @@ export class RedirectIndexingModelComponent implements OnInit { public dialogRef: MatDialogRef<RedirectIndexingModelComponent>, public http: HttpClient, private notify: NotificationService, + private sortPipe: SortPipe, ) { - console.log(data); - this.mainIndexingModel = data.indexingModel; } - ngOnInit(): void { + async ngOnInit() { this.loadIndexingModels(); - this.loadIndexingModelFields(); - this.loadStatuses(); + + this.loadCustomFields(); + + this.loadIndexingModelFields(); } loadIndexingModels() { @@ -54,6 +118,7 @@ export class RedirectIndexingModelComponent implements OnInit { }), tap((data: any) => { this.indexingModels = data; + this.modelIds = this.indexingModels.map(model => model.id); }), finalize(() => this.loading = false), @@ -68,6 +133,12 @@ export class RedirectIndexingModelComponent implements OnInit { this.http.get('../rest/indexingModels/' + this.mainIndexingModel.id).pipe( tap((data: any) => { this.mainIndexingModelFields = data.indexingModel.fields; + this.mainIndexingModelFields = this.mainIndexingModelFields.map(field => { + const availableField = this.availableFields.find(elem => elem.identifier === field.identifier); + + field.label = availableField === undefined ? this.lang.undefined : availableField.label; + return field; + }); }), catchError((err: any) => { this.notify.handleErrors(err); @@ -80,7 +151,6 @@ export class RedirectIndexingModelComponent implements OnInit { this.http.get('../rest/statuses').pipe( tap((data: any) => { this.statuses = data.statuses; - console.log(this.statuses); this.mainIndexingModel.used.forEach((element: any) => { const elementStatus = this.statuses.find(status => status.id === element.status); @@ -96,15 +166,39 @@ export class RedirectIndexingModelComponent implements OnInit { ).subscribe(); } + loadCustomFields() { + this.http.get('../rest/customFields').pipe( + tap((data: any) => { + data.customFields = data.customFields.map((custom: any) => { + return { + identifier: 'indexingCustomField_' + custom.id, + label: custom.label + }; + }); + data.customFields.forEach((custom: any) => { + this.availableFields.push(custom); + }); + + this.sortPipe.transform(this.availableFields, 'label'); + + this.loadIndexingModelFields(); + }), + catchError((err: any) => { + this.notify.handleErrors(err); + return of(false); + }) + ).subscribe(); + } + changeModel(event: any) { this.selectedModelId = event.value; this.http.get('../rest/indexingModels/' + this.selectedModelId).pipe( tap((data: any) => { this.selectedModelFields = data.indexingModel.fields; - console.log(this.selectedModelFields); this.resetFields = this.mainIndexingModelFields.filter(field => this.selectedModelFields.find(selectedField => selectedField.identifier === field.identifier) === undefined); - console.log(this.resetFields); + + this.sortPipe.transform(this.resetFields, 'label'); }), catchError((err: any) => { this.notify.handleErrors(err); @@ -114,7 +208,6 @@ export class RedirectIndexingModelComponent implements OnInit { } onSubmit() { - console.log('selected : ' + this.selectedModelId); this.http.request('DELETE', '../rest/indexingModels/' + this.mainIndexingModel.id, {body: {targetId: this.selectedModelId}}).pipe( tap(() => { this.notify.success(this.lang.indexingModelDeleted); diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts index 1742f579907fb4652c6a24c9b43e811409f7b6f4..cc164d34c4733eb9a2a3c0cc76343287389d3529 100755 --- a/src/frontend/lang/lang-en.ts +++ b/src/frontend/lang/lang-en.ts @@ -1723,4 +1723,9 @@ export const LANG_EN = { "companyLastname": "Company / Lastname", "warnPrivateKeyTitle": "The private key has not been updated !", "warnPrivateKey": "This compromises the security of the application.", + "indexingModelUsedBy": "This model is already used by : ", + "mailsWithStatus": " mail(s) with the status ", + "indexingModelReplaceToDelete": "To delete this model you have to replace it by another.", + "indexingModelFieldsReset": "The following fields are not in the selected model and will be reset for all mails : ", + "indexingModelReassign": "Reassign indexing model", }; diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts index 90a5976be495dfd13d871f5e6635ac3fe1b57896..4eff1d4036c724d2a4632782f483ff2de21dd66e 100755 --- a/src/frontend/lang/lang-fr.ts +++ b/src/frontend/lang/lang-fr.ts @@ -1783,5 +1783,9 @@ export const LANG_FR = { "userAdmin": "Utilisateur système", "stepUserAdmin_desc": "Définissez un utilisateur système afin de vous connecter à l'application.", "launchInstall": "Lancer l'installation", - -}; \ No newline at end of file + "indexingModelUsedBy": "Ce modèle est déjà utilisé par : ", + "mailsWithStatus": " courrier(s) avec le statut ", + "indexingModelReplaceToDelete": "Pour le supprimer vous devez le remplacer par un autre modèle.", + "indexingModelFieldsReset": "Les champs suivants ne sont pas dans le modèle sélectionné et seront réinitialisé pour tous les courriers : ", + "indexingModelReassign": "Réaffection du modèle d'enregistrement" +}; diff --git a/src/frontend/lang/lang-nl.ts b/src/frontend/lang/lang-nl.ts index 4c775611bfbc30afeb99e888fb8c9b577162a391..7bace3db3c301043be9ac86a03fe18ab3c8b305a 100755 --- a/src/frontend/lang/lang-nl.ts +++ b/src/frontend/lang/lang-nl.ts @@ -1704,4 +1704,11 @@ export const LANG_NL = { "targetTable": "Target table", // _TO_TRANSLATE "targetIdentifier": "Target identifier", // _TO_TRANSLATE "companyLastname": "Company / Lastname", // _TO_TRANSLATE + "warnPrivateKeyTitle": "The private key has not been updated !", // _TO_TRANSLATE + "warnPrivateKey": "This compromises the security of the application.", // _TO_TRANSLATE + "indexingModelUsedBy": "This model is already used by : ", // _TO_TRANSLATE + "mailsWithStatus": " mail(s) with the status ", // _TO_TRANSLATE + "indexingModelReplaceToDelete": "To delete this model you have to replace it by another.", // _TO_TRANSLATE + "indexingModelFieldsReset": "The following fields are not in the selected model and will be reset for all mails : ", // _TO_TRANSLATE + "indexingModelReassign": "Reassign indexing model", // _TO_TRANSLATE }; diff --git a/src/frontend/tslint.json b/src/frontend/tslint.json index 09e9705db6bcbe1d321b541eb3c1b00f95846fa9..2315677947171d10618a1dee59f47ec4f6560c5d 100644 --- a/src/frontend/tslint.json +++ b/src/frontend/tslint.json @@ -4,7 +4,8 @@ ], "linterOptions": { "exclude": [ - "../../node_modules/**" + "../../node_modules/**", + "./lang/**" ] }, "rules": { @@ -140,4 +141,4 @@ "component-class-suffix": true, "directive-class-suffix": true } -} \ No newline at end of file +}