reneco-hierarchized-picker 0.3.0 → 0.3.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/reneco-hierarchized-picker.cjs.entry.js +66 -47
- package/dist/collection/components/hierarchized-picker/hierarchized-picker.js +65 -46
- package/dist/collection/components/hierarchized-picker/treejs/index.js +1 -1
- package/dist/custom-elements/index.js +66 -47
- package/dist/esm/reneco-hierarchized-picker.entry.js +66 -47
- package/dist/esm-es5/reneco-hierarchized-picker.entry.js +1 -1
- package/dist/reneco-hierarchized-picker/p-73168a50.system.js +1 -1
- package/dist/reneco-hierarchized-picker/p-8d4533d2.entry.js +1 -0
- package/dist/reneco-hierarchized-picker/p-ae8baa02.system.entry.js +3 -0
- package/dist/reneco-hierarchized-picker/reneco-hierarchized-picker.esm.js +1 -1
- package/package.json +1 -1
- package/dist/reneco-hierarchized-picker/p-b84f8fd8.system.entry.js +0 -3
- package/dist/reneco-hierarchized-picker/p-edf7ee87.entry.js +0 -1
|
@@ -235,7 +235,7 @@ Tree.prototype.bindEvent = function (ele) {
|
|
|
235
235
|
startNode: target.parentNode.nodeId
|
|
236
236
|
})
|
|
237
237
|
.then(data => {
|
|
238
|
-
this.options.parentApi.completeCurrentTreeWithTree(data
|
|
238
|
+
this.options.parentApi.completeCurrentTreeWithTree(data);
|
|
239
239
|
});
|
|
240
240
|
}
|
|
241
241
|
else {
|
|
@@ -18406,10 +18406,22 @@ const HierarchizedPickerComponent = class {
|
|
|
18406
18406
|
var _a;
|
|
18407
18407
|
let that = this;
|
|
18408
18408
|
(_a = this.loader) === null || _a === void 0 ? void 0 : _a.classList.add('loading');
|
|
18409
|
-
let targetURL = url
|
|
18410
|
-
//
|
|
18411
|
-
//
|
|
18409
|
+
let targetURL = url;
|
|
18410
|
+
// search:{
|
|
18411
|
+
// StartNodeID:72773,
|
|
18412
|
+
// lng:'en',
|
|
18413
|
+
// deprecated:0,
|
|
18414
|
+
// searchedValue:'Infectious'
|
|
18412
18415
|
// }
|
|
18416
|
+
if (options.search) {
|
|
18417
|
+
targetURL += '/?StartNodeID=' + options.search.StartNodeID;
|
|
18418
|
+
targetURL += '&lng=' + options.search.lng;
|
|
18419
|
+
targetURL += '&deprecated=' + options.search.deprecated;
|
|
18420
|
+
targetURL += '&searchedValue=' + options.search.searchedValue;
|
|
18421
|
+
}
|
|
18422
|
+
else {
|
|
18423
|
+
targetURL = targetURL + '/' + options.startNode;
|
|
18424
|
+
}
|
|
18413
18425
|
let getDataPromise = new Promise((resolve, reject) => {
|
|
18414
18426
|
this.getToken().then(token => {
|
|
18415
18427
|
let xhr = new browser();
|
|
@@ -18532,8 +18544,9 @@ const HierarchizedPickerComponent = class {
|
|
|
18532
18544
|
}
|
|
18533
18545
|
getApiSearchURL() {
|
|
18534
18546
|
if (this.theOptions.origin == 'classification') {
|
|
18535
|
-
|
|
18536
|
-
|
|
18547
|
+
let substringUpToLastSlash = this.theOptions.url.substring(0, this.theOptions.url.lastIndexOf('/'));
|
|
18548
|
+
let context = substringUpToLastSlash.substring(substringUpToLastSlash.lastIndexOf('/'), substringUpToLastSlash.length);
|
|
18549
|
+
return substringUpToLastSlash.substring(0, substringUpToLastSlash.lastIndexOf('/')) + '/search' + context;
|
|
18537
18550
|
}
|
|
18538
18551
|
else {
|
|
18539
18552
|
return this.theOptions.url.substring(0, this.theOptions.url.lastIndexOf('/')) + '/GetTreeFromSearch';
|
|
@@ -18629,7 +18642,7 @@ const HierarchizedPickerComponent = class {
|
|
|
18629
18642
|
if (this.searchToDisplay > -1 && searchID == this.searchToDisplay) {
|
|
18630
18643
|
this.rawData.children.forEach((value, index) => {
|
|
18631
18644
|
// this.completeCurrentTreeWithTree(value, dataToLoad);
|
|
18632
|
-
this.completeCurrentTreeWithTree(
|
|
18645
|
+
this.completeCurrentTreeWithTree(value);
|
|
18633
18646
|
});
|
|
18634
18647
|
this.triggerTreeDisplay(this.rawData, searched);
|
|
18635
18648
|
this.displayAutocompleteWithResults(this.rawData, searched);
|
|
@@ -18650,10 +18663,12 @@ const HierarchizedPickerComponent = class {
|
|
|
18650
18663
|
if (this.theOptions.origin == 'classification') {
|
|
18651
18664
|
// WS Call
|
|
18652
18665
|
this.getDataFromSourceClassification(this.getApiSearchURL(), {
|
|
18653
|
-
|
|
18654
|
-
|
|
18655
|
-
|
|
18656
|
-
|
|
18666
|
+
search: {
|
|
18667
|
+
StartNodeID: this.theOptions.options.startNode,
|
|
18668
|
+
lng: this.theOptions.options.lng,
|
|
18669
|
+
deprecated: this.theOptions.options.IsDeprecated,
|
|
18670
|
+
searchedValue: searched
|
|
18671
|
+
}
|
|
18657
18672
|
}).then(displayResults),
|
|
18658
18673
|
err => {
|
|
18659
18674
|
console.error('err', err);
|
|
@@ -18732,7 +18747,8 @@ const HierarchizedPickerComponent = class {
|
|
|
18732
18747
|
let childrenPropFromNode = this.getPropertyFromNode(value, 'children', false);
|
|
18733
18748
|
let deprecated = this.getPropertyFromNode(value, 'deprecated', false);
|
|
18734
18749
|
// Quick fix until I fully understand what is going on ...
|
|
18735
|
-
|
|
18750
|
+
// EDIT : this "quick fix" doesnt work for nodes of higher level (1 and 2)
|
|
18751
|
+
// childrenPropFromNode = childrenPropFromNode.filter(subvalue => this.getPropertyFromNode(subvalue, 'fullpath').includes(fullpathPropFromNode));
|
|
18736
18752
|
let objToPush = {
|
|
18737
18753
|
id: keyPropFromNode,
|
|
18738
18754
|
depth: depth,
|
|
@@ -18836,7 +18852,7 @@ const HierarchizedPickerComponent = class {
|
|
|
18836
18852
|
translateDataFromClassification(dataToLoad, searched = null) {
|
|
18837
18853
|
if (this.theOptions.origin != 'classification' || !dataToLoad)
|
|
18838
18854
|
return;
|
|
18839
|
-
|
|
18855
|
+
const that = this;
|
|
18840
18856
|
let fillTreeWithObject = function (tree, object, depth = 0) {
|
|
18841
18857
|
if (object.length) {
|
|
18842
18858
|
object.forEach(function (value, _index) {
|
|
@@ -18872,7 +18888,7 @@ const HierarchizedPickerComponent = class {
|
|
|
18872
18888
|
const matched = searchValue(objToPush, false);
|
|
18873
18889
|
objToPush.isDesaturated = !matched;
|
|
18874
18890
|
objToPush.searchMatch = searchValue(objToPush, true);
|
|
18875
|
-
pushMe = matched ||
|
|
18891
|
+
pushMe = matched || that.theOptions.searchResultPresentsUnMatched;
|
|
18876
18892
|
}
|
|
18877
18893
|
else {
|
|
18878
18894
|
pushMe = true;
|
|
@@ -18892,7 +18908,9 @@ const HierarchizedPickerComponent = class {
|
|
|
18892
18908
|
}
|
|
18893
18909
|
// Finds the root of the new tree in the current tree (wherever it may be), and adds the children of the new tree to it
|
|
18894
18910
|
completeCurrentTreeWithTree(newTree) {
|
|
18895
|
-
|
|
18911
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
18912
|
+
const that = this;
|
|
18913
|
+
const ElmID = (newTree.key ? newTree.key : (newTree.id ? newTree.id : newTree.ID));
|
|
18896
18914
|
// Creates a new tree with results from WS call
|
|
18897
18915
|
let shortFillTreeWithObject = function (parent, tree, object, first, depth) {
|
|
18898
18916
|
// If passed node has elements
|
|
@@ -18906,8 +18924,8 @@ const HierarchizedPickerComponent = class {
|
|
|
18906
18924
|
depth: depth,
|
|
18907
18925
|
parent: parent,
|
|
18908
18926
|
text: that.getPropertyFromNode(value, 'Name'),
|
|
18909
|
-
fullpath: that.getPropertyFromNode(value.Properties, '
|
|
18910
|
-
fullpathTranslated: that.getPropertyFromNode(value.Properties, '
|
|
18927
|
+
fullpath: that.getPropertyFromNode(value.Properties, 'Fullpath'),
|
|
18928
|
+
fullpathTranslated: that.getPropertyFromNode(value.Properties, 'Fullpath'),
|
|
18911
18929
|
children: that.getPropertyFromNode(value, 'hasChildren', false) && that.getPropertyFromNode(value, 'children').length == 0 ? [{}] : [],
|
|
18912
18930
|
deprecated: that.getPropertyFromNode(value.Properties, 'IsDeprecated', false),
|
|
18913
18931
|
};
|
|
@@ -18934,45 +18952,46 @@ const HierarchizedPickerComponent = class {
|
|
|
18934
18952
|
return tree;
|
|
18935
18953
|
};
|
|
18936
18954
|
// targetNode = an object stored by the library
|
|
18937
|
-
|
|
18955
|
+
const targetNode = this.findNodeById(this.loadedTreeJs, ElmID);
|
|
18938
18956
|
if (targetNode != null) {
|
|
18939
18957
|
// empty the children of the node in the library
|
|
18940
18958
|
targetNode.children = [];
|
|
18941
|
-
|
|
18942
|
-
var ulElem = this.loadedTreeJs.liElementsById[liElmID].querySelector('ul');
|
|
18959
|
+
const ulElem = (this.loadedTreeJs.liElementsById[ElmID] ? this.loadedTreeJs.liElementsById[ElmID].querySelector('ul') : null);
|
|
18943
18960
|
let filledtree = shortFillTreeWithObject({
|
|
18944
|
-
id:
|
|
18961
|
+
id: ElmID,
|
|
18945
18962
|
depth: targetNode.depth,
|
|
18946
|
-
parent: this.loadedTreeJs.nodesById[
|
|
18947
|
-
text: this.loadedTreeJs.nodesById[
|
|
18948
|
-
fullpath: this.loadedTreeJs.nodesById[
|
|
18949
|
-
fullpathTranslated: this.loadedTreeJs.nodesById[
|
|
18950
|
-
children: this.loadedTreeJs.nodesById[
|
|
18963
|
+
parent: (_b = (_a = this.loadedTreeJs.nodesById[ElmID]) === null || _a === void 0 ? void 0 : _a.parent) !== null && _b !== void 0 ? _b : null,
|
|
18964
|
+
text: (_d = (_c = this.loadedTreeJs.nodesById[ElmID]) === null || _c === void 0 ? void 0 : _c.text) !== null && _d !== void 0 ? _d : null,
|
|
18965
|
+
fullpath: (_f = (_e = this.loadedTreeJs.nodesById[ElmID]) === null || _e === void 0 ? void 0 : _e.fullpath) !== null && _f !== void 0 ? _f : null,
|
|
18966
|
+
fullpathTranslated: (_h = (_g = this.loadedTreeJs.nodesById[ElmID]) === null || _g === void 0 ? void 0 : _g.fullpathTranslated) !== null && _h !== void 0 ? _h : null,
|
|
18967
|
+
children: (_k = (_j = this.loadedTreeJs.nodesById[ElmID]) === null || _j === void 0 ? void 0 : _j.children) !== null && _k !== void 0 ? _k : null,
|
|
18951
18968
|
}, [], newTree.children, true, targetNode.depth + 1);
|
|
18952
|
-
if (filledtree.length > 0) {
|
|
18969
|
+
if (filledtree.length > 0 && ulElem) {
|
|
18953
18970
|
ulElem.innerHTML = '';
|
|
18954
18971
|
}
|
|
18955
|
-
|
|
18956
|
-
|
|
18957
|
-
|
|
18958
|
-
|
|
18959
|
-
|
|
18960
|
-
|
|
18961
|
-
|
|
18962
|
-
|
|
18963
|
-
|
|
18964
|
-
|
|
18965
|
-
|
|
18966
|
-
|
|
18967
|
-
|
|
18968
|
-
|
|
18969
|
-
|
|
18970
|
-
|
|
18971
|
-
|
|
18972
|
-
|
|
18972
|
+
if (ulElem) {
|
|
18973
|
+
// this.rawData = result from WS call
|
|
18974
|
+
(filledtree).forEach((item) => {
|
|
18975
|
+
if (Object.keys(item).length != 0) {
|
|
18976
|
+
//Foreach item in the newly created tree, create the DOM elements to inject - BEGIN
|
|
18977
|
+
let liElm = this.loadedTreeJs.createLiEle(item, true);
|
|
18978
|
+
ulElem.appendChild(liElm);
|
|
18979
|
+
//Foreach item in the newly created tree, create the DOM elements to inject - END
|
|
18980
|
+
//Add the loaded elements to the library properties
|
|
18981
|
+
targetNode.children.push(item);
|
|
18982
|
+
this.loadedTreeJs.nodesById[item.id] = item;
|
|
18983
|
+
this.loadedTreeJs.liElementsById[item.id] = liElm;
|
|
18984
|
+
this.loadedTreeJs.treeNodes.push(item);
|
|
18985
|
+
//If has children, prepare sub elements
|
|
18986
|
+
if (item.children && item.children.length > 0) {
|
|
18987
|
+
var liElems = ulElem.querySelectorAll('li');
|
|
18988
|
+
liElems[liElems.length - 1].appendChild(this.loadedTreeJs.createUlEle());
|
|
18989
|
+
liElems[liElems.length - 1].querySelector('ul').appendChild(this.loadedTreeJs.createLiEle(item.children));
|
|
18990
|
+
this.completeCurrentTreeWithTree(item);
|
|
18991
|
+
}
|
|
18973
18992
|
}
|
|
18974
|
-
}
|
|
18975
|
-
}
|
|
18993
|
+
});
|
|
18994
|
+
}
|
|
18976
18995
|
}
|
|
18977
18996
|
this.deactivateNodesOutOfDepthSettings();
|
|
18978
18997
|
}
|
|
@@ -629,10 +629,22 @@ export class HierarchizedPickerComponent {
|
|
|
629
629
|
var _a;
|
|
630
630
|
let that = this;
|
|
631
631
|
(_a = this.loader) === null || _a === void 0 ? void 0 : _a.classList.add('loading');
|
|
632
|
-
let targetURL = url
|
|
633
|
-
//
|
|
634
|
-
//
|
|
632
|
+
let targetURL = url;
|
|
633
|
+
// search:{
|
|
634
|
+
// StartNodeID:72773,
|
|
635
|
+
// lng:'en',
|
|
636
|
+
// deprecated:0,
|
|
637
|
+
// searchedValue:'Infectious'
|
|
635
638
|
// }
|
|
639
|
+
if (options.search) {
|
|
640
|
+
targetURL += '/?StartNodeID=' + options.search.StartNodeID;
|
|
641
|
+
targetURL += '&lng=' + options.search.lng;
|
|
642
|
+
targetURL += '&deprecated=' + options.search.deprecated;
|
|
643
|
+
targetURL += '&searchedValue=' + options.search.searchedValue;
|
|
644
|
+
}
|
|
645
|
+
else {
|
|
646
|
+
targetURL = targetURL + '/' + options.startNode;
|
|
647
|
+
}
|
|
636
648
|
let getDataPromise = new Promise((resolve, reject) => {
|
|
637
649
|
this.getToken().then(token => {
|
|
638
650
|
let xhr = new XMLHttpRequest();
|
|
@@ -755,8 +767,9 @@ export class HierarchizedPickerComponent {
|
|
|
755
767
|
}
|
|
756
768
|
getApiSearchURL() {
|
|
757
769
|
if (this.theOptions.origin == 'classification') {
|
|
758
|
-
|
|
759
|
-
|
|
770
|
+
let substringUpToLastSlash = this.theOptions.url.substring(0, this.theOptions.url.lastIndexOf('/'));
|
|
771
|
+
let context = substringUpToLastSlash.substring(substringUpToLastSlash.lastIndexOf('/'), substringUpToLastSlash.length);
|
|
772
|
+
return substringUpToLastSlash.substring(0, substringUpToLastSlash.lastIndexOf('/')) + '/search' + context;
|
|
760
773
|
}
|
|
761
774
|
else {
|
|
762
775
|
return this.theOptions.url.substring(0, this.theOptions.url.lastIndexOf('/')) + '/GetTreeFromSearch';
|
|
@@ -852,7 +865,7 @@ export class HierarchizedPickerComponent {
|
|
|
852
865
|
if (this.searchToDisplay > -1 && searchID == this.searchToDisplay) {
|
|
853
866
|
this.rawData.children.forEach((value, index) => {
|
|
854
867
|
// this.completeCurrentTreeWithTree(value, dataToLoad);
|
|
855
|
-
this.completeCurrentTreeWithTree(
|
|
868
|
+
this.completeCurrentTreeWithTree(value);
|
|
856
869
|
});
|
|
857
870
|
this.triggerTreeDisplay(this.rawData, searched);
|
|
858
871
|
this.displayAutocompleteWithResults(this.rawData, searched);
|
|
@@ -873,10 +886,12 @@ export class HierarchizedPickerComponent {
|
|
|
873
886
|
if (this.theOptions.origin == 'classification') {
|
|
874
887
|
// WS Call
|
|
875
888
|
this.getDataFromSourceClassification(this.getApiSearchURL(), {
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
889
|
+
search: {
|
|
890
|
+
StartNodeID: this.theOptions.options.startNode,
|
|
891
|
+
lng: this.theOptions.options.lng,
|
|
892
|
+
deprecated: this.theOptions.options.IsDeprecated,
|
|
893
|
+
searchedValue: searched
|
|
894
|
+
}
|
|
880
895
|
}).then(displayResults),
|
|
881
896
|
err => {
|
|
882
897
|
console.error('err', err);
|
|
@@ -955,7 +970,8 @@ export class HierarchizedPickerComponent {
|
|
|
955
970
|
let childrenPropFromNode = this.getPropertyFromNode(value, 'children', false);
|
|
956
971
|
let deprecated = this.getPropertyFromNode(value, 'deprecated', false);
|
|
957
972
|
// Quick fix until I fully understand what is going on ...
|
|
958
|
-
|
|
973
|
+
// EDIT : this "quick fix" doesnt work for nodes of higher level (1 and 2)
|
|
974
|
+
// childrenPropFromNode = childrenPropFromNode.filter(subvalue => this.getPropertyFromNode(subvalue, 'fullpath').includes(fullpathPropFromNode));
|
|
959
975
|
let objToPush = {
|
|
960
976
|
id: keyPropFromNode,
|
|
961
977
|
depth: depth,
|
|
@@ -1059,7 +1075,7 @@ export class HierarchizedPickerComponent {
|
|
|
1059
1075
|
translateDataFromClassification(dataToLoad, searched = null) {
|
|
1060
1076
|
if (this.theOptions.origin != 'classification' || !dataToLoad)
|
|
1061
1077
|
return;
|
|
1062
|
-
|
|
1078
|
+
const that = this;
|
|
1063
1079
|
let fillTreeWithObject = function (tree, object, depth = 0) {
|
|
1064
1080
|
if (object.length) {
|
|
1065
1081
|
object.forEach(function (value, _index) {
|
|
@@ -1095,7 +1111,7 @@ export class HierarchizedPickerComponent {
|
|
|
1095
1111
|
const matched = searchValue(objToPush, false);
|
|
1096
1112
|
objToPush.isDesaturated = !matched;
|
|
1097
1113
|
objToPush.searchMatch = searchValue(objToPush, true);
|
|
1098
|
-
pushMe = matched ||
|
|
1114
|
+
pushMe = matched || that.theOptions.searchResultPresentsUnMatched;
|
|
1099
1115
|
}
|
|
1100
1116
|
else {
|
|
1101
1117
|
pushMe = true;
|
|
@@ -1115,7 +1131,9 @@ export class HierarchizedPickerComponent {
|
|
|
1115
1131
|
}
|
|
1116
1132
|
// Finds the root of the new tree in the current tree (wherever it may be), and adds the children of the new tree to it
|
|
1117
1133
|
completeCurrentTreeWithTree(newTree) {
|
|
1118
|
-
|
|
1134
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1135
|
+
const that = this;
|
|
1136
|
+
const ElmID = (newTree.key ? newTree.key : (newTree.id ? newTree.id : newTree.ID));
|
|
1119
1137
|
// Creates a new tree with results from WS call
|
|
1120
1138
|
let shortFillTreeWithObject = function (parent, tree, object, first, depth) {
|
|
1121
1139
|
// If passed node has elements
|
|
@@ -1129,8 +1147,8 @@ export class HierarchizedPickerComponent {
|
|
|
1129
1147
|
depth: depth,
|
|
1130
1148
|
parent: parent,
|
|
1131
1149
|
text: that.getPropertyFromNode(value, 'Name'),
|
|
1132
|
-
fullpath: that.getPropertyFromNode(value.Properties, '
|
|
1133
|
-
fullpathTranslated: that.getPropertyFromNode(value.Properties, '
|
|
1150
|
+
fullpath: that.getPropertyFromNode(value.Properties, 'Fullpath'),
|
|
1151
|
+
fullpathTranslated: that.getPropertyFromNode(value.Properties, 'Fullpath'),
|
|
1134
1152
|
children: that.getPropertyFromNode(value, 'hasChildren', false) && that.getPropertyFromNode(value, 'children').length == 0 ? [{}] : [],
|
|
1135
1153
|
deprecated: that.getPropertyFromNode(value.Properties, 'IsDeprecated', false),
|
|
1136
1154
|
};
|
|
@@ -1157,45 +1175,46 @@ export class HierarchizedPickerComponent {
|
|
|
1157
1175
|
return tree;
|
|
1158
1176
|
};
|
|
1159
1177
|
// targetNode = an object stored by the library
|
|
1160
|
-
|
|
1178
|
+
const targetNode = this.findNodeById(this.loadedTreeJs, ElmID);
|
|
1161
1179
|
if (targetNode != null) {
|
|
1162
1180
|
// empty the children of the node in the library
|
|
1163
1181
|
targetNode.children = [];
|
|
1164
|
-
|
|
1165
|
-
var ulElem = this.loadedTreeJs.liElementsById[liElmID].querySelector('ul');
|
|
1182
|
+
const ulElem = (this.loadedTreeJs.liElementsById[ElmID] ? this.loadedTreeJs.liElementsById[ElmID].querySelector('ul') : null);
|
|
1166
1183
|
let filledtree = shortFillTreeWithObject({
|
|
1167
|
-
id:
|
|
1184
|
+
id: ElmID,
|
|
1168
1185
|
depth: targetNode.depth,
|
|
1169
|
-
parent: this.loadedTreeJs.nodesById[
|
|
1170
|
-
text: this.loadedTreeJs.nodesById[
|
|
1171
|
-
fullpath: this.loadedTreeJs.nodesById[
|
|
1172
|
-
fullpathTranslated: this.loadedTreeJs.nodesById[
|
|
1173
|
-
children: this.loadedTreeJs.nodesById[
|
|
1186
|
+
parent: (_b = (_a = this.loadedTreeJs.nodesById[ElmID]) === null || _a === void 0 ? void 0 : _a.parent) !== null && _b !== void 0 ? _b : null,
|
|
1187
|
+
text: (_d = (_c = this.loadedTreeJs.nodesById[ElmID]) === null || _c === void 0 ? void 0 : _c.text) !== null && _d !== void 0 ? _d : null,
|
|
1188
|
+
fullpath: (_f = (_e = this.loadedTreeJs.nodesById[ElmID]) === null || _e === void 0 ? void 0 : _e.fullpath) !== null && _f !== void 0 ? _f : null,
|
|
1189
|
+
fullpathTranslated: (_h = (_g = this.loadedTreeJs.nodesById[ElmID]) === null || _g === void 0 ? void 0 : _g.fullpathTranslated) !== null && _h !== void 0 ? _h : null,
|
|
1190
|
+
children: (_k = (_j = this.loadedTreeJs.nodesById[ElmID]) === null || _j === void 0 ? void 0 : _j.children) !== null && _k !== void 0 ? _k : null,
|
|
1174
1191
|
}, [], newTree.children, true, targetNode.depth + 1);
|
|
1175
|
-
if (filledtree.length > 0) {
|
|
1192
|
+
if (filledtree.length > 0 && ulElem) {
|
|
1176
1193
|
ulElem.innerHTML = '';
|
|
1177
1194
|
}
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1195
|
+
if (ulElem) {
|
|
1196
|
+
// this.rawData = result from WS call
|
|
1197
|
+
(filledtree).forEach((item) => {
|
|
1198
|
+
if (Object.keys(item).length != 0) {
|
|
1199
|
+
//Foreach item in the newly created tree, create the DOM elements to inject - BEGIN
|
|
1200
|
+
let liElm = this.loadedTreeJs.createLiEle(item, true);
|
|
1201
|
+
ulElem.appendChild(liElm);
|
|
1202
|
+
//Foreach item in the newly created tree, create the DOM elements to inject - END
|
|
1203
|
+
//Add the loaded elements to the library properties
|
|
1204
|
+
targetNode.children.push(item);
|
|
1205
|
+
this.loadedTreeJs.nodesById[item.id] = item;
|
|
1206
|
+
this.loadedTreeJs.liElementsById[item.id] = liElm;
|
|
1207
|
+
this.loadedTreeJs.treeNodes.push(item);
|
|
1208
|
+
//If has children, prepare sub elements
|
|
1209
|
+
if (item.children && item.children.length > 0) {
|
|
1210
|
+
var liElems = ulElem.querySelectorAll('li');
|
|
1211
|
+
liElems[liElems.length - 1].appendChild(this.loadedTreeJs.createUlEle());
|
|
1212
|
+
liElems[liElems.length - 1].querySelector('ul').appendChild(this.loadedTreeJs.createLiEle(item.children));
|
|
1213
|
+
this.completeCurrentTreeWithTree(item);
|
|
1214
|
+
}
|
|
1196
1215
|
}
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1199
1218
|
}
|
|
1200
1219
|
this.deactivateNodesOutOfDepthSettings();
|
|
1201
1220
|
}
|
|
@@ -203,7 +203,7 @@ Tree.prototype.bindEvent = function (ele) {
|
|
|
203
203
|
startNode: target.parentNode.nodeId
|
|
204
204
|
})
|
|
205
205
|
.then(data => {
|
|
206
|
-
this.options.parentApi.completeCurrentTreeWithTree(data
|
|
206
|
+
this.options.parentApi.completeCurrentTreeWithTree(data);
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
209
|
else {
|
|
@@ -232,7 +232,7 @@ Tree.prototype.bindEvent = function (ele) {
|
|
|
232
232
|
startNode: target.parentNode.nodeId
|
|
233
233
|
})
|
|
234
234
|
.then(data => {
|
|
235
|
-
this.options.parentApi.completeCurrentTreeWithTree(data
|
|
235
|
+
this.options.parentApi.completeCurrentTreeWithTree(data);
|
|
236
236
|
});
|
|
237
237
|
}
|
|
238
238
|
else {
|
|
@@ -18404,10 +18404,22 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
18404
18404
|
var _a;
|
|
18405
18405
|
let that = this;
|
|
18406
18406
|
(_a = this.loader) === null || _a === void 0 ? void 0 : _a.classList.add('loading');
|
|
18407
|
-
let targetURL = url
|
|
18408
|
-
//
|
|
18409
|
-
//
|
|
18407
|
+
let targetURL = url;
|
|
18408
|
+
// search:{
|
|
18409
|
+
// StartNodeID:72773,
|
|
18410
|
+
// lng:'en',
|
|
18411
|
+
// deprecated:0,
|
|
18412
|
+
// searchedValue:'Infectious'
|
|
18410
18413
|
// }
|
|
18414
|
+
if (options.search) {
|
|
18415
|
+
targetURL += '/?StartNodeID=' + options.search.StartNodeID;
|
|
18416
|
+
targetURL += '&lng=' + options.search.lng;
|
|
18417
|
+
targetURL += '&deprecated=' + options.search.deprecated;
|
|
18418
|
+
targetURL += '&searchedValue=' + options.search.searchedValue;
|
|
18419
|
+
}
|
|
18420
|
+
else {
|
|
18421
|
+
targetURL = targetURL + '/' + options.startNode;
|
|
18422
|
+
}
|
|
18411
18423
|
let getDataPromise = new Promise((resolve, reject) => {
|
|
18412
18424
|
this.getToken().then(token => {
|
|
18413
18425
|
let xhr = new browser();
|
|
@@ -18530,8 +18542,9 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
18530
18542
|
}
|
|
18531
18543
|
getApiSearchURL() {
|
|
18532
18544
|
if (this.theOptions.origin == 'classification') {
|
|
18533
|
-
|
|
18534
|
-
|
|
18545
|
+
let substringUpToLastSlash = this.theOptions.url.substring(0, this.theOptions.url.lastIndexOf('/'));
|
|
18546
|
+
let context = substringUpToLastSlash.substring(substringUpToLastSlash.lastIndexOf('/'), substringUpToLastSlash.length);
|
|
18547
|
+
return substringUpToLastSlash.substring(0, substringUpToLastSlash.lastIndexOf('/')) + '/search' + context;
|
|
18535
18548
|
}
|
|
18536
18549
|
else {
|
|
18537
18550
|
return this.theOptions.url.substring(0, this.theOptions.url.lastIndexOf('/')) + '/GetTreeFromSearch';
|
|
@@ -18627,7 +18640,7 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
18627
18640
|
if (this.searchToDisplay > -1 && searchID == this.searchToDisplay) {
|
|
18628
18641
|
this.rawData.children.forEach((value, index) => {
|
|
18629
18642
|
// this.completeCurrentTreeWithTree(value, dataToLoad);
|
|
18630
|
-
this.completeCurrentTreeWithTree(
|
|
18643
|
+
this.completeCurrentTreeWithTree(value);
|
|
18631
18644
|
});
|
|
18632
18645
|
this.triggerTreeDisplay(this.rawData, searched);
|
|
18633
18646
|
this.displayAutocompleteWithResults(this.rawData, searched);
|
|
@@ -18648,10 +18661,12 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
18648
18661
|
if (this.theOptions.origin == 'classification') {
|
|
18649
18662
|
// WS Call
|
|
18650
18663
|
this.getDataFromSourceClassification(this.getApiSearchURL(), {
|
|
18651
|
-
|
|
18652
|
-
|
|
18653
|
-
|
|
18654
|
-
|
|
18664
|
+
search: {
|
|
18665
|
+
StartNodeID: this.theOptions.options.startNode,
|
|
18666
|
+
lng: this.theOptions.options.lng,
|
|
18667
|
+
deprecated: this.theOptions.options.IsDeprecated,
|
|
18668
|
+
searchedValue: searched
|
|
18669
|
+
}
|
|
18655
18670
|
}).then(displayResults),
|
|
18656
18671
|
err => {
|
|
18657
18672
|
console.error('err', err);
|
|
@@ -18730,7 +18745,8 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
18730
18745
|
let childrenPropFromNode = this.getPropertyFromNode(value, 'children', false);
|
|
18731
18746
|
let deprecated = this.getPropertyFromNode(value, 'deprecated', false);
|
|
18732
18747
|
// Quick fix until I fully understand what is going on ...
|
|
18733
|
-
|
|
18748
|
+
// EDIT : this "quick fix" doesnt work for nodes of higher level (1 and 2)
|
|
18749
|
+
// childrenPropFromNode = childrenPropFromNode.filter(subvalue => this.getPropertyFromNode(subvalue, 'fullpath').includes(fullpathPropFromNode));
|
|
18734
18750
|
let objToPush = {
|
|
18735
18751
|
id: keyPropFromNode,
|
|
18736
18752
|
depth: depth,
|
|
@@ -18834,7 +18850,7 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
18834
18850
|
translateDataFromClassification(dataToLoad, searched = null) {
|
|
18835
18851
|
if (this.theOptions.origin != 'classification' || !dataToLoad)
|
|
18836
18852
|
return;
|
|
18837
|
-
|
|
18853
|
+
const that = this;
|
|
18838
18854
|
let fillTreeWithObject = function (tree, object, depth = 0) {
|
|
18839
18855
|
if (object.length) {
|
|
18840
18856
|
object.forEach(function (value, _index) {
|
|
@@ -18870,7 +18886,7 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
18870
18886
|
const matched = searchValue(objToPush, false);
|
|
18871
18887
|
objToPush.isDesaturated = !matched;
|
|
18872
18888
|
objToPush.searchMatch = searchValue(objToPush, true);
|
|
18873
|
-
pushMe = matched ||
|
|
18889
|
+
pushMe = matched || that.theOptions.searchResultPresentsUnMatched;
|
|
18874
18890
|
}
|
|
18875
18891
|
else {
|
|
18876
18892
|
pushMe = true;
|
|
@@ -18890,7 +18906,9 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
18890
18906
|
}
|
|
18891
18907
|
// Finds the root of the new tree in the current tree (wherever it may be), and adds the children of the new tree to it
|
|
18892
18908
|
completeCurrentTreeWithTree(newTree) {
|
|
18893
|
-
|
|
18909
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
18910
|
+
const that = this;
|
|
18911
|
+
const ElmID = (newTree.key ? newTree.key : (newTree.id ? newTree.id : newTree.ID));
|
|
18894
18912
|
// Creates a new tree with results from WS call
|
|
18895
18913
|
let shortFillTreeWithObject = function (parent, tree, object, first, depth) {
|
|
18896
18914
|
// If passed node has elements
|
|
@@ -18904,8 +18922,8 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
18904
18922
|
depth: depth,
|
|
18905
18923
|
parent: parent,
|
|
18906
18924
|
text: that.getPropertyFromNode(value, 'Name'),
|
|
18907
|
-
fullpath: that.getPropertyFromNode(value.Properties, '
|
|
18908
|
-
fullpathTranslated: that.getPropertyFromNode(value.Properties, '
|
|
18925
|
+
fullpath: that.getPropertyFromNode(value.Properties, 'Fullpath'),
|
|
18926
|
+
fullpathTranslated: that.getPropertyFromNode(value.Properties, 'Fullpath'),
|
|
18909
18927
|
children: that.getPropertyFromNode(value, 'hasChildren', false) && that.getPropertyFromNode(value, 'children').length == 0 ? [{}] : [],
|
|
18910
18928
|
deprecated: that.getPropertyFromNode(value.Properties, 'IsDeprecated', false),
|
|
18911
18929
|
};
|
|
@@ -18932,45 +18950,46 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
18932
18950
|
return tree;
|
|
18933
18951
|
};
|
|
18934
18952
|
// targetNode = an object stored by the library
|
|
18935
|
-
|
|
18953
|
+
const targetNode = this.findNodeById(this.loadedTreeJs, ElmID);
|
|
18936
18954
|
if (targetNode != null) {
|
|
18937
18955
|
// empty the children of the node in the library
|
|
18938
18956
|
targetNode.children = [];
|
|
18939
|
-
|
|
18940
|
-
var ulElem = this.loadedTreeJs.liElementsById[liElmID].querySelector('ul');
|
|
18957
|
+
const ulElem = (this.loadedTreeJs.liElementsById[ElmID] ? this.loadedTreeJs.liElementsById[ElmID].querySelector('ul') : null);
|
|
18941
18958
|
let filledtree = shortFillTreeWithObject({
|
|
18942
|
-
id:
|
|
18959
|
+
id: ElmID,
|
|
18943
18960
|
depth: targetNode.depth,
|
|
18944
|
-
parent: this.loadedTreeJs.nodesById[
|
|
18945
|
-
text: this.loadedTreeJs.nodesById[
|
|
18946
|
-
fullpath: this.loadedTreeJs.nodesById[
|
|
18947
|
-
fullpathTranslated: this.loadedTreeJs.nodesById[
|
|
18948
|
-
children: this.loadedTreeJs.nodesById[
|
|
18961
|
+
parent: (_b = (_a = this.loadedTreeJs.nodesById[ElmID]) === null || _a === void 0 ? void 0 : _a.parent) !== null && _b !== void 0 ? _b : null,
|
|
18962
|
+
text: (_d = (_c = this.loadedTreeJs.nodesById[ElmID]) === null || _c === void 0 ? void 0 : _c.text) !== null && _d !== void 0 ? _d : null,
|
|
18963
|
+
fullpath: (_f = (_e = this.loadedTreeJs.nodesById[ElmID]) === null || _e === void 0 ? void 0 : _e.fullpath) !== null && _f !== void 0 ? _f : null,
|
|
18964
|
+
fullpathTranslated: (_h = (_g = this.loadedTreeJs.nodesById[ElmID]) === null || _g === void 0 ? void 0 : _g.fullpathTranslated) !== null && _h !== void 0 ? _h : null,
|
|
18965
|
+
children: (_k = (_j = this.loadedTreeJs.nodesById[ElmID]) === null || _j === void 0 ? void 0 : _j.children) !== null && _k !== void 0 ? _k : null,
|
|
18949
18966
|
}, [], newTree.children, true, targetNode.depth + 1);
|
|
18950
|
-
if (filledtree.length > 0) {
|
|
18967
|
+
if (filledtree.length > 0 && ulElem) {
|
|
18951
18968
|
ulElem.innerHTML = '';
|
|
18952
18969
|
}
|
|
18953
|
-
|
|
18954
|
-
|
|
18955
|
-
|
|
18956
|
-
|
|
18957
|
-
|
|
18958
|
-
|
|
18959
|
-
|
|
18960
|
-
|
|
18961
|
-
|
|
18962
|
-
|
|
18963
|
-
|
|
18964
|
-
|
|
18965
|
-
|
|
18966
|
-
|
|
18967
|
-
|
|
18968
|
-
|
|
18969
|
-
|
|
18970
|
-
|
|
18970
|
+
if (ulElem) {
|
|
18971
|
+
// this.rawData = result from WS call
|
|
18972
|
+
(filledtree).forEach((item) => {
|
|
18973
|
+
if (Object.keys(item).length != 0) {
|
|
18974
|
+
//Foreach item in the newly created tree, create the DOM elements to inject - BEGIN
|
|
18975
|
+
let liElm = this.loadedTreeJs.createLiEle(item, true);
|
|
18976
|
+
ulElem.appendChild(liElm);
|
|
18977
|
+
//Foreach item in the newly created tree, create the DOM elements to inject - END
|
|
18978
|
+
//Add the loaded elements to the library properties
|
|
18979
|
+
targetNode.children.push(item);
|
|
18980
|
+
this.loadedTreeJs.nodesById[item.id] = item;
|
|
18981
|
+
this.loadedTreeJs.liElementsById[item.id] = liElm;
|
|
18982
|
+
this.loadedTreeJs.treeNodes.push(item);
|
|
18983
|
+
//If has children, prepare sub elements
|
|
18984
|
+
if (item.children && item.children.length > 0) {
|
|
18985
|
+
var liElems = ulElem.querySelectorAll('li');
|
|
18986
|
+
liElems[liElems.length - 1].appendChild(this.loadedTreeJs.createUlEle());
|
|
18987
|
+
liElems[liElems.length - 1].querySelector('ul').appendChild(this.loadedTreeJs.createLiEle(item.children));
|
|
18988
|
+
this.completeCurrentTreeWithTree(item);
|
|
18989
|
+
}
|
|
18971
18990
|
}
|
|
18972
|
-
}
|
|
18973
|
-
}
|
|
18991
|
+
});
|
|
18992
|
+
}
|
|
18974
18993
|
}
|
|
18975
18994
|
this.deactivateNodesOutOfDepthSettings();
|
|
18976
18995
|
}
|