reneco-hierarchized-picker 0.4.2-beta.9 → 0.4.3-beta.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 +162 -64
- package/dist/collection/components/hierarchized-picker/hierarchized-picker.js +117 -29
- package/dist/collection/components/treejs/index.js +19 -15
- package/dist/collection/core/options-manager.js +6 -0
- package/dist/collection/core/raw-data-manager.js +14 -4
- package/dist/collection/features/tree/drag-drop.js +15 -5
- package/dist/collection/features/tree/tree-utils.js +10 -11
- package/dist/collection/utils/conf-helper.js +0 -1
- package/dist/custom-elements/index.js +163 -65
- 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 +162 -64
- 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 +1 -1
- package/dist/reneco-hierarchized-picker/p-0b13f57d.entry.js +1 -0
- package/dist/reneco-hierarchized-picker/p-4b05e2f5.system.entry.js +3 -0
- package/dist/reneco-hierarchized-picker/p-73168a50.system.js +1 -1
- package/dist/reneco-hierarchized-picker/reneco-hierarchized-picker.esm.js +1 -1
- package/dist/types/components/hierarchized-picker/hierarchized-picker.d.ts +3 -0
- package/dist/types/components.d.ts +2 -0
- package/dist/types/core/options-manager.d.ts +1 -0
- package/dist/types/core/raw-data-manager.d.ts +2 -1
- package/dist/types/features/tree/drag-drop.d.ts +5 -5
- package/package.json +1 -1
- package/dist/reneco-hierarchized-picker/p-3b063318.entry.js +0 -1
- package/dist/reneco-hierarchized-picker/p-f29100a4.system.entry.js +0 -3
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["reneco-hierarchized-picker_2.cjs",[[0,"reneco-hierarchized-picker",{"options":[1],"valueChangeCallback":[16],"disabled":[4],"newoptions":[1],"newfilter":[1],"isDisabled":[32],"componentID":[32],"rawData":[32],"pickerClass":[32],"displayedValue":[32],"value":[32],"shownTree":[32],"searchResultData":[32],"hasFocus":[32],"errorToLog":[32],"getValue":[64],"refreshPicker":[64],"setOptions":[64],"getSearchResult":[64],"filterTree":[64],"clearPicker":[64],"showSelectedNodes":[64]}],[0,"search-input",{"placeholder":[1],"setFocus":[64]}]]]], options);
|
|
17
|
+
return index.bootstrapLazy([["reneco-hierarchized-picker_2.cjs",[[0,"reneco-hierarchized-picker",{"options":[1],"valueChangeCallback":[16],"disabled":[4],"newoptions":[1],"newfilter":[1],"activatedDragAndDrop":[4,"activated-drag-and-drop"],"isDisabled":[32],"componentID":[32],"rawData":[32],"pickerClass":[32],"displayedValue":[32],"value":[32],"shownTree":[32],"searchResultData":[32],"hasFocus":[32],"errorToLog":[32],"getValue":[64],"refreshPicker":[64],"setOptions":[64],"getSearchResult":[64],"filterTree":[64],"clearPicker":[64],"showSelectedNodes":[64]}],[0,"search-input",{"placeholder":[1],"setFocus":[64]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -17,7 +17,7 @@ const patchBrowser = () => {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
patchBrowser().then(options => {
|
|
20
|
-
return index.bootstrapLazy([["reneco-hierarchized-picker_2.cjs",[[0,"reneco-hierarchized-picker",{"options":[1],"valueChangeCallback":[16],"disabled":[4],"newoptions":[1],"newfilter":[1],"isDisabled":[32],"componentID":[32],"rawData":[32],"pickerClass":[32],"displayedValue":[32],"value":[32],"shownTree":[32],"searchResultData":[32],"hasFocus":[32],"errorToLog":[32],"getValue":[64],"refreshPicker":[64],"setOptions":[64],"getSearchResult":[64],"filterTree":[64],"clearPicker":[64],"showSelectedNodes":[64]}],[0,"search-input",{"placeholder":[1],"setFocus":[64]}]]]], options);
|
|
20
|
+
return index.bootstrapLazy([["reneco-hierarchized-picker_2.cjs",[[0,"reneco-hierarchized-picker",{"options":[1],"valueChangeCallback":[16],"disabled":[4],"newoptions":[1],"newfilter":[1],"activatedDragAndDrop":[4,"activated-drag-and-drop"],"isDisabled":[32],"componentID":[32],"rawData":[32],"pickerClass":[32],"displayedValue":[32],"value":[32],"shownTree":[32],"searchResultData":[32],"hasFocus":[32],"errorToLog":[32],"getValue":[64],"refreshPicker":[64],"setOptions":[64],"getSearchResult":[64],"filterTree":[64],"clearPicker":[64],"showSelectedNodes":[64]}],[0,"search-input",{"placeholder":[1],"setFocus":[64]}]]]], options);
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
exports.setNonce = index.setNonce;
|
|
@@ -52,7 +52,9 @@ const acceptableDelayBetweenSimilarActions = 300;
|
|
|
52
52
|
/**
|
|
53
53
|
* Handles the drag start event.
|
|
54
54
|
*/
|
|
55
|
-
function onItemDragStart(el, e) {
|
|
55
|
+
function onItemDragStart(el, e, active = true) {
|
|
56
|
+
if (!active)
|
|
57
|
+
return;
|
|
56
58
|
curDraggingItem = el;
|
|
57
59
|
el.classList.add('dragging');
|
|
58
60
|
e.stopPropagation();
|
|
@@ -60,7 +62,9 @@ function onItemDragStart(el, e) {
|
|
|
60
62
|
/**
|
|
61
63
|
* Handles the drag end event.
|
|
62
64
|
*/
|
|
63
|
-
function onItemDragEnd(el, e) {
|
|
65
|
+
function onItemDragEnd(el, e, active = true) {
|
|
66
|
+
if (!active)
|
|
67
|
+
return;
|
|
64
68
|
el.classList.remove('dragging');
|
|
65
69
|
e.stopPropagation();
|
|
66
70
|
clearDragOverStyles(el.parentElement);
|
|
@@ -68,7 +72,9 @@ function onItemDragEnd(el, e) {
|
|
|
68
72
|
/**
|
|
69
73
|
* Handles the drag over event.
|
|
70
74
|
*/
|
|
71
|
-
function onItemDragOver(el, e) {
|
|
75
|
+
function onItemDragOver(el, e, active = true) {
|
|
76
|
+
if (!active)
|
|
77
|
+
return;
|
|
72
78
|
const now = new Date().getTime();
|
|
73
79
|
if (now - lastDraggedOverTimeForAscendent < 50 && el.dataset.nodeId !== lastDraggedOverNodeId) {
|
|
74
80
|
return;
|
|
@@ -97,7 +103,9 @@ function onItemDragOver(el, e) {
|
|
|
97
103
|
/**
|
|
98
104
|
* Handles the drag leave event.
|
|
99
105
|
*/
|
|
100
|
-
function onItemDragLeave(el, e) {
|
|
106
|
+
function onItemDragLeave(el, e, active = true) {
|
|
107
|
+
if (!active)
|
|
108
|
+
return;
|
|
101
109
|
clearDragOverStyles(el);
|
|
102
110
|
el.classList.remove('dragover');
|
|
103
111
|
e.stopPropagation();
|
|
@@ -105,7 +113,9 @@ function onItemDragLeave(el, e) {
|
|
|
105
113
|
/**
|
|
106
114
|
* Handles the drop event.
|
|
107
115
|
*/
|
|
108
|
-
function onItemDrop(el, e, dropCallback) {
|
|
116
|
+
function onItemDrop(el, e, active = true, dropCallback) {
|
|
117
|
+
if (!active)
|
|
118
|
+
return;
|
|
109
119
|
clearDragOverStyles(el);
|
|
110
120
|
el.classList.remove('dragover');
|
|
111
121
|
e.stopPropagation();
|
|
@@ -290,7 +300,6 @@ Tree.prototype.bindEvent = function (ele) {
|
|
|
290
300
|
: Object.assign(Object.assign({}, item), { callback: async (e) => {
|
|
291
301
|
const pickerValue = await this.options.parentApi.getValue();
|
|
292
302
|
const treeJsNodeInfo = Object.assign({}, this.options.parentApi.loadedTreeJs.nodesById[pickerValue.nodeid]);
|
|
293
|
-
console.log("---- HELLO ", pickerValue, treeJsNodeInfo);
|
|
294
303
|
let targetOutput = Object.assign(Object.assign({}, treeJsNodeInfo), { hasChildren: treeJsNodeInfo.children.length > 0 });
|
|
295
304
|
delete targetOutput.children;
|
|
296
305
|
this.options.parentApi.onItemContextMenuItemClick(Object.assign(Object.assign({}, e), { target: targetOutput, contextMenuItem: item }));
|
|
@@ -303,10 +312,10 @@ Tree.prototype.bindEvent = function (ele) {
|
|
|
303
312
|
return;
|
|
304
313
|
const { target } = e;
|
|
305
314
|
if (target.nodeName === 'SPAN' && (target.classList.contains('treejs-checkbox') || target.classList.contains('treejs-label'))) {
|
|
306
|
-
this.onItemClick(target.parentNode.nodeId);
|
|
315
|
+
this.onItemClick(target.parentNode.nodeId, e.button == 2);
|
|
307
316
|
}
|
|
308
317
|
else if (target.nodeName === 'LI' && target.classList.contains('treejs-node')) {
|
|
309
|
-
this.onItemClick(target.nodeId);
|
|
318
|
+
this.onItemClick(target.nodeId, e.button == 2);
|
|
310
319
|
}
|
|
311
320
|
else if (target.nodeName === 'SPAN' && target.classList.contains('treejs-switcher')) {
|
|
312
321
|
this.onSwitcherClick(target);
|
|
@@ -330,9 +339,11 @@ Tree.prototype.bindEvent = function (ele) {
|
|
|
330
339
|
// If source is webservice (it shouldn't be something else)
|
|
331
340
|
if (this.options.parentApi.theOptions.source == 'webservice') {
|
|
332
341
|
if (this.options.parentApi.theOptions.origin == 'classification') {
|
|
342
|
+
const contextualApiParams = this.options.parentApi.getContextualApiParams(Object.assign(Object.assign({}, this.options.parentApi.theOptions.options), { startNode: target.parentNode.nodeId }));
|
|
343
|
+
const contextualApiURL = this.options.parentApi.getContextualApiURL();
|
|
333
344
|
// WS Call
|
|
334
345
|
this.options.rawDataManager
|
|
335
|
-
.getFromClassification(
|
|
346
|
+
.getFromClassification(contextualApiURL, contextualApiParams, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + " .loader"))
|
|
336
347
|
.then(data => {
|
|
337
348
|
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
338
349
|
});
|
|
@@ -344,7 +355,7 @@ Tree.prototype.bindEvent = function (ele) {
|
|
|
344
355
|
StartNodeID: target.parentNode.nodeId,
|
|
345
356
|
lng: this.options.parentApi.theOptions.options.lng,
|
|
346
357
|
IsDeprecated: this.options.parentApi.theOptions.options.IsDeprecated,
|
|
347
|
-
})
|
|
358
|
+
}, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + " .loader"))
|
|
348
359
|
.then(data => {
|
|
349
360
|
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
350
361
|
});
|
|
@@ -354,13 +365,16 @@ Tree.prototype.bindEvent = function (ele) {
|
|
|
354
365
|
}
|
|
355
366
|
}, false);
|
|
356
367
|
};
|
|
357
|
-
Tree.prototype.onItemClick = function (id) {
|
|
368
|
+
Tree.prototype.onItemClick = async function (id, rightclick = false) {
|
|
358
369
|
// TODO Temporarily ignores disabled mode for selecting nodes if mode is tree
|
|
359
370
|
if (this.options.parentApi.isDisabled && this.options.parentApi.optionsManager.getOptions().mode != "tree")
|
|
360
371
|
return;
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
372
|
+
const pickerValue = await this.options.parentApi.getValue();
|
|
373
|
+
if (!rightclick || !pickerValue || pickerValue.nodeid != id) {
|
|
374
|
+
if (!this.options.parentApi.theOptions.multiple)
|
|
375
|
+
this.emptyNodesCheckStatus();
|
|
376
|
+
this.options.parentApi.setNodeAsSelected(id, this, true);
|
|
377
|
+
}
|
|
364
378
|
};
|
|
365
379
|
Tree.prototype.unCheckElement = function (id) {
|
|
366
380
|
this.setValue(id);
|
|
@@ -634,7 +648,7 @@ Tree.prototype.createUlEle = function () {
|
|
|
634
648
|
Tree.prototype.createLiEle = function (node, closed) {
|
|
635
649
|
const li = document.createElement('li');
|
|
636
650
|
li.classList.add('treejs-node');
|
|
637
|
-
if (node.deprecated) {
|
|
651
|
+
if (node.deprecated || node.Is_Deprecated) {
|
|
638
652
|
li.classList.add('treejs-node__deprecated');
|
|
639
653
|
}
|
|
640
654
|
if (node.isDesaturated) {
|
|
@@ -667,19 +681,19 @@ Tree.prototype.createLiEle = function (node, closed) {
|
|
|
667
681
|
if (this.options.parentApi.theOptions.dragAndDropEnabled) {
|
|
668
682
|
li.setAttribute('draggable', 'true');
|
|
669
683
|
li.addEventListener('dragstart', e => {
|
|
670
|
-
onItemDragStart(li, e);
|
|
684
|
+
onItemDragStart(li, e, this.options.parentApi.activatedDragAndDrop);
|
|
671
685
|
});
|
|
672
686
|
li.addEventListener('dragend', e => {
|
|
673
|
-
onItemDragEnd(li, e);
|
|
687
|
+
onItemDragEnd(li, e, this.options.parentApi.activatedDragAndDrop);
|
|
674
688
|
});
|
|
675
689
|
li.addEventListener('dragover', e => {
|
|
676
|
-
onItemDragOver(li, e);
|
|
690
|
+
onItemDragOver(li, e, this.options.parentApi.activatedDragAndDrop);
|
|
677
691
|
});
|
|
678
692
|
li.addEventListener('dragleave', e => {
|
|
679
|
-
onItemDragLeave(li, e);
|
|
693
|
+
onItemDragLeave(li, e, this.options.parentApi.activatedDragAndDrop);
|
|
680
694
|
});
|
|
681
695
|
li.addEventListener('drop', e => {
|
|
682
|
-
onItemDrop(li, e, (dragEl, dropEl, position) => {
|
|
696
|
+
onItemDrop(li, e, this.options.parentApi.activatedDragAndDrop, (dragEl, dropEl, position) => {
|
|
683
697
|
this.options.parentApi.itemDropped.emit({ dragEl, dropEl, position });
|
|
684
698
|
});
|
|
685
699
|
});
|
|
@@ -17890,7 +17904,6 @@ function isInstanceOfIConf(object) {
|
|
|
17890
17904
|
toret = false;
|
|
17891
17905
|
errorToLog = "options.url value '" + object.url + "' doesn't meet interface IConf requirements, is wrongly formated or doesn't match option.source value";
|
|
17892
17906
|
}
|
|
17893
|
-
//TODO allow Function along with string
|
|
17894
17907
|
if (!((object.source != 'webservice' && !object.token) ||
|
|
17895
17908
|
(object.source == 'webservice' && object.token && (typeof object.token == 'string' || typeof object.token == 'function')))) {
|
|
17896
17909
|
toret = false;
|
|
@@ -18183,7 +18196,7 @@ class RawDataManager {
|
|
|
18183
18196
|
continue;
|
|
18184
18197
|
const value = options[key];
|
|
18185
18198
|
const lowerKey = key.toLowerCase();
|
|
18186
|
-
if ((lowerKey === 'startnode'
|
|
18199
|
+
if ((lowerKey === 'startnode') && !pathSegment) {
|
|
18187
18200
|
pathSegment = encodeURIComponent(value);
|
|
18188
18201
|
continue; // Skip adding this to the query string
|
|
18189
18202
|
}
|
|
@@ -18270,8 +18283,16 @@ class RawDataManager {
|
|
|
18270
18283
|
* Merge new data into the existing data.
|
|
18271
18284
|
* @param newData New data to merge.
|
|
18272
18285
|
*/
|
|
18273
|
-
mergeData(newData) {
|
|
18274
|
-
|
|
18286
|
+
mergeData(newData, idKey) {
|
|
18287
|
+
if (!this.rawData)
|
|
18288
|
+
this.rawData = newData;
|
|
18289
|
+
else {
|
|
18290
|
+
this.rawData = this.genericMerge(this.rawData, newData, idKey, 'children');
|
|
18291
|
+
}
|
|
18292
|
+
}
|
|
18293
|
+
reorderItems(referenceArray, toReorderArray, idKey) {
|
|
18294
|
+
const idMap = new Map(toReorderArray.map(item => [item[idKey], item]));
|
|
18295
|
+
return referenceArray.map(refItem => idMap.get(refItem[idKey])).filter(Boolean);
|
|
18275
18296
|
}
|
|
18276
18297
|
/**
|
|
18277
18298
|
* Generic merge method.
|
|
@@ -18287,9 +18308,11 @@ class RawDataManager {
|
|
|
18287
18308
|
}
|
|
18288
18309
|
if (!toAdd || !((_a = toAdd[childrenKey]) === null || _a === void 0 ? void 0 : _a.length))
|
|
18289
18310
|
return source;
|
|
18311
|
+
if (source[childrenKey] && source[childrenKey].length > 0 && toAdd[childrenKey] && toAdd[childrenKey].length > 0)
|
|
18312
|
+
toAdd[childrenKey] = this.reorderItems(source[childrenKey], toAdd[childrenKey], idKey);
|
|
18290
18313
|
source[childrenKey] = ((_b = source[childrenKey]) === null || _b === void 0 ? void 0 : _b.length)
|
|
18291
18314
|
? source[childrenKey].map((child, index) => {
|
|
18292
|
-
return this.genericMerge(child, toAdd[childrenKey].filter(item => item.key == child.key)[
|
|
18315
|
+
return this.genericMerge(child, toAdd[childrenKey].filter(item => item.key == child.key)[index], idKey, childrenKey);
|
|
18293
18316
|
})
|
|
18294
18317
|
: toAdd[childrenKey];
|
|
18295
18318
|
return source;
|
|
@@ -18359,6 +18382,12 @@ class OptionsManager {
|
|
|
18359
18382
|
delete this.options.defaultValue;
|
|
18360
18383
|
}
|
|
18361
18384
|
}
|
|
18385
|
+
// This method is pretty ugly and shouldn't have to be called, but temporarily works until a better solution is set
|
|
18386
|
+
dropReach() {
|
|
18387
|
+
if (this.options.options && this.options.options.Reach) {
|
|
18388
|
+
delete this.options.options.Reach;
|
|
18389
|
+
}
|
|
18390
|
+
}
|
|
18362
18391
|
}
|
|
18363
18392
|
|
|
18364
18393
|
/**
|
|
@@ -18413,7 +18442,7 @@ function fillTreeWithObject(tree, myObject, searched, options, depth = 0) {
|
|
|
18413
18442
|
const searchResultPresentsUnMatched = options.searchResultPresentsUnMatched;
|
|
18414
18443
|
if (myObject && myObject.length) {
|
|
18415
18444
|
myObject.forEach(value => {
|
|
18416
|
-
var _a, _b, _c, _d
|
|
18445
|
+
var _a, _b, _c, _d;
|
|
18417
18446
|
let keyPropFromNode = null;
|
|
18418
18447
|
let valueTranslatedPropFromNode = null;
|
|
18419
18448
|
let fullpathPropFromNode = null;
|
|
@@ -18421,15 +18450,12 @@ function fillTreeWithObject(tree, myObject, searched, options, depth = 0) {
|
|
|
18421
18450
|
if (options.origin == "classification") {
|
|
18422
18451
|
keyPropFromNode = getPropertyFromNode(value, 'ID');
|
|
18423
18452
|
valueTranslatedPropFromNode = (_a = getPropertyFromNode(value, 'Translations')[options.language]) === null || _a === void 0 ? void 0 : _a.translated_name;
|
|
18424
|
-
|
|
18425
|
-
|
|
18426
|
-
|
|
18427
|
-
|
|
18428
|
-
|
|
18429
|
-
|
|
18430
|
-
fullpathPropFromNode = (_d = getPropertyFromNode(value, 'Properties')) === null || _d === void 0 ? void 0 : _d.System_Fullpath;
|
|
18431
|
-
fullpathTranslatedPropFromNode = (_e = getPropertyFromNode(value, 'Translations')[options.language]) === null || _e === void 0 ? void 0 : _e.translated_fullpath;
|
|
18432
|
-
}
|
|
18453
|
+
fullpathPropFromNode = (_b = getPropertyFromNode(value, 'Properties')) === null || _b === void 0 ? void 0 : _b.System_Fullpath;
|
|
18454
|
+
fullpathTranslatedPropFromNode = (_c = getPropertyFromNode(value, 'Translations')[options.language]) === null || _c === void 0 ? void 0 : _c.translated_fullpath;
|
|
18455
|
+
if (!fullpathPropFromNode)
|
|
18456
|
+
fullpathPropFromNode = (_d = getPropertyFromNode(value, 'Properties')) === null || _d === void 0 ? void 0 : _d.System_FullPath;
|
|
18457
|
+
if (!fullpathTranslatedPropFromNode)
|
|
18458
|
+
fullpathTranslatedPropFromNode = getPropertyFromNode(value, 'fullpathTranslated');
|
|
18433
18459
|
}
|
|
18434
18460
|
else {
|
|
18435
18461
|
keyPropFromNode = getPropertyFromNode(value, 'key');
|
|
@@ -18438,7 +18464,9 @@ function fillTreeWithObject(tree, myObject, searched, options, depth = 0) {
|
|
|
18438
18464
|
fullpathTranslatedPropFromNode = getPropertyFromNode(value, 'fullpathTranslated');
|
|
18439
18465
|
}
|
|
18440
18466
|
const childrenPropFromNode = getPropertyFromNode(value, 'children', false);
|
|
18441
|
-
|
|
18467
|
+
let deprecated = getPropertyFromNode(value, 'deprecated', null);
|
|
18468
|
+
if (deprecated === null)
|
|
18469
|
+
deprecated = getPropertyFromNode(value, 'Is_Deprecated', false);
|
|
18442
18470
|
const objToPush = {
|
|
18443
18471
|
id: keyPropFromNode,
|
|
18444
18472
|
nodeId: keyPropFromNode,
|
|
@@ -18752,7 +18780,7 @@ const HierarchizedPickerComponent = class {
|
|
|
18752
18780
|
// this.rawData = null;
|
|
18753
18781
|
// }
|
|
18754
18782
|
// this.ready = false;
|
|
18755
|
-
//NOTE: This could work in a synchronous environment =>
|
|
18783
|
+
//NOTE: This could work in a synchronous environment =>
|
|
18756
18784
|
// reloadCurrentValues() {
|
|
18757
18785
|
// let savedValues = this.value;
|
|
18758
18786
|
// this.value = [];
|
|
@@ -18761,6 +18789,10 @@ const HierarchizedPickerComponent = class {
|
|
|
18761
18789
|
// });
|
|
18762
18790
|
// ---------------------------------------
|
|
18763
18791
|
// this.theOptions = newValue;
|
|
18792
|
+
if (oldValue && JSON.stringify(newValue.options) == JSON.stringify(oldValue.options)) {
|
|
18793
|
+
this.ready = true;
|
|
18794
|
+
return;
|
|
18795
|
+
}
|
|
18764
18796
|
if (typeof newValue == 'string')
|
|
18765
18797
|
newValue = JSON.parse(newValue);
|
|
18766
18798
|
if (typeof oldValue == 'string')
|
|
@@ -18813,7 +18845,10 @@ const HierarchizedPickerComponent = class {
|
|
|
18813
18845
|
const isEqual = lodash.isEqual(newV, oldV);
|
|
18814
18846
|
if (!newV.defaultValue && !oldV.defaultValue)
|
|
18815
18847
|
return;
|
|
18816
|
-
const
|
|
18848
|
+
const newDefault = Array.isArray(newV.defaultValue) ? newV.defaultValue : [newV.defaultValue];
|
|
18849
|
+
const oldDefault = Array.isArray(oldV.defaultValue) ? oldV.defaultValue : [oldV.defaultValue];
|
|
18850
|
+
const changeDefaultValue = newDefault.length !== oldDefault.length ||
|
|
18851
|
+
!newDefault.every(value => oldDefault.includes(value));
|
|
18817
18852
|
if (!isEqual && changeDefaultValue) {
|
|
18818
18853
|
return changeDefaultValue;
|
|
18819
18854
|
}
|
|
@@ -18863,6 +18898,7 @@ const HierarchizedPickerComponent = class {
|
|
|
18863
18898
|
this.value = [];
|
|
18864
18899
|
this.shownTree = false;
|
|
18865
18900
|
this.searchResultData = [];
|
|
18901
|
+
this.activatedDragAndDrop = true;
|
|
18866
18902
|
this.hasFocus = undefined;
|
|
18867
18903
|
this.errorToLog = '';
|
|
18868
18904
|
this.checkFields = this.checkFields.bind(this);
|
|
@@ -18907,7 +18943,7 @@ const HierarchizedPickerComponent = class {
|
|
|
18907
18943
|
return;
|
|
18908
18944
|
}
|
|
18909
18945
|
if (((_a = this.optionsManager.getOptions()) === null || _a === void 0 ? void 0 : _a.loading) == 'display') {
|
|
18910
|
-
this.loadDataForTree(true);
|
|
18946
|
+
this.loadDataForTree(true, document.querySelector("#hierarchized-picker-" + this.componentID + " .loader"));
|
|
18911
18947
|
}
|
|
18912
18948
|
}
|
|
18913
18949
|
async initComponent() {
|
|
@@ -19097,14 +19133,62 @@ const HierarchizedPickerComponent = class {
|
|
|
19097
19133
|
}
|
|
19098
19134
|
getApiSearchURL() {
|
|
19099
19135
|
if (this.optionsManager.getOptions().origin == 'classification') {
|
|
19100
|
-
|
|
19101
|
-
|
|
19102
|
-
|
|
19136
|
+
const baseURL = this.optionsManager.getOptions().url;
|
|
19137
|
+
if (baseURL.indexOf("getTree") > -1) {
|
|
19138
|
+
return baseURL.replace("/getTree/", "/search/");
|
|
19139
|
+
}
|
|
19140
|
+
else {
|
|
19141
|
+
let substringUpToLastSlash = this.optionsManager.getOptions().url.substring(0, this.optionsManager.getOptions().url.lastIndexOf('/'));
|
|
19142
|
+
let context = substringUpToLastSlash.substring(substringUpToLastSlash.lastIndexOf('/'), substringUpToLastSlash.length);
|
|
19143
|
+
return substringUpToLastSlash.substring(0, substringUpToLastSlash.lastIndexOf('/')) + '/search' + context;
|
|
19144
|
+
}
|
|
19103
19145
|
}
|
|
19104
19146
|
else {
|
|
19105
19147
|
return this.optionsManager.getOptions().url.substring(0, this.optionsManager.getOptions().url.lastIndexOf('/')) + '/GetTreeFromSearch';
|
|
19106
19148
|
}
|
|
19107
19149
|
}
|
|
19150
|
+
// TODO > Celine would rather like the context (thesaurus or position) to be extracted another way
|
|
19151
|
+
getContextualApiURL(init = false) {
|
|
19152
|
+
const { options, url } = this.optionsManager.getOptions();
|
|
19153
|
+
if (init && options.Reach) {
|
|
19154
|
+
// Use a base URL for relative paths
|
|
19155
|
+
const base = window.location.origin; // fallback for relative URLs
|
|
19156
|
+
const parsedUrl = new URL(url, base);
|
|
19157
|
+
const pathSegments = parsedUrl.pathname.split('/');
|
|
19158
|
+
let dynamicType = pathSegments[pathSegments.length - 2];
|
|
19159
|
+
if (['thesaurus', 'position'].indexOf(dynamicType) == -1)
|
|
19160
|
+
dynamicType = pathSegments[pathSegments.length - 1];
|
|
19161
|
+
const newPathname = `/api/v1/classification/reach/${dynamicType}/${options.Reach}`;
|
|
19162
|
+
return `${parsedUrl.origin}${newPathname}`;
|
|
19163
|
+
}
|
|
19164
|
+
return url;
|
|
19165
|
+
}
|
|
19166
|
+
getContextualApiParams(options = null, search = null, init = false) {
|
|
19167
|
+
if (!options)
|
|
19168
|
+
options = this.optionsManager.getOptions().options;
|
|
19169
|
+
let optionsToReturn = Object.assign({}, options);
|
|
19170
|
+
if (!init)
|
|
19171
|
+
delete optionsToReturn.Reach;
|
|
19172
|
+
if (optionsToReturn.Reach) {
|
|
19173
|
+
delete optionsToReturn.Reach;
|
|
19174
|
+
if ("startNode" in optionsToReturn) {
|
|
19175
|
+
optionsToReturn.startingnode = optionsToReturn.startNode;
|
|
19176
|
+
delete optionsToReturn.startNode;
|
|
19177
|
+
}
|
|
19178
|
+
else if ("StartNodeID" in optionsToReturn) {
|
|
19179
|
+
optionsToReturn.startingnode = optionsToReturn.StartNodeID;
|
|
19180
|
+
delete optionsToReturn.StartNodeID;
|
|
19181
|
+
}
|
|
19182
|
+
}
|
|
19183
|
+
else if (search) {
|
|
19184
|
+
optionsToReturn.searchedValue = search;
|
|
19185
|
+
if ("startNode" in optionsToReturn) {
|
|
19186
|
+
optionsToReturn.StartNodeID = optionsToReturn.startNode;
|
|
19187
|
+
delete optionsToReturn.startNode;
|
|
19188
|
+
}
|
|
19189
|
+
}
|
|
19190
|
+
return optionsToReturn;
|
|
19191
|
+
}
|
|
19108
19192
|
translateDataForTree(dataToLoad, searchID = null, searched = null) {
|
|
19109
19193
|
if (searched && searched != "") {
|
|
19110
19194
|
this.loadSearchDataInCurrentTree(searchID, searched);
|
|
@@ -19116,11 +19200,11 @@ const HierarchizedPickerComponent = class {
|
|
|
19116
19200
|
loadSearchDataInCurrentTree(searchID, searched) {
|
|
19117
19201
|
let displayResults = (newtree) => {
|
|
19118
19202
|
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) {
|
|
19119
|
-
this.rawDataManager.mergeData(newtree);
|
|
19203
|
+
this.rawDataManager.mergeData(newtree, this.theOptions.origin == 'classification' ? "ID" : "key");
|
|
19120
19204
|
newtree.children.forEach((value, index) => {
|
|
19121
19205
|
completeCurrentTreeWithTree(this.loadedTreeJs, value, this.optionsManager.getOptions());
|
|
19122
19206
|
});
|
|
19123
|
-
this.triggerTreeDisplay(this.
|
|
19207
|
+
this.triggerTreeDisplay(this.rawDataManager.getData(), searched);
|
|
19124
19208
|
displayAutocompleteWithResults(this.rawDataManager.getData(), searched, this.optionsManager, this.editValue.bind(this), this.showTree.bind(this));
|
|
19125
19209
|
// Deploys all nodes
|
|
19126
19210
|
document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-node').forEach((item) => {
|
|
@@ -19138,9 +19222,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19138
19222
|
if (this.theOptions.source == 'webservice') {
|
|
19139
19223
|
if (this.theOptions.origin == 'classification') {
|
|
19140
19224
|
// WS Call
|
|
19141
|
-
this.rawDataManager.getFromClassification(this.getApiSearchURL(), {
|
|
19142
|
-
searchedValue: searched
|
|
19143
|
-
})
|
|
19225
|
+
this.rawDataManager.getFromClassification(this.getApiSearchURL(), Object.assign({}, this.getContextualApiParams(null, searched)), document.querySelector("#hierarchized-picker-" + this.componentID + " .loader"))
|
|
19144
19226
|
.then((data) => {
|
|
19145
19227
|
displayResults(data);
|
|
19146
19228
|
if (!searched) {
|
|
@@ -19159,7 +19241,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19159
19241
|
searchedValue: searched,
|
|
19160
19242
|
searchNameOnly: true,
|
|
19161
19243
|
deprecated: false,
|
|
19162
|
-
})
|
|
19244
|
+
}, document.querySelector("#hierarchized-picker-" + this.componentID + " .loader"))
|
|
19163
19245
|
.then((data) => {
|
|
19164
19246
|
displayResults(data);
|
|
19165
19247
|
if (!searched) {
|
|
@@ -19289,19 +19371,24 @@ const HierarchizedPickerComponent = class {
|
|
|
19289
19371
|
// ----- BEGIN -----
|
|
19290
19372
|
let node = treeToUpdate.nodesById[id];
|
|
19291
19373
|
let onChange = treeToUpdate.options.onChange;
|
|
19292
|
-
if (!node
|
|
19293
|
-
|
|
19294
|
-
treeToUpdate.updateLiElements();
|
|
19374
|
+
if (!node) {
|
|
19375
|
+
this.logError("The current selected value is not part of the loaded tree!");
|
|
19295
19376
|
}
|
|
19296
|
-
|
|
19297
|
-
|
|
19298
|
-
|
|
19299
|
-
|
|
19300
|
-
|
|
19301
|
-
|
|
19302
|
-
|
|
19303
|
-
|
|
19304
|
-
|
|
19377
|
+
else {
|
|
19378
|
+
if (!node.disabled) {
|
|
19379
|
+
treeToUpdate.setValue(id);
|
|
19380
|
+
treeToUpdate.updateLiElements();
|
|
19381
|
+
}
|
|
19382
|
+
userClick && onChange && onChange.call(treeToUpdate);
|
|
19383
|
+
// ------ END ------
|
|
19384
|
+
if (this.setValueOnClick) {
|
|
19385
|
+
this.editValue(node, userClick);
|
|
19386
|
+
if (this.shownTree && userClick) {
|
|
19387
|
+
// TODO > is this required ?
|
|
19388
|
+
// await focusMainInput(this);
|
|
19389
|
+
if (!this.optionsManager.getOptions().multiple) {
|
|
19390
|
+
this.showTree('hide');
|
|
19391
|
+
}
|
|
19305
19392
|
}
|
|
19306
19393
|
}
|
|
19307
19394
|
}
|
|
@@ -19380,6 +19467,11 @@ const HierarchizedPickerComponent = class {
|
|
|
19380
19467
|
if (this.hasFocus.indexOf('hide') > -1 && !isStillInsidePicker) {
|
|
19381
19468
|
this.hasFocus = [];
|
|
19382
19469
|
}
|
|
19470
|
+
else {
|
|
19471
|
+
if (!this.shownTree && this.theOptions.loading == 'click' && !this.ready) {
|
|
19472
|
+
this.loadDataForTree(true, document.querySelector("#hierarchized-picker-" + this.componentID + " .loader"));
|
|
19473
|
+
}
|
|
19474
|
+
}
|
|
19383
19475
|
const previousShownTree = this.shownTree;
|
|
19384
19476
|
this.shownTree = this.hasFocus.length > 0;
|
|
19385
19477
|
if (this.shownTree && !previousShownTree) {
|
|
@@ -19428,12 +19520,13 @@ const HierarchizedPickerComponent = class {
|
|
|
19428
19520
|
if (!value)
|
|
19429
19521
|
value = this.value;
|
|
19430
19522
|
this.displayedValue = value.map(item => {
|
|
19431
|
-
var _a
|
|
19432
|
-
return (
|
|
19523
|
+
var _a;
|
|
19524
|
+
return (_a = (this.optionsManager.getOptions().isFullpath ? item.fullpathTranslated : item.shortpathTranslated)) !== null && _a !== void 0 ? _a : `Node ${item.nodeid}`;
|
|
19433
19525
|
}).join(';');
|
|
19434
19526
|
}
|
|
19435
19527
|
// Search a value in the tree and triggers a search when necessary
|
|
19436
19528
|
search(searched) {
|
|
19529
|
+
this.loader.classList.add('loading');
|
|
19437
19530
|
let searchinput = document.querySelector('#hierarchized-picker-' + this.componentID + ' .hierarchized-picker-search input');
|
|
19438
19531
|
if (this.optionsManager.getOptions().mode == 'input' && searchinput) {
|
|
19439
19532
|
searchinput.classList.remove('fieldError');
|
|
@@ -19470,6 +19563,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19470
19563
|
// this.checkFields(this.value, false);
|
|
19471
19564
|
this.setSearchResults([]);
|
|
19472
19565
|
}
|
|
19566
|
+
this.loader.classList.remove('loading');
|
|
19473
19567
|
}
|
|
19474
19568
|
// Refresh the tree with search results
|
|
19475
19569
|
triggerSearch(searched) {
|
|
@@ -19488,7 +19582,9 @@ const HierarchizedPickerComponent = class {
|
|
|
19488
19582
|
loadDataForTree(init, loader) {
|
|
19489
19583
|
if (this.optionsManager.getOptions().source == 'webservice') {
|
|
19490
19584
|
if (this.optionsManager.getOptions().origin == 'classification') {
|
|
19491
|
-
this.
|
|
19585
|
+
const contextualApiParams = this.getContextualApiParams(null, null, true);
|
|
19586
|
+
const contextualApiURL = this.getContextualApiURL(true);
|
|
19587
|
+
this.rawDataManager.getFromClassification(contextualApiURL, contextualApiParams, loader).then((data) => {
|
|
19492
19588
|
this.rawData = data;
|
|
19493
19589
|
if (init) {
|
|
19494
19590
|
this.formatDefaultValue();
|
|
@@ -19632,7 +19728,9 @@ const HierarchizedPickerComponent = class {
|
|
|
19632
19728
|
this.scrollable = el;
|
|
19633
19729
|
}, class: 'hierarchized-picker-modal-area ' + (!this.shownTree ? ' hidden ' : ''), onClick: event => {
|
|
19634
19730
|
clickPickerModalArea(this);
|
|
19635
|
-
} }, index.h("div", { class:
|
|
19731
|
+
} }, index.h("div", { class: "loader", ref: el => {
|
|
19732
|
+
this.loader = el;
|
|
19733
|
+
} }, index.h("div", { class: "loader-inner" }, "Loading...")), index.h("div", { class: 'hierarchized-picker-modal ' + (!this.ready ? 'hidden' : '') }, index.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) }), index.h("ul", { id: "autocomplete-results-area" }), index.h("div", { id: 'tree-area-' + this.componentID, class: 'hierarchized-picker-tree hierarchized-picker-tree-area ' + this.pickerClass }))))) : (index.h("div", { class: 'hierarchized-picker-raw-tree-area' + (this.isDisabled ? ' readonly' : ''), onClick: event => {
|
|
19636
19734
|
clickPickerModalArea(this);
|
|
19637
19735
|
} }, index.h("div", { class: "loader", ref: el => {
|
|
19638
19736
|
this.loader = el;
|