|
@@ -30,6 +30,7 @@ import { IPerson } from '../../models/person.model';
|
|
import PromiseService from '../../services/promise.service';
|
|
import PromiseService from '../../services/promise.service';
|
|
import SearchResult from '../../models/search-result.model';
|
|
import SearchResult from '../../models/search-result.model';
|
|
import {IAdvancedSearchConfig, IAdvancedSearchQuery, IAttributeMetadata} from '../../services/base-config.service';
|
|
import {IAdvancedSearchConfig, IAdvancedSearchQuery, IAttributeMetadata} from '../../services/base-config.service';
|
|
|
|
+import CommonSearchService from '../../services/common-search.service';
|
|
|
|
|
|
abstract class PeopleSearchBaseComponent {
|
|
abstract class PeopleSearchBaseComponent {
|
|
advancedSearch = false;
|
|
advancedSearch = false;
|
|
@@ -57,15 +58,12 @@ abstract class PeopleSearchBaseComponent {
|
|
protected localStorageService: LocalStorageService,
|
|
protected localStorageService: LocalStorageService,
|
|
protected peopleService: IPeopleService,
|
|
protected peopleService: IPeopleService,
|
|
protected promiseService: PromiseService,
|
|
protected promiseService: PromiseService,
|
|
- protected pwmService: IPwmService) {
|
|
|
|
|
|
+ protected pwmService: IPwmService,
|
|
|
|
+ protected commonSearchService: CommonSearchService) {
|
|
this.searchTextLocalStorageKey = this.localStorageService.keys.SEARCH_TEXT;
|
|
this.searchTextLocalStorageKey = this.localStorageService.keys.SEARCH_TEXT;
|
|
this.searchViewLocalStorageKey = this.localStorageService.keys.SEARCH_VIEW;
|
|
this.searchViewLocalStorageKey = this.localStorageService.keys.SEARCH_VIEW;
|
|
|
|
|
|
this.inputDebounce = this.pwmService.ajaxTypingWait;
|
|
this.inputDebounce = this.pwmService.ajaxTypingWait;
|
|
-
|
|
|
|
- $scope.$watch('$ctrl.query', (newValue: string, oldValue: string) => {
|
|
|
|
- this.onSearchTextChange(newValue, oldValue);
|
|
|
|
- });
|
|
|
|
}
|
|
}
|
|
|
|
|
|
getMessage(): string {
|
|
getMessage(): string {
|
|
@@ -77,7 +75,7 @@ abstract class PeopleSearchBaseComponent {
|
|
}
|
|
}
|
|
|
|
|
|
private gotoState(state: string): void {
|
|
private gotoState(state: string): void {
|
|
- this.$state.go(state, { query: this.query });
|
|
|
|
|
|
+ this.$state.go(state);
|
|
}
|
|
}
|
|
|
|
|
|
private initiateSearch() {
|
|
private initiateSearch() {
|
|
@@ -90,17 +88,20 @@ abstract class PeopleSearchBaseComponent {
|
|
// Make sure we set the default value if the type is select
|
|
// Make sure we set the default value if the type is select
|
|
const attributeMetadata: IAttributeMetadata = this.advancedSearchTags[query.key];
|
|
const attributeMetadata: IAttributeMetadata = this.advancedSearchTags[query.key];
|
|
if (attributeMetadata.type == 'select') {
|
|
if (attributeMetadata.type == 'select') {
|
|
- query.value = this.getDefaultValue(attributeMetadata);
|
|
|
|
|
|
+ query.value = this.commonSearchService.getDefaultValue(attributeMetadata);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ this.commonSearchService.setPsAdvSearchQueries(this.queries);
|
|
this.initiateSearch();
|
|
this.initiateSearch();
|
|
}
|
|
}
|
|
|
|
|
|
private onAdvancedSearchAttributeValueChanged() {
|
|
private onAdvancedSearchAttributeValueChanged() {
|
|
|
|
+ this.commonSearchService.setPsAdvSearchQueries(this.queries);
|
|
this.initiateSearch();
|
|
this.initiateSearch();
|
|
}
|
|
}
|
|
|
|
|
|
private onAdvancedSearchValueChanged() {
|
|
private onAdvancedSearchValueChanged() {
|
|
|
|
+ this.commonSearchService.setPsAdvSearchQueries(this.queries);
|
|
this.initiateSearch();
|
|
this.initiateSearch();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -115,6 +116,7 @@ abstract class PeopleSearchBaseComponent {
|
|
|
|
|
|
removeSearchTag(tagIndex: number): void {
|
|
removeSearchTag(tagIndex: number): void {
|
|
this.queries.splice(tagIndex, 1);
|
|
this.queries.splice(tagIndex, 1);
|
|
|
|
+ this.commonSearchService.setPsAdvSearchQueries(this.queries);
|
|
|
|
|
|
if (this.queries.length > 0) {
|
|
if (this.queries.length > 0) {
|
|
this.initiateSearch();
|
|
this.initiateSearch();
|
|
@@ -122,6 +124,7 @@ abstract class PeopleSearchBaseComponent {
|
|
else {
|
|
else {
|
|
this.clearSearch();
|
|
this.clearSearch();
|
|
this.advancedSearch = false;
|
|
this.advancedSearch = false;
|
|
|
|
+ this.commonSearchService.setPsAdvancedSearchActive(this.advancedSearch);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -131,25 +134,12 @@ abstract class PeopleSearchBaseComponent {
|
|
|
|
|
|
const query: IAdvancedSearchQuery = {
|
|
const query: IAdvancedSearchQuery = {
|
|
key: attributeMetaData.attribute,
|
|
key: attributeMetaData.attribute,
|
|
- value: this.getDefaultValue(attributeMetaData),
|
|
|
|
|
|
+ value: this.commonSearchService.getDefaultValue(attributeMetaData),
|
|
};
|
|
};
|
|
|
|
|
|
this.queries.push(query);
|
|
this.queries.push(query);
|
|
}
|
|
}
|
|
|
|
|
|
- private getDefaultValue(attributeMetaData: IAttributeMetadata) {
|
|
|
|
- if (attributeMetaData) {
|
|
|
|
- if (attributeMetaData.type === 'select') {
|
|
|
|
- const keys: string[] = Object.keys(attributeMetaData.options);
|
|
|
|
- if (keys && keys.length > 0) {
|
|
|
|
- return keys[0];
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return '';
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
selectPerson(person: IPerson): void {
|
|
selectPerson(person: IPerson): void {
|
|
this.$state.go('.details', { personId: person.userKey, query: this.query });
|
|
this.$state.go('.details', { personId: person.userKey, query: this.query });
|
|
}
|
|
}
|
|
@@ -272,26 +262,38 @@ abstract class PeopleSearchBaseComponent {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- protected initialize(): void {
|
|
|
|
- // Determine whether org-chart should appear
|
|
|
|
- this.configService.orgChartEnabled().then((orgChartEnabled: boolean) => {
|
|
|
|
- this.orgChartEnabled = orgChartEnabled;
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- this.configService.advancedSearchConfig().then((advancedSearchConfig: IAdvancedSearchConfig) => {
|
|
|
|
- this.advancedSearchEnabled = advancedSearchConfig.enabled;
|
|
|
|
- this.advancedSearchMaxRows = advancedSearchConfig.maxRows;
|
|
|
|
-
|
|
|
|
- for (let advancedSearchTag of advancedSearchConfig.attributes) {
|
|
|
|
- this.advancedSearchTags[advancedSearchTag.attribute] = advancedSearchTag;
|
|
|
|
|
|
+ protected initialize(): IPromise<void> {
|
|
|
|
+ return this.$q.all(
|
|
|
|
+ [
|
|
|
|
+ // Determine whether org-chart should appear
|
|
|
|
+ this.configService.orgChartEnabled().then((orgChartEnabled: boolean) => {
|
|
|
|
+ this.orgChartEnabled = orgChartEnabled;
|
|
|
|
+ }),
|
|
|
|
+ this.configService.advancedSearchConfig().then((advancedSearchConfig: IAdvancedSearchConfig) => {
|
|
|
|
+ this.advancedSearchEnabled = advancedSearchConfig.enabled;
|
|
|
|
+ this.advancedSearchMaxRows = advancedSearchConfig.maxRows;
|
|
|
|
+
|
|
|
|
+ for (let advancedSearchTag of advancedSearchConfig.attributes) {
|
|
|
|
+ this.advancedSearchTags[advancedSearchTag.attribute] = advancedSearchTag;
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ ]
|
|
|
|
+ ).then(result => {
|
|
|
|
+ this.query = this.getSearchText();
|
|
|
|
+ this.advancedSearch = this.commonSearchService.isPsAdvancedSearchActive();
|
|
|
|
+ this.queries = this.commonSearchService.getPsAdvSearchQueries();
|
|
|
|
+ if (this.queries.length === 0) {
|
|
|
|
+ this.addSearchTag();
|
|
}
|
|
}
|
|
- });
|
|
|
|
|
|
|
|
- this.query = this.getSearchText();
|
|
|
|
|
|
+ // Once <ias-search-box> from ng-ias allows the autofocus attribute, we can remove this code
|
|
|
|
+ this.$timeout(() => {
|
|
|
|
+ document.getElementsByTagName('input')[0].focus();
|
|
|
|
+ });
|
|
|
|
|
|
- // Once <ias-search-box> from ng-ias allows the autofocus attribute, we can remove this code
|
|
|
|
- this.$timeout(() => {
|
|
|
|
- document.getElementsByTagName('input')[0].focus();
|
|
|
|
|
|
+ this.$scope.$watch('$ctrl.query', (newValue: string, oldValue: string) => {
|
|
|
|
+ this.onSearchTextChange(newValue, oldValue);
|
|
|
|
+ });
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -316,6 +318,7 @@ abstract class PeopleSearchBaseComponent {
|
|
this.clearSearch();
|
|
this.clearSearch();
|
|
this.addSearchTag();
|
|
this.addSearchTag();
|
|
this.advancedSearch = true;
|
|
this.advancedSearch = true;
|
|
|
|
+ this.commonSearchService.setPsAdvancedSearchActive(this.advancedSearch);
|
|
}
|
|
}
|
|
|
|
|
|
protected toggleView(state: string): void {
|
|
protected toggleView(state: string): void {
|