@nys-cui/cui-formpill 0.2.8 → 0.2.9
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 +28 -0
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) {
|