diff --git a/angular/src/app/adv-search/adv-search.component.ts b/angular/src/app/adv-search/adv-search.component.ts index 2e1dd833c..948e67843 100644 --- a/angular/src/app/adv-search/adv-search.component.ts +++ b/angular/src/app/adv-search/adv-search.component.ts @@ -95,7 +95,7 @@ export class AdvSearchComponent extends FormCanDeactivate implements OnInit, Aft this.searchFieldsListService.watchFields( (fields) =>{ - this.fields = (fields as SelectItem[]); + this.fields = this.toFieldItems(fields); } ); } @@ -579,4 +579,32 @@ export class AdvSearchComponent extends FormCanDeactivate implements OnInit, Aft this.searchQueryService.saveQueries(this.queries); op.hide(); } + + /** + * Advanced Search fields dropdown + */ + toFieldItems(fields: any[]): SelectItem[] { + // let items: SelectItem[] = []; + // items.push({ label: this.ALL, value: 'searchphrase' }); + let fieldItems: SelectItem[] = []; + for (let field of fields) { + if (_.includes(field.tags, 'searchable')) { + let dup = false; + //For some reason, the filter function does not work for fields. Have to use this loop... + for(let item of fieldItems){ + if(item.label == field.label && item.value == field.name.replace('component.', 'components.')){ + dup = true; + break; + } + } + + if(!dup){ + fieldItems.push({ label: field.label, value: field.name.replace('component.', 'components.') }); + } + } + }; + fieldItems = _.sortBy(fieldItems, ['label', 'value']); + + return fieldItems; + } } diff --git a/angular/src/app/search-panel/search-panel.component.html b/angular/src/app/search-panel/search-panel.component.html index 58946f3ab..993773f58 100644 --- a/angular/src/app/search-panel/search-panel.component.html +++ b/angular/src/app/search-panel/search-panel.component.html @@ -18,7 +18,7 @@

{{title}}