reneco-hierarchized-picker 0.4.2-beta.13 → 0.4.2-beta.15
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 +86 -50
- package/dist/collection/components/hierarchized-picker/hierarchized-picker.js +58 -25
- package/dist/collection/components/treejs/index.js +9 -7
- 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 +3 -10
- package/dist/custom-elements/index.js +87 -51
- 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 +86 -50
- 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-615eead9.entry.js +1 -0
- package/dist/reneco-hierarchized-picker/p-73168a50.system.js +1 -1
- package/dist/reneco-hierarchized-picker/p-8c682858.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 +2 -1
- 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-61375f23.entry.js +0 -1
- package/dist/reneco-hierarchized-picker/p-a249a122.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();
|
|
@@ -329,9 +339,11 @@ Tree.prototype.bindEvent = function (ele) {
|
|
|
329
339
|
// If source is webservice (it shouldn't be something else)
|
|
330
340
|
if (this.options.parentApi.theOptions.source == 'webservice') {
|
|
331
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();
|
|
332
344
|
// WS Call
|
|
333
345
|
this.options.rawDataManager
|
|
334
|
-
.getFromClassification(
|
|
346
|
+
.getFromClassification(contextualApiURL, contextualApiParams, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + ".loader"))
|
|
335
347
|
.then(data => {
|
|
336
348
|
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
337
349
|
});
|
|
@@ -343,7 +355,7 @@ Tree.prototype.bindEvent = function (ele) {
|
|
|
343
355
|
StartNodeID: target.parentNode.nodeId,
|
|
344
356
|
lng: this.options.parentApi.theOptions.options.lng,
|
|
345
357
|
IsDeprecated: this.options.parentApi.theOptions.options.IsDeprecated,
|
|
346
|
-
})
|
|
358
|
+
}, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + ".loader"))
|
|
347
359
|
.then(data => {
|
|
348
360
|
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
349
361
|
});
|
|
@@ -666,19 +678,19 @@ Tree.prototype.createLiEle = function (node, closed) {
|
|
|
666
678
|
if (this.options.parentApi.theOptions.dragAndDropEnabled) {
|
|
667
679
|
li.setAttribute('draggable', 'true');
|
|
668
680
|
li.addEventListener('dragstart', e => {
|
|
669
|
-
onItemDragStart(li, e);
|
|
681
|
+
onItemDragStart(li, e, this.options.parentApi.activatedDragAndDrop);
|
|
670
682
|
});
|
|
671
683
|
li.addEventListener('dragend', e => {
|
|
672
|
-
onItemDragEnd(li, e);
|
|
684
|
+
onItemDragEnd(li, e, this.options.parentApi.activatedDragAndDrop);
|
|
673
685
|
});
|
|
674
686
|
li.addEventListener('dragover', e => {
|
|
675
|
-
onItemDragOver(li, e);
|
|
687
|
+
onItemDragOver(li, e, this.options.parentApi.activatedDragAndDrop);
|
|
676
688
|
});
|
|
677
689
|
li.addEventListener('dragleave', e => {
|
|
678
|
-
onItemDragLeave(li, e);
|
|
690
|
+
onItemDragLeave(li, e, this.options.parentApi.activatedDragAndDrop);
|
|
679
691
|
});
|
|
680
692
|
li.addEventListener('drop', e => {
|
|
681
|
-
onItemDrop(li, e, (dragEl, dropEl, position) => {
|
|
693
|
+
onItemDrop(li, e, this.options.parentApi.activatedDragAndDrop, (dragEl, dropEl, position) => {
|
|
682
694
|
this.options.parentApi.itemDropped.emit({ dragEl, dropEl, position });
|
|
683
695
|
});
|
|
684
696
|
});
|
|
@@ -18182,7 +18194,7 @@ class RawDataManager {
|
|
|
18182
18194
|
continue;
|
|
18183
18195
|
const value = options[key];
|
|
18184
18196
|
const lowerKey = key.toLowerCase();
|
|
18185
|
-
if ((lowerKey === 'startnode'
|
|
18197
|
+
if ((lowerKey === 'startnode') && !pathSegment) {
|
|
18186
18198
|
pathSegment = encodeURIComponent(value);
|
|
18187
18199
|
continue; // Skip adding this to the query string
|
|
18188
18200
|
}
|
|
@@ -18269,8 +18281,16 @@ class RawDataManager {
|
|
|
18269
18281
|
* Merge new data into the existing data.
|
|
18270
18282
|
* @param newData New data to merge.
|
|
18271
18283
|
*/
|
|
18272
|
-
mergeData(newData) {
|
|
18273
|
-
|
|
18284
|
+
mergeData(newData, idKey) {
|
|
18285
|
+
if (!this.rawData)
|
|
18286
|
+
this.rawData = newData;
|
|
18287
|
+
else {
|
|
18288
|
+
this.rawData = this.genericMerge(this.rawData, newData, idKey, 'children');
|
|
18289
|
+
}
|
|
18290
|
+
}
|
|
18291
|
+
reorderItems(referenceArray, toReorderArray, idKey) {
|
|
18292
|
+
const idMap = new Map(toReorderArray.map(item => [item[idKey], item]));
|
|
18293
|
+
return referenceArray.map(refItem => idMap.get(refItem[idKey])).filter(Boolean);
|
|
18274
18294
|
}
|
|
18275
18295
|
/**
|
|
18276
18296
|
* Generic merge method.
|
|
@@ -18286,9 +18306,11 @@ class RawDataManager {
|
|
|
18286
18306
|
}
|
|
18287
18307
|
if (!toAdd || !((_a = toAdd[childrenKey]) === null || _a === void 0 ? void 0 : _a.length))
|
|
18288
18308
|
return source;
|
|
18309
|
+
if (source[childrenKey] && source[childrenKey].length > 0 && toAdd[childrenKey] && toAdd[childrenKey].length > 0)
|
|
18310
|
+
toAdd[childrenKey] = this.reorderItems(source[childrenKey], toAdd[childrenKey], idKey);
|
|
18289
18311
|
source[childrenKey] = ((_b = source[childrenKey]) === null || _b === void 0 ? void 0 : _b.length)
|
|
18290
18312
|
? source[childrenKey].map((child, index) => {
|
|
18291
|
-
return this.genericMerge(child, toAdd[childrenKey].filter(item => item.key == child.key)[
|
|
18313
|
+
return this.genericMerge(child, toAdd[childrenKey].filter(item => item.key == child.key)[index], idKey, childrenKey);
|
|
18292
18314
|
})
|
|
18293
18315
|
: toAdd[childrenKey];
|
|
18294
18316
|
return source;
|
|
@@ -18358,6 +18380,12 @@ class OptionsManager {
|
|
|
18358
18380
|
delete this.options.defaultValue;
|
|
18359
18381
|
}
|
|
18360
18382
|
}
|
|
18383
|
+
// This method is pretty ugly and shouldn't have to be called, but temporarily works until a better solution is set
|
|
18384
|
+
dropReach() {
|
|
18385
|
+
if (this.options.options && this.options.options.Reach) {
|
|
18386
|
+
delete this.options.options.Reach;
|
|
18387
|
+
}
|
|
18388
|
+
}
|
|
18361
18389
|
}
|
|
18362
18390
|
|
|
18363
18391
|
/**
|
|
@@ -18412,7 +18440,7 @@ function fillTreeWithObject(tree, myObject, searched, options, depth = 0) {
|
|
|
18412
18440
|
const searchResultPresentsUnMatched = options.searchResultPresentsUnMatched;
|
|
18413
18441
|
if (myObject && myObject.length) {
|
|
18414
18442
|
myObject.forEach(value => {
|
|
18415
|
-
var _a, _b, _c
|
|
18443
|
+
var _a, _b, _c;
|
|
18416
18444
|
let keyPropFromNode = null;
|
|
18417
18445
|
let valueTranslatedPropFromNode = null;
|
|
18418
18446
|
let fullpathPropFromNode = null;
|
|
@@ -18420,15 +18448,8 @@ function fillTreeWithObject(tree, myObject, searched, options, depth = 0) {
|
|
|
18420
18448
|
if (options.origin == "classification") {
|
|
18421
18449
|
keyPropFromNode = getPropertyFromNode(value, 'ID');
|
|
18422
18450
|
valueTranslatedPropFromNode = (_a = getPropertyFromNode(value, 'Translations')[options.language]) === null || _a === void 0 ? void 0 : _a.translated_name;
|
|
18423
|
-
|
|
18424
|
-
|
|
18425
|
-
fullpathPropFromNode = (_b = getPropertyFromNode(value, 'Properties')) === null || _b === void 0 ? void 0 : _b.System_FullPath;
|
|
18426
|
-
fullpathTranslatedPropFromNode = (_c = getPropertyFromNode(value, 'fullpathTranslated')[options.language]) === null || _c === void 0 ? void 0 : _c.translated_fullpath;
|
|
18427
|
-
}
|
|
18428
|
-
else {
|
|
18429
|
-
fullpathPropFromNode = (_d = getPropertyFromNode(value, 'Properties')) === null || _d === void 0 ? void 0 : _d.System_Fullpath;
|
|
18430
|
-
fullpathTranslatedPropFromNode = (_e = getPropertyFromNode(value, 'Translations')[options.language]) === null || _e === void 0 ? void 0 : _e.translated_fullpath;
|
|
18431
|
-
}
|
|
18451
|
+
fullpathPropFromNode = (_b = getPropertyFromNode(value, 'Properties')) === null || _b === void 0 ? void 0 : _b.System_Fullpath;
|
|
18452
|
+
fullpathTranslatedPropFromNode = (_c = getPropertyFromNode(value, 'Translations')[options.language]) === null || _c === void 0 ? void 0 : _c.translated_fullpath;
|
|
18432
18453
|
}
|
|
18433
18454
|
else {
|
|
18434
18455
|
keyPropFromNode = getPropertyFromNode(value, 'key');
|
|
@@ -18865,6 +18886,7 @@ const HierarchizedPickerComponent = class {
|
|
|
18865
18886
|
this.value = [];
|
|
18866
18887
|
this.shownTree = false;
|
|
18867
18888
|
this.searchResultData = [];
|
|
18889
|
+
this.activatedDragAndDrop = true;
|
|
18868
18890
|
this.hasFocus = undefined;
|
|
18869
18891
|
this.errorToLog = '';
|
|
18870
18892
|
this.checkFields = this.checkFields.bind(this);
|
|
@@ -18909,7 +18931,7 @@ const HierarchizedPickerComponent = class {
|
|
|
18909
18931
|
return;
|
|
18910
18932
|
}
|
|
18911
18933
|
if (((_a = this.optionsManager.getOptions()) === null || _a === void 0 ? void 0 : _a.loading) == 'display') {
|
|
18912
|
-
this.loadDataForTree(true);
|
|
18934
|
+
this.loadDataForTree(true, document.querySelector("#hierarchized-picker-" + this.componentID + ".loader"));
|
|
18913
18935
|
}
|
|
18914
18936
|
}
|
|
18915
18937
|
async initComponent() {
|
|
@@ -19116,15 +19138,15 @@ const HierarchizedPickerComponent = class {
|
|
|
19116
19138
|
const pathSegments = parsedUrl.pathname.split('/');
|
|
19117
19139
|
const dynamicType = pathSegments[pathSegments.length - 2];
|
|
19118
19140
|
const newPathname = `/api/v1/classification/reach/${dynamicType}/${options.Reach}`;
|
|
19141
|
+
this.optionsManager.dropReach();
|
|
19119
19142
|
return `${parsedUrl.origin}${newPathname}`;
|
|
19120
19143
|
}
|
|
19121
19144
|
return url;
|
|
19122
19145
|
}
|
|
19123
|
-
getContextualApiParams(
|
|
19124
|
-
|
|
19125
|
-
|
|
19146
|
+
getContextualApiParams(search = null) {
|
|
19147
|
+
const options = this.optionsManager.getOptions().options;
|
|
19148
|
+
let optionsToReturn = Object.assign({}, options);
|
|
19126
19149
|
if (options.Reach) {
|
|
19127
|
-
let optionsToReturn = Object.assign({}, options);
|
|
19128
19150
|
delete optionsToReturn.Reach;
|
|
19129
19151
|
if ("startNode" in optionsToReturn) {
|
|
19130
19152
|
optionsToReturn.startingnode = optionsToReturn.startNode;
|
|
@@ -19134,10 +19156,17 @@ const HierarchizedPickerComponent = class {
|
|
|
19134
19156
|
optionsToReturn.startingnode = optionsToReturn.StartNodeID;
|
|
19135
19157
|
delete optionsToReturn.StartNodeID;
|
|
19136
19158
|
}
|
|
19137
|
-
|
|
19159
|
+
}
|
|
19160
|
+
else if (search) {
|
|
19161
|
+
optionsToReturn.searchedValue = search;
|
|
19162
|
+
if ("startNode" in optionsToReturn) {
|
|
19163
|
+
optionsToReturn.StartNodeID = optionsToReturn.startNode;
|
|
19164
|
+
delete optionsToReturn.startNode;
|
|
19165
|
+
}
|
|
19138
19166
|
}
|
|
19139
19167
|
else
|
|
19140
19168
|
return options;
|
|
19169
|
+
return optionsToReturn;
|
|
19141
19170
|
}
|
|
19142
19171
|
translateDataForTree(dataToLoad, searchID = null, searched = null) {
|
|
19143
19172
|
if (searched && searched != "") {
|
|
@@ -19150,7 +19179,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19150
19179
|
loadSearchDataInCurrentTree(searchID, searched) {
|
|
19151
19180
|
let displayResults = (newtree) => {
|
|
19152
19181
|
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) {
|
|
19153
|
-
this.rawDataManager.mergeData(newtree);
|
|
19182
|
+
this.rawDataManager.mergeData(newtree, this.theOptions.origin == 'classification' ? "ID" : "key");
|
|
19154
19183
|
newtree.children.forEach((value, index) => {
|
|
19155
19184
|
completeCurrentTreeWithTree(this.loadedTreeJs, value, this.optionsManager.getOptions());
|
|
19156
19185
|
});
|
|
@@ -19172,9 +19201,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19172
19201
|
if (this.theOptions.source == 'webservice') {
|
|
19173
19202
|
if (this.theOptions.origin == 'classification') {
|
|
19174
19203
|
// WS Call
|
|
19175
|
-
this.rawDataManager.getFromClassification(this.getApiSearchURL(), {
|
|
19176
|
-
searchedValue: searched
|
|
19177
|
-
})
|
|
19204
|
+
this.rawDataManager.getFromClassification(this.getApiSearchURL(), Object.assign({}, this.getContextualApiParams(searched)), document.querySelector("#hierarchized-picker-" + this.componentID + ".loader"))
|
|
19178
19205
|
.then((data) => {
|
|
19179
19206
|
displayResults(data);
|
|
19180
19207
|
if (!searched) {
|
|
@@ -19193,7 +19220,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19193
19220
|
searchedValue: searched,
|
|
19194
19221
|
searchNameOnly: true,
|
|
19195
19222
|
deprecated: false,
|
|
19196
|
-
})
|
|
19223
|
+
}, document.querySelector("#hierarchized-picker-" + this.componentID + ".loader"))
|
|
19197
19224
|
.then((data) => {
|
|
19198
19225
|
displayResults(data);
|
|
19199
19226
|
if (!searched) {
|
|
@@ -19323,19 +19350,24 @@ const HierarchizedPickerComponent = class {
|
|
|
19323
19350
|
// ----- BEGIN -----
|
|
19324
19351
|
let node = treeToUpdate.nodesById[id];
|
|
19325
19352
|
let onChange = treeToUpdate.options.onChange;
|
|
19326
|
-
if (!node
|
|
19327
|
-
|
|
19328
|
-
treeToUpdate.updateLiElements();
|
|
19353
|
+
if (!node) {
|
|
19354
|
+
this.logError("The current selected value is not part of the loaded tree!");
|
|
19329
19355
|
}
|
|
19330
|
-
|
|
19331
|
-
|
|
19332
|
-
|
|
19333
|
-
|
|
19334
|
-
|
|
19335
|
-
|
|
19336
|
-
|
|
19337
|
-
|
|
19338
|
-
|
|
19356
|
+
else {
|
|
19357
|
+
if (!node.disabled) {
|
|
19358
|
+
treeToUpdate.setValue(id);
|
|
19359
|
+
treeToUpdate.updateLiElements();
|
|
19360
|
+
}
|
|
19361
|
+
userClick && onChange && onChange.call(treeToUpdate);
|
|
19362
|
+
// ------ END ------
|
|
19363
|
+
if (this.setValueOnClick) {
|
|
19364
|
+
this.editValue(node, userClick);
|
|
19365
|
+
if (this.shownTree && userClick) {
|
|
19366
|
+
// TODO > is this required ?
|
|
19367
|
+
// await focusMainInput(this);
|
|
19368
|
+
if (!this.optionsManager.getOptions().multiple) {
|
|
19369
|
+
this.showTree('hide');
|
|
19370
|
+
}
|
|
19339
19371
|
}
|
|
19340
19372
|
}
|
|
19341
19373
|
}
|
|
@@ -19468,6 +19500,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19468
19500
|
}
|
|
19469
19501
|
// Search a value in the tree and triggers a search when necessary
|
|
19470
19502
|
search(searched) {
|
|
19503
|
+
this.loader.classList.add('loading');
|
|
19471
19504
|
let searchinput = document.querySelector('#hierarchized-picker-' + this.componentID + ' .hierarchized-picker-search input');
|
|
19472
19505
|
if (this.optionsManager.getOptions().mode == 'input' && searchinput) {
|
|
19473
19506
|
searchinput.classList.remove('fieldError');
|
|
@@ -19504,6 +19537,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19504
19537
|
// this.checkFields(this.value, false);
|
|
19505
19538
|
this.setSearchResults([]);
|
|
19506
19539
|
}
|
|
19540
|
+
this.loader.classList.remove('loading');
|
|
19507
19541
|
}
|
|
19508
19542
|
// Refresh the tree with search results
|
|
19509
19543
|
triggerSearch(searched) {
|
|
@@ -19522,7 +19556,9 @@ const HierarchizedPickerComponent = class {
|
|
|
19522
19556
|
loadDataForTree(init, loader) {
|
|
19523
19557
|
if (this.optionsManager.getOptions().source == 'webservice') {
|
|
19524
19558
|
if (this.optionsManager.getOptions().origin == 'classification') {
|
|
19525
|
-
|
|
19559
|
+
const contextualApiParams = this.getContextualApiParams();
|
|
19560
|
+
const contextualApiURL = this.getContextualApiURL();
|
|
19561
|
+
this.rawDataManager.getFromClassification(contextualApiURL, contextualApiParams, loader).then((data) => {
|
|
19526
19562
|
this.rawData = data;
|
|
19527
19563
|
if (init) {
|
|
19528
19564
|
this.formatDefaultValue();
|
|
@@ -204,6 +204,7 @@ export class HierarchizedPickerComponent {
|
|
|
204
204
|
this.value = [];
|
|
205
205
|
this.shownTree = false;
|
|
206
206
|
this.searchResultData = [];
|
|
207
|
+
this.activatedDragAndDrop = true;
|
|
207
208
|
this.hasFocus = undefined;
|
|
208
209
|
this.errorToLog = '';
|
|
209
210
|
this.checkFields = this.checkFields.bind(this);
|
|
@@ -248,7 +249,7 @@ export class HierarchizedPickerComponent {
|
|
|
248
249
|
return;
|
|
249
250
|
}
|
|
250
251
|
if (((_a = this.optionsManager.getOptions()) === null || _a === void 0 ? void 0 : _a.loading) == 'display') {
|
|
251
|
-
this.loadDataForTree(true);
|
|
252
|
+
this.loadDataForTree(true, document.querySelector("#hierarchized-picker-" + this.componentID + ".loader"));
|
|
252
253
|
}
|
|
253
254
|
}
|
|
254
255
|
async initComponent() {
|
|
@@ -458,15 +459,15 @@ export class HierarchizedPickerComponent {
|
|
|
458
459
|
const pathSegments = parsedUrl.pathname.split('/');
|
|
459
460
|
const dynamicType = pathSegments[pathSegments.length - 2];
|
|
460
461
|
const newPathname = `/api/v1/classification/reach/${dynamicType}/${options.Reach}`;
|
|
462
|
+
this.optionsManager.dropReach();
|
|
461
463
|
return `${parsedUrl.origin}${newPathname}`;
|
|
462
464
|
}
|
|
463
465
|
return url;
|
|
464
466
|
}
|
|
465
|
-
getContextualApiParams(
|
|
466
|
-
|
|
467
|
-
|
|
467
|
+
getContextualApiParams(search = null) {
|
|
468
|
+
const options = this.optionsManager.getOptions().options;
|
|
469
|
+
let optionsToReturn = Object.assign({}, options);
|
|
468
470
|
if (options.Reach) {
|
|
469
|
-
let optionsToReturn = Object.assign({}, options);
|
|
470
471
|
delete optionsToReturn.Reach;
|
|
471
472
|
if ("startNode" in optionsToReturn) {
|
|
472
473
|
optionsToReturn.startingnode = optionsToReturn.startNode;
|
|
@@ -476,10 +477,17 @@ export class HierarchizedPickerComponent {
|
|
|
476
477
|
optionsToReturn.startingnode = optionsToReturn.StartNodeID;
|
|
477
478
|
delete optionsToReturn.StartNodeID;
|
|
478
479
|
}
|
|
479
|
-
|
|
480
|
+
}
|
|
481
|
+
else if (search) {
|
|
482
|
+
optionsToReturn.searchedValue = search;
|
|
483
|
+
if ("startNode" in optionsToReturn) {
|
|
484
|
+
optionsToReturn.StartNodeID = optionsToReturn.startNode;
|
|
485
|
+
delete optionsToReturn.startNode;
|
|
486
|
+
}
|
|
480
487
|
}
|
|
481
488
|
else
|
|
482
489
|
return options;
|
|
490
|
+
return optionsToReturn;
|
|
483
491
|
}
|
|
484
492
|
translateDataForTree(dataToLoad, searchID = null, searched = null) {
|
|
485
493
|
if (searched && searched != "") {
|
|
@@ -492,7 +500,7 @@ export class HierarchizedPickerComponent {
|
|
|
492
500
|
loadSearchDataInCurrentTree(searchID, searched) {
|
|
493
501
|
let displayResults = (newtree) => {
|
|
494
502
|
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) {
|
|
495
|
-
this.rawDataManager.mergeData(newtree);
|
|
503
|
+
this.rawDataManager.mergeData(newtree, this.theOptions.origin == 'classification' ? "ID" : "key");
|
|
496
504
|
newtree.children.forEach((value, index) => {
|
|
497
505
|
completeCurrentTreeWithTree(this.loadedTreeJs, value, this.optionsManager.getOptions());
|
|
498
506
|
});
|
|
@@ -514,9 +522,7 @@ export class HierarchizedPickerComponent {
|
|
|
514
522
|
if (this.theOptions.source == 'webservice') {
|
|
515
523
|
if (this.theOptions.origin == 'classification') {
|
|
516
524
|
// WS Call
|
|
517
|
-
this.rawDataManager.getFromClassification(this.getApiSearchURL(), {
|
|
518
|
-
searchedValue: searched
|
|
519
|
-
})
|
|
525
|
+
this.rawDataManager.getFromClassification(this.getApiSearchURL(), Object.assign({}, this.getContextualApiParams(searched)), document.querySelector("#hierarchized-picker-" + this.componentID + ".loader"))
|
|
520
526
|
.then((data) => {
|
|
521
527
|
displayResults(data);
|
|
522
528
|
if (!searched) {
|
|
@@ -535,7 +541,7 @@ export class HierarchizedPickerComponent {
|
|
|
535
541
|
searchedValue: searched,
|
|
536
542
|
searchNameOnly: true,
|
|
537
543
|
deprecated: false,
|
|
538
|
-
})
|
|
544
|
+
}, document.querySelector("#hierarchized-picker-" + this.componentID + ".loader"))
|
|
539
545
|
.then((data) => {
|
|
540
546
|
displayResults(data);
|
|
541
547
|
if (!searched) {
|
|
@@ -665,19 +671,24 @@ export class HierarchizedPickerComponent {
|
|
|
665
671
|
// ----- BEGIN -----
|
|
666
672
|
let node = treeToUpdate.nodesById[id];
|
|
667
673
|
let onChange = treeToUpdate.options.onChange;
|
|
668
|
-
if (!node
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
674
|
+
if (!node) {
|
|
675
|
+
this.logError("The current selected value is not part of the loaded tree!");
|
|
676
|
+
}
|
|
677
|
+
else {
|
|
678
|
+
if (!node.disabled) {
|
|
679
|
+
treeToUpdate.setValue(id);
|
|
680
|
+
treeToUpdate.updateLiElements();
|
|
681
|
+
}
|
|
682
|
+
userClick && onChange && onChange.call(treeToUpdate);
|
|
683
|
+
// ------ END ------
|
|
684
|
+
if (this.setValueOnClick) {
|
|
685
|
+
this.editValue(node, userClick);
|
|
686
|
+
if (this.shownTree && userClick) {
|
|
687
|
+
// TODO > is this required ?
|
|
688
|
+
// await focusMainInput(this);
|
|
689
|
+
if (!this.optionsManager.getOptions().multiple) {
|
|
690
|
+
this.showTree('hide');
|
|
691
|
+
}
|
|
681
692
|
}
|
|
682
693
|
}
|
|
683
694
|
}
|
|
@@ -810,6 +821,7 @@ export class HierarchizedPickerComponent {
|
|
|
810
821
|
}
|
|
811
822
|
// Search a value in the tree and triggers a search when necessary
|
|
812
823
|
search(searched) {
|
|
824
|
+
this.loader.classList.add('loading');
|
|
813
825
|
let searchinput = document.querySelector('#hierarchized-picker-' + this.componentID + ' .hierarchized-picker-search input');
|
|
814
826
|
if (this.optionsManager.getOptions().mode == 'input' && searchinput) {
|
|
815
827
|
searchinput.classList.remove('fieldError');
|
|
@@ -846,6 +858,7 @@ export class HierarchizedPickerComponent {
|
|
|
846
858
|
// this.checkFields(this.value, false);
|
|
847
859
|
this.setSearchResults([]);
|
|
848
860
|
}
|
|
861
|
+
this.loader.classList.remove('loading');
|
|
849
862
|
}
|
|
850
863
|
// Refresh the tree with search results
|
|
851
864
|
triggerSearch(searched) {
|
|
@@ -864,7 +877,9 @@ export class HierarchizedPickerComponent {
|
|
|
864
877
|
loadDataForTree(init, loader) {
|
|
865
878
|
if (this.optionsManager.getOptions().source == 'webservice') {
|
|
866
879
|
if (this.optionsManager.getOptions().origin == 'classification') {
|
|
867
|
-
|
|
880
|
+
const contextualApiParams = this.getContextualApiParams();
|
|
881
|
+
const contextualApiURL = this.getContextualApiURL();
|
|
882
|
+
this.rawDataManager.getFromClassification(contextualApiURL, contextualApiParams, loader).then((data) => {
|
|
868
883
|
this.rawData = data;
|
|
869
884
|
if (init) {
|
|
870
885
|
this.formatDefaultValue();
|
|
@@ -1120,6 +1135,24 @@ export class HierarchizedPickerComponent {
|
|
|
1120
1135
|
},
|
|
1121
1136
|
"attribute": "newfilter",
|
|
1122
1137
|
"reflect": false
|
|
1138
|
+
},
|
|
1139
|
+
"activatedDragAndDrop": {
|
|
1140
|
+
"type": "boolean",
|
|
1141
|
+
"mutable": false,
|
|
1142
|
+
"complexType": {
|
|
1143
|
+
"original": "boolean",
|
|
1144
|
+
"resolved": "boolean",
|
|
1145
|
+
"references": {}
|
|
1146
|
+
},
|
|
1147
|
+
"required": false,
|
|
1148
|
+
"optional": false,
|
|
1149
|
+
"docs": {
|
|
1150
|
+
"tags": [],
|
|
1151
|
+
"text": ""
|
|
1152
|
+
},
|
|
1153
|
+
"attribute": "activated-drag-and-drop",
|
|
1154
|
+
"reflect": false,
|
|
1155
|
+
"defaultValue": "true"
|
|
1123
1156
|
}
|
|
1124
1157
|
};
|
|
1125
1158
|
}
|
|
@@ -207,9 +207,11 @@ Tree.prototype.bindEvent = function (ele) {
|
|
|
207
207
|
// If source is webservice (it shouldn't be something else)
|
|
208
208
|
if (this.options.parentApi.theOptions.source == 'webservice') {
|
|
209
209
|
if (this.options.parentApi.theOptions.origin == 'classification') {
|
|
210
|
+
const contextualApiParams = this.options.parentApi.getContextualApiParams(Object.assign(Object.assign({}, this.options.parentApi.theOptions.options), { startNode: target.parentNode.nodeId }));
|
|
211
|
+
const contextualApiURL = this.options.parentApi.getContextualApiURL();
|
|
210
212
|
// WS Call
|
|
211
213
|
this.options.rawDataManager
|
|
212
|
-
.getFromClassification(
|
|
214
|
+
.getFromClassification(contextualApiURL, contextualApiParams, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + ".loader"))
|
|
213
215
|
.then(data => {
|
|
214
216
|
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
215
217
|
});
|
|
@@ -221,7 +223,7 @@ Tree.prototype.bindEvent = function (ele) {
|
|
|
221
223
|
StartNodeID: target.parentNode.nodeId,
|
|
222
224
|
lng: this.options.parentApi.theOptions.options.lng,
|
|
223
225
|
IsDeprecated: this.options.parentApi.theOptions.options.IsDeprecated,
|
|
224
|
-
})
|
|
226
|
+
}, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + ".loader"))
|
|
225
227
|
.then(data => {
|
|
226
228
|
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
227
229
|
});
|
|
@@ -545,19 +547,19 @@ Tree.prototype.createLiEle = function (node, closed) {
|
|
|
545
547
|
if (this.options.parentApi.theOptions.dragAndDropEnabled) {
|
|
546
548
|
li.setAttribute('draggable', 'true');
|
|
547
549
|
li.addEventListener('dragstart', e => {
|
|
548
|
-
onItemDragStart(li, e);
|
|
550
|
+
onItemDragStart(li, e, this.options.parentApi.activatedDragAndDrop);
|
|
549
551
|
});
|
|
550
552
|
li.addEventListener('dragend', e => {
|
|
551
|
-
onItemDragEnd(li, e);
|
|
553
|
+
onItemDragEnd(li, e, this.options.parentApi.activatedDragAndDrop);
|
|
552
554
|
});
|
|
553
555
|
li.addEventListener('dragover', e => {
|
|
554
|
-
onItemDragOver(li, e);
|
|
556
|
+
onItemDragOver(li, e, this.options.parentApi.activatedDragAndDrop);
|
|
555
557
|
});
|
|
556
558
|
li.addEventListener('dragleave', e => {
|
|
557
|
-
onItemDragLeave(li, e);
|
|
559
|
+
onItemDragLeave(li, e, this.options.parentApi.activatedDragAndDrop);
|
|
558
560
|
});
|
|
559
561
|
li.addEventListener('drop', e => {
|
|
560
|
-
onItemDrop(li, e, (dragEl, dropEl, position) => {
|
|
562
|
+
onItemDrop(li, e, this.options.parentApi.activatedDragAndDrop, (dragEl, dropEl, position) => {
|
|
561
563
|
this.options.parentApi.itemDropped.emit({ dragEl, dropEl, position });
|
|
562
564
|
});
|
|
563
565
|
});
|
|
@@ -45,4 +45,10 @@ export class OptionsManager {
|
|
|
45
45
|
delete this.options.defaultValue;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
+
// This method is pretty ugly and shouldn't have to be called, but temporarily works until a better solution is set
|
|
49
|
+
dropReach() {
|
|
50
|
+
if (this.options.options && this.options.options.Reach) {
|
|
51
|
+
delete this.options.options.Reach;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
48
54
|
}
|
|
@@ -62,7 +62,7 @@ export class RawDataManager {
|
|
|
62
62
|
continue;
|
|
63
63
|
const value = options[key];
|
|
64
64
|
const lowerKey = key.toLowerCase();
|
|
65
|
-
if ((lowerKey === 'startnode'
|
|
65
|
+
if ((lowerKey === 'startnode') && !pathSegment) {
|
|
66
66
|
pathSegment = encodeURIComponent(value);
|
|
67
67
|
continue; // Skip adding this to the query string
|
|
68
68
|
}
|
|
@@ -149,8 +149,16 @@ export class RawDataManager {
|
|
|
149
149
|
* Merge new data into the existing data.
|
|
150
150
|
* @param newData New data to merge.
|
|
151
151
|
*/
|
|
152
|
-
mergeData(newData) {
|
|
153
|
-
|
|
152
|
+
mergeData(newData, idKey) {
|
|
153
|
+
if (!this.rawData)
|
|
154
|
+
this.rawData = newData;
|
|
155
|
+
else {
|
|
156
|
+
this.rawData = this.genericMerge(this.rawData, newData, idKey, 'children');
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
reorderItems(referenceArray, toReorderArray, idKey) {
|
|
160
|
+
const idMap = new Map(toReorderArray.map(item => [item[idKey], item]));
|
|
161
|
+
return referenceArray.map(refItem => idMap.get(refItem[idKey])).filter(Boolean);
|
|
154
162
|
}
|
|
155
163
|
/**
|
|
156
164
|
* Generic merge method.
|
|
@@ -166,9 +174,11 @@ export class RawDataManager {
|
|
|
166
174
|
}
|
|
167
175
|
if (!toAdd || !((_a = toAdd[childrenKey]) === null || _a === void 0 ? void 0 : _a.length))
|
|
168
176
|
return source;
|
|
177
|
+
if (source[childrenKey] && source[childrenKey].length > 0 && toAdd[childrenKey] && toAdd[childrenKey].length > 0)
|
|
178
|
+
toAdd[childrenKey] = this.reorderItems(source[childrenKey], toAdd[childrenKey], idKey);
|
|
169
179
|
source[childrenKey] = ((_b = source[childrenKey]) === null || _b === void 0 ? void 0 : _b.length)
|
|
170
180
|
? source[childrenKey].map((child, index) => {
|
|
171
|
-
return this.genericMerge(child, toAdd[childrenKey].filter(item => item.key == child.key)[
|
|
181
|
+
return this.genericMerge(child, toAdd[childrenKey].filter(item => item.key == child.key)[index], idKey, childrenKey);
|
|
172
182
|
})
|
|
173
183
|
: toAdd[childrenKey];
|
|
174
184
|
return source;
|