@dereekb/dbx-web 9.24.8 → 9.24.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.
@@ -5,7 +5,7 @@ import { BehaviorSubject, map, combineLatest, distinctUntilChanged, shareReplay,
5
5
  import * as i1$1 from '@angular/material/snack-bar';
6
6
  import { MAT_SNACK_BAR_DATA, MatSnackBarModule } from '@angular/material/snack-bar';
7
7
  import * as i1$2 from '@dereekb/dbx-core';
8
- import { AbstractSubscriptionDirective, safeMarkForCheck, AbstractDbxButtonDirective, provideDbxButton, DbxCoreButtonModule, AbstractTransitionWatcherDirective, AbstractDbxActionValueOnTriggerDirective, safeDetectChanges, DbxInjectionComponentModule, AbstractDbxActionHandlerDirective, provideActionStoreSource, AbstractDbxAnchorDirective, expandClickableAnchorLinkTrees, AbstractTransitionDirective, tapDetectChanges, AbstractIfDirective, DbxCoreFilterModule, asSegueRef, isSegueRefActive, DBX_INJECTION_COMPONENT_DATA, checkNgContentWrapperHasContent, anchorTypeForAnchor, AnchorType, DbxCoreActionModule, isIdleActionState, canTriggerAction, onDbxAppAuth, SimpleStorageAccessorFactory } from '@dereekb/dbx-core';
8
+ import { AbstractSubscriptionDirective, safeMarkForCheck, AbstractDbxButtonDirective, provideDbxButton, DbxCoreButtonModule, AbstractTransitionWatcherDirective, AbstractDbxActionValueOnTriggerDirective, safeDetectChanges, DbxInjectionComponentModule, AbstractDbxActionHandlerDirective, provideActionStoreSource, isClickableFilterPreset, AbstractDbxAnchorDirective, expandClickableAnchorLinkTrees, AbstractTransitionDirective, tapDetectChanges, AbstractIfDirective, DbxCoreFilterModule, asSegueRef, isSegueRefActive, DBX_INJECTION_COMPONENT_DATA, checkNgContentWrapperHasContent, anchorTypeForAnchor, AnchorType, DbxCoreActionModule, isIdleActionState, canTriggerAction, onDbxAppAuth, SimpleStorageAccessorFactory } from '@dereekb/dbx-core';
9
9
  import ms from 'ms';
10
10
  import * as i1 from '@angular/common';
11
11
  import { CommonModule } from '@angular/common';
@@ -2281,18 +2281,41 @@ class AbstractDbxPresetFilterMenuComponent {
2281
2281
  //TODO: Rename to AbstractDbxPresetFilterMenuDirective with next breaking changes
2282
2282
  this._presets = new BehaviorSubject([]);
2283
2283
  this.selected$ = this.filterSourceDirective.filter$.pipe(startWith(undefined), distinctUntilChanged(), shareReplay(1));
2284
+ this.presetsWithPresetStringOnly$ = this._presets.pipe(map((x) => x.filter((y) => Boolean(y.preset))));
2284
2285
  this.selectedPresetString$ = this.selected$.pipe(map((selectedFilter) => (selectedFilter ? selectedFilter.preset : undefined)), distinctUntilChanged());
2285
- this.presetAnchors$ = combineLatest([this._presets, this.selectedPresetString$]).pipe(map(([presets, selectedPresetString]) => {
2286
- return presets.map((x) => ({
2287
- ...x,
2288
- selected: x.preset === selectedPresetString,
2289
- onClick: () => {
2290
- this.selectPreset(x);
2286
+ this.presetAnchorsPairs$ = combineLatest([this._presets, this.selected$, this.selectedPresetString$]).pipe(map(([presets, currentFilterValue, selectedPresetString]) => {
2287
+ return presets.map((x) => {
2288
+ let selected;
2289
+ let type;
2290
+ if (isClickableFilterPreset(x)) {
2291
+ selected = x.preset === selectedPresetString;
2292
+ type = 'preset';
2291
2293
  }
2292
- }));
2294
+ else {
2295
+ selected = x.isActive(currentFilterValue);
2296
+ type = 'partialPreset';
2297
+ }
2298
+ return [
2299
+ type,
2300
+ x,
2301
+ {
2302
+ ...x,
2303
+ selected,
2304
+ onClick: () => {
2305
+ this.selectPreset(x);
2306
+ }
2307
+ }
2308
+ ];
2309
+ });
2310
+ }), shareReplay(1));
2311
+ this.presetAnchors$ = this.presetAnchorsPairs$.pipe(map((x) => x.map((x) => x[2])), shareReplay(1));
2312
+ this.firstSelectedAnchorPair$ = this.presetAnchorsPairs$.pipe(map((presets) => {
2313
+ const firstSelected = presets.find((x) => x[2].selected);
2314
+ return firstSelected ? firstSelected : undefined;
2293
2315
  }), shareReplay(1));
2294
- this.selectedPreset$ = combineLatest([this._presets, this.selectedPresetString$]).pipe(map(([presets, selectedPresetString]) => {
2295
- return selectedPresetString != null ? presets.find((x) => x.preset === selectedPresetString) : undefined;
2316
+ this.selectedPreset$ = this.presetAnchorsPairs$.pipe(map((presets) => {
2317
+ const firstSelected = presets.filter((x) => x[0] === 'preset').find((x) => x[2].selected);
2318
+ return firstSelected ? firstSelected[1] : undefined;
2296
2319
  }), shareReplay(1));
2297
2320
  }
2298
2321
  get presets() {
@@ -2302,18 +2325,19 @@ class AbstractDbxPresetFilterMenuComponent {
2302
2325
  this._presets.next(presets);
2303
2326
  }
2304
2327
  selectPreset(preset) {
2305
- const presetValue = preset.presetValue;
2328
+ const presetString = preset.preset;
2329
+ const presetValue = preset.presetValue || preset.partialPresetValue;
2306
2330
  if (presetValue == null || (typeof presetValue !== 'function' && objectHasNoKeys(presetValue))) {
2307
2331
  // set and then reset if the value is null or empty
2308
2332
  this.filterSourceDirective.setFilter((presetValue ?? {}));
2309
2333
  this.filterSourceDirective.resetFilter();
2310
2334
  }
2311
2335
  else {
2312
- let filter = getValueFromGetter(preset.presetValue);
2313
- if (filter.preset !== preset.preset) {
2336
+ let filter = getValueFromGetter(presetValue);
2337
+ if (filter.preset !== presetString) {
2314
2338
  filter = {
2315
2339
  ...filter,
2316
- preset: preset.preset
2340
+ preset: presetString
2317
2341
  };
2318
2342
  }
2319
2343
  this.filterSourceDirective.setFilter(filter);