浏览代码

Assistant displayed in OrgChart

Joe Hawkins 8 年之前
父节点
当前提交
6800d24772

+ 5 - 5
src/main/angular/src/models/orgchart-data.model.ts

@@ -22,9 +22,9 @@
 
 
 
 
 import { IPerson } from './person.model';
 import { IPerson } from './person.model';
-export default class OrgChartData {
-
-    constructor(public manager: IPerson,
-                public children: IPerson[],
-                public self: IPerson) {}
+export default class IOrgChartData {
+    manager?: IPerson;
+    children?: IPerson[];
+    self: IPerson;
+    assistant?: IPerson;
 }
 }

+ 1 - 0
src/main/angular/src/peoplesearch/orgchart-search.component.html

@@ -55,6 +55,7 @@
 <org-chart person="$ctrl.person"
 <org-chart person="$ctrl.person"
            direct-reports="$ctrl.directReports"
            direct-reports="$ctrl.directReports"
            show-images="$ctrl.photosEnabled"
            show-images="$ctrl.photosEnabled"
+           assistant="$ctrl.assistant"
            management-chain="$ctrl.managementChain">
            management-chain="$ctrl.managementChain">
 </org-chart>
 </org-chart>
 
 

+ 8 - 3
src/main/angular/src/peoplesearch/orgchart-search.component.ts

@@ -27,7 +27,7 @@ import { IPeopleService } from '../services/people.service';
 import IPwmService from '../services/pwm.service';
 import IPwmService from '../services/pwm.service';
 import { isArray, isString, IPromise, IQService, IScope } from 'angular';
 import { isArray, isString, IPromise, IQService, IScope } from 'angular';
 import LocalStorageService from '../services/local-storage.service';
 import LocalStorageService from '../services/local-storage.service';
