wj-elements 0.1.50 → 0.1.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/dist/wje-accordion-item.js +26 -33
- package/dist/wje-accordion.js +9 -11
- package/dist/wje-avatar.js +5 -8
- package/dist/wje-dialog.js +6 -6
- package/dist/wje-master.js +103 -101
- package/dist/wje-orgchart-item.js +49 -0
- package/dist/wje-orgchart.js +511 -0
- package/dist/wje-orgchartItem.js +4 -0
- package/dist/wje-sliding-container.js +99 -55
- package/dist/wje-store.js +35 -35
- package/dist/wje-tab-group.js +32 -13
- package/dist/wje-tab.js +1 -1
- package/package.json +1 -1
- package/dist/wje-inline-edit.js +0 -145
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
var p = Object.defineProperty;
|
|
2
|
+
var f = (n, l, t) => l in n ? p(n, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[l] = t;
|
|
3
|
+
var h = (n, l, t) => (f(n, typeof l != "symbol" ? l + "" : l, t), t);
|
|
4
|
+
import m from "./wje-element.js";
|
|
5
|
+
const v = '#orgChartView{margin:10px}div#UpToManager,div.manager_undefined,div.manager_true{border:solid #dcdee0 2px;border-radius:10px!important}div#UpToManager,.topPerson .nestedPerson div.manager_undefined,.topPerson .nestedPerson div.manager_true{cursor:pointer}.topPerson div.manager_undefined,.topPerson div.manager_true{cursor:default}span.link:hover{text-decoration:underline;cursor:pointer}body,table{font-size:16px;color:#1d252c}thead th{font-size:20px}thead td{font-size:12px;font-style:italic}.suppressPointerEvents *{pointer-events:none}#UpToManager{width:500px;font-weight:700;font-size:20px;background-color:#f3f3f4;min-height:20px}.manager{margin:-10px;padding-top:10px;height:35px}ol.organizational-chart,ol.organizational-chart ol,ol.organizational-chart li,ol.organizational-chart li>div{position:relative}ol.organizational-chart,ol.organizational-chart ol{list-style:none;margin:0;padding:0}ol.organizational-chart{text-align:center}ol.organizational-chart ol{padding-top:1em}ol.organizational-chart ol:before,ol.organizational-chart ol:after,ol.organizational-chart li:before,ol.organizational-chart li:after,ol.organizational-chart>li>div:before,ol.organizational-chart>li>div:after{background-color:#b7a6aa;content:"";position:absolute}ol.organizational-chart ol>li{padding:1em 0 0 1em}ol.organizational-chart>li ol:before{height:1.2em;left:50%;top:0;width:3px}ol.organizational-chart>li ol:after{height:3px;left:3px;top:1em;width:50%}ol.organizational-chart>li ol>li:not(:last-of-type):before{height:3px;left:0;top:2em;width:1em}ol.organizational-chart>li ol>li:not(:last-of-type):after{height:100%;left:0;top:0;width:3px}ol.organizational-chart>li ol>li:last-of-type:before{height:3px;left:0;top:2em;width:1em}ol.organizational-chart>li ol>li:last-of-type:after{height:2em;left:0;top:0;width:3px}ol.organizational-chart li>div{background-color:#fff;border-radius:3px;min-height:2em;padding:.5em}ol.organizational-chart>li>div{background-color:#8dccad;margin-right:1em}ol.organizational-chart>li>div+div{margin-top:1em}ol.organizational-chart>li>div+div:after{right:-1em;top:-1em;width:3px}ol.organizational-chart>li>ol:before{left:inherit}ol.organizational-chart>li>ol:after{left:0}ol.organizational-chart>li>ol>li>div{background-color:#f3f3f4}ol.organizational-chart>li>div.contractor_true,ol.organizational-chart>li>ol>li>div.contractor_true,ol.organizational-chart>li>ol>li>ol>li>div.contractor_true,ol.organizational-chart>li>ol>li>ol>li>ol>li>div.contractor_true,ol.organizational-chart>li>ol>li>ol>li>ol>li>ol>li>div.contractor_true{background-color:#c2c2c2}ol.organizational-chart>li>ol>li>ol>li>div{background-color:#f3f3f4}ol.organizational-chart>li>ol>li>ol>li>ol>li>div{background-color:#f3f3f4}ol.organizational-chart>li>ol>li>ol>li>ol>li>ol>li>div{background-color:#f3f3f4}@media only screen and (max-width: 64em){.largePhoto{width:100px!important;height:100px!important}}@media only screen and (min-width: 64em){ol.organizational-chart{margin-left:-1em;margin-right:-1em}ol.organizational-chart li div.topPersonDiv,#UpToManager{width:500px}ol.organizational-chart>li>div{display:inline-block;float:none;margin:0 1em 1em;vertical-align:bottom}ol.organizational-chart>li>div:only-of-type{margin-bottom:0}ol.organizational-chart>li>div:before,ol.organizational-chart>li>div:after{bottom:-1em!important;top:inherit!important}ol.organizational-chart>li>div:before{height:1em!important;left:50%!important;width:3px!important}ol.organizational-chart>li>div:only-of-type:after{display:none}ol.organizational-chart>li>div:first-of-type:not(:only-of-type):after,ol.organizational-chart>li>div:last-of-type:not(:only-of-type):after{bottom:-1em;height:3px;width:calc(50% + 1em + 3px)}ol.organizational-chart>li>div:first-of-type:not(:only-of-type):after{left:calc(50% + 3px)}ol.organizational-chart>li>div:last-of-type:not(:only-of-type):after{left:calc(-1em - 3px)}ol.organizational-chart>li>div+div:not(:last-of-type):after{height:3px;left:-2em;width:calc(100% + 4em)}ol.organizational-chart>li>ol{display:flex;flex-wrap:nowrap}ol.organizational-chart>li>ol:before,ol.organizational-chart>li>ol>li:before{height:1em!important;left:50%!important;top:0!important;width:3px!important}ol.organizational-chart>li>ol:after{display:none}ol.organizational-chart>li>ol>li{flex-grow:1;padding-left:1em;padding-right:1em;padding-top:1em}ol.organizational-chart>li>ol>li:only-of-type{padding-top:0}ol.organizational-chart>li>ol>li:only-of-type:before,ol.organizational-chart>li>ol>li:only-of-type:after{display:none}ol.organizational-chart>li>ol>li:first-of-type:not(:only-of-type):after,ol.organizational-chart>li>ol>li:last-of-type:not(:only-of-type):after{height:3px;top:0;width:50%}ol.organizational-chart>li>ol>li:first-of-type:not(:only-of-type):after{left:50%}ol.organizational-chart>li>ol>li:last-of-type:not(:only-of-type):after{left:0}ol.organizational-chart>li>ol>li+li:not(:last-of-type):after{height:3px;left:0;top:0;width:100%}}ol.level_3,ol.level_4,ol.level_5{display:none}.center{text-align:center}.left{text-align:left}.largePhoto{margin:1em 0 1em 2em}.orgChartViewContainer{position:absolute;left:20px;top:110px;height:600px;margin-top:-50px;overflow:hidden}ol.organizational-chart li div.topPersonDiv{padding:2px;margin:0}.organizational-chart{margin-top:150px}#orgChartView{top:85px;position:relative}#searchArea{margin-top:0}.jobTitle,ol.organizational-chart li div.nestedPersonDiv .jobTitle{font-size:12px;font-style:italic;font-weight:400}div.nestedSearchDiv{padding:2px;min-height:53px;margin:10px;width:400px;background-color:#fff;cursor:pointer}ol.organizational-chart li div.nestedPersonDiv{padding:2px;min-height:53px}.smallPhoto{float:left;border-radius:50px;margin:2px}#searchArea{position:absolute;margin:0 20px;background-color:#d881fe;z-index:2;padding:15px;border-radius:20px}#detailView{font-size:90%;width:90%}#detailView table{font-size:90%}#detailView .largePhoto{height:100px;width:100px}';
|
|
6
|
+
class g extends m {
|
|
7
|
+
/**
|
|
8
|
+
* Creates an instance of Orgchart.
|
|
9
|
+
*
|
|
10
|
+
* @constructor
|
|
11
|
+
*/
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
h(this, "className", "Orgchart");
|
|
15
|
+
h(this, "getCookieValue", (t) => {
|
|
16
|
+
var i;
|
|
17
|
+
return ((i = document.cookie.match("(^|;)\\s*" + t + "\\s*=\\s*([^;]+)")) == null ? void 0 : i.pop()) || "";
|
|
18
|
+
});
|
|
19
|
+
h(this, "upTemplate", (t) => (console.log("PERSON:", t), `<div class="manager">${t["Reports To Full Name"]}</div>`));
|
|
20
|
+
//
|
|
21
|
+
// hide() {
|
|
22
|
+
// document.getElementById('detailView').style.display = "none";
|
|
23
|
+
// }
|
|
24
|
+
//
|
|
25
|
+
// showDetails(person_id) {
|
|
26
|
+
// let oldMaxDepth = this.maxDepth;
|
|
27
|
+
// this.maxDepth = 1;
|
|
28
|
+
// document.getElementById('detailView').style.display = "block";
|
|
29
|
+
// document.getElementById('detailView').innerHTML = this.render(this.ORGCHART_DATA[person_id], personTemplate);
|
|
30
|
+
// this.maxDepth = oldMaxDepth;
|
|
31
|
+
// }
|
|
32
|
+
//
|
|
33
|
+
// search(sText, sType) {
|
|
34
|
+
// if (sText.length === 0) {
|
|
35
|
+
// return;
|
|
36
|
+
// }
|
|
37
|
+
// const people = this.ORGCHART_DATA;
|
|
38
|
+
// const searchString = new RegExp(sText, "i");
|
|
39
|
+
// const oMatches = {};
|
|
40
|
+
// switch (sType) {
|
|
41
|
+
// case "name" :
|
|
42
|
+
// searchName(searchString);
|
|
43
|
+
// break;
|
|
44
|
+
//
|
|
45
|
+
// case "team" :
|
|
46
|
+
// searchTeam(searchString);
|
|
47
|
+
// break;
|
|
48
|
+
//
|
|
49
|
+
// case "title" :
|
|
50
|
+
// searchJobTitle(searchString);
|
|
51
|
+
// break;
|
|
52
|
+
// }
|
|
53
|
+
// showResults();
|
|
54
|
+
//
|
|
55
|
+
// function showResults() {
|
|
56
|
+
// document.getElementById("searchResults").innerHTML = "";
|
|
57
|
+
// for (let person in oMatches) {
|
|
58
|
+
// document.getElementById("searchResults").innerHTML += this.render(oMatches [person], searchResultTemplate);
|
|
59
|
+
// }
|
|
60
|
+
// }
|
|
61
|
+
//
|
|
62
|
+
// function searchTeam(searchString) {
|
|
63
|
+
// let iMatches = 0;
|
|
64
|
+
//
|
|
65
|
+
// for (const person_id in people) {
|
|
66
|
+
// const person = people[person_id];
|
|
67
|
+
// if (searchString.test(person["Department"]) || searchString.test(person["Division"]) || searchString.test(person["Teams"])) {
|
|
68
|
+
// if (iMatches < 20) {
|
|
69
|
+
// iMatches++;
|
|
70
|
+
// oMatches[person_id] = person;
|
|
71
|
+
// } else {
|
|
72
|
+
// break;
|
|
73
|
+
// }
|
|
74
|
+
// }
|
|
75
|
+
// }
|
|
76
|
+
// return iMatches;
|
|
77
|
+
// }
|
|
78
|
+
//
|
|
79
|
+
// function searchJobTitle() {
|
|
80
|
+
// let iMatches = 0;
|
|
81
|
+
// for (const person_id in people) {
|
|
82
|
+
// const person = people[person_id];
|
|
83
|
+
// if (searchString.test(person["Job Title"])) {
|
|
84
|
+
// if (iMatches < 20) {
|
|
85
|
+
// iMatches++;
|
|
86
|
+
// oMatches[person_id] = person;
|
|
87
|
+
// } else {
|
|
88
|
+
// break;
|
|
89
|
+
// }
|
|
90
|
+
// }
|
|
91
|
+
// }
|
|
92
|
+
// return iMatches;
|
|
93
|
+
// }
|
|
94
|
+
//
|
|
95
|
+
// function isInList(aList) {
|
|
96
|
+
// let results = false;
|
|
97
|
+
// if (aList) {
|
|
98
|
+
// for (let i = 0; aList.length > i; i++) {
|
|
99
|
+
//
|
|
100
|
+
// const sListItem = aList[i];
|
|
101
|
+
// if (searchString.test(sListItem)) {
|
|
102
|
+
// results = true;
|
|
103
|
+
// break;
|
|
104
|
+
// }
|
|
105
|
+
// }
|
|
106
|
+
// }
|
|
107
|
+
// return results;
|
|
108
|
+
// }
|
|
109
|
+
//
|
|
110
|
+
// function searchName() {
|
|
111
|
+
// let iMatches = 0;
|
|
112
|
+
// for (const person_id in people) {
|
|
113
|
+
// const person = people[person_id];
|
|
114
|
+
// if (searchString.test(person["First name"]) ||
|
|
115
|
+
// searchString.test(person["Preferred first name"]) ||
|
|
116
|
+
// searchString.test(person["Last name"]) ||
|
|
117
|
+
// searchString.test(person["id"]) ||
|
|
118
|
+
// searchString.test((person["First name"] + " " + person["Last name"])) ||
|
|
119
|
+
// searchString.test((person["Preferred first name"] + " " + person["Last name"]))
|
|
120
|
+
// ) {
|
|
121
|
+
// if (iMatches < 20) {
|
|
122
|
+
// iMatches++;
|
|
123
|
+
// oMatches[person_id] = person;
|
|
124
|
+
// } else {
|
|
125
|
+
// break;
|
|
126
|
+
// }
|
|
127
|
+
// }
|
|
128
|
+
// }
|
|
129
|
+
// return iMatches;
|
|
130
|
+
// }
|
|
131
|
+
// }
|
|
132
|
+
//
|
|
133
|
+
// showSearchResults() {
|
|
134
|
+
// const oSearchResults = document.getElementById('searchResults');
|
|
135
|
+
// oSearchResults.style.display = 'block';
|
|
136
|
+
// if (event.keyCode === 13) {
|
|
137
|
+
// oSearchResults.children[0].onmouseover(null);
|
|
138
|
+
// this.hideSearchResults();
|
|
139
|
+
// }
|
|
140
|
+
// }
|
|
141
|
+
//
|
|
142
|
+
// previewPerson(person_id) {
|
|
143
|
+
// const person = this.ORGCHART_DATA[person_id];
|
|
144
|
+
// if (person) {
|
|
145
|
+
// this.initializeLevels(person);
|
|
146
|
+
// this.makeRoot(person.id, true);
|
|
147
|
+
// this.hide();
|
|
148
|
+
// }
|
|
149
|
+
// }
|
|
150
|
+
//
|
|
151
|
+
// showSearch() {
|
|
152
|
+
// this.native.getElementById('searchArea').style.display = 'block';
|
|
153
|
+
// }
|
|
154
|
+
//
|
|
155
|
+
// hideSearchResults() {
|
|
156
|
+
// document.getElementById('searchResults').style.display = 'none';
|
|
157
|
+
// const newHash = "person=" + this.lastUnsavedId;
|
|
158
|
+
// if (newHash && newHash !== "person=null" && ("#" + newHash) !== (document.location.hash)) {
|
|
159
|
+
// this.lastHash = "#" + newHash;
|
|
160
|
+
// document.location.hash = newHash;
|
|
161
|
+
// }
|
|
162
|
+
// setTimeout(function() {
|
|
163
|
+
// document.getElementById('searchResults').style.display = 'none';
|
|
164
|
+
// }, 10); // does this need to be async?
|
|
165
|
+
// }
|
|
166
|
+
//
|
|
167
|
+
h(this, "personTemplate", (t) => {
|
|
168
|
+
this.htmlTemplate`
|
|
169
|
+
<!--suppress ALL -->
|
|
170
|
+
<li class="topPerson">
|
|
171
|
+
<div id="${this.initializeLevels(t)}"
|
|
172
|
+
class="topPersonDiv manager_${t.directs && t.directs.length > 0}
|
|
173
|
+
survived_${this.isCurrentEmployee(t.id)}
|
|
174
|
+
contractor_${this.isContractor(t.id)}
|
|
175
|
+
">
|
|
176
|
+
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
|
177
|
+
<thead>
|
|
178
|
+
<tr>
|
|
179
|
+
<th colspan="3" class="center">
|
|
180
|
+
${this.getFullName(t.id)}
|
|
181
|
+
</th>
|
|
182
|
+
</tr>
|
|
183
|
+
<tr>
|
|
184
|
+
<td colspan="3" class="center" class="center">
|
|
185
|
+
${t["Job Title"]}
|
|
186
|
+
</td>
|
|
187
|
+
</tr>
|
|
188
|
+
</thead>
|
|
189
|
+
<tbody>
|
|
190
|
+
|
|
191
|
+
<tr>
|
|
192
|
+
<td rowspan="3" width="1"><img src="${this.getPhotoUrl(t.id, "medium")}"
|
|
193
|
+
class="largePhoto"
|
|
194
|
+
height="200"
|
|
195
|
+
width="200"
|
|
196
|
+
alt="a photograph of ${this.getFullName(t.id)}" onerror="this.hideImage(this)"/>
|
|
197
|
+
</td>
|
|
198
|
+
<td rowspan="3" width="5%"> </td>
|
|
199
|
+
</tr>
|
|
200
|
+
|
|
201
|
+
<tr>
|
|
202
|
+
<td>
|
|
203
|
+
</td>
|
|
204
|
+
</tr>
|
|
205
|
+
<tr>
|
|
206
|
+
<td class="left">
|
|
207
|
+
|
|
208
|
+
<div title="${t["Start date"]}">
|
|
209
|
+
Higher Standards for
|
|
210
|
+
</div>
|
|
211
|
+
${this.getRelativeTime(t["Start date"])}
|
|
212
|
+
|
|
213
|
+
<div>Department:
|
|
214
|
+
${t.Department}
|
|
215
|
+
</div>
|
|
216
|
+
|
|
217
|
+
${t.Division ? `
|
|
218
|
+
<div>Division:
|
|
219
|
+
${t.Division}
|
|
220
|
+
</div>` : ""}
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
<div>Email:
|
|
225
|
+
<a href="mailto:${t.Email}" target="_blank" rel="noreferrer">${t.Email}</a>
|
|
226
|
+
</div>
|
|
227
|
+
${t["Mobile phone"] ? `
|
|
228
|
+
<div>Phone:
|
|
229
|
+
${t["Mobile phone"]}
|
|
230
|
+
</div>` : ""}
|
|
231
|
+
<div>Location:
|
|
232
|
+
${t["Office Locations"]}
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
<div> </div>
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
<!-- <div>Email</div>-->
|
|
241
|
+
<!-- <div>Phone</div>-->
|
|
242
|
+
<!-- <div>Employment Status</div>-->
|
|
243
|
+
<!-- <div>End Date</div>-->
|
|
244
|
+
<!-- <div>GitHub</div>-->
|
|
245
|
+
<!-- <div>Jira</div>-->
|
|
246
|
+
<!-- <div>OpsGenie</div>-->
|
|
247
|
+
<!-- <div>Blameless</div>-->
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
</td>
|
|
251
|
+
|
|
252
|
+
</tr>
|
|
253
|
+
</tbody>
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
</table>
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
</div>
|
|
260
|
+
${t.directs && t.level < this.maxDepth ? `<ol class="level_${t.level}"> ${this.orgchartRender(t.directs.map((i) => this.ORGCHART_DATA[i]), this.nestedPersonTemplate)} </ol>` : ""}
|
|
261
|
+
</li>`;
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Returns the CSS styles for the component.
|
|
266
|
+
*
|
|
267
|
+
* @static
|
|
268
|
+
* @returns {CSSStyleSheet}
|
|
269
|
+
*/
|
|
270
|
+
static get cssStyleSheet() {
|
|
271
|
+
return v;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Sets up the attributes for the component.
|
|
275
|
+
*/
|
|
276
|
+
setupAttributes() {
|
|
277
|
+
this.isShadowRoot = "open";
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Draws the component.
|
|
281
|
+
*
|
|
282
|
+
* @param {Object} context - The context for drawing.
|
|
283
|
+
* @param {Object} store - The store for drawing.
|
|
284
|
+
* @param {Object} params - The parameters for drawing.
|
|
285
|
+
* @returns {DocumentFragment}
|
|
286
|
+
*/
|
|
287
|
+
draw(t, i, e) {
|
|
288
|
+
let a = document.createDocumentFragment(), o = document.createElement("div");
|
|
289
|
+
return o.setAttribute("part", "native"), o.classList.add("orgchart"), o.innerHTML = `<div id="searchArea">
|
|
290
|
+
<form name="SearchForm">
|
|
291
|
+
<label>
|
|
292
|
+
Search:
|
|
293
|
+
<input type="text" placeholder="Search" name="searchText" id="searchText"></label>
|
|
294
|
+
<label>For:
|
|
295
|
+
<select name="type">
|
|
296
|
+
<option value="name" selected="selected">Name</option>
|
|
297
|
+
<option value="team">Team</option>
|
|
298
|
+
<option value="title">Job Title</option>
|
|
299
|
+
</select>
|
|
300
|
+
</label>
|
|
301
|
+
<button >Search</button>
|
|
302
|
+
<div id="searchResults">
|
|
303
|
+
<div></div>
|
|
304
|
+
</div>
|
|
305
|
+
</form>
|
|
306
|
+
</div>
|
|
307
|
+
<div id="orgChartView">
|
|
308
|
+
<div class="orgChartViewContainer">
|
|
309
|
+
<div id="detailView"></div>
|
|
310
|
+
</div>
|
|
311
|
+
<ol class="organizational-chart">
|
|
312
|
+
<li>
|
|
313
|
+
<div id="UpToManager"></div>
|
|
314
|
+
<ol class="organizational-chart" id="root">
|
|
315
|
+
<li>
|
|
316
|
+
<div>
|
|
317
|
+
<h1>Org Chart</h1>
|
|
318
|
+
</div>
|
|
319
|
+
</li>
|
|
320
|
+
</ol>
|
|
321
|
+
</li>
|
|
322
|
+
</ol>
|
|
323
|
+
</div>`, a.appendChild(o), this.native = o, a;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* After Draws the component.
|
|
327
|
+
*
|
|
328
|
+
* @param {Object} context - The context for drawing.
|
|
329
|
+
* @param {Object} store - The store for drawing.
|
|
330
|
+
* @param {Object} params - The parameters for drawing.
|
|
331
|
+
* @returns {DocumentFragment}
|
|
332
|
+
*/
|
|
333
|
+
afterDraw(t, i, e) {
|
|
334
|
+
this.orgchartInit(), this.maxDepth = 3, this.lastUnsavedId = null, this.lastHash = document.location.hash;
|
|
335
|
+
}
|
|
336
|
+
// submitForm(logData) {
|
|
337
|
+
// const sLogData = this.encode(logData);
|
|
338
|
+
// const sRemoteUrl = "https://acklenx.com/orgchart.png?" + sLogData;
|
|
339
|
+
// document.getElementById("visitor").src = sRemoteUrl;
|
|
340
|
+
// }
|
|
341
|
+
//
|
|
342
|
+
// encode(data) {
|
|
343
|
+
// return Object.keys(data).map((key) => encodeURIComponent(key) + "=" + encodeURIComponent(data[key])).join("&");
|
|
344
|
+
// }
|
|
345
|
+
orgchartInit() {
|
|
346
|
+
this.loadExternalDataset(), this.loadPerson(), this.native.querySelector("#searchText").focus();
|
|
347
|
+
}
|
|
348
|
+
loadExternalDataset() {
|
|
349
|
+
new URLSearchParams(window.location.search);
|
|
350
|
+
let t = "/demo/assets/data/orgchart.json";
|
|
351
|
+
{
|
|
352
|
+
var i = this.getData(t);
|
|
353
|
+
this.ORGCHART_DATA = JSON.parse(i);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
getData(t = "demo/assets/data/orgchart.json", i) {
|
|
357
|
+
let e = "";
|
|
358
|
+
const a = new XMLHttpRequest();
|
|
359
|
+
return a.onreadystatechange = function() {
|
|
360
|
+
this.readyState == 4 && this.status == 200 && (e = a.responseText);
|
|
361
|
+
}, a.open("GET", t, !1), a.send(), e;
|
|
362
|
+
}
|
|
363
|
+
getVisitorId() {
|
|
364
|
+
let t = this.getCookieValue("visitor");
|
|
365
|
+
return t || (t = "visitor_" + Math.floor(Math.random() * 1e7), document.cookie = "visitor=" + t + "; expires=Fri, 31 Dec 9999 23:59:59 GMT; SameSite=Strict; Secure"), t;
|
|
366
|
+
}
|
|
367
|
+
htmlTemplate(t, ...i) {
|
|
368
|
+
let e = t.raw, a = "", o = 1, r = arguments.length, s, d;
|
|
369
|
+
for (; o < r; )
|
|
370
|
+
s = e[o - 1], d = i[o - 1], a += s + d, o++;
|
|
371
|
+
return a += e[e.length - 1], a;
|
|
372
|
+
}
|
|
373
|
+
orgchartRender(t, i) {
|
|
374
|
+
if (i) {
|
|
375
|
+
if (typeof t == "string")
|
|
376
|
+
return i(t);
|
|
377
|
+
if (typeof t == "object" && !Array.isArray(t))
|
|
378
|
+
return console.log("DATA:", t, i(t)), i(t);
|
|
379
|
+
if (Array.isArray(t))
|
|
380
|
+
return t.map((e) => i(e)).join("");
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
loadPerson(t, i) {
|
|
384
|
+
this.native.querySelector("#orgChartView").style.display = "block", (!t || !this.ORGCHART_DATA[t]) && (t = this.getStartingPersonFromUrl(), t || (t = Object.keys(this.ORGCHART_DATA)[0])), i ? this.lastUnsavedId = t : (document.location.hash = "person=" + t, this.lastUnsavedId = null), document.title = "OrgChart:" + this.getFullName(t), this.native.querySelector("#root").innerHTML = this.personTemplate(this.ORGCHART_DATA[t]), this.native.querySelector("#UpToManager").innerHTML = this.orgchartRender(this.ORGCHART_DATA[t], this.upTemplate), this.setUpToManagerColor(this.ORGCHART_DATA[t]), this.lastHash = document.location.hash, this.context.querySelector(".manager").addEventListener("click", () => {
|
|
385
|
+
this.makeRoot(t);
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
setUpToManagerColor(t) {
|
|
389
|
+
const i = this.isCurrentEmployee(t["Reports To ID"]);
|
|
390
|
+
this.native.querySelector("#UpToManager").classList.remove("survived_true"), this.native.querySelector("#UpToManager").classList.remove("survived_false"), this.native.querySelector("#UpToManager").classList.add("survived_" + i);
|
|
391
|
+
}
|
|
392
|
+
getStartingPersonFromUrl() {
|
|
393
|
+
let t = null, e = document.location.hash.match(/person=([^&]*)/gi);
|
|
394
|
+
return e && e[0] && (e = e[0].replace("person=", ""), this.ORGCHART_DATA[e] && (t = e)), t;
|
|
395
|
+
}
|
|
396
|
+
//
|
|
397
|
+
// hideImage(oImage) {
|
|
398
|
+
// oImage.style.display = 'none';
|
|
399
|
+
// }
|
|
400
|
+
initializeLevels(t) {
|
|
401
|
+
if (t.level || (t.level = 1), t.directs)
|
|
402
|
+
for (let i = 0; t.directs.length > i; i++) {
|
|
403
|
+
const e = this.ORGCHART_DATA[t.directs[i]];
|
|
404
|
+
e.level = t.level + 1;
|
|
405
|
+
}
|
|
406
|
+
return "";
|
|
407
|
+
}
|
|
408
|
+
makeRoot(t, i) {
|
|
409
|
+
if (t) {
|
|
410
|
+
let e = this.ORGCHART_DATA[t];
|
|
411
|
+
e.level === 1 && (e = this.ORGCHART_DATA[this.ORGCHART_DATA[t].id], e || (e = this.ORGCHART_DATA[t])), e.level = null, this.loadPerson(t, i), document.body.scrollTop = 0, document.documentElement.scrollTop = 0;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
getFullName(t) {
|
|
415
|
+
const i = this.ORGCHART_DATA[t];
|
|
416
|
+
return (i["Preferred first name"] || i["First name"] || i.name) + " " + i["Last name"];
|
|
417
|
+
}
|
|
418
|
+
getPhotoUrl(t, i) {
|
|
419
|
+
return i = "", "./photos/" + i + t + ".jpg";
|
|
420
|
+
}
|
|
421
|
+
isCurrentEmployee(t) {
|
|
422
|
+
let i = !0;
|
|
423
|
+
const e = this.ORGCHART_DATA[t];
|
|
424
|
+
return e && e["End date"] && (i = !1), i;
|
|
425
|
+
}
|
|
426
|
+
isContractor(t) {
|
|
427
|
+
let i = !1;
|
|
428
|
+
return this.ORGCHART_DATA[t]["Employee type"] === "Contractor" && (i = !0), i;
|
|
429
|
+
}
|
|
430
|
+
// getRole(person) {
|
|
431
|
+
// let sRole = "";
|
|
432
|
+
// let sTeam = person["Teams"];
|
|
433
|
+
// if (person.directs && person.directs.length > 0 && sTeam && sTeam !== "") {
|
|
434
|
+
// if (sTeam === "CTO Team") {
|
|
435
|
+
// sRole = person["Job Title"].replace(/^VP,? /, "");
|
|
436
|
+
// } else {
|
|
437
|
+
// sRole = sTeam;
|
|
438
|
+
// }
|
|
439
|
+
// } else {
|
|
440
|
+
// sRole += person["Job Title"];
|
|
441
|
+
// }
|
|
442
|
+
// return sRole;
|
|
443
|
+
// }
|
|
444
|
+
getRelativeTime(t) {
|
|
445
|
+
const i = new Date(t), e = (/* @__PURE__ */ new Date() - i) / 26298e5;
|
|
446
|
+
let a = e / 12, o = "";
|
|
447
|
+
if (a >= 1) {
|
|
448
|
+
o = Math.floor(a) + " Year", o !== "1 Year" && (o += "s");
|
|
449
|
+
let r = Math.floor(e % 12) + " month";
|
|
450
|
+
r !== "1 month" && (r += "s"), o += " " + r;
|
|
451
|
+
} else {
|
|
452
|
+
let r = e % 12, s = Math.floor(r) + " month";
|
|
453
|
+
if (r >= 1)
|
|
454
|
+
s !== "1 month" && (s += "s"), o += s;
|
|
455
|
+
else {
|
|
456
|
+
let d = (/* @__PURE__ */ new Date() - i) / 864e5, c = Math.ceil(d) + " day";
|
|
457
|
+
c !== "1 day" && (c += "s"), o += c;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
return o;
|
|
461
|
+
}
|
|
462
|
+
// nestedPersonTemplate = ( person ) => {
|
|
463
|
+
// htmlTemplate`
|
|
464
|
+
// <!--suppress ALL -->
|
|
465
|
+
// <li class="nestedPerson">
|
|
466
|
+
// <div onclick="${this.initializeLevels( person ) };this.makeRoot( '${ person.id }' ); this.hide();"
|
|
467
|
+
// onmouseover="this.showDetails( '${ person.id }' ); this.hideSearchResults();"
|
|
468
|
+
// onmouseout="this.hide()"
|
|
469
|
+
// class="manager_${ person.directs && person.directs.length > 0 }
|
|
470
|
+
// survived_${this.isCurrentEmployee( person.id ) }
|
|
471
|
+
// contractor_${this.isContractor( person.id ) }
|
|
472
|
+
// suppressPointerEvents nestedPersonDiv">
|
|
473
|
+
//
|
|
474
|
+
// <img src="${this.getPhotoUrl( person.id, '50x50' ) }"
|
|
475
|
+
// alt="Small photograph of ${this.getFullName( person.id ) }"
|
|
476
|
+
// class="smallPhoto"
|
|
477
|
+
// height="50" width="50"
|
|
478
|
+
// onerror="this.hideImage(this)"/>
|
|
479
|
+
//
|
|
480
|
+
// <strong>${this.getFullName( person.id ) }</strong>
|
|
481
|
+
// <br/>
|
|
482
|
+
// <span class="jobTitle" title="${ person[ 'Job Title' ] }">${this.getRole( person ) }</span>
|
|
483
|
+
//
|
|
484
|
+
// </div>
|
|
485
|
+
// ${ person.directs && person.level < this.maxDepth ? `<ol class="level_${ person.level }"> ${this.render( person.directs.map( person_id => this.ORGCHART_DATA[ person_id ] ), this.nestedPersonTemplate ) } </ol>` : "" }
|
|
486
|
+
// </li>`;
|
|
487
|
+
// }
|
|
488
|
+
//
|
|
489
|
+
// searchResultTemplate = ( person ) => {
|
|
490
|
+
// htmlTemplate`
|
|
491
|
+
// <!--suppress HtmlDeprecatedAttribute -->
|
|
492
|
+
// <div onmouseover="this.previewPerson( '${ person.id }' )"
|
|
493
|
+
// class="nestedSearchDiv manager_${ person.directs && person.directs.length > 0 } suppressPointerEvents"
|
|
494
|
+
// onclick="this.hideSearchResults();">
|
|
495
|
+
//
|
|
496
|
+
// <img src="${this.getPhotoUrl( person.id, 'thumbnail' ) }"
|
|
497
|
+
// alt="Small photograph of ${this.getFullName( person.id ) }"
|
|
498
|
+
// class="smallPhoto"
|
|
499
|
+
// height="50" width="50" onerror="this.hideImage(this)" />
|
|
500
|
+
//
|
|
501
|
+
// <strong>${this.getFullName( person.id ) }</strong>
|
|
502
|
+
// <br/>
|
|
503
|
+
// <span class="jobTitle" >${ person[ "Job Title" ] }</span>
|
|
504
|
+
// </div>
|
|
505
|
+
// `;
|
|
506
|
+
// }
|
|
507
|
+
}
|
|
508
|
+
g.define("wje-orgchart", g);
|
|
509
|
+
export {
|
|
510
|
+
g as default
|
|
511
|
+
};
|