Bladeren bron

Advanced Search: removed the default option "Select Attribute..." and instead defaulted to the first available attribute.

jalbr74 6 jaren geleden
bovenliggende
commit
b002b4f3a2

+ 10 - 4
client/src/modules/helpdesk/helpdesk-search-base.component.ts

@@ -36,7 +36,7 @@ let recentVerificationsDialogTemplateUrl = require('./recent-verifications-dialo
 
 export default abstract class HelpDeskSearchBaseComponent {
     advancedSearch = false;
-    advancedSearchTags = [];
+    advancedSearchTags: any[];
     advancedSearchEnabled: boolean;
     advancedSearchMaxRows: number;
     columnConfiguration: any;
@@ -45,7 +45,8 @@ export default abstract class HelpDeskSearchBaseComponent {
     protected pendingRequests: IPromise<any>[] = [];
     photosEnabled: boolean;
     query: string;
-    queries = [{key: null, value: ''}];
+    queries: any[];
+    initialQueryKey: string;
     searchMessage: string;
     searchResult: SearchResult;
     searchTextLocalStorageKey: string;
@@ -85,6 +86,11 @@ export default abstract class HelpDeskSearchBaseComponent {
             this.advancedSearchEnabled = advancedSearchConfig.enabled;
             this.advancedSearchTags = advancedSearchConfig.attributes;
             this.advancedSearchMaxRows = advancedSearchConfig.maxRows;
+
+            // Save the first attribute to use as the initial selection of new query rows
+            if (this.advancedSearchTags && this.advancedSearchTags.length > 0) {
+                this.initialQueryKey = this.advancedSearchTags[0].attribute;
+            }
         });
 
         // Once <ias-search-box> from ng-ias allows the autofocus attribute, we can remove this code
@@ -114,7 +120,7 @@ export default abstract class HelpDeskSearchBaseComponent {
 
     protected clearSearch(): void {
         this.query = null;
-        this.queries = [{key: null, value: ''}];
+        this.queries = [{key: this.initialQueryKey, value: ''}];
         this.searchResult = null;
         this.clearErrorMessage();
         this.clearSearchMessage();
@@ -257,7 +263,7 @@ export default abstract class HelpDeskSearchBaseComponent {
     }
 
     addSearchTag(): void {
-        this.queries.push({key: null, value: ''});
+        this.queries.push({key: this.initialQueryKey, value: ''});
     }
 
     protected selectPerson(person: IPerson): void {

+ 0 - 1
client/src/modules/helpdesk/helpdesk-search-cards.component.html

@@ -38,7 +38,6 @@
     <div class="advanced-search-container" ng-if="$ctrl.advancedSearch">
         <div class="attribute-row" ng-repeat="query in $ctrl.queries">
             <select ng-model="query.key">
-                <option value="" selected disabled>{{ 'Display_SelectAttribute' | translate }}</option>
                 <option ng-repeat="tag in $ctrl.advancedSearchTags" ng-attr-value="{{tag.attribute}}">{{tag.label}}</option>
             </select>
             <input ng-model="query.value" autocomplete="off" ng-change="$ctrl.onAdvancedSearchValueChanged($event)"

+ 0 - 1
client/src/modules/helpdesk/helpdesk-search-table.component.html

@@ -37,7 +37,6 @@
     <div class="advanced-search-container" ng-if="$ctrl.advancedSearch">
         <div class="attribute-row" ng-repeat="query in $ctrl.queries">
             <select ng-model="query.key">
-                <option value="" selected disabled>{{ 'Display_SelectAttribute' | translate }}</option>
                 <option ng-repeat="tag in $ctrl.advancedSearchTags" ng-attr-value="{{tag.attribute}}">{{tag.label}}</option>
             </select>
             <input ng-model="query.value" autocomplete="off" ng-change="$ctrl.onAdvancedSearchValueChanged($event)"

+ 10 - 4
client/src/modules/peoplesearch/peoplesearch-base.component.ts

@@ -33,7 +33,7 @@ import {IAdvancedSearchConfig} from '../../services/base-config.service';
 
 abstract class PeopleSearchBaseComponent {
     advancedSearch = false;
-    advancedSearchTags = [];
+    advancedSearchTags: any[];
     advancedSearchEnabled: boolean;
     advancedSearchMaxRows: number;
     errorMessage: string;
@@ -43,7 +43,8 @@ abstract class PeopleSearchBaseComponent {
     searchMessage: string;
     searchResult: SearchResult;
     query: string;
-    queries = [{key: null, value: ''}];
+    queries: any[];
+    initialQueryKey: string;
     searchTextLocalStorageKey: string;
     searchViewLocalStorageKey: string;
 
@@ -112,7 +113,7 @@ abstract class PeopleSearchBaseComponent {
     }
 
     addSearchTag(): void {
-        this.queries.push({key: null, value: ''});
+        this.queries.push({key: this.initialQueryKey, value: ''});
     }
 
     selectPerson(person: IPerson): void {
@@ -166,7 +167,7 @@ abstract class PeopleSearchBaseComponent {
 
     protected clearSearch(): void {
         this.query = null;
-        this.queries = [{key: null, value: ''}];
+        this.queries = [{key: this.initialQueryKey, value: ''}];
         this.searchResult = null;
         this.clearErrorMessage();
         this.clearSearchMessage();
@@ -247,6 +248,11 @@ abstract class PeopleSearchBaseComponent {
             this.advancedSearchEnabled = advancedSearchConfig.enabled;
             this.advancedSearchTags = advancedSearchConfig.attributes;
             this.advancedSearchMaxRows = advancedSearchConfig.maxRows;
+
+            // Save the first attribute to use as the initial selection of new query rows
+            if (this.advancedSearchTags && this.advancedSearchTags.length > 0) {
+                this.initialQueryKey = this.advancedSearchTags[0].attribute;
+            }
         });
 
         this.query = this.getSearchText();

+ 0 - 1
client/src/modules/peoplesearch/peoplesearch-cards.component.html

@@ -37,7 +37,6 @@
     <div class="advanced-search-container" ng-if="$ctrl.advancedSearch">
         <div class="attribute-row" ng-repeat="query in $ctrl.queries">
             <select ng-model="query.key">
-                <option value="" selected disabled>{{ 'Display_SelectAttribute' | translate }}</option>
                 <option ng-repeat="tag in $ctrl.advancedSearchTags" ng-attr-value="{{tag.attribute}}">{{tag.label}}</option>
             </select>
             <input ng-model="query.value" autocomplete="off" ng-change="$ctrl.onAdvancedSearchValueChanged($event)"

+ 0 - 1
client/src/modules/peoplesearch/peoplesearch-table.component.html

@@ -37,7 +37,6 @@
     <div class="advanced-search-container" ng-if="$ctrl.advancedSearch">
         <div class="attribute-row" ng-repeat="query in $ctrl.queries">
             <select ng-model="query.key">
-                <option value="" selected disabled>{{ 'Display_SelectAttribute' | translate }}</option>
                 <option ng-repeat="tag in $ctrl.advancedSearchTags" ng-attr-value="{{tag.attribute}}">{{tag.label}}</option>
             </select>
             <input ng-model="query.value" autocomplete="off" ng-change="$ctrl.onAdvancedSearchValueChanged($event)"