From 662d87b464abdb63f71c0bfb67db8ccb0fa4f0ab Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Wed, 7 Oct 2020 17:21:16 +0200 Subject: [PATCH] FEAT #14790 TIME 1:40 add param keepDiffusionRoleInOutgoingIndexation --- migration/20.10/2010.sql | 3 ++ sql/data_en.sql | 5 ++ sql/data_fr.sql | 1 + .../diffusions/diffusions-list.component.ts | 50 ++++++++++++++----- .../indexing-form.component.html | 2 +- 5 files changed, 48 insertions(+), 13 deletions(-) diff --git a/migration/20.10/2010.sql b/migration/20.10/2010.sql index 6714a21f403..10c359f7b2c 100755 --- a/migration/20.10/2010.sql +++ b/migration/20.10/2010.sql @@ -262,6 +262,9 @@ INSERT INTO parameters (id, param_value_string) VALUES ('registeredMailImportedS DELETE FROM parameters WHERE id = 'traffic_record_summary_sheet'; INSERT INTO parameters (id, description, param_value_string) VALUES ('traffic_record_summary_sheet', 'Module circulation pour la fiche de liaison', ''); +DELETE FROM parameters WHERE id = 'keepDiffusionRoleInOutgoingIndexation'; +INSERT INTO parameters (id, param_value_int) VALUES ('keepDiffusionRoleInOutgoingIndexation', 1); + ALTER TABLE configurations RENAME COLUMN service TO privilege; DELETE FROM configurations WHERE privilege = 'admin_search'; INSERT INTO configurations (privilege, value) VALUES ('admin_search', '{"listEvent": {"defaultTab": "dashboard"},"listDisplay":{"templateColumns":6,"subInfos":[{"value":"getPriority","cssClasses":["align_leftData"],"icon":"fa-traffic-light"},{"value":"getCreationAndProcessLimitDates","cssClasses":["align_leftData"],"icon":"fa-calendar"},{"value":"getAssignee","cssClasses":["align_leftData"],"icon":"fa-sitemap"},{"value":"getDoctype","cssClasses":["align_leftData"],"icon":"fa-suitcase"},{"value":"getRecipients","cssClasses":["align_leftData"],"icon":"fa-user"},{"value":"getSenders","cssClasses":["align_leftData"],"icon":"fa-book"}]}}'); diff --git a/sql/data_en.sql b/sql/data_en.sql index f0fa95db5aa..13241d37896 100755 --- a/sql/data_en.sql +++ b/sql/data_en.sql @@ -841,6 +841,11 @@ INSERT INTO parameters (id, description, param_value_string) VALUES ('thumbnails INSERT INTO parameters (id, description, param_value_int) VALUES ('keepDestForRedirection', 'If enabled (1), put recipient in copy for diffusion list when redirecting', 0); INSERT INTO parameters (id, description, param_value_int) VALUES ('QrCodePrefix', 'If enabled (1), add "Maarch_" before the content in QrCode. (Can be use with MaarchCapture >= 1.4)', 0); INSERT INTO parameters (id, description, param_value_int) VALUES ('workingDays', 'If enabled (1), processing time is calculated in working days (Monday to Friday). Otherwise, in calendar days', 1); +INSERT INTO parameters (id, param_value_int) VALUES ('last_deposit_id', 0); +INSERT INTO parameters (id, param_value_string) VALUES ('registeredMailNotDistributedStatus', 'PND'); +INSERT INTO parameters (id, param_value_string) VALUES ('registeredMailDistributedStatus', 'DSTRIBUTED'); +INSERT INTO parameters (id, param_value_string) VALUES ('registeredMailImportedStatus', 'NEW'); +INSERT INTO parameters (id, param_value_int) VALUES ('keepDiffusionRoleInOutgoingIndexation', 1); ------------ --DIFFLIST_TYPES diff --git a/sql/data_fr.sql b/sql/data_fr.sql index ba3cd8c3ec8..5748d62b3ec 100755 --- a/sql/data_fr.sql +++ b/sql/data_fr.sql @@ -1020,6 +1020,7 @@ INSERT INTO parameters (id, param_value_int) VALUES ('last_deposit_id', 0); INSERT INTO parameters (id, param_value_string) VALUES ('registeredMailNotDistributedStatus', 'PND'); INSERT INTO parameters (id, param_value_string) VALUES ('registeredMailDistributedStatus', 'DSTRIBUTED'); INSERT INTO parameters (id, param_value_string) VALUES ('registeredMailImportedStatus', 'NEW'); +INSERT INTO parameters (id, param_value_int) VALUES ('keepDiffusionRoleInOutgoingIndexation', 1); ------------ --DIFFLIST_TYPES diff --git a/src/frontend/app/diffusions/diffusions-list.component.ts b/src/frontend/app/diffusions/diffusions-list.component.ts index dadd975e9b3..9470acafd61 100644 --- a/src/frontend/app/diffusions/diffusions-list.component.ts +++ b/src/frontend/app/diffusions/diffusions-list.component.ts @@ -18,7 +18,7 @@ import { HeaderService } from '@service/header.service'; }) export class DiffusionsListComponent implements OnInit { - + roles: any = []; loading: boolean = true; availableRoles: any[] = []; @@ -31,6 +31,7 @@ export class DiffusionsListComponent implements OnInit { listinstanceClone: any = []; hasNoDest: boolean = false; + keepDiffusionRoleInOutgoingIndexation: boolean = false; /** * Ressource identifier to load listinstance (Incompatible with templateId) @@ -52,6 +53,11 @@ export class DiffusionsListComponent implements OnInit { */ @Input() selfDest: boolean = false; + /** + * To specify the context to load listModel + */ + @Input() category: string = ''; + /** * For manage current loaded list */ @@ -97,7 +103,7 @@ export class DiffusionsListComponent implements OnInit { ) { } async ngOnInit(): Promise<void> { - + await this.initParams(); await this.initRoles(); if (this.resId !== null && this.resId != 0 && this.target !== 'redirect') { this.loadListinstance(this.resId); @@ -173,6 +179,14 @@ export class DiffusionsListComponent implements OnInit { } } + if (this.category === 'outgoing' && this.keepDiffusionRoleInOutgoingIndexation) { + Object.keys(this.diffList).forEach(key => { + if (key !== 'dest') { + this.diffList[key].items = []; + } + }); + } + if (this.diffFormControl !== undefined) { this.setFormValues(); } @@ -220,7 +234,7 @@ export class DiffusionsListComponent implements OnInit { this.http.get(`../rest/resources/${resId}/listInstance`).pipe( map((data: any) => { data.listInstance = data.listInstance.map((item: any) => { - + const obj: any = { listinstance_id: item.listinstance_id, item_mode: item.item_mode, @@ -348,6 +362,18 @@ export class DiffusionsListComponent implements OnInit { }); } + initParams() { + return new Promise((resolve, reject) => { + this.http.get('../rest/parameters/keepDiffusionRoleInOutgoingIndexation') + .subscribe((data: any) => { + this.keepDiffusionRoleInOutgoingIndexation = data.parameter.param_value_int; + resolve(true); + }, (err) => { + this.notify.handleSoftErrors(err); + }); + }); + } + deleteItem(roleId: string, index: number) { this.diffList[roleId].items.splice(index, 1); if (this.diffFormControl !== undefined) { @@ -357,7 +383,7 @@ export class DiffusionsListComponent implements OnInit { getCurrentListinstance() { let listInstanceFormatted: any = []; - + if (this.diffList !== null) { Object.keys(this.diffList).forEach(role => { if (this.diffList[role].items.length > 0) { @@ -374,7 +400,7 @@ export class DiffusionsListComponent implements OnInit { } }); } - + return listInstanceFormatted; } @@ -456,11 +482,11 @@ export class DiffusionsListComponent implements OnInit { isItemInThisRole(element: any, roleId: string) { const result = this.diffList[roleId].items.map((item: any, index: number) => { - return { - ...item, - index: index - } - }).filter((item: any) => item.itemSerialId === element.itemSerialId && item.item_type === element.item_type); + return { + ...item, + index: index + }; + }).filter((item: any) => item.itemSerialId === element.itemSerialId && item.item_type === element.item_type); return result.length > 0; } @@ -555,13 +581,13 @@ export class DiffusionsListComponent implements OnInit { return { ...item, index: index - } + }; }).filter((item: any) => item.itemSerialId === user.itemSerialId && item.item_type === user.item_type); if (result.length > 0) { this.diffList[oldRole.id].items.splice(result[0].index, 1); } - + user.item_mode = 'dest'; this.diffList['dest'].items[0] = user; diff --git a/src/frontend/app/indexation/indexing-form/indexing-form.component.html b/src/frontend/app/indexation/indexing-form/indexing-form.component.html index 1b4b60e933f..28eaa7412ce 100644 --- a/src/frontend/app/indexation/indexing-form/indexing-form.component.html +++ b/src/frontend/app/indexation/indexing-form/indexing-form.component.html @@ -246,7 +246,7 @@ <i class="fas fa-check fieldFull" *ngIf="!adminMode && arrFormControl['diffusionList'].valid && !isEmptyField(field)"></i> </div> </div> - <app-diffusions-list #appDiffusionsList [resId]="resId" [entityId]="arrFormControl[field.identifier].value" [diffFormControl]="arrFormControl['diffusionList']" [allowedEntities]="field.allowedEntities" [target]="'indexation'" [selfDest]="selfDest" (triggerEvent)="changeDestination($event,field.allowedEntities)"> + <app-diffusions-list #appDiffusionsList [resId]="resId" [entityId]="arrFormControl[field.identifier].value" [diffFormControl]="arrFormControl['diffusionList']" [allowedEntities]="field.allowedEntities" [category]="currentCategory" [target]="'indexation'" [selfDest]="selfDest" (triggerEvent)="changeDestination($event,field.allowedEntities)"> </app-diffusions-list> <mat-divider></mat-divider> </div> -- GitLab