Skip to content

Commit 60d446a

Browse files
committed
Fixed dup dropdown in Customize View and main search box suggestion list
1 parent a9856f6 commit 60d446a

3 files changed

Lines changed: 22 additions & 5 deletions

File tree

angular/src/app/search-panel/search-panel.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ export class SearchPanelComponent implements OnInit {
280280
this.suggestedTaxonomyList = [];
281281
for (let i = 0; i < this.suggestedTaxonomies.length; i++) {
282282
let keyw = this.suggestedTaxonomies[i];
283-
if (keyw.toLowerCase().indexOf(suggTaxonomy.trim().toLowerCase()) >= 0) {
283+
if (keyw.toLowerCase().indexOf(suggTaxonomy.trim().toLowerCase()) >= 0 && this.suggestedTaxonomyList.indexOf(keyw) < 0) {
284284
this.suggestedTaxonomyList.push(keyw);
285285
}
286286
}

angular/src/app/search/search.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@
352352
<b>Sort Results</b> <br>
353353
</div>
354354
<div>
355-
<p-dropdown [options]="fields" [(ngModel)]="sortItemKey" placeholder="Field Name"
355+
<p-dropdown [options]="filterableFields" [(ngModel)]="sortItemKey" placeholder="Field Name"
356356
(onChange)="SortByFields()"
357357
[style]="{'width':'200px','display': 'flex','align-items':'center','background-color': '#FFFFFF','height': '40px','font-weight': '400','font-style': 'italic','float':'left'}">
358358
</p-dropdown>

angular/src/app/search/search.component.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,21 @@ export class SearchComponent implements OnInit, OnDestroy {
236236
let items: SelectItem[] = [];
237237
let sortItems: SelectItem[] = [];
238238
this.displayFields = [];
239+
this.fields = [];
240+
let dupFound: boolean = false;
239241

240242
for (let field of fields) {
241243
if (_.includes(field.tags, 'filterable')) {
242244
if (field.type !== 'object') {
243245
if (field.name !== 'component.topic.tag') {
244-
if(sortItems.filter(item => {item.label==field.label && item.value==field.name}).length == 0)
246+
dupFound = false;
247+
for(let item of sortItems){
248+
if(item.label==field.label && item.value==field.name){
249+
dupFound = true;
250+
break;
251+
}
252+
}
253+
if(!dupFound)
245254
sortItems.push({ label: field.label, value: field.name });
246255
}
247256
if (field.label !== 'Resource Title') {
@@ -256,12 +265,20 @@ export class SearchComponent implements OnInit, OnDestroy {
256265
if (_.includes(field.tags, 'searchable')) {
257266
let lValue = field.name.replace('component.', 'components.');
258267

259-
this.fields.push({ label: field.label, value: lValue });
260-
268+
dupFound = false;
269+
for(let item of this.fields){
270+
if(item.label==field.label && item.value==lValue){
271+
dupFound = true;
272+
break;
273+
}
274+
}
275+
if(!dupFound)
276+
this.fields.push({ label: field.label, value: lValue });
261277
}
262278
}
263279

264280
this.fields = _.sortBy(this.fields, ['label','value']);
281+
265282
return sortItems;
266283
}
267284

0 commit comments

Comments
 (0)