From 261670e79bd51494c0acc28eca656a3009377ff0 Mon Sep 17 00:00:00 2001 From: argirok Date: Wed, 11 May 2022 12:02:23 +0300 Subject: [PATCH] claims: update search input, fix query issues --- .../displayClaims/displayClaims.component.html | 7 +++---- .../displayClaims/displayClaims.component.ts | 9 +-------- claims/claim-utils/service/claims.service.ts | 10 +++++----- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/claims/claim-utils/displayClaims/displayClaims.component.html b/claims/claim-utils/displayClaims/displayClaims.component.html index 3489c324..eabced9b 100644 --- a/claims/claim-utils/displayClaims/displayClaims.component.html +++ b/claims/claim-utils/displayClaims/displayClaims.component.html @@ -10,11 +10,10 @@ -
+
-
+
Filter by:
diff --git a/claims/claim-utils/displayClaims/displayClaims.component.ts b/claims/claim-utils/displayClaims/displayClaims.component.ts index d3147abe..acd5a711 100644 --- a/claims/claim-utils/displayClaims/displayClaims.component.ts +++ b/claims/claim-utils/displayClaims/displayClaims.component.ts @@ -161,9 +161,6 @@ export class DisplayClaimsComponent { this.subscriptions.push(this.filterForm.get('entities').valueChanges.subscribe(value => { this.goTo(); })); - this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => { - this.changekeyword(); - })); this.subscriptions.push(this.filterForm.get('sort').valueChanges.subscribe(value => { this.goTo(); })); @@ -336,14 +333,10 @@ export class DisplayClaimsComponent { for(let type of typesParam?typesParam.split(','):[]){ this.entitiesCtrl.push(new FormControl(type)); } - let types = typesParam?typesParam.split(','):[] - console.log(types); - } changekeyword() { - - if (this.filterForm.get("keyword").value.length >= 3 || this.filterForm.get("keyword").value.length == 0) { + if (this.filterForm.get("keyword") && (this.filterForm.get("keyword").value.length >= 3 || this.filterForm.get("keyword").value.length == 0)) { this.searchTermStream.next(this.filterForm.get("keyword").value); } } diff --git a/claims/claim-utils/service/claims.service.ts b/claims/claim-utils/service/claims.service.ts index 4efbe042..b9f32054 100644 --- a/claims/claim-utils/service/claims.service.ts +++ b/claims/claim-utils/service/claims.service.ts @@ -13,31 +13,31 @@ export class ClaimsService { return this.http.get(url, CustomOptions.getAuthOptions()); } getClaims( size : number, page : number, keyword:string, sortby: string, descending: boolean, types: string, apiUrl:string):any { - let url = apiUrl +"claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types; + let url = apiUrl +"claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+(types.length>0?"&"+types:types); return this.getClaimRequest(size,page,url,true); } getClaimsByUser( size : number, page : number, user:string, keyword:string, sortby: string, descending: boolean, types: string, apiUrl:string):any { //console.info('ClaimsService: getClaims for user : '+user); - let url = apiUrl +"users/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types; + let url = apiUrl +"users/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+(types.length>0?"&"+types:types); return this.getClaimRequest(size,page,url,false); } getClaimsBycontext( size : number, page : number, contextId:string, keyword:string, sortby: string, descending: boolean, types: string , apiUrl:string):any { //console.info('ClaimsService: getClaims for context : '+contextId); - let url = apiUrl +"contexts/"+contextId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types; + let url = apiUrl +"contexts/"+contextId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+(types.length>0?"&"+types:types); return this.getClaimRequest(size,page,url,true); } getClaimsByResult( size : number, page : number, resultId:string, keyword:string, sortby: string, descending: boolean, types: string, apiUrl:string ):any { //console.info('ClaimsService: getClaims for entity : '+resultId); - let url = apiUrl +"results/"+resultId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types; + let url = apiUrl +"results/"+resultId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+(types.length>0?"&"+types:types); return this.getClaimRequest(size,page,url,true); } getClaimsByProject( size : number, page : number, projectId:string, keyword:string, sortby: string, descending: boolean, types: string, apiUrl:string ):any { //console.info('ClaimsService: getClaims for project : '+projectId); - let url = apiUrl +"projects/"+projectId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types; + let url = apiUrl +"projects/"+projectId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+(types.length>0?"&"+types:types); return this.getClaimRequest(size,page,url,true); }