-import OrgChartData from '../models/orgchart-data.model';
+import IOrgChartData from '../models/orgchart-data.model';
 import { IPerson } from '../models/person.model';
 import { IPerson } from '../models/person.model';
 
 
 @Component({
 @Component({
@@ -38,6 +38,7 @@ export default class OrgChartSearchComponent {
     directReports: IPerson[];
     directReports: IPerson[];
     inputDebounce: number;
     inputDebounce: number;
     managementChain: IPerson[];
     managementChain: IPerson[];
+    assistant: IPerson;
     person: IPerson;
     person: IPerson;
     photosEnabled: boolean;
     photosEnabled: boolean;
     query: string;
     query: string;
@@ -77,7 +78,7 @@ export default class OrgChartSearchComponent {
         let personId: string = this.$stateParams['personId'];
         let personId: string = this.$stateParams['personId'];
 
 
         this.fetchOrgChartData(personId)
         this.fetchOrgChartData(personId)
-            .then((orgChartData: OrgChartData) => {
+            .then((orgChartData: IOrgChartData) => {
                 if (!orgChartData) {
                 if (!orgChartData) {
                     return;
                     return;
                 }
                 }
@@ -85,6 +86,10 @@ export default class OrgChartSearchComponent {
                 // Override personId in case it was undefined
                 // Override personId in case it was undefined
                 personId = orgChartData.self.userKey;
                 personId = orgChartData.self.userKey;
 
 
+                if (orgChartData.assistant) {
+                    self.assistant = orgChartData.assistant;
+                }
+
                 self.peopleService.getPerson(personId)
                 self.peopleService.getPerson(personId)
                     .then((person: IPerson) => {
                     .then((person: IPerson) => {
                             self.person = person;
                             self.person = person;
@@ -131,7 +136,7 @@ export default class OrgChartSearchComponent {
         this.storeSearchText();
         this.storeSearchText();
     }
     }
 
 
-    private fetchOrgChartData(personId): IPromise<OrgChartData> {
+    private fetchOrgChartData(personId): IPromise<IOrgChartData> {
         return this.peopleService.getOrgChartData(personId, true);
         return this.peopleService.getOrgChartData(personId, true);
     }
     }
 
 

+ 10 - 1
src/main/angular/src/peoplesearch/orgchart.component.html

@@ -38,13 +38,22 @@
     </div>
     </div>
 </div>
 </div>
 
 
-<div class="org-chart-section">
+<div class="org-chart-section self">
     <person-card person="$ctrl.person"
     <person-card person="$ctrl.person"
                  direct-reports="$ctrl.directReports"
                  direct-reports="$ctrl.directReports"
                  ng-click="$ctrl.onClickPerson()"
                  ng-click="$ctrl.onClickPerson()"
+                 class="self"
                  size="large"
                  size="large"
                  show-direct-report-count="true"
                  show-direct-report-count="true"
                  show-image="$ctrl.showImages"></person-card>
                  show-image="$ctrl.showImages"></person-card>
+    <div class="assistant" ng-if="$ctrl.assistant">
+        <div class="org-chart-connector dashed"></div>
+        <person-card person="$ctrl.assistant"
+                     size="small"
+                     show-direct-report-count="false"
+                     show-image="$ctrl.showImages"
+                     ng-click="$ctrl.selectPerson($ctrl.assistant.userKey)"></person-card>
+    </div>
 </div>
 </div>
 
 
 <div class="org-chart-section direct-reports" ng-if="$ctrl.hasDirectReports()">
 <div class="org-chart-section direct-reports" ng-if="$ctrl.hasDirectReports()">

+ 37 - 0
src/main/angular/src/peoplesearch/orgchart.component.scss

@@ -32,6 +32,10 @@ org-chart {
   display: block;
   display: block;
   max-width: 100%;
   max-width: 100%;
 
 
+  .assistant {
+    display: none;
+  }
+
   // (S) Too wide for full width person-card in direct reports
   // (S) Too wide for full width person-card in direct reports
   &.small {
   &.small {
     > .org-chart-section {
     > .org-chart-section {
@@ -127,6 +131,27 @@ org-chart {
           }
           }
         }
         }
       }
       }
+
+      &.self {
+        person-card {
+          display: inline-block;
+        }
+
+        > .assistant {
+          display: inline-block;
+          margin-left: 33px;
+          position: relative;
+
+          > .org-chart-connector {
+            background-color: transparent;
+            border-top: 3px dashed $org-chart-connector-color;
+            height: 0;
+            left: -37px;
+            top: 26px;
+            width: 69px;
+          }
+        }
+      }
     }
     }
   }
   }
 
 
@@ -315,6 +340,18 @@ org-chart {
             }
             }
           }
           }
         }
         }
+
+        &.self {
+          > .assistant {
+            margin-left: 0;
+            margin-right: 33px;
+
+            > .org-chart-connector {
+              left: auto;
+              right: -37px;
+            }
+          }
+        }
       }
       }
     }
     }
   }
   }

+ 3 - 1
src/main/angular/src/peoplesearch/orgchart.component.ts

