diff --git a/lang/en.json b/lang/en.json index 5f82cbb0fbfc67da7eb1cbfb4a41ec7fc04f5bba..b176d4a81dbe5164063855d617f819c50fb6a6b4 100755 --- a/lang/en.json +++ b/lang/en.json @@ -660,10 +660,12 @@ "manage_documents": "All-document access", "indexation": "Workflow initiation", "can_purge": "Document deletion", - "documentStateSearch": "Document state", + "documentStateSearch": "Document status", "deleted": "Deleted", "hardDelete": "Physical deletion", "hardDeleted": "Document physically deleted", - "cannotAcces": "Unable to access document" + "cannotAcces": "Unable to access document", + "documentSoftDeleted": "Marked as deleted", + "documentHardDeleted":"Deleted" } } \ No newline at end of file diff --git a/lang/fr.json b/lang/fr.json index bc831c70d55a7645a894030e6da1e95b82e91fe2..499fa364f6692c8ab061ca20dcc2e1a72b0132d2 100755 --- a/lang/fr.json +++ b/lang/fr.json @@ -653,16 +653,18 @@ "errorConvertingDocument": "Erreur lors de la conversion du document", "emptyGroupUsers": "Aucun utilisateur associé à ce groupe", "emptyUsers": "Aucun utilisateur disponible à associer", - "can_purgeAdmin": "Supprimer logiquement les processus de signature interrompus ou terminés", + "can_purgeAdmin": "Supprimer logiquement et physiquement les processus de signature interrompus ou terminés", "purgeDocument": "Supprimer le document", "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", - "documentStateSearch": "Etat du document", + "documentStateSearch": "Statuts du document", "deleted": "Supprimé", "hardDelete": "Suppression physique", "hardDeleted": "Document supprimé physiquement", - "cannotAcces": "Impossible d'accéder au document" + "cannotAcces": "Impossible d'accéder au document", + "documentSoftDeleted": "Marqué comme supprimé", + "documentHardDeleted":"Supprimé" } } diff --git a/src/frontend/app/search/search.component.html b/src/frontend/app/search/search.component.html index 7437800c177eb5bedac63635c62dc49e0d0072c6..1778d6b7a63c5e29d01430f452f8ea0b5603cda1 100644 --- a/src/frontend/app/search/search.component.html +++ b/src/frontend/app/search/search.component.html @@ -48,11 +48,11 @@ </ion-chip> </div> <div *ngIf="currentFilter.id === 'documentState' && currentFilter.val.length > 0"> - <ion-chip outline color="primary" + <ion-chip outline color="primary" *ngFor="let item of currentFilter.val" style="background: white;" [title]="'lang.documentStateSearch' | translate" - (click)="removeFilter(currentFilter, 'documentDeleted')"> + (click)="removeFilter(currentFilter, item)"> <ion-icon name="document-outline"></ion-icon> - <ion-label>{{ 'lang.' + currentFilter.val[0] | translate }}</ion-label> + <ion-label>{{ 'lang.' + item | translate }}</ion-label> <ion-icon name="close-circle"></ion-icon> </ion-chip> </div> @@ -99,24 +99,22 @@ </ion-toolbar> <ion-item-sliding #slidingItem (ionDrag)="onSliding($event, element.id)"> <ion-item lines="none"> - <ng-container *ngIf="functionsService.empty(element.status) || (!functionsService.empty(element.status) && element.status !== 'HARD_DEL')"> - <ion-icon *ngIf="element.state == 'PROG'" color="primary" slot="start" - name="hourglass-outline"> - </ion-icon> - <ion-icon *ngIf="element.state == 'STOP'" color="danger" slot="start" - name="hand-left-outline"> - </ion-icon> - <ion-icon *ngIf="element.state == 'VAL'" color="success" slot="start" - name="thumbs-up-outline"> - </ion-icon> - <ion-icon *ngIf="element.state == 'REF'" color="danger" slot="start" - name="thumbs-down-outline"> - </ion-icon> - </ng-container> - <ng-container *ngIf="!functionsService.empty(element.status) && element.status === 'HARD_DEL'"> - <ion-icon color="danger" slot="start" - name="close-circle-outline"></ion-icon> - </ng-container> + <ion-icon *ngIf="element.state == 'PROG'" color="primary" slot="start" + name="hourglass-outline"> + </ion-icon> + <ion-icon *ngIf="element.state == 'STOP'" color="danger" slot="start" + name="hand-left-outline"> + </ion-icon> + <ion-icon *ngIf="element.state == 'VAL'" color="success" slot="start" + name="thumbs-up-outline"> + </ion-icon> + <ion-icon *ngIf="element.state == 'REF'" color="danger" slot="start" + name="thumbs-down-outline"> + </ion-icon> + <button mat-icon-button class="deleted" [title]="(element.status !== 'HARD_DEL' ? 'lang.documentSoftDeleted': 'lang.documentHardDeleted') | translate"> + <ion-icon *ngIf="element?.status === 'SOFT_DEL'" name="remove-circle-outline"></ion-icon> + <ion-icon *ngIf="element?.status === 'HARD_DEL'" name="close-circle-outline"></ion-icon> + </button> <ion-label (click)="goTo(element)" [title]="(element.status !== 'HARD_DEL' ? 'lang.accessDocument': 'lang.cannotAcces') | translate" [ngStyle]="{'cursor': element.status !== 'HARD_DEL' ? 'pointer' : 'not-allowed'}"> <p [class.unavailableDoc]="element.state === 'DEL'">{{element.reference}}</p> diff --git a/src/frontend/app/search/search.component.scss b/src/frontend/app/search/search.component.scss index 0295a5b931100c6190c30e79de994b83a2863c07..10cb0172baacf126a18aedc90656617ef6b71559 100644 --- a/src/frontend/app/search/search.component.scss +++ b/src/frontend/app/search/search.component.scss @@ -77,5 +77,15 @@ } .unavailableDoc { - text-decoration: line-through 1px var(--ion-color-danger);; + text-decoration: line-through 1px var(--ion-color-danger); +} + +.deleted { + color: var(--ion-color-danger); + font-size: 4em; + margin-left: 85%; + margin-bottom: 15px; + opacity: 0.15; + position: absolute; + cursor: default; } \ No newline at end of file diff --git a/src/frontend/app/search/search.component.ts b/src/frontend/app/search/search.component.ts index 2ac63d34dd9d82022cf15870c160b80777e0f71a..0835d0c32f1ea1d01f0dd3b2df674d5bad1d303a 100644 --- a/src/frontend/app/search/search.component.ts +++ b/src/frontend/app/search/search.component.ts @@ -5,7 +5,7 @@ import { ActivatedRoute, ParamMap, Router } from '@angular/router'; import { ActionSheetController, AlertController, IonInfiniteScroll, LoadingController, MenuController } from '@ionic/angular'; import { TranslateService } from '@ngx-translate/core'; import { of } from 'rxjs'; -import { catchError, exhaustMap, finalize, tap } from 'rxjs/operators'; +import { catchError, tap } from 'rxjs/operators'; import { VisaWorkflowComponent } from '../document/visa-workflow/visa-workflow.component'; import { AuthService } from '../service/auth.service'; import { FunctionsService } from '../service/functions.service'; @@ -72,11 +72,6 @@ export class SearchComponent implements OnInit { label: 'lang.refused', selected: false }, - { - id: 'HARD_DEL', - label: 'lang.hardDeleted', - selected: false - } ] }, { @@ -112,6 +107,8 @@ export class SearchComponent implements OnInit { documentId: any; canPurge: boolean = false; physicalPurge: boolean = true; + hasSoftDeletedDoc: boolean = false; + hasHardDeletedDoc: boolean = false; constructor( public http: HttpClient, @@ -140,14 +137,17 @@ export class SearchComponent implements OnInit { val: [], values: [ { - id: 'documentDeleted', - label: 'lang.documentDeleted', + id: 'documentSoftDeleted', + label: 'lang.documentSoftDeleted', + selected: false + }, + { + id: 'documentHardDeleted', + label: 'lang.documentHardDeleted', selected: false } ] }); - } else { - this.filters.find((element: any) => element.id === 'workflowStates').values.pop(); } this._activatedRoute.queryParamMap.subscribe((paramMap: ParamMap) => { if (!this.functionsService.empty(paramMap.get('documentId'))) { @@ -287,11 +287,6 @@ export class SearchComponent implements OnInit { spinner: 'dots' }).then(async (load: HTMLIonLoadingElement) => { load.present(); - if (!this.functionsService.empty(this.filters.find((el: any) => el.id === 'documentState'))) { - if (this.filters.find((el: any) => el.id === 'documentState').values[0].selected === false) { - this.filters.find((el: any) => el.id === 'documentState').val = []; - } - } await this.launchSearch(); load.dismiss(); }); @@ -304,18 +299,17 @@ export class SearchComponent implements OnInit { return new Promise((resolve) => { 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('&softDeleted=true') : uri; - const formatedData: any = this.formatDatas(); - if (!this.functionsService.empty(formatedData.workflowStates)) { - if (formatedData.workflowStates.indexOf('HARD_DEL') > -1) { - uri = uri.concat('&hardDeleted=true'); - formatedData.workflowStates.pop(); - } + const documentState: any = this.currentFilters.find((filter: any) => filter.id === 'documentState'); + if (this.canPurge && !this.functionsService.empty(documentState)) { + uri = documentState.val.indexOf('documentSoftDeleted') > -1 ? uri.concat('&softDeleted=true') : uri; + uri = documentState.val.indexOf('documentHardDeleted') > -1 ? uri.concat('&hardDeleted=true') : uri; } - this.http.post(`${uri}`, formatedData) + this.http.post(`${uri}`, this.formatDatas()) .pipe( tap((data: any) => { this.ressources = this.formatListDatas(data.documents); + this.hasSoftDeletedDoc = this.ressources.filter((res: any) => res.status === 'SOFT_DEL').length > 0; + this.hasHardDeletedDoc = this.ressources.filter((res: any) => res.status === 'HARD_DEL').length > 0; this.count = data.count; this.infiniteScroll.disabled = false; resolve(true); @@ -455,8 +449,6 @@ export class SearchComponent implements OnInit { { text: this.translate.instant('lang.download'), handler: async (mode) => { - console.log('mode', mode); - await this.downloadProof(item, mode); alert.dismiss(); } @@ -529,14 +521,10 @@ export class SearchComponent implements OnInit { if (!Array.isArray(filter.val)) { this.filters.find((element: any) => element.id === filter.id).val = ''; } else { - if (filter.id !== 'workflowUsers') { + if (filter.id === 'workflowStates') { this.filters.find((element: any) => element.id === filter.id).values.filter((element: any) => element.id === item)[0].selected = false; - if (!this.functionsService.empty(this.filters.find((el: any) => el.id === 'documentState'))) { - if (!this.filters.find((el: any) => el.id === 'documentState').values[0].selected) { - this.filters.find((el: any) => el.id === 'documentState').val = []; - } - } } else { + this.filters.find((element: any) => element.id === filter.id).values.filter((element: any) => element.id === item)[0].selected = false; const index = filter.val.indexOf(item); this.filters.filter((element: any) => element.id === filter.id)[0].val.splice(index, 1); } @@ -551,7 +539,7 @@ export class SearchComponent implements OnInit { checkInput() { if ((this.filters.find((el: any) => el.id === 'title').val === '') && (this.filters.find((el: any) => el.id === 'reference').val === '') && (this.filters.find((el: any) => el.id === 'documentId').val === '')) { - if ((this.filters.find((el: any) => el.id === 'workflowStates').val.length === 0) && (this.filters.find((el: any) => el.id === 'workflowUsers').val.length === 0)) { + if ((this.filters.find((el: any) => el.id === 'workflowStates').val.length === 0) && (this.filters.find((el: any) => el.id === 'workflowUsers').val.length === 0) && (this.filters.find((el: any) => el.id === 'documentState').val.length === 0)) { this.clearFilters(); this.currentFilters = []; } @@ -606,4 +594,9 @@ export class SearchComponent implements OnInit { }); await alert.present(); } + + isDeletedDocument(): boolean { + const documentState: any = this.currentFilters.find((filter: any) => filter.id === 'documentState'); + return documentState?.val.indexOf('documentSoftDeleted') > -1 || documentState?.val.indexOf('documentHardDeleted') > -1; + } }