diff --git a/lang/en.json b/lang/en.json index 1e5d8fc9b802c7afebe55b61e3748cbf13c74349..899c2fd9f3f0f6d89d348832867b0d1496d8fe10 100755 --- a/lang/en.json +++ b/lang/en.json @@ -653,6 +653,7 @@ "downloadProofOnPurge": "You may not view the document after it is removed; its complete proof folder will be suggested for download afterwards.", "manage_documents": "All-document access", "indexation": "Workflow initiation", - "can_purge": "Document deletion" + "can_purge": "Document deletion", + "documentStateSearch": "Document state" } } \ No newline at end of file diff --git a/lang/fr.json b/lang/fr.json index d9dbda6d0f09c92d2a4162c7c20d14b6ea0cc238..69f61d1eb4285e7465c0d432760e4cfbe763609b 100755 --- a/lang/fr.json +++ b/lang/fr.json @@ -652,6 +652,7 @@ "downloadProofOnPurge": "Après suppression, le document ne sera plus consultable ; son dossier complet vous sera ensuite proposé au téléchargement.", "manage_documents": "Accès à tous les documents", "indexation": "Initiation de circuit", - "can_purge": "Suppression de document" + "can_purge": "Suppression de document", + "documentStateSearch": "Etat du document" } } diff --git a/src/frontend/app/search/search.component.html b/src/frontend/app/search/search.component.html index a4376e78d152658c44b4bbf70575508facbe8e22..71a2ef092dac6bb5c52d53875e76614abe984fa7 100644 --- a/src/frontend/app/search/search.component.html +++ b/src/frontend/app/search/search.component.html @@ -47,6 +47,15 @@ <ion-icon name="close-circle"></ion-icon> </ion-chip> </div> + <div *ngIf="currentFilter.id === 'documentState' && currentFilter.val.length > 0"> + <ion-chip outline color="primary" + style="background: white;" [title]="'lang.documentStateSearch' | translate" + (click)="removeFilter(currentFilter, 'documentDeleted')"> + <ion-icon name="document-outline"></ion-icon> + <ion-label>{{ 'lang.' + currentFilter.val[0] | translate }}</ion-label> + <ion-icon name="close-circle"></ion-icon> + </ion-chip> + </div> </div> </div> </div> diff --git a/src/frontend/app/search/search.component.ts b/src/frontend/app/search/search.component.ts index e070f9286b8d6e9ef81f1aa8bb3aa9428742a128..6d5e53736db2ca5a5dc376da1aa8e799edeb59a9 100644 --- a/src/frontend/app/search/search.component.ts +++ b/src/frontend/app/search/search.component.ts @@ -105,6 +105,7 @@ export class SearchComponent implements OnInit { openedLine = ''; reActiveInfinite: any; documentId: any; + canPurge: boolean = false; constructor( public http: HttpClient, @@ -124,6 +125,22 @@ export class SearchComponent implements OnInit { ) { } ngOnInit(): void { + this.canPurge = this.authService.user.appPrivileges.find((privilege: any) => privilege.id === 'can_purge') !== undefined; + if (this.canPurge) { + this.filters.splice(3, 0, + { + id: 'documentState', + type: 'checkbox', + val: [], + values: [ + { + id: 'documentDeleted', + label: 'lang.documentDeleted', + selected: false + } + ] + }); + } this._activatedRoute.queryParamMap.subscribe((paramMap: ParamMap) => { if (!this.functionsService.empty(paramMap.get('documentId'))) { this.documentId = paramMap.get('documentId'); @@ -178,6 +195,7 @@ export class SearchComponent implements OnInit { filter.val.splice(index, 1); } else { filter.val.push(item.id); + filter.val = [... new Set(filter.val)]; } } @@ -241,7 +259,7 @@ export class SearchComponent implements OnInit { } canShowButton(id: string, item: any) { - if (id === 'purgeDocument' && this.authService.user.appPrivileges.find((privilege: any) => privilege.id === 'can_purge') !== undefined && ['STOP', 'VAL', 'REF'].indexOf(item.state) > -1) { + if (id === 'purgeDocument' && this.canPurge && ['STOP', 'VAL', 'REF'].indexOf(item.state) > -1) { return true; } else if (id === 'interruptWorkflow' && item.canInterrupt) { return true; @@ -269,7 +287,9 @@ export class SearchComponent implements OnInit { this.refreshCurrentFilter(); return new Promise((resolve) => { - this.http.post('../rest/search/documents?limit=10&offset=0', this.formatDatas()) + let uri: string = '../rest/search/documents?limit=10&offset=0'; + uri = this.canPurge && this.filters.find((filter: any) => filter.id === 'documentState').values[0].selected ? uri.concat('&withDeleted=true') : uri; + this.http.post(`${uri}`, this.formatDatas()) .pipe( tap((data: any) => { this.ressources = this.formatListDatas(data.documents); @@ -288,13 +308,16 @@ export class SearchComponent implements OnInit { refreshCurrentFilter() { this.currentFilters = JSON.parse(JSON.stringify(this.filters.filter((item: any) => !this.functionsService.empty(item.val)))); - if (this.currentFilters.filter((item: any) => item.id === 'workflowStates').length > 0) { this.currentFilters.filter((item: any) => item.id === 'workflowStates')[0].val = this.currentFilters.filter((item: any) => item.id === 'workflowStates')[0].values.filter((item: any) => item.selected); if (this.currentFilters.filter((item: any) => item.id === 'workflowStates')[0].val.length === 0) { this.currentFilters = this.currentFilters.filter((item: any) => item.id !== 'workflowStates'); } } + + if (this.filters.find((el: any) => el.id === 'documentState').values[0].selected === false) { + this.filters.find((el: any) => el.id === 'documentState').val = []; + } } loadData(event: any) { @@ -475,8 +498,11 @@ export class SearchComponent implements OnInit { if (!Array.isArray(filter.val)) { this.filters.find((element: any) => element.id === filter.id).val = ''; } else { - if (filter.id === 'workflowStates') { + if (filter.id !== 'workflowUsers') { this.filters.find((element: any) => element.id === filter.id).values.filter((element: any) => element.id === item)[0].selected = false; + if (!this.filters.find((el: any) => el.id === 'documentState').values[0].selected) { + this.filters.find((el: any) => el.id === 'documentState').val = []; + } } else { const index = filter.val.indexOf(item); this.filters.filter((element: any) => element.id === filter.id)[0].val.splice(index, 1);