reneco-hierarchized-picker 0.4.2 → 0.4.3-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.
@@ -312,10 +312,10 @@ Tree.prototype.bindEvent = function (ele) {
312
312
  return;
313
313
  const { target } = e;
314
314
  if (target.nodeName === 'SPAN' && (target.classList.contains('treejs-checkbox') || target.classList.contains('treejs-label'))) {
315
- this.onItemClick(target.parentNode.nodeId);
315
+ this.onItemClick(target.parentNode.nodeId, e.button == 2);
316
316
  }
317
317
  else if (target.nodeName === 'LI' && target.classList.contains('treejs-node')) {
318
- this.onItemClick(target.nodeId);
318
+ this.onItemClick(target.nodeId, e.button == 2);
319
319
  }
320
320
  else if (target.nodeName === 'SPAN' && target.classList.contains('treejs-switcher')) {
321
321
  this.onSwitcherClick(target);
@@ -365,13 +365,16 @@ Tree.prototype.bindEvent = function (ele) {
365
365
  }
366
366
  }, false);
367
367
  };
368
- Tree.prototype.onItemClick = function (id) {
368
+ Tree.prototype.onItemClick = async function (id, rightclick = false) {
369
369
  // TODO Temporarily ignores disabled mode for selecting nodes if mode is tree
370
370
  if (this.options.parentApi.isDisabled && this.options.parentApi.optionsManager.getOptions().mode != "tree")
371
371
  return;
372
- if (!this.options.parentApi.theOptions.multiple)
373
- this.emptyNodesCheckStatus();
374
- this.options.parentApi.setNodeAsSelected(id, this, true);
372
+ const pickerValue = await this.options.parentApi.getValue();
373
+ if (!rightclick || !pickerValue || pickerValue.nodeid != id) {
374
+ if (!this.options.parentApi.theOptions.multiple)
375
+ this.emptyNodesCheckStatus();
376
+ this.options.parentApi.setNodeAsSelected(id, this, true);
377
+ }
375
378
  };
376
379
  Tree.prototype.unCheckElement = function (id) {
377
380
  this.setValue(id);
@@ -17901,7 +17904,6 @@ function isInstanceOfIConf(object) {
17901
17904
  toret = false;
17902
17905
  errorToLog = "options.url value '" + object.url + "' doesn't meet interface IConf requirements, is wrongly formated or doesn't match option.source value";
17903
17906
  }
17904
- //TODO allow Function along with string
17905
17907
  if (!((object.source != 'webservice' && !object.token) ||
17906
17908
  (object.source == 'webservice' && object.token && (typeof object.token == 'string' || typeof object.token == 'function')))) {
17907
17909
  toret = false;
@@ -18778,7 +18780,7 @@ const HierarchizedPickerComponent = class {
18778
18780
  // this.rawData = null;
18779
18781
  // }
18780
18782
  // this.ready = false;
18781
- //NOTE: This could work in a synchronous environment =>
18783
+ //NOTE: This could work in a synchronous environment =>
18782
18784
  // reloadCurrentValues() {
18783
18785
  // let savedValues = this.value;
18784
18786
  // this.value = [];
@@ -18787,6 +18789,10 @@ const HierarchizedPickerComponent = class {
18787
18789
  // });
18788
18790
  // ---------------------------------------
18789
18791
  // this.theOptions = newValue;
18792
+ if (oldValue && JSON.stringify(newValue.options) == JSON.stringify(oldValue.options)) {
18793
+ this.ready = true;
18794
+ return;
18795
+ }
18790
18796
  if (typeof newValue == 'string')
18791
18797
  newValue = JSON.parse(newValue);
18792
18798
  if (typeof oldValue == 'string')
@@ -19142,9 +19148,9 @@ const HierarchizedPickerComponent = class {
19142
19148
  }
19143
19149
  }
19144
19150
  // TODO > Celine would rather like the context (thesaurus or position) to be extracted another way
19145
- getContextualApiURL() {
19151
+ getContextualApiURL(init = false) {
19146
19152
  const { options, url } = this.optionsManager.getOptions();
19147
- if (options.Reach) {
19153
+ if (init && options.Reach) {
19148
19154
  // Use a base URL for relative paths
19149
19155
  const base = window.location.origin; // fallback for relative URLs
19150
19156
  const parsedUrl = new URL(url, base);
@@ -19153,16 +19159,17 @@ const HierarchizedPickerComponent = class {
19153
19159
  if (['thesaurus', 'position'].indexOf(dynamicType) == -1)
19154
19160
  dynamicType = pathSegments[pathSegments.length - 1];
19155
19161
  const newPathname = `/api/v1/classification/reach/${dynamicType}/${options.Reach}`;
19156
- this.optionsManager.dropReach();
19157
19162
  return `${parsedUrl.origin}${newPathname}`;
19158
19163
  }
19159
19164
  return url;
19160
19165
  }
19161
- getContextualApiParams(options = null, search = null) {
19166
+ getContextualApiParams(options = null, search = null, init = false) {
19162
19167
  if (!options)
19163
19168
  options = this.optionsManager.getOptions().options;
19164
19169
  let optionsToReturn = Object.assign({}, options);
19165
- if (options.Reach) {
19170
+ if (!init)
19171
+ delete optionsToReturn.Reach;
19172
+ if (optionsToReturn.Reach) {
19166
19173
  delete optionsToReturn.Reach;
19167
19174
  if ("startNode" in optionsToReturn) {
19168
19175
  optionsToReturn.startingnode = optionsToReturn.startNode;
@@ -19575,8 +19582,8 @@ const HierarchizedPickerComponent = class {
19575
19582
  loadDataForTree(init, loader) {
19576
19583
  if (this.optionsManager.getOptions().source == 'webservice') {
19577
19584
  if (this.optionsManager.getOptions().origin == 'classification') {
19578
- const contextualApiParams = this.getContextualApiParams();
19579
- const contextualApiURL = this.getContextualApiURL();
19585
+ const contextualApiParams = this.getContextualApiParams(null, null, true);
19586
+ const contextualApiURL = this.getContextualApiURL(true);
19580
19587
  this.rawDataManager.getFromClassification(contextualApiURL, contextualApiParams, loader).then((data) => {
19581
19588
  this.rawData = data;
19582
19589
  if (init) {
@@ -95,7 +95,7 @@ export class HierarchizedPickerComponent {
95
95
  // this.rawData = null;
96
96
  // }
97
97
  // this.ready = false;
98
- //NOTE: This could work in a synchronous environment =>
98
+ //NOTE: This could work in a synchronous environment =>
99
99
  // reloadCurrentValues() {
100
100
  // let savedValues = this.value;
101
101
  // this.value = [];
@@ -104,6 +104,10 @@ export class HierarchizedPickerComponent {
104
104
  // });
105
105
  // ---------------------------------------
106
106
  // this.theOptions = newValue;
107
+ if (oldValue && JSON.stringify(newValue.options) == JSON.stringify(oldValue.options)) {
108
+ this.ready = true;
109
+ return;
110
+ }
107
111
  if (typeof newValue == 'string')
108
112
  newValue = JSON.parse(newValue);
109
113
  if (typeof oldValue == 'string')
@@ -457,9 +461,9 @@ export class HierarchizedPickerComponent {
457
461
  }
458
462
  }
459
463
  // TODO > Celine would rather like the context (thesaurus or position) to be extracted another way
460
- getContextualApiURL() {
464
+ getContextualApiURL(init = false) {
461
465
  const { options, url } = this.optionsManager.getOptions();
462
- if (options.Reach) {
466
+ if (init && options.Reach) {
463
467
  // Use a base URL for relative paths
464
468
  const base = window.location.origin; // fallback for relative URLs
465
469
  const parsedUrl = new URL(url, base);
@@ -468,16 +472,17 @@ export class HierarchizedPickerComponent {
468
472
  if (['thesaurus', 'position'].indexOf(dynamicType) == -1)
469
473
  dynamicType = pathSegments[pathSegments.length - 1];
470
474
  const newPathname = `/api/v1/classification/reach/${dynamicType}/${options.Reach}`;
471
- this.optionsManager.dropReach();
472
475
  return `${parsedUrl.origin}${newPathname}`;
473
476
  }
474
477
  return url;
475
478
  }
476
- getContextualApiParams(options = null, search = null) {
479
+ getContextualApiParams(options = null, search = null, init = false) {
477
480
  if (!options)
478
481
  options = this.optionsManager.getOptions().options;
479
482
  let optionsToReturn = Object.assign({}, options);
480
- if (options.Reach) {
483
+ if (!init)
484
+ delete optionsToReturn.Reach;
485
+ if (optionsToReturn.Reach) {
481
486
  delete optionsToReturn.Reach;
482
487
  if ("startNode" in optionsToReturn) {
483
488
  optionsToReturn.startingnode = optionsToReturn.startNode;
@@ -890,8 +895,8 @@ export class HierarchizedPickerComponent {
890
895
  loadDataForTree(init, loader) {
891
896
  if (this.optionsManager.getOptions().source == 'webservice') {
892
897
  if (this.optionsManager.getOptions().origin == 'classification') {
893
- const contextualApiParams = this.getContextualApiParams();
894
- const contextualApiURL = this.getContextualApiURL();
898
+ const contextualApiParams = this.getContextualApiParams(null, null, true);
899
+ const contextualApiURL = this.getContextualApiURL(true);
895
900
  this.rawDataManager.getFromClassification(contextualApiURL, contextualApiParams, loader).then((data) => {
896
901
  this.rawData = data;
897
902
  if (init) {
@@ -180,10 +180,10 @@ Tree.prototype.bindEvent = function (ele) {
180
180
  return;
181
181
  const { target } = e;
182
182
  if (target.nodeName === 'SPAN' && (target.classList.contains('treejs-checkbox') || target.classList.contains('treejs-label'))) {
183
- this.onItemClick(target.parentNode.nodeId);
183
+ this.onItemClick(target.parentNode.nodeId, e.button == 2);
184
184
  }
185
185
  else if (target.nodeName === 'LI' && target.classList.contains('treejs-node')) {
186
- this.onItemClick(target.nodeId);
186
+ this.onItemClick(target.nodeId, e.button == 2);
187
187
  }
188
188
  else if (target.nodeName === 'SPAN' && target.classList.contains('treejs-switcher')) {
189
189
  this.onSwitcherClick(target);
@@ -233,13 +233,16 @@ Tree.prototype.bindEvent = function (ele) {
233
233
  }
234
234
  }, false);
235
235
  };
236
- Tree.prototype.onItemClick = function (id) {
236
+ Tree.prototype.onItemClick = async function (id, rightclick = false) {
237
237
  // TODO Temporarily ignores disabled mode for selecting nodes if mode is tree
238
238
  if (this.options.parentApi.isDisabled && this.options.parentApi.optionsManager.getOptions().mode != "tree")
239
239
  return;
240
- if (!this.options.parentApi.theOptions.multiple)
241
- this.emptyNodesCheckStatus();
242
- this.options.parentApi.setNodeAsSelected(id, this, true);
240
+ const pickerValue = await this.options.parentApi.getValue();
241
+ if (!rightclick || !pickerValue || pickerValue.nodeid != id) {
242
+ if (!this.options.parentApi.theOptions.multiple)
243
+ this.emptyNodesCheckStatus();
244
+ this.options.parentApi.setNodeAsSelected(id, this, true);
245
+ }
243
246
  };
244
247
  Tree.prototype.unCheckElement = function (id) {
245
248
  this.setValue(id);
@@ -11,7 +11,6 @@ export function isInstanceOfIConf(object) {
11
11
  toret = false;
12
12
  errorToLog = "options.url value '" + object.url + "' doesn't meet interface IConf requirements, is wrongly formated or doesn't match option.source value";
13
13
  }
14
- //TODO allow Function along with string
15
14
  if (!((object.source != 'webservice' && !object.token) ||
16
15
  (object.source == 'webservice' && object.token && (typeof object.token == 'string' || typeof object.token == 'function')))) {
17
16
  toret = false;
@@ -309,10 +309,10 @@ Tree.prototype.bindEvent = function (ele) {
309
309
  return;
310
310
  const { target } = e;
311
311
  if (target.nodeName === 'SPAN' && (target.classList.contains('treejs-checkbox') || target.classList.contains('treejs-label'))) {
312
- this.onItemClick(target.parentNode.nodeId);
312
+ this.onItemClick(target.parentNode.nodeId, e.button == 2);
313
313
  }
314
314
  else if (target.nodeName === 'LI' && target.classList.contains('treejs-node')) {
315
- this.onItemClick(target.nodeId);
315
+ this.onItemClick(target.nodeId, e.button == 2);
316
316
  }
317
317
  else if (target.nodeName === 'SPAN' && target.classList.contains('treejs-switcher')) {
318
318
  this.onSwitcherClick(target);
@@ -362,13 +362,16 @@ Tree.prototype.bindEvent = function (ele) {
362
362
  }
363
363
  }, false);
364
364
  };
365
- Tree.prototype.onItemClick = function (id) {
365
+ Tree.prototype.onItemClick = async function (id, rightclick = false) {
366
366
  // TODO Temporarily ignores disabled mode for selecting nodes if mode is tree
367
367
  if (this.options.parentApi.isDisabled && this.options.parentApi.optionsManager.getOptions().mode != "tree")
368
368
  return;
369
- if (!this.options.parentApi.theOptions.multiple)
370
- this.emptyNodesCheckStatus();
371
- this.options.parentApi.setNodeAsSelected(id, this, true);
369
+ const pickerValue = await this.options.parentApi.getValue();
370
+ if (!rightclick || !pickerValue || pickerValue.nodeid != id) {
371
+ if (!this.options.parentApi.theOptions.multiple)
372
+ this.emptyNodesCheckStatus();
373
+ this.options.parentApi.setNodeAsSelected(id, this, true);
374
+ }
372
375
  };
373
376
  Tree.prototype.unCheckElement = function (id) {
374
377
  this.setValue(id);
@@ -17898,7 +17901,6 @@ function isInstanceOfIConf(object) {
17898
17901
  toret = false;
17899
17902
  errorToLog = "options.url value '" + object.url + "' doesn't meet interface IConf requirements, is wrongly formated or doesn't match option.source value";
17900
17903
  }
17901
- //TODO allow Function along with string
17902
17904
  if (!((object.source != 'webservice' && !object.token) ||
17903
17905
  (object.source == 'webservice' && object.token && (typeof object.token == 'string' || typeof object.token == 'function')))) {
17904
17906
  toret = false;
@@ -18775,7 +18777,7 @@ const HierarchizedPickerComponent = class extends HTMLElement {
18775
18777
  // this.rawData = null;
18776
18778
  // }
18777
18779
  // this.ready = false;
18778
- //NOTE: This could work in a synchronous environment =>
18780
+ //NOTE: This could work in a synchronous environment =>
18779
18781
  // reloadCurrentValues() {
18780
18782
  // let savedValues = this.value;
18781
18783
  // this.value = [];
@@ -18784,6 +18786,10 @@ const HierarchizedPickerComponent = class extends HTMLElement {
18784
18786
  // });
18785
18787
  // ---------------------------------------
18786
18788
  // this.theOptions = newValue;
18789
+ if (oldValue && JSON.stringify(newValue.options) == JSON.stringify(oldValue.options)) {
18790
+ this.ready = true;
18791
+ return;
18792
+ }
18787
18793
  if (typeof newValue == 'string')
18788
18794
  newValue = JSON.parse(newValue);
18789
18795
  if (typeof oldValue == 'string')
@@ -19140,9 +19146,9 @@ const HierarchizedPickerComponent = class extends HTMLElement {
19140
19146
  }
19141
19147
  }
19142
19148
  // TODO > Celine would rather like the context (thesaurus or position) to be extracted another way
19143
- getContextualApiURL() {
19149
+ getContextualApiURL(init = false) {
19144
19150
  const { options, url } = this.optionsManager.getOptions();
19145
- if (options.Reach) {
19151
+ if (init && options.Reach) {
19146
19152
  // Use a base URL for relative paths
19147
19153
  const base = window.location.origin; // fallback for relative URLs
19148
19154
  const parsedUrl = new URL(url, base);
@@ -19151,16 +19157,17 @@ const HierarchizedPickerComponent = class extends HTMLElement {
19151
19157
  if (['thesaurus', 'position'].indexOf(dynamicType) == -1)
19152
19158
  dynamicType = pathSegments[pathSegments.length - 1];
19153
19159
  const newPathname = `/api/v1/classification/reach/${dynamicType}/${options.Reach}`;
19154
- this.optionsManager.dropReach();
19155
19160
  return `${parsedUrl.origin}${newPathname}`;
19156
19161
  }
19157
19162
  return url;
19158
19163
  }
19159
- getContextualApiParams(options = null, search = null) {
19164
+ getContextualApiParams(options = null, search = null, init = false) {
19160
19165
  if (!options)
19161
19166
  options = this.optionsManager.getOptions().options;
19162
19167
  let optionsToReturn = Object.assign({}, options);
19163
- if (options.Reach) {
19168
+ if (!init)
19169
+ delete optionsToReturn.Reach;
19170
+ if (optionsToReturn.Reach) {
19164
19171
  delete optionsToReturn.Reach;
19165
19172
  if ("startNode" in optionsToReturn) {
19166
19173
  optionsToReturn.startingnode = optionsToReturn.startNode;
@@ -19573,8 +19580,8 @@ const HierarchizedPickerComponent = class extends HTMLElement {
19573
19580
  loadDataForTree(init, loader) {
19574
19581
  if (this.optionsManager.getOptions().source == 'webservice') {
19575
19582
  if (this.optionsManager.getOptions().origin == 'classification') {
19576
- const contextualApiParams = this.getContextualApiParams();
19577
- const contextualApiURL = this.getContextualApiURL();
19583
+ const contextualApiParams = this.getContextualApiParams(null, null, true);
19584
+ const contextualApiURL = this.getContextualApiURL(true);
19578
19585
  this.rawDataManager.getFromClassification(contextualApiURL, contextualApiParams, loader).then((data) => {
19579
19586
  this.rawData = data;
19580
19587
  if (init) {
@@ -308,10 +308,10 @@ Tree.prototype.bindEvent = function (ele) {
308
308
  return;
309
309
  const { target } = e;
310
310
  if (target.nodeName === 'SPAN' && (target.classList.contains('treejs-checkbox') || target.classList.contains('treejs-label'))) {
311
- this.onItemClick(target.parentNode.nodeId);
311
+ this.onItemClick(target.parentNode.nodeId, e.button == 2);
312
312
  }
313
313
  else if (target.nodeName === 'LI' && target.classList.contains('treejs-node')) {
314
- this.onItemClick(target.nodeId);
314
+ this.onItemClick(target.nodeId, e.button == 2);
315
315
  }
316
316
  else if (target.nodeName === 'SPAN' && target.classList.contains('treejs-switcher')) {
317
317
  this.onSwitcherClick(target);
@@ -361,13 +361,16 @@ Tree.prototype.bindEvent = function (ele) {
361
361
  }
362
362
  }, false);
363
363
  };
364
- Tree.prototype.onItemClick = function (id) {
364
+ Tree.prototype.onItemClick = async function (id, rightclick = false) {
365
365
  // TODO Temporarily ignores disabled mode for selecting nodes if mode is tree
366
366
  if (this.options.parentApi.isDisabled && this.options.parentApi.optionsManager.getOptions().mode != "tree")
367
367
  return;
368
- if (!this.options.parentApi.theOptions.multiple)
369
- this.emptyNodesCheckStatus();
370
- this.options.parentApi.setNodeAsSelected(id, this, true);
368
+ const pickerValue = await this.options.parentApi.getValue();
369
+ if (!rightclick || !pickerValue || pickerValue.nodeid != id) {
370
+ if (!this.options.parentApi.theOptions.multiple)
371
+ this.emptyNodesCheckStatus();
372
+ this.options.parentApi.setNodeAsSelected(id, this, true);
373
+ }
371
374
  };
372
375
  Tree.prototype.unCheckElement = function (id) {
373
376
  this.setValue(id);
@@ -17897,7 +17900,6 @@ function isInstanceOfIConf(object) {
17897
17900
  toret = false;
17898
17901
  errorToLog = "options.url value '" + object.url + "' doesn't meet interface IConf requirements, is wrongly formated or doesn't match option.source value";
17899
17902
  }
17900
- //TODO allow Function along with string
17901
17903
  if (!((object.source != 'webservice' && !object.token) ||
17902
17904
  (object.source == 'webservice' && object.token && (typeof object.token == 'string' || typeof object.token == 'function')))) {
17903
17905
  toret = false;
@@ -18774,7 +18776,7 @@ const HierarchizedPickerComponent = class {
18774
18776
  // this.rawData = null;
18775
18777
  // }
18776
18778
  // this.ready = false;
18777
- //NOTE: This could work in a synchronous environment =>
18779
+ //NOTE: This could work in a synchronous environment =>
18778
18780
  // reloadCurrentValues() {
18779
18781
  // let savedValues = this.value;
18780
18782
  // this.value = [];
@@ -18783,6 +18785,10 @@ const HierarchizedPickerComponent = class {
18783
18785
  // });
18784
18786
  // ---------------------------------------
18785
18787
  // this.theOptions = newValue;
18788
+ if (oldValue && JSON.stringify(newValue.options) == JSON.stringify(oldValue.options)) {
18789
+ this.ready = true;
18790
+ return;
18791
+ }
18786
18792
  if (typeof newValue == 'string')
18787
18793
  newValue = JSON.parse(newValue);
18788
18794
  if (typeof oldValue == 'string')
@@ -19138,9 +19144,9 @@ const HierarchizedPickerComponent = class {
19138
19144
  }
19139
19145
  }
19140
19146
  // TODO > Celine would rather like the context (thesaurus or position) to be extracted another way
19141
- getContextualApiURL() {
19147
+ getContextualApiURL(init = false) {
19142
19148
  const { options, url } = this.optionsManager.getOptions();
19143
- if (options.Reach) {
19149
+ if (init && options.Reach) {
19144
19150
  // Use a base URL for relative paths
19145
19151
  const base = window.location.origin; // fallback for relative URLs
19146
19152
  const parsedUrl = new URL(url, base);
@@ -19149,16 +19155,17 @@ const HierarchizedPickerComponent = class {
19149
19155
  if (['thesaurus', 'position'].indexOf(dynamicType) == -1)
19150
19156
  dynamicType = pathSegments[pathSegments.length - 1];
19151
19157
  const newPathname = `/api/v1/classification/reach/${dynamicType}/${options.Reach}`;
19152
- this.optionsManager.dropReach();
19153
19158
  return `${parsedUrl.origin}${newPathname}`;
19154
19159
  }
19155
19160
  return url;
19156
19161
  }
19157
- getContextualApiParams(options = null, search = null) {
19162
+ getContextualApiParams(options = null, search = null, init = false) {
19158
19163
  if (!options)
19159
19164
  options = this.optionsManager.getOptions().options;
19160
19165
  let optionsToReturn = Object.assign({}, options);
19161
- if (options.Reach) {
19166
+ if (!init)
19167
+ delete optionsToReturn.Reach;
19168
+ if (optionsToReturn.Reach) {
19162
19169
  delete optionsToReturn.Reach;
19163
19170
  if ("startNode" in optionsToReturn) {
19164
19171
  optionsToReturn.startingnode = optionsToReturn.startNode;
@@ -19571,8 +19578,8 @@ const HierarchizedPickerComponent = class {
19571
19578
  loadDataForTree(init, loader) {
19572
19579
  if (this.optionsManager.getOptions().source == 'webservice') {
19573
19580
  if (this.optionsManager.getOptions().origin == 'classification') {
19574
- const contextualApiParams = this.getContextualApiParams();
19575
- const contextualApiURL = this.getContextualApiURL();
19581
+ const contextualApiParams = this.getContextualApiParams(null, null, true);
19582
+ const contextualApiURL = this.getContextualApiURL(true);
19576
19583
  this.rawDataManager.getFromClassification(contextualApiURL, contextualApiParams, loader).then((data) => {
19577
19584
  this.rawData = data;
19578
19585
  if (init) {