Skip to content
Snippets Groups Projects
Commit e909cad7 authored by Hamza HRAMCHI's avatar Hamza HRAMCHI
Browse files

FEAT #15056 TIME 2 add freezing + binding buttons in search result

parent 19af078c
No related branches found
No related tags found
No related merge requests found
...@@ -169,6 +169,16 @@ ...@@ -169,6 +169,16 @@
<mat-icon [ngClass]="[row.mailTracking === true ? 'fas fa-star' : 'far fa-star']" <mat-icon [ngClass]="[row.mailTracking === true ? 'fas fa-star' : 'far fa-star']"
style="margin-bottom: 5px;"></mat-icon> style="margin-bottom: 5px;"></mat-icon>
</button> </button>
<button *ngIf="privilegeService.hasCurrentUserPrivilege('freeze_retention_rule')"
mat-icon-button [title]="this.translate.instant('lang.freezeRetentionRule')"
class="categoryLabel" (click)="toggleFreezing(row)">
<mat-icon class="{{informationWithFreeze.includes(row.resId) === true ? 'freezeIcon' : 'thawIcon'}} fas fa-snowflake" style="font-size: 20px;"></mat-icon>
</button>
<button *ngIf="privilegeService.hasCurrentUserPrivilege('set_binding_document')"
mat-icon-button [title]="this.translate.instant('lang.setBindingDocument')"
class="categoryLabel" (click)="toggleBinding(row)">
<mat-icon class=" {{ informationWithBinding.includes(row.resId) === true ? 'bindIcon' : 'noBindIcon'}} fas fa-exclamation" style="font-size: 20px;"></mat-icon>
</button>
<span style="cursor:pointer;" [class.highlightResultIcon]="row.inStatus" class="main-info-status" <span style="cursor:pointer;" [class.highlightResultIcon]="row.inStatus" class="main-info-status"
(click)="launch(row);"> (click)="launch(row);">
<mat-icon *ngIf="row.isLocked !== true" title="{{row.statusLabel}}" <mat-icon *ngIf="row.isLocked !== true" title="{{row.statusLabel}}"
......
...@@ -174,6 +174,21 @@ ...@@ -174,6 +174,21 @@
width: 120px; width: 120px;
} }
.freezeIcon {
color: $secondary;
}
.thawIcon {
color: $primary;
}
.bindIcon {
color: $secondary;
}
.noBindIcon {
color: $primary;
}
.watermark { .watermark {
position: absolute; position: absolute;
left: 50%; left: 50%;
......
...@@ -24,6 +24,8 @@ import { CriteriaSearchService } from '@service/criteriaSearch.service'; ...@@ -24,6 +24,8 @@ import { CriteriaSearchService } from '@service/criteriaSearch.service';
import { HighlightPipe } from '@plugins/highlight.pipe'; import { HighlightPipe } from '@plugins/highlight.pipe';
import { FilterToolComponent } from '@appRoot/search/filter-tool/filter-tool.component'; import { FilterToolComponent } from '@appRoot/search/filter-tool/filter-tool.component';
import { ContactResourceModalComponent } from '@appRoot/contact/contact-resource/modal/contact-resource-modal.component'; import { ContactResourceModalComponent } from '@appRoot/contact/contact-resource/modal/contact-resource-modal.component';
import { PrivilegeService } from '@service/privileges.service';
import { THIS_EXPR } from '@angular/compiler/src/output/output_ast';
declare var $: any; declare var $: any;
...@@ -81,6 +83,12 @@ export class SearchResultListComponent implements OnInit, OnDestroy { ...@@ -81,6 +83,12 @@ export class SearchResultListComponent implements OnInit, OnDestroy {
} }
]; ];
informationWithFreeze: any[] = [];
informationWithBinding: any[] = [];
resourceFreezed: boolean = false;
resourceBinded: boolean = false;
resultListDatabase: ResultListHttpDao | null; resultListDatabase: ResultListHttpDao | null;
data: any = []; data: any = [];
resultsLength = 0; resultsLength = 0;
...@@ -154,6 +162,7 @@ export class SearchResultListComponent implements OnInit, OnDestroy { ...@@ -154,6 +162,7 @@ export class SearchResultListComponent implements OnInit, OnDestroy {
public functions: FunctionsService, public functions: FunctionsService,
public indexingFieldService: IndexingFieldsService, public indexingFieldService: IndexingFieldsService,
public highlightPipe: HighlightPipe, public highlightPipe: HighlightPipe,
public privilegeService: PrivilegeService,
) { ) {
_activatedRoute.queryParams.subscribe( _activatedRoute.queryParams.subscribe(
params => { params => {
...@@ -200,6 +209,7 @@ export class SearchResultListComponent implements OnInit, OnDestroy { ...@@ -200,6 +209,7 @@ export class SearchResultListComponent implements OnInit, OnDestroy {
this.loading = false; this.loading = false;
} }
initSavedCriteria() { initSavedCriteria() {
if (Object.keys(this.listProperties.criteria).length > 0) { if (Object.keys(this.listProperties.criteria).length > 0) {
const obj = { query: [] }; const obj = { query: [] };
...@@ -303,6 +313,7 @@ export class SearchResultListComponent implements OnInit, OnDestroy { ...@@ -303,6 +313,7 @@ export class SearchResultListComponent implements OnInit, OnDestroy {
this.resultsLength = data.count; this.resultsLength = data.count;
this.paginatorLength = data.count > 10000 ? 10000 : data.count; this.paginatorLength = data.count > 10000 ? 10000 : data.count;
this.allResInBasket = data.allResources; this.allResInBasket = data.allResources;
this.getInfos(data.resources);
return data.resources; return data.resources;
}), }),
catchError((err: any) => { catchError((err: any) => {
...@@ -683,6 +694,76 @@ export class SearchResultListComponent implements OnInit, OnDestroy { ...@@ -683,6 +694,76 @@ export class SearchResultListComponent implements OnInit, OnDestroy {
} }
} }
toggleFreezing(row: any) {
const indexData = this.informationWithFreeze.indexOf(row.resId);
if (this.informationWithFreeze.includes(row.resId)) {
this.resourceFreezed = false;
this.informationWithFreeze.splice(indexData, 1);
} else {
this.resourceFreezed = true;
this.informationWithFreeze.push(row.resId);
}
this.http.put('../rest/archival/freezeRetentionRule', { resources: [row.resId], freeze : this.resourceFreezed }).pipe(
tap(() => {
if (this.resourceFreezed) {
this.notify.success(this.translate.instant('lang.retentionRuleFrozen'));
} else {
this.notify.success(this.translate.instant('lang.retentionRuleThawed'));
}
}
),
catchError((err: any) => {
this.notify.handleSoftErrors(err);
return of(false);
})
).subscribe();
}
toggleBinding(row: any) {
const indexData = this.informationWithBinding.indexOf(row.resId);
if (this.informationWithBinding.includes(row.resId)) {
this.resourceBinded = false;
this.informationWithBinding.splice(indexData, 1);
} else {
this.resourceBinded = true;
this.informationWithBinding.push(row.resId);
}
this.http.put('../rest/archival/binding', { resources: [row.resId], binding : this.resourceBinded }).pipe(
tap(() => {
if (this.resourceBinded) {
this.notify.success(this.translate.instant('lang.bindingMail'));
} else {
this.notify.success(this.translate.instant('lang.noBindingMal'));
}
}
),
catchError((err: any) => {
this.resourceBinded = !this.resourceBinded;
this.notify.handleSoftErrors(err);
return of(false);
})
).subscribe();
}
getInfos(data) {
data.forEach(element => {
this.http.get(`../rest/resources/${element.resId}?light=true`).pipe(
tap((infos: any) => {
if (infos.retentionFrozen) {
this.informationWithFreeze.push(infos.resId);
}
if(infos.binding) {
this.informationWithBinding.push(infos.resId);
}
}),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
});
}
viewDocument(row: any) { viewDocument(row: any) {
this.http.get(`../rest/resources/${row.resId}/content?mode=view`, { responseType: 'blob' }).pipe( this.http.get(`../rest/resources/${row.resId}/content?mode=view`, { responseType: 'blob' }).pipe(
tap((data: any) => { tap((data: any) => {
......
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