reneco-hierarchized-picker 0.2.4 → 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);
@@ -18485,7 +18513,8 @@ const HierarchizedPickerComponent = class {
18485
18513
  if (!this.ready) {
18486
18514
  this.translateDataForTree(dataToLoad);
18487
18515
  if (this.theOptions.openTreeWhenLoaded) {
18488
- this.showTree("picker");
18516
+ this.showTree("modale");
18517
+ setTimeout(() => { this.focusSearchInput(); }, 200);
18489
18518
  }
18490
18519
  }
18491
18520
  }
@@ -19176,7 +19205,7 @@ const HierarchizedPickerComponent = class {
19176
19205
  this.clearAutocomplete(true);
19177
19206
  }
19178
19207
  if (focused == 'picker') {
19179
- setTimeout(() => { this.focusSearchInput(); }, 0);
19208
+ this.focusSearchInput();
19180
19209
  }
19181
19210
  else {
19182
19211
  this.focusModal();
@@ -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);
@@ -708,7 +736,8 @@ export class HierarchizedPickerComponent {
708
736
  if (!this.ready) {
709
737
  this.translateDataForTree(dataToLoad);
710
738
  if (this.theOptions.openTreeWhenLoaded) {
711
- this.showTree("picker");
739
+ this.showTree("modale");
740
+ setTimeout(() => { this.focusSearchInput(); }, 200);
712
741
  }
713
742
  }
714
743
  }
@@ -1399,7 +1428,7 @@ export class HierarchizedPickerComponent {
1399
1428
  this.clearAutocomplete(true);
1400
1429
  }
1401
1430
  if (focused == 'picker') {
1402
- setTimeout(() => { this.focusSearchInput(); }, 0);
1431
+ this.focusSearchInput();
1403
1432
  }
1404
1433
  else {
1405
1434
  this.focusModal();
@@ -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);
@@ -18483,7 +18511,8 @@ const HierarchizedPickerComponent = class extends HTMLElement {
18483
18511
  if (!this.ready) {
18484
18512
  this.translateDataForTree(dataToLoad);
18485
18513
  if (this.theOptions.openTreeWhenLoaded) {
18486
- this.showTree("picker");
18514
+ this.showTree("modale");
18515
+ setTimeout(() => { this.focusSearchInput(); }, 200);
18487
18516
  }
18488
18517
  }
18489
18518
  }
@@ -19174,7 +19203,7 @@ const HierarchizedPickerComponent = class extends HTMLElement {
19174
19203
  this.clearAutocomplete(true);
19175
19204
  }
19176
19205
  if (focused == 'picker') {
19177
- setTimeout(() => { this.focusSearchInput(); }, 0);
19206
+ this.focusSearchInput();
19178
19207
  }
19179
19208
  else {
19180
19209
  this.focusModal();
@@ -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);
@@ -18481,7 +18509,8 @@ const HierarchizedPickerComponent = class {
18481
18509
  if (!this.ready) {
18482
18510
  this.translateDataForTree(dataToLoad);
18483
18511
  if (this.theOptions.openTreeWhenLoaded) {
18484
- this.showTree("picker");
18512
+ this.showTree("modale");
18513
+ setTimeout(() => { this.focusSearchInput(); }, 200);
18485
18514
  }
18486
18515
  }
18487
18516
  }
@@ -19172,7 +19201,7 @@ const HierarchizedPickerComponent = class {
19172
19201
  this.clearAutocomplete(true);
19173
19202
  }
19174
19203
  if (focused == 'picker') {
19175
- setTimeout(() => { this.focusSearchInput(); }, 0);
19204
+ this.focusSearchInput();
19176
19205
  }
19177
19206
  else {
19178
19207
  this.focusModal();