@@ -29,13 +29,14 @@ import { IPerson } from '../models/person.model';
 export enum OrgChartSize {
 export enum OrgChartSize {
     ExtraSmall = 0,
     ExtraSmall = 0,
     Small = 365,
     Small = 365,
-    Large = 480
+    Large = 631
 }
 }
 
 
 @Component({
 @Component({
     bindings: {
     bindings: {
         directReports: '<',
         directReports: '<',
         managementChain: '<',
         managementChain: '<',
+        assistant: '<',
         person: '<',
         person: '<',
         showImages: '<'
         showImages: '<'
     },
     },
@@ -48,6 +49,7 @@ export default class OrgChartComponent {
     isLargeLayout: boolean;
     isLargeLayout: boolean;
     managementChain: IPerson[];
     managementChain: IPerson[];
     person: IPerson;
     person: IPerson;
+    assistant: IPerson;
 
 
     private elementSize: OrgChartSize = OrgChartSize.ExtraSmall;
     private elementSize: OrgChartSize = OrgChartSize.ExtraSmall;
     private maxVisibleManagers: number;
     private maxVisibleManagers: number;

+ 11 - 0
src/main/angular/src/services/people.data.json

@@ -710,6 +710,17 @@
             "userKey": 3
             "userKey": 3
           }
           }
         ]
         ]
+      },
+      "assistant": {
+        "name": "assistant",
+        "label": "Assistant",
+        "type": "userDN",
+        "userReferences": [
+          {
+            "displayName": "Joe Stevens - Automation Specialist",
+            "userKey": 14
+          }
+        ]
       }
       }
     },
     },
     "links": [
     "links": [

+ 16 - 5
src/main/angular/src/services/people.service.dev.ts

@@ -24,7 +24,7 @@
 import { IPromise, IQService, ITimeoutService } from 'angular';
 import { IPromise, IQService, ITimeoutService } from 'angular';
 import { IPerson } from '../models/person.model';
 import { IPerson } from '../models/person.model';
 import { IPeopleService } from './people.service';
 import { IPeopleService } from './people.service';
-import OrgChartData from '../models/orgchart-data.model';
+import IOrgChartData from '../models/orgchart-data.model';
 import SearchResult from '../models/search-result.model';
 import SearchResult from '../models/search-result.model';
 
 
 const peopleData = require('./people.data');
 const peopleData = require('./people.data');
@@ -99,16 +99,19 @@ export default class PeopleService implements IPeopleService {
         return this.$q.reject(`Person with id: "${id}" not found.`);
         return this.$q.reject(`Person with id: "${id}" not found.`);
     }
     }
 
 
-    getOrgChartData(personId: string): angular.IPromise<OrgChartData> {
+    getOrgChartData(personId: string): angular.IPromise<IOrgChartData> {
         if (!personId) {
         if (!personId) {
             personId = '9';
             personId = '9';
         }
         }
 
 
         const self = this.findPerson(personId);
         const self = this.findPerson(personId);
-        const manager = this.findManager(self);
-        const children = this.findDirectReports(personId);
 
 
-        const orgChartData = new OrgChartData(manager, children, self);
+        const orgChartData: IOrgChartData = {
+            manager: this.findManager(self),
+            children: this.findDirectReports(personId),
+            self: self,
+            assistant: this.findAssistant(self)
+        };
 
 
         return this.$q.resolve(orgChartData);
         return this.$q.resolve(orgChartData);
     }
     }
@@ -183,6 +186,14 @@ export default class PeopleService implements IPeopleService {
         return this.people.filter((person: IPerson) => person.detail['manager']['userReferences'][0].userKey == id);
         return this.people.filter((person: IPerson) => person.detail['manager']['userReferences'][0].userKey == id);
     }
     }
 
 
+    private findAssistant(person: IPerson): IPerson {
+        if (!('assistant' in person.detail)) {
+            return null;
+        }
+
+        return this.findPerson(person.detail['assistant']['userReferences'][0].userKey);
+    }
+
     private findManager(person: IPerson): IPerson {
     private findManager(person: IPerson): IPerson {
         return this.findPerson(person.detail['manager']['userReferences'][0].userKey);
         return this.findPerson(person.detail['manager']['userReferences'][0].userKey);
     }
     }

+ 20 - 7
src/main/angular/src/services/people.service.ts

@@ -24,7 +24,7 @@
 import { isString, IHttpService, ILogService, IPromise, IQService, IWindowService } from 'angular';
 import { isString, IHttpService, ILogService, IPromise, IQService, IWindowService } from 'angular';
 import { IPerson } from '../models/person.model';
 import { IPerson } from '../models/person.model';
 import IPwmService from './pwm.service';
 import IPwmService from './pwm.service';
