@annalib/anna-core 28.6.21 → 28.6.22

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.
@@ -1596,11 +1596,13 @@ class TooltipModelForColumnLevelFiltering {
1596
1596
  }
1597
1597
  }
1598
1598
  class RadioButtonModel {
1599
- constructor(key, value, sort, filter) {
1599
+ constructor(key, value, sort, filter, showSplitedOptions = false, splitDelimiter = ", ") {
1600
1600
  this.key = key;
1601
1601
  this.label = value;
1602
1602
  this.isSortRequired = sort;
1603
1603
  this.isFilterRequired = filter;
1604
+ this.showSplitedOptions = showSplitedOptions;
1605
+ this.splitDelimiter = splitDelimiter;
1604
1606
  }
1605
1607
  }
1606
1608
  var AllSelectedStatus;
@@ -1789,6 +1791,8 @@ class AnnaFilterService {
1789
1791
  this.tooltipMap = new Map();
1790
1792
  this.tooltipSelectedMap = new Map();
1791
1793
  this.appliedFiltersArray = [];
1794
+ this.SPLITED_CHECKBOX_FILTER_KEY = "_SplitedCheckBoxOptions";
1795
+ this.DEFAULT_SPLIT_SEPARATOR = ", ";
1792
1796
  this.sliderCurrencySet = new Set([
1793
1797
  "booked",
1794
1798
  "cpp",
@@ -2180,6 +2184,11 @@ class AnnaFilterService {
2180
2184
  filteredData = this.checkIfSortingIsAppliedThenSortTheData(originalData);
2181
2185
  }
2182
2186
  this.tooltipSelectedMap.forEach((value, key) => {
2187
+ const filterSplitedValues = key.includes(this.SPLITED_CHECKBOX_FILTER_KEY);
2188
+ if (filterSplitedValues) {
2189
+ // eslint-disable-next-line no-param-reassign
2190
+ key = key.split(this.SPLITED_CHECKBOX_FILTER_KEY)[0];
2191
+ }
2183
2192
  if (key !== keyToSkip && originalData.length > 0 && Object.keys(originalData[0]).includes(key)) {
2184
2193
  if (this.sliderSet.has(key)) {
2185
2194
  filteredData = filteredData.filter((obj) => obj[key] >= value.min && obj[key] <= value.max);
@@ -2223,7 +2232,7 @@ class AnnaFilterService {
2223
2232
  filteredData = filteredData.filter((obj) => this.returnDataForStartAndEndTimeRange(obj, value, key));
2224
2233
  }
2225
2234
  else if (value.length > 0) {
2226
- filteredData = filteredData.filter((u) => value.includes(u[key]));
2235
+ filteredData = filteredData.filter((u) => filterSplitedValues ? value.find((val) => u[key].includes(val)) : value.includes(u[key]));
2227
2236
  }
2228
2237
  }
2229
2238
  });
@@ -2530,19 +2539,33 @@ class AnnaFilterService {
2530
2539
  currentColumnSortFilter = currentColumnSortFilter || SortTypeEnum.DEFAULT;
2531
2540
  return currentColumnSortFilter;
2532
2541
  }
2533
- createListForCheckboxFilter(header, optionData) {
2534
- const tooltipOptions = this.getTooltipModelFromOptionData(optionData, header);
2542
+ createListForCheckboxFilter(header, optionData, showSplitedOptions = false, splitDelimiter = this.DEFAULT_SPLIT_SEPARATOR) {
2543
+ const tooltipOptions = this.getTooltipModelFromOptionData(optionData, header, showSplitedOptions, splitDelimiter);
2535
2544
  this.selectUnselectListCheckbox(tooltipOptions, header);
2536
2545
  this.formatNullOptionToSpecifiedString(tooltipOptions, this.nullToBeFormatedIntoString);
2537
2546
  return tooltipOptions;
2538
2547
  }
2539
- getTooltipModelFromOptionData(optionData, header) {
2540
- const uniqOptionData = uniq(optionData.map((item) => item[header]));
2548
+ getTooltipModelFromOptionData(optionData, header, showSplitedOptions = false, splitDelimiter = this.DEFAULT_SPLIT_SEPARATOR) {
2549
+ let uniqOptionData = [];
2550
+ if (showSplitedOptions) {
2551
+ let splittedOptions = [];
2552
+ optionData.forEach((option) => {
2553
+ splittedOptions = [...splittedOptions, ...option[header].split(splitDelimiter)];
2554
+ });
2555
+ uniqOptionData = uniq(splittedOptions);
2556
+ }
2557
+ else {
2558
+ uniqOptionData = uniq(optionData.map((item) => item[header]));
2559
+ }
2541
2560
  return uniqOptionData.map((item, index) => new TooltipModel(item, index + 1));
2542
2561
  }
2543
2562
  selectUnselectListCheckbox(tooltipOptions, header) {
2544
- if (this.tooltipSelectedMap.has(header)) {
2545
- const selectedValueSet = new Set(this.tooltipSelectedMap.get(header));
2563
+ const tooltipSelectedMapWithOriginalKeys = new Map();
2564
+ this.tooltipSelectedMap.forEach((value, key) => {
2565
+ tooltipSelectedMapWithOriginalKeys.set(key.split(this.SPLITED_CHECKBOX_FILTER_KEY)[0], value);
2566
+ });
2567
+ if (tooltipSelectedMapWithOriginalKeys.has(header)) {
2568
+ const selectedValueSet = new Set(tooltipSelectedMapWithOriginalKeys.get(header));
2546
2569
  tooltipOptions.forEach((item) => {
2547
2570
  item.isSelected = selectedValueSet.has(item.value);
2548
2571
  });
@@ -3294,10 +3317,13 @@ class AnnaColumnCheckboxFilterComponent {
3294
3317
  this.searchItem = null;
3295
3318
  this.showSortComponent = activeTab.isSortRequired;
3296
3319
  this.showFilterComponent = activeTab.isFilterRequired;
3320
+ this.showSplitedOptions = activeTab.showSplitedOptions;
3321
+ this.splitDelimiter = this.showSplitedOptions ? (activeTab.splitDelimiter ?? this.annaFilterService.DEFAULT_SPLIT_SEPARATOR) : "";
3297
3322
  this.tempSortOrder = null;
3298
3323
  this.isFilterChanged = false;
3299
3324
  this.isSortChanged = false;
3300
3325
  this.annaFilterService.selectedRadio = header;
3326
+ this.selectedRadioKey = `${header}${(this.showSplitedOptions) ? (this.annaFilterService.SPLITED_CHECKBOX_FILTER_KEY) : ""}`;
3301
3327
  if (reload) {
3302
3328
  setTimeout(() => {
3303
3329
  this.createFilterTooltipData(activeTab, header);
@@ -3327,7 +3353,7 @@ class AnnaColumnCheckboxFilterComponent {
3327
3353
  }
3328
3354
  createListForCheckboxFilter(header) {
3329
3355
  const optionData = this.annaFilterService.getFilterOptionsData(this.tableData, this.clonedTableData);
3330
- const tooltipOptions = this.annaFilterService.createListForCheckboxFilter(header, optionData);
3356
+ const tooltipOptions = this.annaFilterService.createListForCheckboxFilter(header, optionData, this.showSplitedOptions, this.splitDelimiter);
3331
3357
  return tooltipOptions;
3332
3358
  }
3333
3359
  selectUnselectListCheckbox(tooltipOptions, header) {
@@ -3425,7 +3451,7 @@ class AnnaColumnCheckboxFilterComponent {
3425
3451
  if (this.showFilterComponent && this.isFilterChanged) {
3426
3452
  const currentSelectedValue = this.annaFilterService.getCheckboxCurrentSelectedValue(this.searchItem, this.tooltipOptions);
3427
3453
  this.annaFilterService.reOrderAppliedFiltersState(this.clonedTableData, currentSelectedValue);
3428
- this.annaFilterService.tooltipSelectedMap.set(this.annaFilterService.selectedRadio, currentSelectedValue);
3454
+ this.annaFilterService.tooltipSelectedMap.set(this.selectedRadioKey, currentSelectedValue);
3429
3455
  this.tableData = this.annaFilterService.filterData(this.clonedTableData, "");
3430
3456
  this.annaSortService.noSortingAppliedData = cloneDeep(this.tableData);
3431
3457
  }
@@ -4920,7 +4946,7 @@ class AnnaNonEditableGenericTableComponent {
4920
4946
  this.filterTabObjects = header.map((key, index) => {
4921
4947
  // change to display name
4922
4948
  const value = this.tooltipRadioTextMap.has(key) ? this.tooltipRadioTextMap.get(key) : key;
4923
- return new RadioButtonModel(key, value, columnHeader.isSortRequired[index], columnHeader.isFilterRequired[index]);
4949
+ return new RadioButtonModel(key, value, columnHeader.isSortRequired[index], columnHeader.isFilterRequired[index], columnHeader?.showSplitedOptionsInFilter[index], columnHeader?.splitDelimiter[index]);
4924
4950
  });
4925
4951
  }
4926
4952
  disableEnableEachColumnTooltipIcon() {