Skip to content

Commit

Permalink
Fixed dup dropdown in Customize View and main search box suggestion list
Browse files Browse the repository at this point in the history
  • Loading branch information
chuanlin2018 committed Sep 30, 2020
1 parent a9856f6 commit 60d446a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion angular/src/app/search-panel/search-panel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export class SearchPanelComponent implements OnInit {
this.suggestedTaxonomyList = [];
for (let i = 0; i < this.suggestedTaxonomies.length; i++) {
let keyw = this.suggestedTaxonomies[i];
if (keyw.toLowerCase().indexOf(suggTaxonomy.trim().toLowerCase()) >= 0) {
if (keyw.toLowerCase().indexOf(suggTaxonomy.trim().toLowerCase()) >= 0 && this.suggestedTaxonomyList.indexOf(keyw) < 0) {
this.suggestedTaxonomyList.push(keyw);
}
}
Expand Down
2 changes: 1 addition & 1 deletion angular/src/app/search/search.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@
<b>Sort Results</b> <br>
</div>
<div>
<p-dropdown [options]="fields" [(ngModel)]="sortItemKey" placeholder="Field Name"
<p-dropdown [options]="filterableFields" [(ngModel)]="sortItemKey" placeholder="Field Name"
(onChange)="SortByFields()"
[style]="{'width':'200px','display': 'flex','align-items':'center','background-color': '#FFFFFF','height': '40px','font-weight': '400','font-style': 'italic','float':'left'}">
</p-dropdown>
Expand Down
23 changes: 20 additions & 3 deletions angular/src/app/search/search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,21 @@ export class SearchComponent implements OnInit, OnDestroy {
let items: SelectItem[] = [];
let sortItems: SelectItem[] = [];
this.displayFields = [];
this.fields = [];
let dupFound: boolean = false;

for (let field of fields) {
if (_.includes(field.tags, 'filterable')) {
if (field.type !== 'object') {
if (field.name !== 'component.topic.tag') {
if(sortItems.filter(item => {item.label==field.label && item.value==field.name}).length == 0)
dupFound = false;
for(let item of sortItems){
if(item.label==field.label && item.value==field.name){
dupFound = true;
break;
}
}
if(!dupFound)
sortItems.push({ label: field.label, value: field.name });
}
if (field.label !== 'Resource Title') {
Expand All @@ -256,12 +265,20 @@ export class SearchComponent implements OnInit, OnDestroy {
if (_.includes(field.tags, 'searchable')) {
let lValue = field.name.replace('component.', 'components.');

this.fields.push({ label: field.label, value: lValue });

dupFound = false;
for(let item of this.fields){
if(item.label==field.label && item.value==lValue){
dupFound = true;
break;
}
}
if(!dupFound)
this.fields.push({ label: field.label, value: lValue });
}
}

this.fields = _.sortBy(this.fields, ['label','value']);

return sortItems;
}

Expand Down

0 comments on commit 60d446a

Please sign in to comment.