@nys-cui/cui-formpill 0.2.8 → 0.2.10
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/package.json +1 -1
- package/src/cui-formpill.js +30 -1
package/package.json
CHANGED
package/src/cui-formpill.js
CHANGED
@@ -416,6 +416,34 @@ class CUI_FORMPILL extends HTMLElement {
|
|
416
416
|
|
417
417
|
this.shadowRoot.innerHTML = `${this.sFieldLayout} `;
|
418
418
|
|
419
|
+
|
420
|
+
if (this._state.adPills.length > 0) {
|
421
|
+
for (let pill of this._state.adPills) {
|
422
|
+
|
423
|
+
let removedValue = pill._state.sValue1;
|
424
|
+
|
425
|
+
const initialIndex = this._initialState.configData.filterCriteria.items.findIndex(item => item.value === removedValue);
|
426
|
+
|
427
|
+
|
428
|
+
// Check if the item is already in criteriaList
|
429
|
+
if (!this._state.criteriaList.some(item => item.value === removedValue)) {
|
430
|
+
// Find the item in configData.filterCriteria.items
|
431
|
+
const itemToAdd = this._state.configData.filterCriteria.items.find(item => item.value === removedValue);
|
432
|
+
if (itemToAdd) {
|
433
|
+
// Insert the item at the same position as in _initialState
|
434
|
+
if (initialIndex !== -1) {
|
435
|
+
this._state.criteriaList.splice(initialIndex, 0, itemToAdd);
|
436
|
+
} else {
|
437
|
+
// If the item is not found in _initialState, default to adding at the end
|
438
|
+
this._state.criteriaList.push(itemToAdd);
|
439
|
+
}
|
440
|
+
}
|
441
|
+
}
|
442
|
+
}
|
443
|
+
}
|
444
|
+
|
445
|
+
|
446
|
+
|
419
447
|
this._state.adPills = [];
|
420
448
|
|
421
449
|
if (this._state.configData?.filterCriteria && !this._state.configData.filterCriteria.loadedPills) {
|
@@ -1305,7 +1333,8 @@ class CUI_FORMPILL extends HTMLElement {
|
|
1305
1333
|
|
1306
1334
|
// Loop through each value in pill.values
|
1307
1335
|
for (const val of pill.values) {
|
1308
|
-
const
|
1336
|
+
const optionProperty = foundItem.controls.value.options ?? foundItem.controls.value.control ?? null;
|
1337
|
+
const option = optionProperty ? optionProperty.find(opt => opt.value === val) : null;
|
1309
1338
|
if (option) {
|
1310
1339
|
labelsArray.push(option.label);
|
1311
1340
|
} else {
|