reneco-hierarchized-picker 0.2.3 → 0.2.5-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17862,27 +17862,55 @@ const HierarchizedPickerComponent = class {
17862
17862
  });
17863
17863
  }
17864
17864
  async setNewOption(newValue, oldValue = null) {
17865
- this.canload = true;
17865
+ // --------------------------------------- DEPRECATED ?
17866
+ // this.canload = true;
17867
+ // this.theOptions = newValue;
17868
+ // if (this.theOptions.source != "file") {
17869
+ // this.rawData = null;
17870
+ // }
17871
+ // this.ready = false;
17872
+ //NOTE: This could work in a synchronous environment => this.reloadCurrentValues();
17873
+ // ---------------------------------------
17866
17874
  this.theOptions = newValue;
17867
- if (this.theOptions.source != "file") {
17875
+ if (((oldValue && (newValue.origin != oldValue.origin
17876
+ || newValue.options.StartNodeID != oldValue.options.StartNodeID)) || !oldValue)
17877
+ && this.theOptions.source != "file") {
17868
17878
  this.rawData = null;
17869
17879
  }
17870
17880
  this.ready = false;
17871
- await this.loadHierarchizedPicker();
17872
- this.displayWhenLoaded();
17873
- //NOTE: This could work in a synchronous environment => this.reloadCurrentValues();
17881
+ this.canload = this.isInstanceOfIConf(this.theOptions);
17882
+ if (!this.canload) {
17883
+ this.displayPickerError('Error(s) in the picker configuration!');
17884
+ return;
17885
+ }
17886
+ if (oldValue && JSON.stringify(newValue.options) != JSON.stringify(oldValue.options)) {
17887
+ this.value = [];
17888
+ }
17889
+ if (newValue && newValue.loading == "display") {
17890
+ if ((oldValue && this.isChangeInOptions(newValue, oldValue)) || !oldValue) {
17891
+ await this.loadHierarchizedPicker();
17892
+ this.displayWhenLoaded();
17893
+ }
17894
+ else {
17895
+ this.ready = true;
17896
+ }
17897
+ }
17874
17898
  }
17875
17899
  setNewOptions(newoptions) {
17876
- this.setOptions(JSON.parse(newoptions));
17900
+ if (typeof newoptions == 'string')
17901
+ newoptions = JSON.parse(newoptions);
17902
+ this.setOptions(newoptions);
17877
17903
  }
17878
17904
  setNewFilter(newfilter) {
17879
17905
  this.filterTree(newfilter);
17880
17906
  }
17881
- optionsChange(newValue) {
17907
+ optionsChange(newValue, oldValue) {
17882
17908
  if (!this.theOptions || !this.ready || this.ignoreOptionsChanges) {
17883
17909
  return;
17884
17910
  }
17885
- this.setNewOption(newValue);
17911
+ if (typeof newValue == 'string')
17912
+ newValue = JSON.parse(newValue);
17913
+ this.setNewOption(newValue, oldValue);
17886
17914
  }
17887
17915
  isChangeInOptions(newV, oldV) {
17888
17916
  const isEqual = lodash.isEqual(newV, oldV);
@@ -18486,6 +18514,7 @@ const HierarchizedPickerComponent = class {
18486
18514
  this.translateDataForTree(dataToLoad);
18487
18515
  if (this.theOptions.openTreeWhenLoaded) {
18488
18516
  this.showTree("modale");
18517
+ setTimeout(() => { this.focusSearchInput(); }, 200);
18489
18518
  }
18490
18519
  }
18491
18520
  }
@@ -18650,15 +18679,17 @@ const HierarchizedPickerComponent = class {
18650
18679
  if (this.theOptions.origin != 'thesaurus' || !dataToLoad)
18651
18680
  return;
18652
18681
  this.mylog('Translate from Thesaurus ! (' + this.theOptions.source + ')', dataToLoad);
18653
- let fillTreeWithObject = (tree, object, depth = 0) => {
18654
- if (object && object.length) {
18655
- object.forEach((value, _index) => {
18682
+ let fillTreeWithObject = (tree, myobject, depth = 0) => {
18683
+ if (myobject && myobject.length) {
18684
+ myobject.forEach((value, _index) => {
18656
18685
  let keyPropFromNode = this.getPropertyFromNode(value, 'key');
18657
18686
  let valueTranslatedPropFromNode = this.getPropertyFromNode(value, 'valueTranslated');
18658
18687
  let fullpathPropFromNode = this.getPropertyFromNode(value, 'fullpath');
18659
18688
  let fullpathTranslatedPropFromNode = this.getPropertyFromNode(value, 'fullpathTranslated');
18660
18689
  let childrenPropFromNode = this.getPropertyFromNode(value, 'children', false);
18661
18690
  let deprecated = this.getPropertyFromNode(value, 'deprecated', false);
18691
+ // Quick fix until I fully understand what is going on ...
18692
+ childrenPropFromNode = childrenPropFromNode.filter(subvalue => this.getPropertyFromNode(subvalue, 'fullpath').includes(fullpathPropFromNode));
18662
18693
  let objToPush = {
18663
18694
  id: keyPropFromNode,
18664
18695
  depth: depth,
@@ -82,27 +82,55 @@ export class HierarchizedPickerComponent {
82
82
  });
83
83
  }
84
84
  async setNewOption(newValue, oldValue = null) {
85
- this.canload = true;
85
+ // --------------------------------------- DEPRECATED ?
86
+ // this.canload = true;
87
+ // this.theOptions = newValue;
88
+ // if (this.theOptions.source != "file") {
89
+ // this.rawData = null;
90
+ // }
91
+ // this.ready = false;
92
+ //NOTE: This could work in a synchronous environment => this.reloadCurrentValues();
93
+ // ---------------------------------------
86
94
  this.theOptions = newValue;
87
- if (this.theOptions.source != "file") {
95
+ if (((oldValue && (newValue.origin != oldValue.origin
96
+ || newValue.options.StartNodeID != oldValue.options.StartNodeID)) || !oldValue)
97
+ && this.theOptions.source != "file") {
88
98
  this.rawData = null;
89
99
  }
90
100
  this.ready = false;
91
- await this.loadHierarchizedPicker();
92
- this.displayWhenLoaded();
93
- //NOTE: This could work in a synchronous environment => this.reloadCurrentValues();
101
+ this.canload = this.isInstanceOfIConf(this.theOptions);
102
+ if (!this.canload) {
103
+ this.displayPickerError('Error(s) in the picker configuration!');
104
+ return;
105
+ }
106
+ if (oldValue && JSON.stringify(newValue.options) != JSON.stringify(oldValue.options)) {
107
+ this.value = [];
108
+ }
109
+ if (newValue && newValue.loading == "display") {
110
+ if ((oldValue && this.isChangeInOptions(newValue, oldValue)) || !oldValue) {
111
+ await this.loadHierarchizedPicker();
112
+ this.displayWhenLoaded();
113
+ }
114
+ else {
115
+ this.ready = true;
116
+ }
117
+ }
94
118
  }
95
119
  setNewOptions(newoptions) {
96
- this.setOptions(JSON.parse(newoptions));
120
+ if (typeof newoptions == 'string')
121
+ newoptions = JSON.parse(newoptions);
122
+ this.setOptions(newoptions);
97
123
  }
98
124
  setNewFilter(newfilter) {
99
125
  this.filterTree(newfilter);
100
126
  }
101
- optionsChange(newValue) {
127
+ optionsChange(newValue, oldValue) {
102
128
  if (!this.theOptions || !this.ready || this.ignoreOptionsChanges) {
103
129
  return;
104
130
  }
105
- this.setNewOption(newValue);
131
+ if (typeof newValue == 'string')
132
+ newValue = JSON.parse(newValue);
133
+ this.setNewOption(newValue, oldValue);
106
134
  }
107
135
  isChangeInOptions(newV, oldV) {
108
136
  const isEqual = _.isEqual(newV, oldV);
@@ -709,6 +737,7 @@ export class HierarchizedPickerComponent {
709
737
  this.translateDataForTree(dataToLoad);
710
738
  if (this.theOptions.openTreeWhenLoaded) {
711
739
  this.showTree("modale");
740
+ setTimeout(() => { this.focusSearchInput(); }, 200);
712
741
  }
713
742
  }
714
743
  }
@@ -873,15 +902,17 @@ export class HierarchizedPickerComponent {
873
902
  if (this.theOptions.origin != 'thesaurus' || !dataToLoad)
874
903
  return;
875
904
  this.mylog('Translate from Thesaurus ! (' + this.theOptions.source + ')', dataToLoad);
876
- let fillTreeWithObject = (tree, object, depth = 0) => {
877
- if (object && object.length) {
878
- object.forEach((value, _index) => {
905
+ let fillTreeWithObject = (tree, myobject, depth = 0) => {
906
+ if (myobject && myobject.length) {
907
+ myobject.forEach((value, _index) => {
879
908
  let keyPropFromNode = this.getPropertyFromNode(value, 'key');
880
909
  let valueTranslatedPropFromNode = this.getPropertyFromNode(value, 'valueTranslated');
881
910
  let fullpathPropFromNode = this.getPropertyFromNode(value, 'fullpath');
882
911
  let fullpathTranslatedPropFromNode = this.getPropertyFromNode(value, 'fullpathTranslated');
883
912
  let childrenPropFromNode = this.getPropertyFromNode(value, 'children', false);
884
913
  let deprecated = this.getPropertyFromNode(value, 'deprecated', false);
914
+ // Quick fix until I fully understand what is going on ...
915
+ childrenPropFromNode = childrenPropFromNode.filter(subvalue => this.getPropertyFromNode(subvalue, 'fullpath').includes(fullpathPropFromNode));
885
916
  let objToPush = {
886
917
  id: keyPropFromNode,
887
918
  depth: depth,
@@ -17860,27 +17860,55 @@ const HierarchizedPickerComponent = class extends HTMLElement {
17860
17860
  });
17861
17861
  }
17862
17862
  async setNewOption(newValue, oldValue = null) {
17863
- this.canload = true;
17863
+ // --------------------------------------- DEPRECATED ?
17864
+ // this.canload = true;
17865
+ // this.theOptions = newValue;
17866
+ // if (this.theOptions.source != "file") {
17867
+ // this.rawData = null;
17868
+ // }
17869
+ // this.ready = false;
17870
+ //NOTE: This could work in a synchronous environment => this.reloadCurrentValues();
17871
+ // ---------------------------------------
17864
17872
  this.theOptions = newValue;
17865
- if (this.theOptions.source != "file") {
17873
+ if (((oldValue && (newValue.origin != oldValue.origin
17874
+ || newValue.options.StartNodeID != oldValue.options.StartNodeID)) || !oldValue)
17875
+ && this.theOptions.source != "file") {
17866
17876
  this.rawData = null;
17867
17877
  }
17868
17878
  this.ready = false;
17869
- await this.loadHierarchizedPicker();
17870
- this.displayWhenLoaded();
17871
- //NOTE: This could work in a synchronous environment => this.reloadCurrentValues();
17879
+ this.canload = this.isInstanceOfIConf(this.theOptions);
17880
+ if (!this.canload) {
17881
+ this.displayPickerError('Error(s) in the picker configuration!');
17882
+ return;
17883
+ }
17884
+ if (oldValue && JSON.stringify(newValue.options) != JSON.stringify(oldValue.options)) {
17885
+ this.value = [];
17886
+ }
17887
+ if (newValue && newValue.loading == "display") {
17888
+ if ((oldValue && this.isChangeInOptions(newValue, oldValue)) || !oldValue) {
17889
+ await this.loadHierarchizedPicker();
17890
+ this.displayWhenLoaded();
17891
+ }
17892
+ else {
17893
+ this.ready = true;
17894
+ }
17895
+ }
17872
17896
  }
17873
17897
  setNewOptions(newoptions) {
17874
- this.setOptions(JSON.parse(newoptions));
17898
+ if (typeof newoptions == 'string')
17899
+ newoptions = JSON.parse(newoptions);
17900
+ this.setOptions(newoptions);
17875
17901
  }
17876
17902
  setNewFilter(newfilter) {
17877
17903
  this.filterTree(newfilter);
17878
17904
  }
17879
- optionsChange(newValue) {
17905
+ optionsChange(newValue, oldValue) {
17880
17906
  if (!this.theOptions || !this.ready || this.ignoreOptionsChanges) {
17881
17907
  return;
17882
17908
  }
17883
- this.setNewOption(newValue);
17909
+ if (typeof newValue == 'string')
17910
+ newValue = JSON.parse(newValue);
17911
+ this.setNewOption(newValue, oldValue);
17884
17912
  }
17885
17913
  isChangeInOptions(newV, oldV) {
17886
17914
  const isEqual = lodash.isEqual(newV, oldV);
@@ -18484,6 +18512,7 @@ const HierarchizedPickerComponent = class extends HTMLElement {
18484
18512
  this.translateDataForTree(dataToLoad);
18485
18513
  if (this.theOptions.openTreeWhenLoaded) {
18486
18514
  this.showTree("modale");
18515
+ setTimeout(() => { this.focusSearchInput(); }, 200);
18487
18516
  }
18488
18517
  }
18489
18518
  }
@@ -18648,15 +18677,17 @@ const HierarchizedPickerComponent = class extends HTMLElement {
18648
18677
  if (this.theOptions.origin != 'thesaurus' || !dataToLoad)
18649
18678
  return;
18650
18679
  this.mylog('Translate from Thesaurus ! (' + this.theOptions.source + ')', dataToLoad);
18651
- let fillTreeWithObject = (tree, object, depth = 0) => {
18652
- if (object && object.length) {
18653
- object.forEach((value, _index) => {
18680
+ let fillTreeWithObject = (tree, myobject, depth = 0) => {
18681
+ if (myobject && myobject.length) {
18682
+ myobject.forEach((value, _index) => {
18654
18683
  let keyPropFromNode = this.getPropertyFromNode(value, 'key');
18655
18684
  let valueTranslatedPropFromNode = this.getPropertyFromNode(value, 'valueTranslated');
18656
18685
  let fullpathPropFromNode = this.getPropertyFromNode(value, 'fullpath');
18657
18686
  let fullpathTranslatedPropFromNode = this.getPropertyFromNode(value, 'fullpathTranslated');
18658
18687
  let childrenPropFromNode = this.getPropertyFromNode(value, 'children', false);
18659
18688
  let deprecated = this.getPropertyFromNode(value, 'deprecated', false);
18689
+ // Quick fix until I fully understand what is going on ...
18690
+ childrenPropFromNode = childrenPropFromNode.filter(subvalue => this.getPropertyFromNode(subvalue, 'fullpath').includes(fullpathPropFromNode));
18660
18691
  let objToPush = {
18661
18692
  id: keyPropFromNode,
18662
18693
  depth: depth,
@@ -17858,27 +17858,55 @@ const HierarchizedPickerComponent = class {
17858
17858
  });
17859
17859
  }
17860
17860
  async setNewOption(newValue, oldValue = null) {
17861
- this.canload = true;
17861
+ // --------------------------------------- DEPRECATED ?
17862
+ // this.canload = true;
17863
+ // this.theOptions = newValue;
17864
+ // if (this.theOptions.source != "file") {
17865
+ // this.rawData = null;
17866
+ // }
17867
+ // this.ready = false;
17868
+ //NOTE: This could work in a synchronous environment => this.reloadCurrentValues();
17869
+ // ---------------------------------------
17862
17870
  this.theOptions = newValue;
17863
- if (this.theOptions.source != "file") {
17871
+ if (((oldValue && (newValue.origin != oldValue.origin
17872
+ || newValue.options.StartNodeID != oldValue.options.StartNodeID)) || !oldValue)
17873
+ && this.theOptions.source != "file") {
17864
17874
  this.rawData = null;
17865
17875
  }
17866
17876
  this.ready = false;
17867
- await this.loadHierarchizedPicker();
17868
- this.displayWhenLoaded();
17869
- //NOTE: This could work in a synchronous environment => this.reloadCurrentValues();
17877
+ this.canload = this.isInstanceOfIConf(this.theOptions);
17878
+ if (!this.canload) {
17879
+ this.displayPickerError('Error(s) in the picker configuration!');
17880
+ return;
17881
+ }
17882
+ if (oldValue && JSON.stringify(newValue.options) != JSON.stringify(oldValue.options)) {
17883
+ this.value = [];
17884
+ }
17885
+ if (newValue && newValue.loading == "display") {
17886
+ if ((oldValue && this.isChangeInOptions(newValue, oldValue)) || !oldValue) {
17887
+ await this.loadHierarchizedPicker();
17888
+ this.displayWhenLoaded();
17889
+ }
17890
+ else {
17891
+ this.ready = true;
17892
+ }
17893
+ }
17870
17894
  }
17871
17895
  setNewOptions(newoptions) {
17872
- this.setOptions(JSON.parse(newoptions));
17896
+ if (typeof newoptions == 'string')
17897
+ newoptions = JSON.parse(newoptions);
17898
+ this.setOptions(newoptions);
17873
17899
  }
17874
17900
  setNewFilter(newfilter) {
17875
17901
  this.filterTree(newfilter);
17876
17902
  }
17877
- optionsChange(newValue) {
17903
+ optionsChange(newValue, oldValue) {
17878
17904
  if (!this.theOptions || !this.ready || this.ignoreOptionsChanges) {
17879
17905
  return;
17880
17906
  }
17881
- this.setNewOption(newValue);
17907
+ if (typeof newValue == 'string')
17908
+ newValue = JSON.parse(newValue);
17909
+ this.setNewOption(newValue, oldValue);
17882
17910
  }
17883
17911
  isChangeInOptions(newV, oldV) {
17884
17912
  const isEqual = lodash.isEqual(newV, oldV);
@@ -18482,6 +18510,7 @@ const HierarchizedPickerComponent = class {
18482
18510
  this.translateDataForTree(dataToLoad);
18483
18511
  if (this.theOptions.openTreeWhenLoaded) {
18484
18512
  this.showTree("modale");
18513
+ setTimeout(() => { this.focusSearchInput(); }, 200);
18485
18514
  }
18486
18515
  }
18487
18516
  }
@@ -18646,15 +18675,17 @@ const HierarchizedPickerComponent = class {
18646
18675
  if (this.theOptions.origin != 'thesaurus' || !dataToLoad)
18647
18676
  return;
18648
18677
  this.mylog('Translate from Thesaurus ! (' + this.theOptions.source + ')', dataToLoad);
18649
- let fillTreeWithObject = (tree, object, depth = 0) => {
18650
- if (object && object.length) {
18651
- object.forEach((value, _index) => {
18678
+ let fillTreeWithObject = (tree, myobject, depth = 0) => {
18679
+ if (myobject && myobject.length) {
18680
+ myobject.forEach((value, _index) => {
18652
18681
  let keyPropFromNode = this.getPropertyFromNode(value, 'key');
18653
18682
  let valueTranslatedPropFromNode = this.getPropertyFromNode(value, 'valueTranslated');
18654
18683
  let fullpathPropFromNode = this.getPropertyFromNode(value, 'fullpath');
18655
18684
  let fullpathTranslatedPropFromNode = this.getPropertyFromNode(value, 'fullpathTranslated');
18656
18685
  let childrenPropFromNode = this.getPropertyFromNode(value, 'children', false);
18657
18686
  let deprecated = this.getPropertyFromNode(value, 'deprecated', false);
18687
+ // Quick fix until I fully understand what is going on ...
18688
+ childrenPropFromNode = childrenPropFromNode.filter(subvalue => this.getPropertyFromNode(subvalue, 'fullpath').includes(fullpathPropFromNode));
18658
18689
  let objToPush = {
18659
18690
  id: keyPropFromNode,
18660
18691
  depth: depth,