reneco-hierarchized-picker 0.4.2-beta.14 → 0.4.2-beta.16
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/reneco-hierarchized-picker_2.cjs.entry.js +85 -44
- package/dist/collection/components/hierarchized-picker/hierarchized-picker.js +52 -28
- package/dist/collection/components/treejs/index.js +4 -2
- package/dist/collection/core/options-manager.js +6 -0
- package/dist/collection/core/raw-data-manager.js +14 -4
- package/dist/collection/features/tree/tree-utils.js +10 -11
- package/dist/custom-elements/index.js +85 -44
- package/dist/esm/reneco-hierarchized-picker_2.entry.js +85 -44
- package/dist/esm-es5/reneco-hierarchized-picker_2.entry.js +1 -1
- package/dist/reneco-hierarchized-picker/p-63a1c308.entry.js +1 -0
- package/dist/reneco-hierarchized-picker/p-73168a50.system.js +1 -1
- package/dist/reneco-hierarchized-picker/p-f82237e2.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 +1 -1
- package/dist/types/core/options-manager.d.ts +1 -0
- package/dist/types/core/raw-data-manager.d.ts +2 -1
- package/package.json +1 -1
- package/dist/reneco-hierarchized-picker/p-30588b47.system.entry.js +0 -3
- package/dist/reneco-hierarchized-picker/p-73cf2467.entry.js +0 -1
|
@@ -339,9 +339,11 @@ Tree.prototype.bindEvent = function (ele) {
|
|
|
339
339
|
// If source is webservice (it shouldn't be something else)
|
|
340
340
|
if (this.options.parentApi.theOptions.source == 'webservice') {
|
|
341
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();
|
|
342
344
|
// WS Call
|
|
343
345
|
this.options.rawDataManager
|
|
344
|
-
.getFromClassification(
|
|
346
|
+
.getFromClassification(contextualApiURL, contextualApiParams, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + ".loader"))
|
|
345
347
|
.then(data => {
|
|
346
348
|
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
347
349
|
});
|
|
@@ -643,7 +645,7 @@ Tree.prototype.createUlEle = function () {
|
|
|
643
645
|
Tree.prototype.createLiEle = function (node, closed) {
|
|
644
646
|
const li = document.createElement('li');
|
|
645
647
|
li.classList.add('treejs-node');
|
|
646
|
-
if (node.deprecated) {
|
|
648
|
+
if (node.deprecated || node.Is_Deprecated) {
|
|
647
649
|
li.classList.add('treejs-node__deprecated');
|
|
648
650
|
}
|
|
649
651
|
if (node.isDesaturated) {
|
|
@@ -18192,7 +18194,7 @@ class RawDataManager {
|
|
|
18192
18194
|
continue;
|
|
18193
18195
|
const value = options[key];
|
|
18194
18196
|
const lowerKey = key.toLowerCase();
|
|
18195
|
-
if ((lowerKey === 'startnode'
|
|
18197
|
+
if ((lowerKey === 'startnode') && !pathSegment) {
|
|
18196
18198
|
pathSegment = encodeURIComponent(value);
|
|
18197
18199
|
continue; // Skip adding this to the query string
|
|
18198
18200
|
}
|
|
@@ -18279,8 +18281,16 @@ class RawDataManager {
|
|
|
18279
18281
|
* Merge new data into the existing data.
|
|
18280
18282
|
* @param newData New data to merge.
|
|
18281
18283
|
*/
|
|
18282
|
-
mergeData(newData) {
|
|
18283
|
-
|
|
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);
|
|
18284
18294
|
}
|
|
18285
18295
|
/**
|
|
18286
18296
|
* Generic merge method.
|
|
@@ -18296,9 +18306,11 @@ class RawDataManager {
|
|
|
18296
18306
|
}
|
|
18297
18307
|
if (!toAdd || !((_a = toAdd[childrenKey]) === null || _a === void 0 ? void 0 : _a.length))
|
|
18298
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);
|
|
18299
18311
|
source[childrenKey] = ((_b = source[childrenKey]) === null || _b === void 0 ? void 0 : _b.length)
|
|
18300
18312
|
? source[childrenKey].map((child, index) => {
|
|
18301
|
-
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);
|
|
18302
18314
|
})
|
|
18303
18315
|
: toAdd[childrenKey];
|
|
18304
18316
|
return source;
|
|
@@ -18368,6 +18380,12 @@ class OptionsManager {
|
|
|
18368
18380
|
delete this.options.defaultValue;
|
|
18369
18381
|
}
|
|
18370
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
|
+
}
|
|
18371
18389
|
}
|
|
18372
18390
|
|
|
18373
18391
|
/**
|
|
@@ -18422,7 +18440,7 @@ function fillTreeWithObject(tree, myObject, searched, options, depth = 0) {
|
|
|
18422
18440
|
const searchResultPresentsUnMatched = options.searchResultPresentsUnMatched;
|
|
18423
18441
|
if (myObject && myObject.length) {
|
|
18424
18442
|
myObject.forEach(value => {
|
|
18425
|
-
var _a, _b, _c, _d
|
|
18443
|
+
var _a, _b, _c, _d;
|
|
18426
18444
|
let keyPropFromNode = null;
|
|
18427
18445
|
let valueTranslatedPropFromNode = null;
|
|
18428
18446
|
let fullpathPropFromNode = null;
|
|
@@ -18430,15 +18448,12 @@ function fillTreeWithObject(tree, myObject, searched, options, depth = 0) {
|
|
|
18430
18448
|
if (options.origin == "classification") {
|
|
18431
18449
|
keyPropFromNode = getPropertyFromNode(value, 'ID');
|
|
18432
18450
|
valueTranslatedPropFromNode = (_a = getPropertyFromNode(value, 'Translations')[options.language]) === null || _a === void 0 ? void 0 : _a.translated_name;
|
|
18433
|
-
|
|
18434
|
-
|
|
18435
|
-
|
|
18436
|
-
|
|
18437
|
-
|
|
18438
|
-
|
|
18439
|
-
fullpathPropFromNode = (_d = getPropertyFromNode(value, 'Properties')) === null || _d === void 0 ? void 0 : _d.System_Fullpath;
|
|
18440
|
-
fullpathTranslatedPropFromNode = (_e = getPropertyFromNode(value, 'Translations')[options.language]) === null || _e === void 0 ? void 0 : _e.translated_fullpath;
|
|
18441
|
-
}
|
|
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;
|
|
18453
|
+
if (!fullpathPropFromNode)
|
|
18454
|
+
fullpathPropFromNode = (_d = getPropertyFromNode(value, 'Properties')) === null || _d === void 0 ? void 0 : _d.System_FullPath;
|
|
18455
|
+
if (!fullpathTranslatedPropFromNode)
|
|
18456
|
+
fullpathTranslatedPropFromNode = getPropertyFromNode(value, 'fullpathTranslated');
|
|
18442
18457
|
}
|
|
18443
18458
|
else {
|
|
18444
18459
|
keyPropFromNode = getPropertyFromNode(value, 'key');
|
|
@@ -18447,7 +18462,9 @@ function fillTreeWithObject(tree, myObject, searched, options, depth = 0) {
|
|
|
18447
18462
|
fullpathTranslatedPropFromNode = getPropertyFromNode(value, 'fullpathTranslated');
|
|
18448
18463
|
}
|
|
18449
18464
|
const childrenPropFromNode = getPropertyFromNode(value, 'children', false);
|
|
18450
|
-
|
|
18465
|
+
let deprecated = getPropertyFromNode(value, 'deprecated', null);
|
|
18466
|
+
if (deprecated === null)
|
|
18467
|
+
deprecated = getPropertyFromNode(value, 'Is_Deprecated', false);
|
|
18451
18468
|
const objToPush = {
|
|
18452
18469
|
id: keyPropFromNode,
|
|
18453
18470
|
nodeId: keyPropFromNode,
|
|
@@ -19110,9 +19127,15 @@ const HierarchizedPickerComponent = class {
|
|
|
19110
19127
|
}
|
|
19111
19128
|
getApiSearchURL() {
|
|
19112
19129
|
if (this.optionsManager.getOptions().origin == 'classification') {
|
|
19113
|
-
|
|
19114
|
-
|
|
19115
|
-
|
|
19130
|
+
const baseURL = this.optionsManager.getOptions().url;
|
|
19131
|
+
if (baseURL.indexOf("getTree") > -1) {
|
|
19132
|
+
return baseURL.replace("/getTree/", "/search/");
|
|
19133
|
+
}
|
|
19134
|
+
else {
|
|
19135
|
+
let substringUpToLastSlash = this.optionsManager.getOptions().url.substring(0, this.optionsManager.getOptions().url.lastIndexOf('/'));
|
|
19136
|
+
let context = substringUpToLastSlash.substring(substringUpToLastSlash.lastIndexOf('/'), substringUpToLastSlash.length);
|
|
19137
|
+
return substringUpToLastSlash.substring(0, substringUpToLastSlash.lastIndexOf('/')) + '/search' + context;
|
|
19138
|
+
}
|
|
19116
19139
|
}
|
|
19117
19140
|
else {
|
|
19118
19141
|
return this.optionsManager.getOptions().url.substring(0, this.optionsManager.getOptions().url.lastIndexOf('/')) + '/GetTreeFromSearch';
|
|
@@ -19127,15 +19150,16 @@ const HierarchizedPickerComponent = class {
|
|
|
19127
19150
|
const pathSegments = parsedUrl.pathname.split('/');
|
|
19128
19151
|
const dynamicType = pathSegments[pathSegments.length - 2];
|
|
19129
19152
|
const newPathname = `/api/v1/classification/reach/${dynamicType}/${options.Reach}`;
|
|
19153
|
+
this.optionsManager.dropReach();
|
|
19130
19154
|
return `${parsedUrl.origin}${newPathname}`;
|
|
19131
19155
|
}
|
|
19132
19156
|
return url;
|
|
19133
19157
|
}
|
|
19134
|
-
getContextualApiParams(options = null) {
|
|
19158
|
+
getContextualApiParams(options = null, search = null) {
|
|
19135
19159
|
if (!options)
|
|
19136
19160
|
options = this.optionsManager.getOptions().options;
|
|
19161
|
+
let optionsToReturn = Object.assign({}, options);
|
|
19137
19162
|
if (options.Reach) {
|
|
19138
|
-
let optionsToReturn = Object.assign({}, options);
|
|
19139
19163
|
delete optionsToReturn.Reach;
|
|
19140
19164
|
if ("startNode" in optionsToReturn) {
|
|
19141
19165
|
optionsToReturn.startingnode = optionsToReturn.startNode;
|
|
@@ -19145,10 +19169,15 @@ const HierarchizedPickerComponent = class {
|
|
|
19145
19169
|
optionsToReturn.startingnode = optionsToReturn.StartNodeID;
|
|
19146
19170
|
delete optionsToReturn.StartNodeID;
|
|
19147
19171
|
}
|
|
19148
|
-
return optionsToReturn;
|
|
19149
19172
|
}
|
|
19150
|
-
else
|
|
19151
|
-
|
|
19173
|
+
else if (search) {
|
|
19174
|
+
optionsToReturn.searchedValue = search;
|
|
19175
|
+
if ("startNode" in optionsToReturn) {
|
|
19176
|
+
optionsToReturn.StartNodeID = optionsToReturn.startNode;
|
|
19177
|
+
delete optionsToReturn.startNode;
|
|
19178
|
+
}
|
|
19179
|
+
}
|
|
19180
|
+
return optionsToReturn;
|
|
19152
19181
|
}
|
|
19153
19182
|
translateDataForTree(dataToLoad, searchID = null, searched = null) {
|
|
19154
19183
|
if (searched && searched != "") {
|
|
@@ -19161,7 +19190,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19161
19190
|
loadSearchDataInCurrentTree(searchID, searched) {
|
|
19162
19191
|
let displayResults = (newtree) => {
|
|
19163
19192
|
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) {
|
|
19164
|
-
this.rawDataManager.mergeData(newtree);
|
|
19193
|
+
this.rawDataManager.mergeData(newtree, this.theOptions.origin == 'classification' ? "ID" : "key");
|
|
19165
19194
|
newtree.children.forEach((value, index) => {
|
|
19166
19195
|
completeCurrentTreeWithTree(this.loadedTreeJs, value, this.optionsManager.getOptions());
|
|
19167
19196
|
});
|
|
@@ -19183,9 +19212,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19183
19212
|
if (this.theOptions.source == 'webservice') {
|
|
19184
19213
|
if (this.theOptions.origin == 'classification') {
|
|
19185
19214
|
// WS Call
|
|
19186
|
-
this.rawDataManager.getFromClassification(this.getApiSearchURL(), {
|
|
19187
|
-
searchedValue: searched
|
|
19188
|
-
}, document.querySelector("#hierarchized-picker-" + this.componentID + ".loader"))
|
|
19215
|
+
this.rawDataManager.getFromClassification(this.getApiSearchURL(), Object.assign({}, this.getContextualApiParams(null, searched)), document.querySelector("#hierarchized-picker-" + this.componentID + ".loader"))
|
|
19189
19216
|
.then((data) => {
|
|
19190
19217
|
displayResults(data);
|
|
19191
19218
|
if (!searched) {
|
|
@@ -19334,19 +19361,24 @@ const HierarchizedPickerComponent = class {
|
|
|
19334
19361
|
// ----- BEGIN -----
|
|
19335
19362
|
let node = treeToUpdate.nodesById[id];
|
|
19336
19363
|
let onChange = treeToUpdate.options.onChange;
|
|
19337
|
-
if (!node
|
|
19338
|
-
|
|
19339
|
-
treeToUpdate.updateLiElements();
|
|
19364
|
+
if (!node) {
|
|
19365
|
+
this.logError("The current selected value is not part of the loaded tree!");
|
|
19340
19366
|
}
|
|
19341
|
-
|
|
19342
|
-
|
|
19343
|
-
|
|
19344
|
-
|
|
19345
|
-
|
|
19346
|
-
|
|
19347
|
-
|
|
19348
|
-
|
|
19349
|
-
|
|
19367
|
+
else {
|
|
19368
|
+
if (!node.disabled) {
|
|
19369
|
+
treeToUpdate.setValue(id);
|
|
19370
|
+
treeToUpdate.updateLiElements();
|
|
19371
|
+
}
|
|
19372
|
+
userClick && onChange && onChange.call(treeToUpdate);
|
|
19373
|
+
// ------ END ------
|
|
19374
|
+
if (this.setValueOnClick) {
|
|
19375
|
+
this.editValue(node, userClick);
|
|
19376
|
+
if (this.shownTree && userClick) {
|
|
19377
|
+
// TODO > is this required ?
|
|
19378
|
+
// await focusMainInput(this);
|
|
19379
|
+
if (!this.optionsManager.getOptions().multiple) {
|
|
19380
|
+
this.showTree('hide');
|
|
19381
|
+
}
|
|
19350
19382
|
}
|
|
19351
19383
|
}
|
|
19352
19384
|
}
|
|
@@ -19425,6 +19457,11 @@ const HierarchizedPickerComponent = class {
|
|
|
19425
19457
|
if (this.hasFocus.indexOf('hide') > -1 && !isStillInsidePicker) {
|
|
19426
19458
|
this.hasFocus = [];
|
|
19427
19459
|
}
|
|
19460
|
+
else {
|
|
19461
|
+
if (!this.shownTree && this.theOptions.loading == 'click' && !this.ready) {
|
|
19462
|
+
this.loadDataForTree(true, document.querySelector("#hierarchized-picker-" + this.componentID + ".loader"));
|
|
19463
|
+
}
|
|
19464
|
+
}
|
|
19428
19465
|
const previousShownTree = this.shownTree;
|
|
19429
19466
|
this.shownTree = this.hasFocus.length > 0;
|
|
19430
19467
|
if (this.shownTree && !previousShownTree) {
|
|
@@ -19473,12 +19510,13 @@ const HierarchizedPickerComponent = class {
|
|
|
19473
19510
|
if (!value)
|
|
19474
19511
|
value = this.value;
|
|
19475
19512
|
this.displayedValue = value.map(item => {
|
|
19476
|
-
var _a
|
|
19477
|
-
return (
|
|
19513
|
+
var _a;
|
|
19514
|
+
return (_a = (this.optionsManager.getOptions().isFullpath ? item.fullpathTranslated : item.shortpathTranslated)) !== null && _a !== void 0 ? _a : `Node ${item.nodeid}`;
|
|
19478
19515
|
}).join(';');
|
|
19479
19516
|
}
|
|
19480
19517
|
// Search a value in the tree and triggers a search when necessary
|
|
19481
19518
|
search(searched) {
|
|
19519
|
+
this.loader.classList.add('loading');
|
|
19482
19520
|
let searchinput = document.querySelector('#hierarchized-picker-' + this.componentID + ' .hierarchized-picker-search input');
|
|
19483
19521
|
if (this.optionsManager.getOptions().mode == 'input' && searchinput) {
|
|
19484
19522
|
searchinput.classList.remove('fieldError');
|
|
@@ -19515,6 +19553,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19515
19553
|
// this.checkFields(this.value, false);
|
|
19516
19554
|
this.setSearchResults([]);
|
|
19517
19555
|
}
|
|
19556
|
+
this.loader.classList.remove('loading');
|
|
19518
19557
|
}
|
|
19519
19558
|
// Refresh the tree with search results
|
|
19520
19559
|
triggerSearch(searched) {
|
|
@@ -19533,7 +19572,9 @@ const HierarchizedPickerComponent = class {
|
|
|
19533
19572
|
loadDataForTree(init, loader) {
|
|
19534
19573
|
if (this.optionsManager.getOptions().source == 'webservice') {
|
|
19535
19574
|
if (this.optionsManager.getOptions().origin == 'classification') {
|
|
19536
|
-
|
|
19575
|
+
const contextualApiParams = this.getContextualApiParams();
|
|
19576
|
+
const contextualApiURL = this.getContextualApiURL();
|
|
19577
|
+
this.rawDataManager.getFromClassification(contextualApiURL, contextualApiParams, loader).then((data) => {
|
|
19537
19578
|
this.rawData = data;
|
|
19538
19579
|
if (init) {
|
|
19539
19580
|
this.formatDefaultValue();
|
|
@@ -442,9 +442,15 @@ export class HierarchizedPickerComponent {
|
|
|
442
442
|
}
|
|
443
443
|
getApiSearchURL() {
|
|
444
444
|
if (this.optionsManager.getOptions().origin == 'classification') {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
445
|
+
const baseURL = this.optionsManager.getOptions().url;
|
|
446
|
+
if (baseURL.indexOf("getTree") > -1) {
|
|
447
|
+
return baseURL.replace("/getTree/", "/search/");
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
let substringUpToLastSlash = this.optionsManager.getOptions().url.substring(0, this.optionsManager.getOptions().url.lastIndexOf('/'));
|
|
451
|
+
let context = substringUpToLastSlash.substring(substringUpToLastSlash.lastIndexOf('/'), substringUpToLastSlash.length);
|
|
452
|
+
return substringUpToLastSlash.substring(0, substringUpToLastSlash.lastIndexOf('/')) + '/search' + context;
|
|
453
|
+
}
|
|
448
454
|
}
|
|
449
455
|
else {
|
|
450
456
|
return this.optionsManager.getOptions().url.substring(0, this.optionsManager.getOptions().url.lastIndexOf('/')) + '/GetTreeFromSearch';
|
|
@@ -459,15 +465,16 @@ export class HierarchizedPickerComponent {
|
|
|
459
465
|
const pathSegments = parsedUrl.pathname.split('/');
|
|
460
466
|
const dynamicType = pathSegments[pathSegments.length - 2];
|
|
461
467
|
const newPathname = `/api/v1/classification/reach/${dynamicType}/${options.Reach}`;
|
|
468
|
+
this.optionsManager.dropReach();
|
|
462
469
|
return `${parsedUrl.origin}${newPathname}`;
|
|
463
470
|
}
|
|
464
471
|
return url;
|
|
465
472
|
}
|
|
466
|
-
getContextualApiParams(options = null) {
|
|
473
|
+
getContextualApiParams(options = null, search = null) {
|
|
467
474
|
if (!options)
|
|
468
475
|
options = this.optionsManager.getOptions().options;
|
|
476
|
+
let optionsToReturn = Object.assign({}, options);
|
|
469
477
|
if (options.Reach) {
|
|
470
|
-
let optionsToReturn = Object.assign({}, options);
|
|
471
478
|
delete optionsToReturn.Reach;
|
|
472
479
|
if ("startNode" in optionsToReturn) {
|
|
473
480
|
optionsToReturn.startingnode = optionsToReturn.startNode;
|
|
@@ -477,10 +484,15 @@ export class HierarchizedPickerComponent {
|
|
|
477
484
|
optionsToReturn.startingnode = optionsToReturn.StartNodeID;
|
|
478
485
|
delete optionsToReturn.StartNodeID;
|
|
479
486
|
}
|
|
480
|
-
return optionsToReturn;
|
|
481
487
|
}
|
|
482
|
-
else
|
|
483
|
-
|
|
488
|
+
else if (search) {
|
|
489
|
+
optionsToReturn.searchedValue = search;
|
|
490
|
+
if ("startNode" in optionsToReturn) {
|
|
491
|
+
optionsToReturn.StartNodeID = optionsToReturn.startNode;
|
|
492
|
+
delete optionsToReturn.startNode;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
return optionsToReturn;
|
|
484
496
|
}
|
|
485
497
|
translateDataForTree(dataToLoad, searchID = null, searched = null) {
|
|
486
498
|
if (searched && searched != "") {
|
|
@@ -493,7 +505,7 @@ export class HierarchizedPickerComponent {
|
|
|
493
505
|
loadSearchDataInCurrentTree(searchID, searched) {
|
|
494
506
|
let displayResults = (newtree) => {
|
|
495
507
|
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) {
|
|
496
|
-
this.rawDataManager.mergeData(newtree);
|
|
508
|
+
this.rawDataManager.mergeData(newtree, this.theOptions.origin == 'classification' ? "ID" : "key");
|
|
497
509
|
newtree.children.forEach((value, index) => {
|
|
498
510
|
completeCurrentTreeWithTree(this.loadedTreeJs, value, this.optionsManager.getOptions());
|
|
499
511
|
});
|
|
@@ -515,9 +527,7 @@ export class HierarchizedPickerComponent {
|
|
|
515
527
|
if (this.theOptions.source == 'webservice') {
|
|
516
528
|
if (this.theOptions.origin == 'classification') {
|
|
517
529
|
// WS Call
|
|
518
|
-
this.rawDataManager.getFromClassification(this.getApiSearchURL(), {
|
|
519
|
-
searchedValue: searched
|
|
520
|
-
}, document.querySelector("#hierarchized-picker-" + this.componentID + ".loader"))
|
|
530
|
+
this.rawDataManager.getFromClassification(this.getApiSearchURL(), Object.assign({}, this.getContextualApiParams(null, searched)), document.querySelector("#hierarchized-picker-" + this.componentID + ".loader"))
|
|
521
531
|
.then((data) => {
|
|
522
532
|
displayResults(data);
|
|
523
533
|
if (!searched) {
|
|
@@ -666,19 +676,24 @@ export class HierarchizedPickerComponent {
|
|
|
666
676
|
// ----- BEGIN -----
|
|
667
677
|
let node = treeToUpdate.nodesById[id];
|
|
668
678
|
let onChange = treeToUpdate.options.onChange;
|
|
669
|
-
if (!node
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
679
|
+
if (!node) {
|
|
680
|
+
this.logError("The current selected value is not part of the loaded tree!");
|
|
681
|
+
}
|
|
682
|
+
else {
|
|
683
|
+
if (!node.disabled) {
|
|
684
|
+
treeToUpdate.setValue(id);
|
|
685
|
+
treeToUpdate.updateLiElements();
|
|
686
|
+
}
|
|
687
|
+
userClick && onChange && onChange.call(treeToUpdate);
|
|
688
|
+
// ------ END ------
|
|
689
|
+
if (this.setValueOnClick) {
|
|
690
|
+
this.editValue(node, userClick);
|
|
691
|
+
if (this.shownTree && userClick) {
|
|
692
|
+
// TODO > is this required ?
|
|
693
|
+
// await focusMainInput(this);
|
|
694
|
+
if (!this.optionsManager.getOptions().multiple) {
|
|
695
|
+
this.showTree('hide');
|
|
696
|
+
}
|
|
682
697
|
}
|
|
683
698
|
}
|
|
684
699
|
}
|
|
@@ -757,6 +772,11 @@ export class HierarchizedPickerComponent {
|
|
|
757
772
|
if (this.hasFocus.indexOf('hide') > -1 && !isStillInsidePicker) {
|
|
758
773
|
this.hasFocus = [];
|
|
759
774
|
}
|
|
775
|
+
else {
|
|
776
|
+
if (!this.shownTree && this.theOptions.loading == 'click' && !this.ready) {
|
|
777
|
+
this.loadDataForTree(true, document.querySelector("#hierarchized-picker-" + this.componentID + ".loader"));
|
|
778
|
+
}
|
|
779
|
+
}
|
|
760
780
|
const previousShownTree = this.shownTree;
|
|
761
781
|
this.shownTree = this.hasFocus.length > 0;
|
|
762
782
|
if (this.shownTree && !previousShownTree) {
|
|
@@ -805,12 +825,13 @@ export class HierarchizedPickerComponent {
|
|
|
805
825
|
if (!value)
|
|
806
826
|
value = this.value;
|
|
807
827
|
this.displayedValue = value.map(item => {
|
|
808
|
-
var _a
|
|
809
|
-
return (
|
|
828
|
+
var _a;
|
|
829
|
+
return (_a = (this.optionsManager.getOptions().isFullpath ? item.fullpathTranslated : item.shortpathTranslated)) !== null && _a !== void 0 ? _a : `Node ${item.nodeid}`;
|
|
810
830
|
}).join(';');
|
|
811
831
|
}
|
|
812
832
|
// Search a value in the tree and triggers a search when necessary
|
|
813
833
|
search(searched) {
|
|
834
|
+
this.loader.classList.add('loading');
|
|
814
835
|
let searchinput = document.querySelector('#hierarchized-picker-' + this.componentID + ' .hierarchized-picker-search input');
|
|
815
836
|
if (this.optionsManager.getOptions().mode == 'input' && searchinput) {
|
|
816
837
|
searchinput.classList.remove('fieldError');
|
|
@@ -847,6 +868,7 @@ export class HierarchizedPickerComponent {
|
|
|
847
868
|
// this.checkFields(this.value, false);
|
|
848
869
|
this.setSearchResults([]);
|
|
849
870
|
}
|
|
871
|
+
this.loader.classList.remove('loading');
|
|
850
872
|
}
|
|
851
873
|
// Refresh the tree with search results
|
|
852
874
|
triggerSearch(searched) {
|
|
@@ -865,7 +887,9 @@ export class HierarchizedPickerComponent {
|
|
|
865
887
|
loadDataForTree(init, loader) {
|
|
866
888
|
if (this.optionsManager.getOptions().source == 'webservice') {
|
|
867
889
|
if (this.optionsManager.getOptions().origin == 'classification') {
|
|
868
|
-
|
|
890
|
+
const contextualApiParams = this.getContextualApiParams();
|
|
891
|
+
const contextualApiURL = this.getContextualApiURL();
|
|
892
|
+
this.rawDataManager.getFromClassification(contextualApiURL, contextualApiParams, loader).then((data) => {
|
|
869
893
|
this.rawData = data;
|
|
870
894
|
if (init) {
|
|
871
895
|
this.formatDefaultValue();
|
|
@@ -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
|
});
|
|
@@ -512,7 +514,7 @@ Tree.prototype.createLiEle = function (node, closed) {
|
|
|
512
514
|
const li = document.createElement('li');
|
|
513
515
|
;
|
|
514
516
|
li.classList.add('treejs-node');
|
|
515
|
-
if (node.deprecated) {
|
|
517
|
+
if (node.deprecated || node.Is_Deprecated) {
|
|
516
518
|
li.classList.add('treejs-node__deprecated');
|
|
517
519
|
}
|
|
518
520
|
if (node.isDesaturated) {
|
|
@@ -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;
|
|
@@ -51,7 +51,7 @@ export function fillTreeWithObject(tree, myObject, searched, options, depth = 0)
|
|
|
51
51
|
const searchResultPresentsUnMatched = options.searchResultPresentsUnMatched;
|
|
52
52
|
if (myObject && myObject.length) {
|
|
53
53
|
myObject.forEach(value => {
|
|
54
|
-
var _a, _b, _c, _d
|
|
54
|
+
var _a, _b, _c, _d;
|
|
55
55
|
let keyPropFromNode = null;
|
|
56
56
|
let valueTranslatedPropFromNode = null;
|
|
57
57
|
let fullpathPropFromNode = null;
|
|
@@ -59,15 +59,12 @@ export function fillTreeWithObject(tree, myObject, searched, options, depth = 0)
|
|
|
59
59
|
if (options.origin == "classification") {
|
|
60
60
|
keyPropFromNode = getPropertyFromNode(value, 'ID');
|
|
61
61
|
valueTranslatedPropFromNode = (_a = getPropertyFromNode(value, 'Translations')[options.language]) === null || _a === void 0 ? void 0 : _a.translated_name;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
fullpathPropFromNode = (_d = getPropertyFromNode(value, 'Properties')) === null || _d === void 0 ? void 0 : _d.System_Fullpath;
|
|
69
|
-
fullpathTranslatedPropFromNode = (_e = getPropertyFromNode(value, 'Translations')[options.language]) === null || _e === void 0 ? void 0 : _e.translated_fullpath;
|
|
70
|
-
}
|
|
62
|
+
fullpathPropFromNode = (_b = getPropertyFromNode(value, 'Properties')) === null || _b === void 0 ? void 0 : _b.System_Fullpath;
|
|
63
|
+
fullpathTranslatedPropFromNode = (_c = getPropertyFromNode(value, 'Translations')[options.language]) === null || _c === void 0 ? void 0 : _c.translated_fullpath;
|
|
64
|
+
if (!fullpathPropFromNode)
|
|
65
|
+
fullpathPropFromNode = (_d = getPropertyFromNode(value, 'Properties')) === null || _d === void 0 ? void 0 : _d.System_FullPath;
|
|
66
|
+
if (!fullpathTranslatedPropFromNode)
|
|
67
|
+
fullpathTranslatedPropFromNode = getPropertyFromNode(value, 'fullpathTranslated');
|
|
71
68
|
}
|
|
72
69
|
else {
|
|
73
70
|
keyPropFromNode = getPropertyFromNode(value, 'key');
|
|
@@ -76,7 +73,9 @@ export function fillTreeWithObject(tree, myObject, searched, options, depth = 0)
|
|
|
76
73
|
fullpathTranslatedPropFromNode = getPropertyFromNode(value, 'fullpathTranslated');
|
|
77
74
|
}
|
|
78
75
|
const childrenPropFromNode = getPropertyFromNode(value, 'children', false);
|
|
79
|
-
|
|
76
|
+
let deprecated = getPropertyFromNode(value, 'deprecated', null);
|
|
77
|
+
if (deprecated === null)
|
|
78
|
+
deprecated = getPropertyFromNode(value, 'Is_Deprecated', false);
|
|
80
79
|
const objToPush = {
|
|
81
80
|
id: keyPropFromNode,
|
|
82
81
|
nodeId: keyPropFromNode,
|