-import OrgChartData from '../models/orgchart-data.model';
+import IOrgChartData from '../models/orgchart-data.model';
 import SearchResult from '../models/search-result.model';
 import SearchResult from '../models/search-result.model';
 
 
 export interface IPeopleService {
 export interface IPeopleService {
@@ -32,7 +32,7 @@ export interface IPeopleService {
     getDirectReports(personId: string): IPromise<IPerson[]>;
     getDirectReports(personId: string): IPromise<IPerson[]>;
     getNumberOfDirectReports(personId: string): IPromise<number>;
     getNumberOfDirectReports(personId: string): IPromise<number>;
     getManagementChain(personId: string): IPromise<IPerson[]>;
     getManagementChain(personId: string): IPromise<IPerson[]>;
-    getOrgChartData(personId: string, skipChildren: boolean): IPromise<OrgChartData>;
+    getOrgChartData(personId: string, skipChildren: boolean): IPromise<IOrgChartData>;
     getPerson(id: string): IPromise<IPerson>;
     getPerson(id: string): IPromise<IPerson>;
     search(query: string): IPromise<SearchResult>;
     search(query: string): IPromise<SearchResult>;
 }
 }
@@ -68,7 +68,7 @@ export default class PeopleService implements IPeopleService {
     }
     }
 
 
     getDirectReports(id: string): IPromise<IPerson[]> {
     getDirectReports(id: string): IPromise<IPerson[]> {
-        return this.getOrgChartData(id, false).then((orgChartData: OrgChartData) => {
+        return this.getOrgChartData(id, false).then((orgChartData: IOrgChartData) => {
             let people: IPerson[] = [];
             let people: IPerson[] = [];
 
 
             for (let directReport of orgChartData.children) {
             for (let directReport of orgChartData.children) {
@@ -93,7 +93,7 @@ export default class PeopleService implements IPeopleService {
 
 
     private getManagerRecursive(id: string, people: IPerson[]): IPromise<IPerson[]> {
     private getManagerRecursive(id: string, people: IPerson[]): IPromise<IPerson[]> {
         return this.getOrgChartData(id, true)
         return this.getOrgChartData(id, true)
-            .then((orgChartData: OrgChartData) => {
+            .then((orgChartData: IOrgChartData) => {
                 if (orgChartData.manager) {
                 if (orgChartData.manager) {
                     people.push(orgChartData.manager);
                     people.push(orgChartData.manager);
 
 
@@ -104,7 +104,7 @@ export default class PeopleService implements IPeopleService {
             });
             });
     }
     }
 
 
-    getOrgChartData(personId: string, noChildren: boolean): angular.IPromise<OrgChartData> {
+    getOrgChartData(personId: string, noChildren: boolean): angular.IPromise<IOrgChartData> {
         return this.$http
         return this.$http
             .get(this.pwmService.getServerUrl('orgChartData'), {
             .get(this.pwmService.getServerUrl('orgChartData'), {
                 cache: true,
                 cache: true,
@@ -122,11 +122,24 @@ export default class PeopleService implements IPeopleService {
                     let responseData = response.data['data'];
                     let responseData = response.data['data'];
 
 
                     let manager: IPerson;
                     let manager: IPerson;
-                    if ('parent' in responseData) { manager = <IPerson>(responseData['parent']); }
+                    let assistant: IPerson;
+
+                    if ('parent' in responseData) {
+                        manager = <IPerson>(responseData['parent']);
+                    }
+                    if ('assistant' in responseData) {
+                        assistant = <IPerson>(responseData['assistant']);
+                    }
+
                     const children = responseData['children'].map((child: any) => <IPerson>(child));
                     const children = responseData['children'].map((child: any) => <IPerson>(child));
                     const self = <IPerson>(responseData['self']);
                     const self = <IPerson>(responseData['self']);
 
 
-                    return this.$q.resolve(new OrgChartData(manager, children, self));
+                    return this.$q.resolve({
+                        manager: manager,
+                        children: children,
+                        self: self,
+                        assistant: assistant
+                    });
                 },
                 },
                 this.handleHttpError.bind(this));
                 this.handleHttpError.bind(this));
     }
     }