reneco-hierarchized-picker 0.4.3-beta.9 → 0.5.1
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/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/reneco-hierarchized-picker.cjs.js +1 -1
- package/dist/cjs/reneco-hierarchized-picker_2.cjs.entry.js +520 -285
- package/dist/collection/components/hierarchized-picker/hierarchized-picker.css +10 -2
- package/dist/collection/components/hierarchized-picker/hierarchized-picker.js +403 -144
- package/dist/collection/components/search-input/search-input.js +1 -3
- package/dist/collection/components/treejs/index.js +49 -50
- package/dist/collection/core/options-manager.js +2 -0
- package/dist/collection/features/events/focus-handlers.js +15 -11
- package/dist/collection/features/keyboard-navigation/keyboard-navigation.js +82 -57
- package/dist/collection/features/tree/tree-utils.js +12 -3
- package/dist/collection/utils/conf-helper.js +4 -0
- package/dist/collection/utils/constants.js +4 -3
- package/dist/collection/utils/theme-utils.js +1 -0
- package/dist/custom-elements/index.js +520 -285
- package/dist/esm/loader.js +1 -1
- package/dist/esm/reneco-hierarchized-picker.js +1 -1
- package/dist/esm/reneco-hierarchized-picker_2.entry.js +520 -285
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/reneco-hierarchized-picker.js +1 -1
- package/dist/esm-es5/reneco-hierarchized-picker_2.entry.js +2 -2
- package/dist/reneco-hierarchized-picker/p-73168a50.system.js +1 -1
- package/dist/reneco-hierarchized-picker/p-ca142f5a.entry.js +1 -0
- package/dist/reneco-hierarchized-picker/p-d6a25038.system.entry.js +3 -0
- package/dist/reneco-hierarchized-picker/reneco-hierarchized-picker.esm.js +1 -1
- package/dist/types/components/hierarchized-picker/hierarchized-picker.d.ts +13 -2
- package/dist/types/components.d.ts +6 -0
- package/dist/types/core/options-manager.d.ts +1 -1
- package/dist/types/features/keyboard-navigation/keyboard-navigation.d.ts +2 -1
- package/dist/types/features/tree/tree-utils.d.ts +1 -1
- package/dist/types/utils/utils.d.ts +1 -0
- package/package.json +1 -1
- package/dist/reneco-hierarchized-picker/p-934e9cf8.entry.js +0 -1
- package/dist/reneco-hierarchized-picker/p-9ddab37d.system.entry.js +0 -3
|
@@ -9,7 +9,7 @@ import { RawDataManager } from '../../core/raw-data-manager';
|
|
|
9
9
|
import { OptionsManager } from '../../core/options-manager';
|
|
10
10
|
import { fillTreeWithObject, completeCurrentTreeWithTree, getPropertyFromNode } from '../../features/tree/tree-utils';
|
|
11
11
|
import { displayAutocompleteWithResults, clearAutocomplete } from '../../features/autocomplete/autocomplete';
|
|
12
|
-
import { focusSearchInput, focusMainInput, focusInSearchEvent, focusOutSearchEvent, clickPickerModalArea
|
|
12
|
+
import { focusSearchInput, focusMainInput, focusInSearchEvent, focusOutSearchEvent, clickPickerModalArea } from '../../features/events/focus-handlers';
|
|
13
13
|
import { setupKeyboardNavigation } from '../../features/keyboard-navigation/keyboard-navigation';
|
|
14
14
|
export class HierarchizedPickerComponent {
|
|
15
15
|
/**
|
|
@@ -78,14 +78,66 @@ export class HierarchizedPickerComponent {
|
|
|
78
78
|
logError(messageToLog) {
|
|
79
79
|
try {
|
|
80
80
|
console.error('--- Hierarchized picker ' + this.componentID + ' ERROR ---', messageToLog);
|
|
81
|
+
this.lastErrorMessage = messageToLog;
|
|
81
82
|
}
|
|
82
83
|
catch (_a) {
|
|
83
|
-
|
|
84
|
+
const genericErrorMessage = '--- Hierarchized picker generic ERROR ---';
|
|
85
|
+
this.lastErrorMessage = genericErrorMessage;
|
|
86
|
+
console.error(genericErrorMessage);
|
|
84
87
|
}
|
|
88
|
+
this.errorRaised.emit(this.lastErrorMessage);
|
|
85
89
|
}
|
|
86
90
|
get theOptions() {
|
|
87
91
|
return this.optionsManager.getOptions();
|
|
88
92
|
}
|
|
93
|
+
diffKeys(obj1, obj2, prefix = '') {
|
|
94
|
+
const diffs = [];
|
|
95
|
+
const commonKeys = Object.keys(obj1 || {}).filter(key => obj2 && Object.prototype.hasOwnProperty.call(obj2, key));
|
|
96
|
+
for (const key of commonKeys) {
|
|
97
|
+
const fullKey = prefix ? `${prefix}.${key}` : key;
|
|
98
|
+
const val1 = obj1[key];
|
|
99
|
+
const val2 = obj2[key];
|
|
100
|
+
if (Array.isArray(val1) && Array.isArray(val2)) {
|
|
101
|
+
// Compare array length
|
|
102
|
+
if (val1.length !== val2.length) {
|
|
103
|
+
diffs.push(fullKey);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
// Compare each element deeply
|
|
107
|
+
for (let i = 0; i < val1.length; i++) {
|
|
108
|
+
const v1 = val1[i];
|
|
109
|
+
const v2 = val2[i];
|
|
110
|
+
if (typeof v1 === 'object' &&
|
|
111
|
+
v1 !== null &&
|
|
112
|
+
typeof v2 === 'object' &&
|
|
113
|
+
v2 !== null) {
|
|
114
|
+
const subDiffs = this.diffKeys(v1, v2, `${fullKey}[${i}]`);
|
|
115
|
+
if (subDiffs.length > 0) {
|
|
116
|
+
diffs.push(fullKey);
|
|
117
|
+
break; // stop at first mismatch in array
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else if (v1 !== v2) {
|
|
121
|
+
diffs.push(fullKey);
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else if (val1 &&
|
|
127
|
+
val2 &&
|
|
128
|
+
typeof val1 === 'object' &&
|
|
129
|
+
typeof val2 === 'object') {
|
|
130
|
+
// Recursive deep object comparison
|
|
131
|
+
const subDiffs = this.diffKeys(val1, val2, fullKey);
|
|
132
|
+
if (subDiffs.length > 0)
|
|
133
|
+
diffs.push(...subDiffs);
|
|
134
|
+
}
|
|
135
|
+
else if (val1 !== val2) {
|
|
136
|
+
diffs.push(fullKey);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return diffs;
|
|
140
|
+
}
|
|
89
141
|
async setNewOption(newValue, oldValue = null) {
|
|
90
142
|
this.ready = false;
|
|
91
143
|
// --------------------------------------- DEPRECATED ?
|
|
@@ -104,6 +156,7 @@ export class HierarchizedPickerComponent {
|
|
|
104
156
|
// });
|
|
105
157
|
// ---------------------------------------
|
|
106
158
|
// this.theOptions = newValue;
|
|
159
|
+
const savedOldValue = Object.assign({}, this.theOptions);
|
|
107
160
|
if (oldValue && JSON.stringify(newValue.options) == JSON.stringify(oldValue.options)) {
|
|
108
161
|
this.ready = true;
|
|
109
162
|
return;
|
|
@@ -112,6 +165,7 @@ export class HierarchizedPickerComponent {
|
|
|
112
165
|
newValue = JSON.parse(newValue);
|
|
113
166
|
if (typeof oldValue == 'string')
|
|
114
167
|
oldValue = JSON.parse(oldValue);
|
|
168
|
+
this.value = [];
|
|
115
169
|
this.optionsManager.updateOptions(newValue);
|
|
116
170
|
this.setDisplayedValue(this.value);
|
|
117
171
|
const originOrNodeIdAreDifferent = !oldValue || (newValue.origin != oldValue.origin || newValue.options.StartNodeID != oldValue.options.StartNodeID);
|
|
@@ -129,11 +183,28 @@ export class HierarchizedPickerComponent {
|
|
|
129
183
|
if (oldValue && JSON.stringify(newValue.options) != JSON.stringify(oldValue.options)) {
|
|
130
184
|
this.value = [];
|
|
131
185
|
}
|
|
132
|
-
if ((newValue === null || newValue === void 0 ? void 0 : newValue.loading) == 'display') {
|
|
186
|
+
if ((newValue === null || newValue === void 0 ? void 0 : newValue.loading) == 'display' || (newValue && !newValue.loading)) {
|
|
133
187
|
if ((oldValue && this.isChangeInOptions(newValue, oldValue)) || !oldValue) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
188
|
+
if (!oldValue) {
|
|
189
|
+
oldValue = savedOldValue;
|
|
190
|
+
}
|
|
191
|
+
const propDiffs = this.diffKeys(oldValue, this.optionsManager.initializeOptions(newValue));
|
|
192
|
+
const noReloadProps = ["multiple"];
|
|
193
|
+
const ignoredProps = ["token"];
|
|
194
|
+
const filteredDiffs = propDiffs.filter(prop => !ignoredProps.includes(prop));
|
|
195
|
+
if (filteredDiffs.length == 1 && filteredDiffs.some(item => noReloadProps.includes(item))) {
|
|
196
|
+
const propChanged = filteredDiffs[0];
|
|
197
|
+
switch (propChanged) {
|
|
198
|
+
case "multiple":
|
|
199
|
+
document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-checkbox').forEach((item) => (item.style.display = (this.theOptions.multiple ? 'inline-block' : 'none')));
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
this.rawDataManager = new RawDataManager(this.getOptionsAsIConf(this.optionsManager.getOptions()).token, this.optionsManager);
|
|
205
|
+
await this.loadHierarchizedPicker(true);
|
|
206
|
+
this.displayWhenLoaded();
|
|
207
|
+
}
|
|
137
208
|
}
|
|
138
209
|
else {
|
|
139
210
|
this.ready = true;
|
|
@@ -187,6 +258,9 @@ export class HierarchizedPickerComponent {
|
|
|
187
258
|
async filterTree(searchedValue) {
|
|
188
259
|
this.search(searchedValue);
|
|
189
260
|
}
|
|
261
|
+
async getError() {
|
|
262
|
+
return Promise.resolve(this.lastErrorMessage);
|
|
263
|
+
}
|
|
190
264
|
constructor() {
|
|
191
265
|
this.modaleHeight = 200;
|
|
192
266
|
this.modalePosition = 'bottom';
|
|
@@ -197,30 +271,101 @@ export class HierarchizedPickerComponent {
|
|
|
197
271
|
this.lastSearchMatchCounter = 0; // Counter of number of matches for last search
|
|
198
272
|
this.setValueOnClick = true; // Tells wether we edit the picker value on click in the tree
|
|
199
273
|
this.mylog = console.log; // Custom log function for debug purposes
|
|
274
|
+
this.lastErrorMessage = '';
|
|
275
|
+
this.scrollToNode = (targetNodeId = null, displayChildren = false) => {
|
|
276
|
+
var _a;
|
|
277
|
+
let scrollToValue = 0;
|
|
278
|
+
let removeClosedAndLookUp = (element, editScroll = false) => {
|
|
279
|
+
var _a, _b, _c, _d;
|
|
280
|
+
const nodeId = element === null || element === void 0 ? void 0 : element.nodeId;
|
|
281
|
+
if (!element || !nodeId) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
const node = this.loadedTreeJs.nodesById[nodeId];
|
|
285
|
+
if ((_b = (_a = node === null || node === void 0 ? void 0 : node.children) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.id) {
|
|
286
|
+
(_c = element.classList) === null || _c === void 0 ? void 0 : _c.remove('treejs-node__close');
|
|
287
|
+
}
|
|
288
|
+
if (editScroll) {
|
|
289
|
+
scrollToValue += element.offsetTop;
|
|
290
|
+
}
|
|
291
|
+
const parent = (_d = element.parentNode) === null || _d === void 0 ? void 0 : _d.closest('.treejs-node');
|
|
292
|
+
if (parent) {
|
|
293
|
+
removeClosedAndLookUp(parent, editScroll);
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
try {
|
|
297
|
+
if (targetNodeId) {
|
|
298
|
+
const targetNode = this.loadedTreeJs.liElementsById[targetNodeId];
|
|
299
|
+
if (targetNode) {
|
|
300
|
+
removeClosedAndLookUp(targetNode, true);
|
|
301
|
+
if (displayChildren && targetNode.classList.contains('treejs-node__close')) {
|
|
302
|
+
const leftSwitcher = targetNode.querySelector('.treejs-switcher');
|
|
303
|
+
if (leftSwitcher) {
|
|
304
|
+
(_a = this.loadedTreeJs) === null || _a === void 0 ? void 0 : _a.onSwitcherClick(leftSwitcher);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
const checkeds = document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-node__checked');
|
|
311
|
+
checkeds.forEach((item) => removeClosedAndLookUp(item, scrollToValue == 0));
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
catch (err) {
|
|
315
|
+
this.errorToLog = "Error in showSelectedNodes";
|
|
316
|
+
}
|
|
317
|
+
if (scrollToValue && this.scrollable) {
|
|
318
|
+
this.scrollable.scrollTop = scrollToValue;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
200
321
|
this.getShortenedFullpath = (realFullpath) => {
|
|
201
322
|
var _a, _b, _c, _d;
|
|
323
|
+
if (!realFullpath)
|
|
324
|
+
return realFullpath;
|
|
325
|
+
//TODO if one day we want shortenedfulpaths from data loading :
|
|
326
|
+
// const rdmdata = (this.optionsManager.getOptions().source == "webservice" ? this.rawDataManager.getData() : this.rawDataManager.getData().data ?? null);
|
|
327
|
+
//TODO but for now we're doing :
|
|
328
|
+
if (this.optionsManager.getOptions().source !== "webservice")
|
|
329
|
+
return realFullpath;
|
|
202
330
|
let toret = realFullpath;
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
331
|
+
const rdmdata = this.rawDataManager.getData();
|
|
332
|
+
if (rdmdata) {
|
|
333
|
+
try {
|
|
334
|
+
const propertyName_nodeid = (this.optionsManager.getOptions().origin == 'classification' ? "startNode" : "StartNodeID");
|
|
335
|
+
let propertyValue_nodeid = 0;
|
|
336
|
+
switch (this.optionsManager.getOptions().source) {
|
|
337
|
+
case "file":
|
|
338
|
+
//TODO maybe someday ... someday far !
|
|
339
|
+
return realFullpath;
|
|
340
|
+
case "data":
|
|
341
|
+
//TODO maybe someday ... someday far !
|
|
342
|
+
if (this.optionsManager.getOptions().origin == 'classification')
|
|
343
|
+
return realFullpath;
|
|
344
|
+
propertyValue_nodeid = this.theOptions.data.key;
|
|
345
|
+
break;
|
|
346
|
+
case "webservice":
|
|
347
|
+
propertyValue_nodeid = this.optionsManager.getOptions().options[propertyName_nodeid];
|
|
348
|
+
break;
|
|
213
349
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
350
|
+
if (["0", 0].includes(propertyValue_nodeid))
|
|
351
|
+
return toret;
|
|
352
|
+
if (isNumeric(propertyValue_nodeid)) {
|
|
353
|
+
if (this.optionsManager.getOptions().origin == 'classification') {
|
|
354
|
+
const { Translations, Properties } = rdmdata;
|
|
355
|
+
const currentLanguage = this.optionsManager.getOptions().language;
|
|
356
|
+
toret = ((_b = (_a = Translations[currentLanguage]) === null || _a === void 0 ? void 0 : _a.translated_name) !== null && _b !== void 0 ? _b : Properties === null || Properties === void 0 ? void 0 : Properties.System_Name) + realFullpath.replace(((_d = (_c = Translations[currentLanguage]) === null || _c === void 0 ? void 0 : _c.translated_fullpath) !== null && _d !== void 0 ? _d : Properties === null || Properties === void 0 ? void 0 : Properties.System_Fullpath), "");
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
const { fullpath, fullpathTranslated, title, valueTranslated } = rdmdata;
|
|
360
|
+
toret = (valueTranslated !== null && valueTranslated !== void 0 ? valueTranslated : title) + realFullpath.replace((fullpathTranslated !== null && fullpathTranslated !== void 0 ? fullpathTranslated : fullpath), "");
|
|
361
|
+
}
|
|
217
362
|
}
|
|
363
|
+
else
|
|
364
|
+
this.errorToLog = "Error in getShortenedFullpath : startnode is not number";
|
|
365
|
+
}
|
|
366
|
+
catch (error) {
|
|
367
|
+
this.errorToLog = "Error in getShortenedFullpath " + error.toString();
|
|
218
368
|
}
|
|
219
|
-
else
|
|
220
|
-
this.errorToLog = "Error in getFullpath : startnode is not number";
|
|
221
|
-
}
|
|
222
|
-
catch (error) {
|
|
223
|
-
this.errorToLog = "Error in getFullpath " + error.toString();
|
|
224
369
|
}
|
|
225
370
|
return toret;
|
|
226
371
|
};
|
|
@@ -272,7 +417,6 @@ export class HierarchizedPickerComponent {
|
|
|
272
417
|
}
|
|
273
418
|
componentDidLoad() {
|
|
274
419
|
this.mylog('----- componentDidLoad beginning -----');
|
|
275
|
-
setupKeyboardNavigation(this, this.navigateInTree);
|
|
276
420
|
focusMainInput(this);
|
|
277
421
|
}
|
|
278
422
|
displayWhenLoaded() {
|
|
@@ -316,6 +460,8 @@ export class HierarchizedPickerComponent {
|
|
|
316
460
|
this.optionsManager.getOptions().openTreeWhenLoaded = false;
|
|
317
461
|
if (!this.optionsManager.getOptions().displayRootNode)
|
|
318
462
|
this.optionsManager.getOptions().displayRootNode = false;
|
|
463
|
+
if (!this.optionsManager.getOptions().keyboardNavigation)
|
|
464
|
+
this.optionsManager.getOptions().keyboardNavigation = false;
|
|
319
465
|
if (!this.optionsManager.getOptions().dragAndDropEnabled)
|
|
320
466
|
this.optionsManager.getOptions().dragAndDropEnabled = false;
|
|
321
467
|
if (!this.optionsManager.getOptions().defaultValueIsFullpath)
|
|
@@ -333,21 +479,50 @@ export class HierarchizedPickerComponent {
|
|
|
333
479
|
}
|
|
334
480
|
await Promise.all(this.optionsManager.getOptions().defaultValue.map(async (element) => {
|
|
335
481
|
if (this.optionsManager.getOptions().defaultValueIsFullpath || (!(typeof element == 'number') && !strIsNumeric(element))) {
|
|
336
|
-
if (
|
|
337
|
-
|
|
482
|
+
if (!defaultFromFullpaths) {
|
|
483
|
+
defaultFromFullpaths = [];
|
|
484
|
+
}
|
|
485
|
+
let errormsg = '';
|
|
486
|
+
switch (this.optionsManager.getOptions().source) {
|
|
487
|
+
case 'file':
|
|
488
|
+
errormsg = 'The loading of nodes based on fullpath is not available on file mode for now!';
|
|
489
|
+
break;
|
|
490
|
+
case 'data':
|
|
491
|
+
if (this.theOptions.origin == 'classification') {
|
|
492
|
+
errormsg = 'The loading of nodes based on fullpath is not available on file mode for the classification context for now!';
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
495
|
+
const searchIdInData = function (treeData) {
|
|
496
|
+
if (treeData.data.fullpath === element || treeData.data.fullpathTranslated === element) {
|
|
497
|
+
return treeData.key;
|
|
498
|
+
}
|
|
499
|
+
if (treeData.children && treeData.children.length > 0) {
|
|
500
|
+
for (const childTree of treeData.children) {
|
|
501
|
+
const foundId = searchIdInData(childTree);
|
|
502
|
+
if (foundId) {
|
|
503
|
+
return foundId;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
return null;
|
|
508
|
+
};
|
|
509
|
+
if (element) {
|
|
510
|
+
const foundId = searchIdInData(this.theOptions.data);
|
|
511
|
+
if (foundId)
|
|
512
|
+
defaultFromFullpaths.push(foundId);
|
|
513
|
+
}
|
|
514
|
+
break;
|
|
515
|
+
case 'webservice':
|
|
516
|
+
const valtopush = await this.rawDataManager.fetchNodeIdFromFullpath(element, this.optionsManager.getOptions()).catch(err => { this.displayPickerError(err); });
|
|
517
|
+
if (valtopush) {
|
|
518
|
+
defaultFromFullpaths.push(valtopush);
|
|
519
|
+
}
|
|
520
|
+
break;
|
|
521
|
+
}
|
|
522
|
+
if (errormsg.length > 0) {
|
|
338
523
|
this.displayPickerError(errormsg);
|
|
339
524
|
this.errorToLog = errormsg;
|
|
340
525
|
autoAssignReach = false;
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
else {
|
|
344
|
-
if (!defaultFromFullpaths) {
|
|
345
|
-
defaultFromFullpaths = [];
|
|
346
|
-
}
|
|
347
|
-
const valtopush = await this.rawDataManager.fetchNodeIdFromFullpath(element, this.optionsManager.getOptions()).catch(err => { this.displayPickerError(err); });
|
|
348
|
-
if (valtopush) {
|
|
349
|
-
defaultFromFullpaths.push(valtopush);
|
|
350
|
-
}
|
|
351
526
|
}
|
|
352
527
|
}
|
|
353
528
|
}));
|
|
@@ -355,7 +530,7 @@ export class HierarchizedPickerComponent {
|
|
|
355
530
|
this.optionsManager.getOptions().defaultValue = defaultFromFullpaths;
|
|
356
531
|
}
|
|
357
532
|
if (this.optionsManager.getOptions().options) {
|
|
358
|
-
if (
|
|
533
|
+
if (this.optionsManager.getOptions().defaultValue.length > 0) {
|
|
359
534
|
if (autoAssignReach) {
|
|
360
535
|
this.optionsManager.getOptions().options.Reach = this.optionsManager.getOptions().defaultValue.map(element => {
|
|
361
536
|
return Number(element);
|
|
@@ -385,10 +560,16 @@ export class HierarchizedPickerComponent {
|
|
|
385
560
|
this.mylog('----- HIERARCHIZED-PICKER DEBUG MODE ON -----');
|
|
386
561
|
}
|
|
387
562
|
// Setup component unique ID
|
|
388
|
-
if (this.optionsManager.getOptions().id)
|
|
563
|
+
if (this.optionsManager.getOptions().id) {
|
|
389
564
|
this.componentID = this.optionsManager.getOptions().id;
|
|
390
|
-
|
|
391
|
-
|
|
565
|
+
}
|
|
566
|
+
else if (!this.componentID) {
|
|
567
|
+
let componentID = (Array.from(document.querySelectorAll('reneco-hierarchized-picker')).indexOf(this.el) + 1);
|
|
568
|
+
while (document.querySelectorAll(`#hierarchized-picker-${componentID}`).length > 0) {
|
|
569
|
+
componentID++;
|
|
570
|
+
}
|
|
571
|
+
this.componentID = componentID.toString();
|
|
572
|
+
}
|
|
392
573
|
if (!this.optionsManager.getOptions())
|
|
393
574
|
return;
|
|
394
575
|
this.optionsManager.updateDefaultValue();
|
|
@@ -456,7 +637,7 @@ export class HierarchizedPickerComponent {
|
|
|
456
637
|
this.ignoreOptionsChanges = false;
|
|
457
638
|
}
|
|
458
639
|
catch (_b) {
|
|
459
|
-
|
|
640
|
+
this.errorToLog = 'Error loading webservice data!';
|
|
460
641
|
}
|
|
461
642
|
}
|
|
462
643
|
displayPickerError(errorMsg = '') {
|
|
@@ -468,11 +649,11 @@ export class HierarchizedPickerComponent {
|
|
|
468
649
|
}
|
|
469
650
|
this.displayedValue = errorMsg;
|
|
470
651
|
this.isDisabled = true;
|
|
471
|
-
|
|
652
|
+
this.errorToLog = errorMsg;
|
|
472
653
|
}
|
|
473
654
|
}
|
|
474
655
|
catch (_a) {
|
|
475
|
-
|
|
656
|
+
this.errorToLog = errorMsg;
|
|
476
657
|
}
|
|
477
658
|
}
|
|
478
659
|
getApiSearchURL() {
|
|
@@ -492,17 +673,17 @@ export class HierarchizedPickerComponent {
|
|
|
492
673
|
}
|
|
493
674
|
}
|
|
494
675
|
// TODO > Celine would rather like the context (thesaurus or position) to be extracted another way
|
|
495
|
-
getContextualApiURL(init = false) {
|
|
496
|
-
const { options, url } = this.optionsManager.getOptions();
|
|
676
|
+
getContextualApiURL(init = false, forcedOptions = null) {
|
|
677
|
+
const { options, url } = forcedOptions || this.optionsManager.getOptions();
|
|
497
678
|
if (init && options.Reach) {
|
|
498
|
-
|
|
499
|
-
const base = window.location.origin; // fallback for relative URLs
|
|
679
|
+
const base = window.location.origin;
|
|
500
680
|
const parsedUrl = new URL(url, base);
|
|
501
|
-
const pathSegments = parsedUrl.pathname.split('/');
|
|
502
|
-
|
|
503
|
-
if (
|
|
504
|
-
|
|
505
|
-
|
|
681
|
+
const pathSegments = parsedUrl.pathname.split('/').filter(Boolean);
|
|
682
|
+
const idx = pathSegments.indexOf("getTree");
|
|
683
|
+
if (idx !== -1) {
|
|
684
|
+
pathSegments[idx] = "reach";
|
|
685
|
+
}
|
|
686
|
+
const newPathname = "/" + pathSegments.join("/");
|
|
506
687
|
return `${parsedUrl.origin}${newPathname}`;
|
|
507
688
|
}
|
|
508
689
|
return url;
|
|
@@ -541,12 +722,10 @@ export class HierarchizedPickerComponent {
|
|
|
541
722
|
}
|
|
542
723
|
}
|
|
543
724
|
loadSearchDataInCurrentTree(searchID, searched) {
|
|
544
|
-
|
|
545
|
-
if (this.searchToDisplay > -1) {
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
completeCurrentTreeWithTree(this.loadedTreeJs, value, this.optionsManager.getOptions());
|
|
549
|
-
});
|
|
725
|
+
const displayResults = () => {
|
|
726
|
+
if (this.searchToDisplay > -1) {
|
|
727
|
+
if (!searched)
|
|
728
|
+
this.setSearchResults([]);
|
|
550
729
|
this.triggerTreeDisplay(this.rawDataManager.getData(), searched);
|
|
551
730
|
displayAutocompleteWithResults(this.rawDataManager.getData(), searched, this.optionsManager, this.editValue.bind(this), this.showTree.bind(this));
|
|
552
731
|
// Deploys all nodes
|
|
@@ -562,18 +741,24 @@ export class HierarchizedPickerComponent {
|
|
|
562
741
|
});
|
|
563
742
|
}
|
|
564
743
|
};
|
|
744
|
+
const completeLocalTree = (newtree) => {
|
|
745
|
+
if (this.searchToDisplay > -1) { // TODO > Not working anymore after refact, prevents issues in displaying results when running multiple researchs at the same time && searchID == this.searchToDisplay) {
|
|
746
|
+
this.rawDataManager.mergeData(newtree, this.theOptions.origin == 'classification' ? "ID" : "key");
|
|
747
|
+
newtree.children.forEach((value, index) => {
|
|
748
|
+
completeCurrentTreeWithTree(this.loadedTreeJs, value, this.optionsManager.getOptions());
|
|
749
|
+
});
|
|
750
|
+
displayResults();
|
|
751
|
+
}
|
|
752
|
+
};
|
|
565
753
|
if (this.theOptions.source == 'webservice') {
|
|
566
754
|
if (this.theOptions.origin == 'classification') {
|
|
567
755
|
// WS Call
|
|
568
756
|
this.rawDataManager.getFromClassification(this.getApiSearchURL(), Object.assign({}, this.getContextualApiParams(null, searched)), document.querySelector("#hierarchized-picker-" + this.componentID + " .loader"))
|
|
569
757
|
.then((data) => {
|
|
570
|
-
|
|
571
|
-
if (!searched) {
|
|
572
|
-
this.setSearchResults([]);
|
|
573
|
-
}
|
|
758
|
+
completeLocalTree(data);
|
|
574
759
|
})
|
|
575
760
|
.catch(err => {
|
|
576
|
-
|
|
761
|
+
this.errorToLog = err;
|
|
577
762
|
});
|
|
578
763
|
}
|
|
579
764
|
else {
|
|
@@ -586,35 +771,26 @@ export class HierarchizedPickerComponent {
|
|
|
586
771
|
deprecated: false,
|
|
587
772
|
}, document.querySelector("#hierarchized-picker-" + this.componentID + " .loader"))
|
|
588
773
|
.then((data) => {
|
|
589
|
-
|
|
590
|
-
if (!searched) {
|
|
591
|
-
this.setSearchResults([]);
|
|
592
|
-
}
|
|
774
|
+
completeLocalTree(data);
|
|
593
775
|
})
|
|
594
776
|
.catch(error => {
|
|
595
|
-
|
|
777
|
+
this.errorToLog = error;
|
|
596
778
|
try {
|
|
597
779
|
this.errorToLog = 'getDataFromSource 1 rejected:' + JSON.stringify(error, replacer, 2);
|
|
598
780
|
}
|
|
599
781
|
catch (_a) {
|
|
600
|
-
|
|
782
|
+
this.errorToLog = JSON.stringify(error, replacer, 2);
|
|
601
783
|
}
|
|
602
784
|
});
|
|
603
785
|
}
|
|
604
786
|
}
|
|
605
787
|
else {
|
|
606
|
-
if (this.
|
|
607
|
-
|
|
608
|
-
completeCurrentTreeWithTree(this.loadedTreeJs, value, this.optionsManager.getOptions());
|
|
609
|
-
});
|
|
610
|
-
displayAutocompleteWithResults(this.rawDataManager.getData(), searched, this.optionsManager, this.editValue.bind(this), this.showTree.bind(this));
|
|
788
|
+
if (this.optionsManager.getOptions().source == 'data') {
|
|
789
|
+
displayResults();
|
|
611
790
|
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
if (searched) {
|
|
615
|
-
this.setSearchResults(treeToDisplay);
|
|
791
|
+
else {
|
|
792
|
+
console.error("Unhandled picker settings for search scenario !!");
|
|
616
793
|
}
|
|
617
|
-
this.displayTree(treeToDisplay);
|
|
618
794
|
}
|
|
619
795
|
}
|
|
620
796
|
async triggerTreeDisplay(dataToLoad, searched) {
|
|
@@ -696,11 +872,31 @@ export class HierarchizedPickerComponent {
|
|
|
696
872
|
this.showSelectedNodes();
|
|
697
873
|
this.deactivateNodesOutOfDepthSettings();
|
|
698
874
|
// Hides checkboxes in non multiple context
|
|
699
|
-
|
|
700
|
-
document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-checkbox').forEach((item) => (item.style.display = 'none'));
|
|
701
|
-
}
|
|
875
|
+
document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-checkbox').forEach((item) => (item.style.display = (this.theOptions.multiple ? 'inline-block' : 'none')));
|
|
702
876
|
}
|
|
703
877
|
onItemContextMenuItemClick(e) {
|
|
878
|
+
if (e.target && e.target.id) {
|
|
879
|
+
function getDirectParentAndDepth(nodesById, targetId) {
|
|
880
|
+
// Find the direct parent
|
|
881
|
+
const parent = Object.values(nodesById).find(node => { var _a; return (_a = node.children) === null || _a === void 0 ? void 0 : _a.some(child => child.id === targetId); }) || null;
|
|
882
|
+
if (!nodesById[targetId])
|
|
883
|
+
return null; // target not found
|
|
884
|
+
// Depth is 0 for root nodes, 1 for children of root, etc.
|
|
885
|
+
let depth = 0;
|
|
886
|
+
let current = targetId;
|
|
887
|
+
while (true) {
|
|
888
|
+
const directParent = Object.values(nodesById).find(node => { var _a; return (_a = node.children) === null || _a === void 0 ? void 0 : _a.some(child => child.id === current); });
|
|
889
|
+
if (!directParent)
|
|
890
|
+
break;
|
|
891
|
+
depth++;
|
|
892
|
+
current = directParent.id;
|
|
893
|
+
}
|
|
894
|
+
return { parent, depth };
|
|
895
|
+
}
|
|
896
|
+
const result = getDirectParentAndDepth(this.loadedTreeJs.nodesById, e.target.id);
|
|
897
|
+
e.target.depth = result.depth;
|
|
898
|
+
e.target.parentId = result.parent.id;
|
|
899
|
+
}
|
|
704
900
|
this.itemContextMenuItemClick.emit(e);
|
|
705
901
|
}
|
|
706
902
|
setNodeAsSelected(id, treeToUpdate, userClick) {
|
|
@@ -709,8 +905,10 @@ export class HierarchizedPickerComponent {
|
|
|
709
905
|
(this.loadedTreeJs.liElementsById[id] && this.loadedTreeJs.liElementsById[id].classList.value && this.loadedTreeJs.liElementsById[id].classList.value.indexOf('readonly_node') != -1)) {
|
|
710
906
|
return;
|
|
711
907
|
}
|
|
712
|
-
if (treeToUpdate.getValues().indexOf(id.toString()) != -1)
|
|
908
|
+
if (!userClick && treeToUpdate.getValues().indexOf(id.toString()) != -1)
|
|
713
909
|
return;
|
|
910
|
+
if (this.loadedTreeJs && !this.theOptions.multiple)
|
|
911
|
+
this.loadedTreeJs.emptyNodesCheckStatus();
|
|
714
912
|
this.ignoreOptionsChanges = true;
|
|
715
913
|
// Override of treejs normal workaround =>> DONT EDIT IT!
|
|
716
914
|
// ----- BEGIN -----
|
|
@@ -747,46 +945,29 @@ export class HierarchizedPickerComponent {
|
|
|
747
945
|
* This method display the current selected node to the user by expanding all it's parent nodes and scrolling inside the tree
|
|
748
946
|
*/
|
|
749
947
|
async showSelectedNodes(addDelay = false) {
|
|
750
|
-
if (this.optionsManager.getOptions().multiple) {
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
}
|
|
754
|
-
const scrollToNode = () => {
|
|
755
|
-
let scrollToValue = 0;
|
|
756
|
-
let removeClosedAndLookUp = (element) => {
|
|
757
|
-
var _a, _b, _c, _d;
|
|
758
|
-
const nodeId = element === null || element === void 0 ? void 0 : element.nodeId;
|
|
759
|
-
if (!element || !nodeId) {
|
|
760
|
-
return;
|
|
761
|
-
}
|
|
762
|
-
const node = this.loadedTreeJs.nodesById[nodeId];
|
|
763
|
-
if ((_b = (_a = node === null || node === void 0 ? void 0 : node.children) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.id) {
|
|
764
|
-
(_c = element.classList) === null || _c === void 0 ? void 0 : _c.remove('treejs-node__close');
|
|
765
|
-
}
|
|
766
|
-
scrollToValue += element.offsetTop;
|
|
767
|
-
const parent = (_d = element.parentNode) === null || _d === void 0 ? void 0 : _d.closest('.treejs-node');
|
|
768
|
-
if (parent) {
|
|
769
|
-
removeClosedAndLookUp(parent);
|
|
770
|
-
}
|
|
771
|
-
};
|
|
772
|
-
try {
|
|
773
|
-
const checkeds = document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-node__checked');
|
|
774
|
-
checkeds.forEach((item) => removeClosedAndLookUp(item));
|
|
775
|
-
}
|
|
776
|
-
catch (err) {
|
|
777
|
-
// console.error("Error in showSelectedNodes", err);
|
|
778
|
-
}
|
|
779
|
-
if (scrollToValue && this.scrollable) {
|
|
780
|
-
this.scrollable.scrollTop = scrollToValue;
|
|
781
|
-
}
|
|
782
|
-
};
|
|
948
|
+
// if (this.optionsManager.getOptions().multiple) {
|
|
949
|
+
// console.warn('You are not allowed to scroll to selected nodes in multiple mode');
|
|
950
|
+
// return;
|
|
951
|
+
// }
|
|
783
952
|
if (addDelay) {
|
|
784
953
|
setTimeout(() => {
|
|
785
|
-
scrollToNode();
|
|
954
|
+
this.scrollToNode();
|
|
786
955
|
}, 200);
|
|
787
956
|
}
|
|
788
957
|
else {
|
|
789
|
-
scrollToNode();
|
|
958
|
+
this.scrollToNode();
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
async scrollToNodeWithId(targetNodeId, displayChildren = false) {
|
|
962
|
+
const targetNode = this.loadedTreeJs.liElementsById[targetNodeId];
|
|
963
|
+
if (!targetNode) {
|
|
964
|
+
const contextualApiParams = this.getContextualApiParams(Object.assign(Object.assign({}, this.theOptions.options), { Reach: [targetNodeId] }), null, true);
|
|
965
|
+
const contextualApiURL = this.getContextualApiURL(true, Object.assign(Object.assign({}, this.theOptions), { options: contextualApiParams }));
|
|
966
|
+
this.rawDataManager.getFromClassification(contextualApiURL, contextualApiParams, document.querySelector("#hierarchized-picker-" + this.componentID + " .loader"))
|
|
967
|
+
.then(data => {
|
|
968
|
+
completeCurrentTreeWithTree(this.loadedTreeJs, data, this.theOptions);
|
|
969
|
+
this.scrollToNode(targetNodeId, displayChildren);
|
|
970
|
+
});
|
|
790
971
|
}
|
|
791
972
|
}
|
|
792
973
|
showTree(focused) {
|
|
@@ -795,10 +976,10 @@ export class HierarchizedPickerComponent {
|
|
|
795
976
|
clearAutocomplete();
|
|
796
977
|
if (!this.canload || !this.optionsManager.getOptions().displayTree)
|
|
797
978
|
return;
|
|
798
|
-
const isStillInsidePicker = isInsidePicker(this, document.activeElement);
|
|
979
|
+
const isStillInsidePicker = false; // TODO put back? >> isInsidePicker(this, document.activeElement);
|
|
799
980
|
if ((focused === 'hide' || this.isDisabled) && !isStillInsidePicker) {
|
|
800
981
|
this.hasFocus = ['hide'];
|
|
801
|
-
const elem = document.querySelector('#hierarchized-picker-' + this.componentID + ' .hierarchized-picker-search
|
|
982
|
+
const elem = document.querySelector('#hierarchized-picker-' + this.componentID + ' input.hierarchized-picker-search');
|
|
802
983
|
if (elem) {
|
|
803
984
|
elem.value = '';
|
|
804
985
|
}
|
|
@@ -819,16 +1000,16 @@ export class HierarchizedPickerComponent {
|
|
|
819
1000
|
}
|
|
820
1001
|
const previousShownTree = this.shownTree;
|
|
821
1002
|
this.shownTree = this.hasFocus.length > 0;
|
|
822
|
-
if (this.shownTree && !previousShownTree) {
|
|
823
|
-
console.log("component value", document.querySelector('#hierarchized-picker-input-' + this.componentID));
|
|
824
|
-
console.log("shouldOpenModalAbove", this.shouldOpenModalAbove(document.querySelector('#hierarchized-picker-input-' + this.componentID), this.modaleHeight));
|
|
1003
|
+
if (this.shownTree && !previousShownTree && this.optionsManager.getOptions().mode == 'input') {
|
|
825
1004
|
if (this.shouldOpenModalAbove(document.querySelector('#hierarchized-picker-input-' + this.componentID), this.modaleHeight)) {
|
|
826
1005
|
this.modalePosition = 'top';
|
|
827
1006
|
}
|
|
828
1007
|
else {
|
|
829
1008
|
this.modalePosition = 'bottom';
|
|
830
1009
|
}
|
|
831
|
-
focusSearchInput(this);
|
|
1010
|
+
setTimeout(() => focusSearchInput(this), 100);
|
|
1011
|
+
//TODO, this this at the good location ?
|
|
1012
|
+
setupKeyboardNavigation(this, this.optionsManager, this.navigateInTree);
|
|
832
1013
|
}
|
|
833
1014
|
}
|
|
834
1015
|
// Changes the value of the component with passed node
|
|
@@ -841,9 +1022,12 @@ export class HierarchizedPickerComponent {
|
|
|
841
1022
|
return item.nodeid == node.id;
|
|
842
1023
|
});
|
|
843
1024
|
// If the passed node already exists in the array of values, remove it
|
|
844
|
-
if (
|
|
845
|
-
|
|
846
|
-
|
|
1025
|
+
if (result > -1) {
|
|
1026
|
+
if (userClick)
|
|
1027
|
+
this.value.splice(result, 1);
|
|
1028
|
+
else
|
|
1029
|
+
return;
|
|
1030
|
+
}
|
|
847
1031
|
else {
|
|
848
1032
|
if (this.optionsManager.getOptions().multiple) {
|
|
849
1033
|
this.value = [
|
|
@@ -869,13 +1053,23 @@ export class HierarchizedPickerComponent {
|
|
|
869
1053
|
}
|
|
870
1054
|
this.setDisplayedValue(this.value);
|
|
871
1055
|
}
|
|
1056
|
+
getShortpathFromFullpath(fullpath) {
|
|
1057
|
+
if (!fullpath || fullpath.indexOf('>') == -1)
|
|
1058
|
+
return fullpath;
|
|
1059
|
+
return fullpath.substring(fullpath.lastIndexOf(">") + 1);
|
|
1060
|
+
}
|
|
872
1061
|
setDisplayedValue(value = null) {
|
|
873
1062
|
if (!value)
|
|
874
1063
|
value = this.value;
|
|
875
|
-
|
|
876
|
-
var _a, _b;
|
|
877
|
-
return (
|
|
1064
|
+
const toDisplay = value.map(item => {
|
|
1065
|
+
var _a, _b, _c;
|
|
1066
|
+
return (this.optionsManager.getOptions().source == 'data'
|
|
1067
|
+
?
|
|
1068
|
+
(_a = (this.optionsManager.getOptions().language == 'fr' ? this.getShortpathFromFullpath(item.fullpathTranslated) : this.getShortpathFromFullpath(item.fullpath))) !== null && _a !== void 0 ? _a : `Node ${item.nodeid}`
|
|
1069
|
+
:
|
|
1070
|
+
(_c = (this.optionsManager.getOptions().isFullpath ? this.getShortenedFullpath((_b = item.fullpathTranslated) !== null && _b !== void 0 ? _b : item.fullpath) : item.shortpathTranslated)) !== null && _c !== void 0 ? _c : `Node ${item.nodeid}`);
|
|
878
1071
|
}).join(';');
|
|
1072
|
+
this.displayedValue = toDisplay;
|
|
879
1073
|
}
|
|
880
1074
|
// Search a value in the tree and triggers a search when necessary
|
|
881
1075
|
search(searched) {
|
|
@@ -942,10 +1136,11 @@ export class HierarchizedPickerComponent {
|
|
|
942
1136
|
if (init) {
|
|
943
1137
|
this.formatDefaultValue();
|
|
944
1138
|
this.showSelectedNodes();
|
|
1139
|
+
this.checkFields(this.value);
|
|
945
1140
|
}
|
|
946
1141
|
})
|
|
947
1142
|
.catch(error => {
|
|
948
|
-
|
|
1143
|
+
this.errorToLog = error;
|
|
949
1144
|
});
|
|
950
1145
|
}
|
|
951
1146
|
else {
|
|
@@ -958,7 +1153,7 @@ export class HierarchizedPickerComponent {
|
|
|
958
1153
|
}
|
|
959
1154
|
})
|
|
960
1155
|
.catch(error => {
|
|
961
|
-
|
|
1156
|
+
this.errorToLog = error;
|
|
962
1157
|
});
|
|
963
1158
|
}
|
|
964
1159
|
}
|
|
@@ -979,7 +1174,7 @@ export class HierarchizedPickerComponent {
|
|
|
979
1174
|
let enrichedValues = [];
|
|
980
1175
|
if (values) {
|
|
981
1176
|
values.forEach(element => {
|
|
982
|
-
var _a, _b;
|
|
1177
|
+
var _a, _b, _c;
|
|
983
1178
|
let intNodeid = element.nodeid || element.ID || element.key || undefined;
|
|
984
1179
|
if (typeof intNodeid === 'string' && isNumeric(intNodeid)) {
|
|
985
1180
|
intNodeid = parseInt(intNodeid);
|
|
@@ -989,15 +1184,15 @@ export class HierarchizedPickerComponent {
|
|
|
989
1184
|
enrichedValues.push({
|
|
990
1185
|
nodeid: intNodeid,
|
|
991
1186
|
shortpathTranslated: (_a = treeNode.text) !== null && _a !== void 0 ? _a : `Node ${intNodeid}`,
|
|
992
|
-
fullpathTranslated: (_b = treeNode.
|
|
1187
|
+
fullpathTranslated: (_b = treeNode.fullpathTranslated) !== null && _b !== void 0 ? _b : null,
|
|
1188
|
+
fullpath: (_c = treeNode.fullpath) !== null && _c !== void 0 ? _c : null,
|
|
993
1189
|
hasChildren: treeNode.children && treeNode.children.length > 0
|
|
994
1190
|
});
|
|
995
|
-
this.setNodeAsSelected(intNodeid, this.loadedTreeJs, false);
|
|
996
1191
|
}
|
|
997
1192
|
else {
|
|
998
|
-
this.setNodeAsSelected(intNodeid, this.loadedTreeJs, false);
|
|
999
1193
|
console.warn("Node not found in Tree for:", intNodeid);
|
|
1000
1194
|
}
|
|
1195
|
+
this.setNodeAsSelected(intNodeid, this.loadedTreeJs, false);
|
|
1001
1196
|
});
|
|
1002
1197
|
}
|
|
1003
1198
|
this.setDisplayedValue(enrichedValues);
|
|
@@ -1007,8 +1202,19 @@ export class HierarchizedPickerComponent {
|
|
|
1007
1202
|
formatDefaultValue() {
|
|
1008
1203
|
let found = 0;
|
|
1009
1204
|
let that = this;
|
|
1205
|
+
let fieldsToCheck = [];
|
|
1206
|
+
function addToFieldsToCheck(item) {
|
|
1207
|
+
if (Array.isArray(item)) {
|
|
1208
|
+
item.forEach(el => addToFieldsToCheck(el));
|
|
1209
|
+
}
|
|
1210
|
+
else {
|
|
1211
|
+
const exists = fieldsToCheck.some(el => (el.nodeid || el.ID) == (item.nodeid || item.ID));
|
|
1212
|
+
if (!exists) {
|
|
1213
|
+
fieldsToCheck.push(item);
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1010
1217
|
let recursive = function (children) {
|
|
1011
|
-
//158424
|
|
1012
1218
|
children.forEach(element => {
|
|
1013
1219
|
that.theOptions.defaultValue.forEach(dfValue => {
|
|
1014
1220
|
if (typeof dfValue == 'string' && isNumeric(dfValue)) {
|
|
@@ -1018,7 +1224,7 @@ export class HierarchizedPickerComponent {
|
|
|
1018
1224
|
if ((typeof dfValue == 'string' && getPropertyFromNode(element, 'Properties').FullPath == dfValue) ||
|
|
1019
1225
|
(typeof dfValue == 'number' && getPropertyFromNode(element, 'ID') == dfValue)) {
|
|
1020
1226
|
element.nodeid = element.id;
|
|
1021
|
-
|
|
1227
|
+
addToFieldsToCheck([element]);
|
|
1022
1228
|
found++;
|
|
1023
1229
|
}
|
|
1024
1230
|
}
|
|
@@ -1028,7 +1234,7 @@ export class HierarchizedPickerComponent {
|
|
|
1028
1234
|
(typeof dfValue == 'string' && getPropertyFromNode(element, 'fullpathTranslated') == dfValue) ||
|
|
1029
1235
|
(typeof dfValue == 'number' && getPropertyFromNode(element, 'key') == dfValue)) {
|
|
1030
1236
|
element.nodeid = element.key;
|
|
1031
|
-
|
|
1237
|
+
addToFieldsToCheck([element]);
|
|
1032
1238
|
found++;
|
|
1033
1239
|
}
|
|
1034
1240
|
}
|
|
@@ -1040,6 +1246,7 @@ export class HierarchizedPickerComponent {
|
|
|
1040
1246
|
if (this.rawDataManager.getData()) {
|
|
1041
1247
|
recursive([this.rawDataManager.getData()]);
|
|
1042
1248
|
}
|
|
1249
|
+
that.checkFields(fieldsToCheck);
|
|
1043
1250
|
if (this.theOptions.defaultValue.length != found) {
|
|
1044
1251
|
if (found == 0) {
|
|
1045
1252
|
try {
|
|
@@ -1065,6 +1272,8 @@ export class HierarchizedPickerComponent {
|
|
|
1065
1272
|
.join('; ');
|
|
1066
1273
|
}
|
|
1067
1274
|
shouldOpenModalAbove(inputElement, modaleHeight) {
|
|
1275
|
+
if (this.optionsManager.getOptions().mode != 'input')
|
|
1276
|
+
return false;
|
|
1068
1277
|
const inputRect = inputElement.getBoundingClientRect();
|
|
1069
1278
|
const spaceLeft = window.innerHeight - inputRect.y;
|
|
1070
1279
|
return spaceLeft < modaleHeight;
|
|
@@ -1088,7 +1297,7 @@ export class HierarchizedPickerComponent {
|
|
|
1088
1297
|
clickPickerModalArea(this, event);
|
|
1089
1298
|
} }, h("div", { class: "loader", ref: el => {
|
|
1090
1299
|
this.loader = el;
|
|
1091
|
-
} }, h("div", { class: "loader-inner" }, "Loading...")), h("div", { class: `hierarchized-picker-modal ${!this.ready ? 'hidden' : ''}
|
|
1300
|
+
} }, h("div", { class: "loader-inner" }, "Loading...")), h("div", { class: `hierarchized-picker-modal ${!this.ready ? 'hidden' : ''}`, tabindex: "0" }, h("search-input", { placeholder: getLanguageValue(this.optionsManager.getOptions().searchPlaceholder, this.optionsManager.getOptions().language, defaultLanguage), onInputFocus: () => focusInSearchEvent(this), onInputBlur: () => focusOutSearchEvent(this, event), onSearch: (event) => this.search(event.detail) }), h("ul", { id: "autocomplete-results-area" }), h("div", { id: 'tree-area-' + this.componentID, class: 'hierarchized-picker-tree hierarchized-picker-tree-area ' + this.pickerClass }))))) : (h("div", { class: 'hierarchized-picker-raw-tree-area' + (this.isDisabled ? ' readonly' : ''), tabindex: "0", onClick: event => {
|
|
1092
1301
|
clickPickerModalArea(this, event);
|
|
1093
1302
|
} }, h("div", { class: "loader", ref: el => {
|
|
1094
1303
|
this.loader = el;
|
|
@@ -1311,6 +1520,21 @@ export class HierarchizedPickerComponent {
|
|
|
1311
1520
|
"resolved": "any",
|
|
1312
1521
|
"references": {}
|
|
1313
1522
|
}
|
|
1523
|
+
}, {
|
|
1524
|
+
"method": "errorRaised",
|
|
1525
|
+
"name": "errorRaised",
|
|
1526
|
+
"bubbles": true,
|
|
1527
|
+
"cancelable": true,
|
|
1528
|
+
"composed": true,
|
|
1529
|
+
"docs": {
|
|
1530
|
+
"tags": [],
|
|
1531
|
+
"text": "This event is emitted when the picker suffers an error"
|
|
1532
|
+
},
|
|
1533
|
+
"complexType": {
|
|
1534
|
+
"original": "any",
|
|
1535
|
+
"resolved": "any",
|
|
1536
|
+
"references": {}
|
|
1537
|
+
}
|
|
1314
1538
|
}];
|
|
1315
1539
|
}
|
|
1316
1540
|
static get methods() {
|
|
@@ -1408,6 +1632,22 @@ export class HierarchizedPickerComponent {
|
|
|
1408
1632
|
"tags": []
|
|
1409
1633
|
}
|
|
1410
1634
|
},
|
|
1635
|
+
"getError": {
|
|
1636
|
+
"complexType": {
|
|
1637
|
+
"signature": "() => Promise<string>",
|
|
1638
|
+
"parameters": [],
|
|
1639
|
+
"references": {
|
|
1640
|
+
"Promise": {
|
|
1641
|
+
"location": "global"
|
|
1642
|
+
}
|
|
1643
|
+
},
|
|
1644
|
+
"return": "Promise<string>"
|
|
1645
|
+
},
|
|
1646
|
+
"docs": {
|
|
1647
|
+
"text": "",
|
|
1648
|
+
"tags": []
|
|
1649
|
+
}
|
|
1650
|
+
},
|
|
1411
1651
|
"clearPicker": {
|
|
1412
1652
|
"complexType": {
|
|
1413
1653
|
"signature": "() => Promise<void>",
|
|
@@ -1434,9 +1674,6 @@ export class HierarchizedPickerComponent {
|
|
|
1434
1674
|
"references": {
|
|
1435
1675
|
"Promise": {
|
|
1436
1676
|
"location": "global"
|
|
1437
|
-
},
|
|
1438
|
-
"HTMLElement": {
|
|
1439
|
-
"location": "global"
|
|
1440
1677
|
}
|
|
1441
1678
|
},
|
|
1442
1679
|
"return": "Promise<void>"
|
|
@@ -1445,6 +1682,28 @@ export class HierarchizedPickerComponent {
|
|
|
1445
1682
|
"text": "This method display the current selected node to the user by expanding all it's parent nodes and scrolling inside the tree",
|
|
1446
1683
|
"tags": []
|
|
1447
1684
|
}
|
|
1685
|
+
},
|
|
1686
|
+
"scrollToNodeWithId": {
|
|
1687
|
+
"complexType": {
|
|
1688
|
+
"signature": "(targetNodeId: any, displayChildren?: boolean) => Promise<void>",
|
|
1689
|
+
"parameters": [{
|
|
1690
|
+
"tags": [],
|
|
1691
|
+
"text": ""
|
|
1692
|
+
}, {
|
|
1693
|
+
"tags": [],
|
|
1694
|
+
"text": ""
|
|
1695
|
+
}],
|
|
1696
|
+
"references": {
|
|
1697
|
+
"Promise": {
|
|
1698
|
+
"location": "global"
|
|
1699
|
+
}
|
|
1700
|
+
},
|
|
1701
|
+
"return": "Promise<void>"
|
|
1702
|
+
},
|
|
1703
|
+
"docs": {
|
|
1704
|
+
"text": "",
|
|
1705
|
+
"tags": []
|
|
1706
|
+
}
|
|
1448
1707
|
}
|
|
1449
1708
|
};
|
|
1450
1709
|
}
|