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

FIX #17671 TIME 0:15 fix undefined values + delete unless object

parent 0cd2f294
No related branches found
No related tags found
No related merge requests found
...@@ -212,6 +212,9 @@ export class SearchComponent implements OnInit { ...@@ -212,6 +212,9 @@ export class SearchComponent implements OnInit {
objToSend[filter.id] = filter.val; objToSend[filter.id] = filter.val;
} }
}); });
if (!this.functionsService.empty(objToSend['documentState'])) {
delete objToSend['documentState'];
}
return objToSend; return objToSend;
} }
...@@ -276,6 +279,11 @@ export class SearchComponent implements OnInit { ...@@ -276,6 +279,11 @@ export class SearchComponent implements OnInit {
spinner: 'dots' spinner: 'dots'
}).then(async (load: HTMLIonLoadingElement) => { }).then(async (load: HTMLIonLoadingElement) => {
load.present(); 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(); await this.launchSearch();
load.dismiss(); load.dismiss();
}); });
...@@ -288,7 +296,7 @@ export class SearchComponent implements OnInit { ...@@ -288,7 +296,7 @@ export class SearchComponent implements OnInit {
return new Promise((resolve) => { return new Promise((resolve) => {
let uri: string = '../rest/search/documents?limit=10&offset=0'; 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('&deleted=true') : uri; uri = this.canPurge && this.filters.find((filter: any) => filter.id === 'documentState')?.values[0].selected ? uri.concat('&deleted=true') : uri;
this.http.post(`${uri}`, this.formatDatas()) this.http.post(`${uri}`, this.formatDatas())
.pipe( .pipe(
tap((data: any) => { tap((data: any) => {
...@@ -314,10 +322,6 @@ export class SearchComponent implements OnInit { ...@@ -314,10 +322,6 @@ export class SearchComponent implements OnInit {
this.currentFilters = this.currentFilters.filter((item: any) => item.id !== 'workflowStates'); 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) { loadData(event: any) {
...@@ -327,7 +331,7 @@ export class SearchComponent implements OnInit { ...@@ -327,7 +331,7 @@ export class SearchComponent implements OnInit {
} else { } else {
this.offset = this.offset + this.limit; this.offset = this.offset + this.limit;
let uri: string = `../rest/search/documents?limit=${this.limit}&offset=${this.offset}`; let uri: string = `../rest/search/documents?limit=${this.limit}&offset=${this.offset}`;
uri = this.canPurge && this.filters.find((filter: any) => filter.id === 'documentState').values[0].selected ? uri.concat('&deleted=true') : uri; uri = this.canPurge && this.filters.find((filter: any) => filter.id === 'documentState')?.values[0].selected ? uri.concat('&deleted=true') : uri;
this.http.post(uri, this.formatDatas()).pipe( this.http.post(uri, this.formatDatas()).pipe(
tap((data: any) => { tap((data: any) => {
this.ressources = this.ressources.concat(this.formatListDatas(data.documents)); this.ressources = this.ressources.concat(this.formatListDatas(data.documents));
...@@ -501,8 +505,10 @@ export class SearchComponent implements OnInit { ...@@ -501,8 +505,10 @@ export class SearchComponent implements OnInit {
} else { } else {
if (filter.id !== 'workflowUsers') { if (filter.id !== 'workflowUsers') {
this.filters.find((element: any) => element.id === filter.id).values.filter((element: any) => element.id === item)[0].selected = false; 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) { if (!this.functionsService.empty(this.filters.find((el: any) => el.id === 'documentState'))) {
this.filters.find((el: any) => el.id === 'documentState').val = []; if (!this.filters.find((el: any) => el.id === 'documentState').values[0].selected) {
this.filters.find((el: any) => el.id === 'documentState').val = [];
}
} }
} else { } else {
const index = filter.val.indexOf(item); const index = filter.val.indexOf(item);
......
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