Sfoglia il codice sorgente

Honor peoplesearch.orgChart.enableChildCount and peoplesearch.orgChart.maxParents configuration settings in the OrgChart

Joseph White 7 anni fa
parent
commit
26f3dbe914

+ 7 - 1
client/src/peoplesearch/orgchart-search.component.ts

@@ -41,6 +41,7 @@ export default class OrgChartSearchComponent {
     assistant: IPerson;
     person: IPerson;
     photosEnabled: boolean;
+    managementChainLimit: number;
     query: string;
     searchTextLocalStorageKey: string;
 
@@ -70,6 +71,11 @@ export default class OrgChartSearchComponent {
                 this.photosEnabled = photosEnabled;
             });
 
+        this.configService.getOrgChartMaxParents().then(
+            (orgChartMaxParents: number) => {
+                this.managementChainLimit = orgChartMaxParents;
+            });
+
         this.query = this.getSearchText();
 
         let personId: string = this.$stateParams['personId'];
@@ -95,7 +101,7 @@ export default class OrgChartSearchComponent {
                             // TODO: handle error
                         });
 
-                self.peopleService.getManagementChain(personId)
+                self.peopleService.getManagementChain(personId, self.managementChainLimit)
                     .then((managementChain: IPerson[]) => {
                             self.managementChain = managementChain;
                         },

+ 2 - 2
client/src/peoplesearch/orgchart.component.html

@@ -44,7 +44,7 @@
                  ng-click="$ctrl.onClickPerson()"
                  class="self"
                  size="large"
-                 show-direct-report-count="true"
+                 show-direct-report-count="$ctrl.showDirectReports"
                  show-image="$ctrl.showImages"></person-card>
     <div class="assistant" ng-if="$ctrl.assistant">
         <div class="org-chart-connector dashed"></div>
@@ -62,7 +62,7 @@
 
     <div class="ias-grid">
         <person-card person="directReport"
-                     show-direct-report-count="true"
+                     show-direct-report-count="$ctrl.showDirectReports"
                      show-image="$ctrl.showImages"
                      ng-repeat="directReport in $ctrl.directReports | orderBy:'displayNames[0]'"
                      ng-click="$ctrl.selectPerson(directReport.userKey)">

+ 9 - 1
client/src/peoplesearch/orgchart.component.ts

@@ -25,6 +25,7 @@ import { Component } from '../component';
 import { element, IAugmentedJQuery, IFilterService, IScope, IWindowService } from 'angular';
 import ElementSizeService from '../ux/element-size.service';
 import { IPerson } from '../models/person.model';
+import {IPeopleSearchConfigService} from '../services/peoplesearch-config.service';
 
 export enum OrgChartSize {
     ExtraSmall = 0,
@@ -49,19 +50,21 @@ export default class OrgChartComponent {
     isLargeLayout: boolean;
     managementChain: IPerson[];
     person: IPerson;
+    showDirectReports: boolean;
     assistant: IPerson;
 
     private elementSize: OrgChartSize = OrgChartSize.ExtraSmall;
     private maxVisibleManagers: number;
     private visibleManagers: IPerson[];
 
-    static $inject = [ '$element', '$filter', '$scope', '$state', '$window', 'MfElementSizeService' ];
+    static $inject = [ '$element', '$filter', '$scope', '$state', '$window', 'ConfigService', 'MfElementSizeService' ];
     constructor(
         private $element: IAugmentedJQuery,
         private $filter: IFilterService,
         private $scope: IScope,
         private $state: angular.ui.IStateService,
         private $window: IWindowService,
+        private configService: IPeopleSearchConfigService,
         private elementSizeService: ElementSizeService) {
     }
 
@@ -70,6 +73,11 @@ export default class OrgChartComponent {
     }
 
     $onInit(): void {
+        this.configService.orgChartShowChildCount().then(
+            (showChildCount: boolean) => {
+                this.showDirectReports = showChildCount;
+            });
+
         // OrgChartComponent has different functionality at different widths. On element resize, we
         // want to update the state of the component and trigger a $digest
         this.elementSizeService

+ 1 - 1
client/src/services/people.service.dev.ts

@@ -83,7 +83,7 @@ export default class PeopleService implements IPeopleService {
         return this.$q.resolve(people);
     }
 
-    getManagementChain(id: string): angular.IPromise<IPerson[]> {
+    getManagementChain(id: string, managementChainLimit): IPromise<IPerson[]> {
         let person = this.findPerson(id);
 
         if (person) {

+ 21 - 12
client/src/services/people.service.ts

@@ -21,29 +21,38 @@
  */
 
 
-import { IHttpService, ILogService, IPromise, IQService, IWindowService } from 'angular';
-import { IPerson } from '../models/person.model';
+import {IHttpService, ILogService, IPromise, IQService, IWindowService} from 'angular';
+import {IPerson} from '../models/person.model';
 import IPwmService from './pwm.service';
 import IOrgChartData from '../models/orgchart-data.model';
 import SearchResult from '../models/search-result.model';
+import {IPeopleSearchConfigService} from './peoplesearch-config.service';
 
 export interface IPeopleService {
     autoComplete(query: string): IPromise<IPerson[]>;
+
     getDirectReports(personId: string): IPromise<IPerson[]>;
+
     getNumberOfDirectReports(personId: string): IPromise<number>;
-    getManagementChain(personId: string): IPromise<IPerson[]>;
+
+    getManagementChain(id: string, managementChainLimit): IPromise<IPerson[]>;
+
     getOrgChartData(personId: string, skipChildren: boolean): IPromise<IOrgChartData>;
+
     getPerson(id: string): IPromise<IPerson>;
+
     search(query: string): IPromise<SearchResult>;
 }
 
 export default class PeopleService implements IPeopleService {
     PWM_GLOBAL: any;
 
-    static $inject = ['$http', '$log', '$q', 'PwmService', '$window' ];
+    static $inject = ['$http', '$log', '$q', 'ConfigService', 'PwmService', '$window'];
+
     constructor(private $http: IHttpService,
                 private $log: ILogService,
                 private $q: IQService,
+                private configService: IPeopleSearchConfigService,
                 private pwmService: IPwmService,
                 $window: IWindowService) {
         if ($window['PWM_GLOBAL']) {
@@ -55,7 +64,7 @@ export default class PeopleService implements IPeopleService {
     }
 
     autoComplete(query: string): IPromise<IPerson[]> {
-        return this.search(query, { 'includeDisplayName': true })
+        return this.search(query, {'includeDisplayName': true})
             .then((searchResult: SearchResult) => {
                 let people = searchResult.people;
 
@@ -86,18 +95,18 @@ export default class PeopleService implements IPeopleService {
         });
     }
 
-    getManagementChain(id: string): IPromise<IPerson[]> {
+    getManagementChain(id: string, managementChainLimit): IPromise<IPerson[]> {
         let people: IPerson[] = [];
-        return this.getManagerRecursive(id, people);
+        return this.getManagerRecursive(id, people, managementChainLimit);
     }
 
-    private getManagerRecursive(id: string, people: IPerson[]): IPromise<IPerson[]> {
+    private getManagerRecursive(id: string, people: IPerson[], managementChainLimit): IPromise<IPerson[]> {
         return this.getOrgChartData(id, true)
             .then((orgChartData: IOrgChartData) => {
-                if (orgChartData.manager) {
+                if (orgChartData.manager && people.length < managementChainLimit) {
                     people.push(orgChartData.manager);
 
-                    return this.getManagerRecursive(orgChartData.manager.userKey, people);
+                    return this.getManagerRecursive(orgChartData.manager.userKey, people, managementChainLimit);
                 }
 
                 return this.$q.resolve(people);
@@ -151,7 +160,7 @@ export default class PeopleService implements IPeopleService {
         let request = this.$http
             .get(this.pwmService.getPeopleSearchServerUrl('detail'), {
                 cache: true,
-                params: { userKey: id },
+                params: {userKey: id},
                 timeout: httpTimeout.promise
             });
 
@@ -177,7 +186,7 @@ export default class PeopleService implements IPeopleService {
 
         let formID: string = encodeURIComponent('&pwmFormID=' + this.PWM_GLOBAL['pwmFormID']);
         let url: string = this.pwmService.getServerUrl('search', params)
-                        + '&pwmFormID=' + this.PWM_GLOBAL['pwmFormID'];
+            + '&pwmFormID=' + this.PWM_GLOBAL['pwmFormID'];
         let request = this.$http
             .post(url, {
                 username: query,

+ 8 - 0
client/src/services/peoplesearch-config.service.dev.ts

@@ -45,7 +45,15 @@ export default class ConfigService
         });
     }
 
+    getOrgChartMaxParents(): IPromise<number> {
+        return this.$q.resolve(50);
+    }
+
     orgChartEnabled(): IPromise<boolean> {
         return this.$q.resolve(true);
     }
+
+    orgChartShowChildCount(): IPromise<boolean> {
+        return this.$q.resolve(true);
+    }
 }

+ 12 - 0
client/src/services/peoplesearch-config.service.ts

@@ -28,9 +28,13 @@ import {ConfigBaseService, IConfigService} from './base-config.service';
 
 const COLUMN_CONFIG = 'peoplesearch_search_columns';
 const ORGCHART_ENABLED = 'peoplesearch_orgChartEnabled';
+const ORGCHART_MAX_PARENTS = 'orgChartMaxParents';
+const ORGCHART_SHOW_CHILD_COUNT = 'orgChartShowChildCount';
 
 export interface IPeopleSearchConfigService extends IConfigService {
+    getOrgChartMaxParents(): IPromise<number>;
     orgChartEnabled(): IPromise<boolean>;
+    orgChartShowChildCount(): IPromise<boolean>;
 }
 
 export default class PeopleSearchConfigService
@@ -46,8 +50,16 @@ export default class PeopleSearchConfigService
         return this.getValue(COLUMN_CONFIG);
     }
 
+    getOrgChartMaxParents(): IPromise<number> {
+        return this.getValue(ORGCHART_MAX_PARENTS);
+    }
+
     orgChartEnabled(): IPromise<boolean> {
         return this.getValue(ORGCHART_ENABLED)
             .then(null, () => { return this.$q.resolve(true); }); // On error use default
     }
+
+    orgChartShowChildCount(): IPromise<boolean> {
+        return this.getValue(ORGCHART_SHOW_CHILD_COUNT);
+    }
 }