@dereekb/dbx-form 9.23.9 → 9.23.11
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/calendar/lib/calendar.schedule.selection.store.d.ts +36 -4
- package/calendar/lib/field/schedule/calendar.schedule.field.component.d.ts +9 -4
- package/esm2020/calendar/lib/calendar.schedule.selection.store.mjs +133 -37
- package/esm2020/calendar/lib/field/schedule/calendar.schedule.field.component.mjs +24 -3
- package/esm2020/calendar/lib/field/schedule/calendar.schedule.field.mjs +6 -3
- package/fesm2015/dereekb-dbx-form-calendar.mjs +161 -41
- package/fesm2015/dereekb-dbx-form-calendar.mjs.map +1 -1
- package/fesm2020/dereekb-dbx-form-calendar.mjs +161 -41
- package/fesm2020/dereekb-dbx-form-calendar.mjs.map +1 -1
- package/lib/extension/calendar/_calendar.scss +2 -0
- package/mapbox/package.json +4 -4
- package/package.json +4 -4
|
@@ -7,10 +7,10 @@ import { Injectable, SkipSelf, Directive, Injector, Optional, Component, Inject,
|
|
|
7
7
|
import { FieldType } from '@ngx-formly/material';
|
|
8
8
|
import { map, distinctUntilChanged, shareReplay, BehaviorSubject, switchMap, of, startWith, filter, throttleTime, first } from 'rxjs';
|
|
9
9
|
import { filterMaybe, SubscriptionObject, asObservable } from '@dereekb/rxjs';
|
|
10
|
-
import { DateScheduleDayCode, expandDateScheduleDayCodesToDayOfWeekSet, dateTimingRelativeIndexFactory, dateBlockDayOfWeekFactory, isSameDate, isSameDateRange, isSameDateScheduleRange,
|
|
11
|
-
import { setsAreEquivalent, iterableToArray, toggleInSet, addToSet, isIndexNumberInIndexRangeFunction,
|
|
10
|
+
import { DateScheduleDayCode, expandDateScheduleDayCodesToDayOfWeekSet, dateTimingRelativeIndexFactory, dateBlockDayOfWeekFactory, findMaxDate, findMinDate, isSameDate, isSameDateRange, isSameDateScheduleRange, isSameDateDay, dateTimingRelativeIndexArrayFactory, copyDateScheduleDateFilterConfig, dateScheduleDateFilter, expandDateScheduleDayCodes, isDateInDateRangeFunction, isDateWithinDateBlockRangeFunction, dateScheduleEncodedWeek, dateBlockTimingDateFactory, enabledDaysFromDateScheduleDayCodes, dateScheduleDayCodesFromEnabledDays, formatToMonthDayString } from '@dereekb/date';
|
|
11
|
+
import { setsAreEquivalent, unique, mergeArrays, range, iterableToArray, toggleInSet, addToSet, isIndexNumberInIndexRangeFunction, minAndMaxNumber, randomNumberFactory, getDaysOfWeekNames } from '@dereekb/util';
|
|
12
12
|
import { ComponentStore } from '@ngrx/component-store';
|
|
13
|
-
import { startOfDay
|
|
13
|
+
import { startOfDay } from 'date-fns';
|
|
14
14
|
import * as i1 from '@dereekb/dbx-web/calendar';
|
|
15
15
|
import { prepareAndSortCalendarEvents, DbxCalendarStore, DbxCalendarModule } from '@dereekb/dbx-web/calendar';
|
|
16
16
|
import * as i3 from '@angular/forms';
|
|
@@ -36,14 +36,17 @@ import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
|
|
36
36
|
import { FlexLayoutModule } from '@angular/flex-layout';
|
|
37
37
|
|
|
38
38
|
function dateScheduleRangeField(config = {}) {
|
|
39
|
-
const { key = 'schedule', filter } = config;
|
|
39
|
+
const { key = 'schedule', filter, initialSelectionState, computeSelectionResultRelativeToFilter, exclusions } = config;
|
|
40
40
|
const fieldConfig = {
|
|
41
41
|
...formlyField({
|
|
42
42
|
key,
|
|
43
43
|
type: 'date-schedule-range',
|
|
44
44
|
...propsAndConfigForFieldConfig(config, {
|
|
45
45
|
label: config.label ?? 'Schedule',
|
|
46
|
-
filter
|
|
46
|
+
filter,
|
|
47
|
+
computeSelectionResultRelativeToFilter,
|
|
48
|
+
initialSelectionState,
|
|
49
|
+
exclusions
|
|
47
50
|
})
|
|
48
51
|
})
|
|
49
52
|
};
|
|
@@ -95,11 +98,24 @@ function initialCalendarScheduleSelectionState() {
|
|
|
95
98
|
indexDayOfWeek,
|
|
96
99
|
isEnabledFilterDay: () => true,
|
|
97
100
|
isEnabledDay: () => false,
|
|
98
|
-
minDate:
|
|
99
|
-
maxDate:
|
|
101
|
+
minDate: null,
|
|
102
|
+
maxDate: null,
|
|
103
|
+
computeSelectionResultRelativeToFilter: true,
|
|
100
104
|
cellContentFactory: defaultCalendarScheduleSelectionCellContentFactory
|
|
101
105
|
};
|
|
102
106
|
}
|
|
107
|
+
function calendarScheduleMinDate(x) {
|
|
108
|
+
return findMaxDate([x.filter?.start, x.minDate]);
|
|
109
|
+
}
|
|
110
|
+
function calendarScheduleMaxDate(x) {
|
|
111
|
+
return findMinDate([x.filter?.end, x.maxDate]);
|
|
112
|
+
}
|
|
113
|
+
function calendarScheduleMinAndMaxDate(x) {
|
|
114
|
+
return {
|
|
115
|
+
minDate: calendarScheduleMinDate(x),
|
|
116
|
+
maxDate: calendarScheduleMaxDate(x)
|
|
117
|
+
};
|
|
118
|
+
}
|
|
103
119
|
class DbxCalendarScheduleSelectionStore extends ComponentStore {
|
|
104
120
|
constructor() {
|
|
105
121
|
super(initialCalendarScheduleSelectionState());
|
|
@@ -120,18 +136,22 @@ class DbxCalendarScheduleSelectionStore extends ComponentStore {
|
|
|
120
136
|
this.isEnabledFilterDayFunction$ = this.state$.pipe(map((x) => x.isEnabledFilterDay), shareReplay(1));
|
|
121
137
|
this.isEnabledDayFunction$ = this.state$.pipe(map((x) => x.isEnabledDay), shareReplay(1));
|
|
122
138
|
this.currentDateRange$ = this.state$.pipe(map(computeCalendarScheduleSelectionRange), distinctUntilChanged((a, b) => isSameDateRange(a, b)), shareReplay(1));
|
|
139
|
+
this.computeSelectionResultRelativeToFilter$ = this.state$.pipe(map((x) => x.computeSelectionResultRelativeToFilter), shareReplay(1));
|
|
140
|
+
this.startBeingUsedFromFilter$ = this.state$.pipe(map((x) => x.computeSelectionResultRelativeToFilter && x.filter?.start != null), shareReplay(1));
|
|
123
141
|
this.dateRange$ = this.currentDateRange$.pipe(filterMaybe(), shareReplay(1));
|
|
124
142
|
this.scheduleDays$ = this.state$.pipe(map((x) => x.scheduleDays), distinctUntilChanged(setsAreEquivalent), shareReplay(1));
|
|
125
143
|
this.currentSelectionValue$ = this.state$.pipe(map((x) => x.currentSelectionValue), shareReplay(1));
|
|
126
144
|
this.selectionValue$ = this.currentSelectionValue$.pipe(filterMaybe(), shareReplay(1));
|
|
127
145
|
this.currentDateScheduleRangeValue$ = this.currentSelectionValue$.pipe(map((x) => x?.dateScheduleRange), distinctUntilChanged(isSameDateScheduleRange), shareReplay(1));
|
|
128
146
|
this.dateScheduleRangeValue$ = this.currentDateScheduleRangeValue$.pipe(filterMaybe(), shareReplay(1));
|
|
129
|
-
this.minDate$ = this.state$.pipe(map(
|
|
130
|
-
this.maxDate$ = this.state$.pipe(map(
|
|
147
|
+
this.minDate$ = this.state$.pipe(map(calendarScheduleMinDate), distinctUntilChanged(isSameDateDay), shareReplay(1));
|
|
148
|
+
this.maxDate$ = this.state$.pipe(map(calendarScheduleMaxDate), distinctUntilChanged(isSameDateDay), shareReplay(1));
|
|
131
149
|
this.cellContentFactory$ = this.state$.pipe(map((x) => x.cellContentFactory), distinctUntilChanged(), shareReplay(1));
|
|
132
150
|
this.isCustomized$ = this.state$.pipe(map((x) => x.selectedIndexes.size > 0), distinctUntilChanged(), shareReplay(1));
|
|
133
151
|
// MARK: State Changes
|
|
134
152
|
this.setFilter = this.updater((state, filter) => updateStateWithFilter(state, filter));
|
|
153
|
+
this.setExclusions = this.updater((state, exclusions) => updateStateWithExclusions(state, exclusions));
|
|
154
|
+
this.setComputeSelectionResultRelativeToFilter = this.updater((state, computeSelectionResultRelativeToFilter) => updateStateWithComputeSelectionResultRelativeToFilter(state, computeSelectionResultRelativeToFilter));
|
|
135
155
|
this.clearFilter = this.updater((state) => updateStateWithFilter(state, undefined));
|
|
136
156
|
this.setTimezone = this.updater((state, timezone) => ({ ...state, timezone }));
|
|
137
157
|
this.setInputRange = this.updater((state, range) => updateStateWithChangedRange(state, range));
|
|
@@ -139,6 +159,8 @@ class DbxCalendarScheduleSelectionStore extends ComponentStore {
|
|
|
139
159
|
this.addSelectedDates = this.updater((state, add) => updateStateWithChangedDates(state, { add }));
|
|
140
160
|
this.removeSelectedDates = this.updater((state, remove) => updateStateWithChangedDates(state, { remove }));
|
|
141
161
|
this.setSelectedDates = this.updater((state, set) => updateStateWithChangedDates(state, { set }));
|
|
162
|
+
this.selectAllDates = this.updater((state, selectAll = 'all') => updateStateWithChangedDates(state, { selectAll }));
|
|
163
|
+
this.setInitialSelectionState = this.updater((state, initialSelectionState) => updateStateWithInitialSelectionState(state, initialSelectionState));
|
|
142
164
|
this.setScheduleDays = this.updater((state, scheduleDays) => updateStateWithChangedScheduleDays(state, scheduleDays));
|
|
143
165
|
this.setAllowAllScheduleDays = this.updater((state) => updateStateWithChangedScheduleDays(state, null));
|
|
144
166
|
this.setDateScheduleRangeValue = this.updater((state, value) => updateStateWithDateScheduleRangeValue(state, value));
|
|
@@ -150,12 +172,67 @@ DbxCalendarScheduleSelectionStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersi
|
|
|
150
172
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: DbxCalendarScheduleSelectionStore, decorators: [{
|
|
151
173
|
type: Injectable
|
|
152
174
|
}], ctorParameters: function () { return []; } });
|
|
153
|
-
function
|
|
175
|
+
function updateStateWithInitialSelectionState(state, initialSelectionState) {
|
|
176
|
+
const { selectedIndexes } = state;
|
|
177
|
+
if (selectedIndexes.size === 0 && initialSelectionState === 'all') {
|
|
178
|
+
state = updateStateWithChangedDates(state, { selectAll: initialSelectionState });
|
|
179
|
+
}
|
|
180
|
+
return { ...state, initialSelectionState };
|
|
181
|
+
}
|
|
182
|
+
function updateStateWithComputeSelectionResultRelativeToFilter(currentState, computeSelectionResultRelativeToFilter) {
|
|
183
|
+
let state = { ...currentState, computeSelectionResultRelativeToFilter };
|
|
184
|
+
if (Boolean(currentState.computeSelectionResultRelativeToFilter) !== Boolean(computeSelectionResultRelativeToFilter)) {
|
|
185
|
+
state = updateStateWithChangedDates(state, {}); // recalculate if change occurs as it will affect the output value
|
|
186
|
+
}
|
|
187
|
+
return state;
|
|
188
|
+
}
|
|
189
|
+
function updateStateWithExclusions(state, inputExclusions) {
|
|
190
|
+
let computedExclusions;
|
|
191
|
+
if (inputExclusions) {
|
|
192
|
+
const { indexFactory } = state;
|
|
193
|
+
const indexArrayFactory = dateTimingRelativeIndexArrayFactory(indexFactory);
|
|
194
|
+
computedExclusions = indexArrayFactory(inputExclusions);
|
|
195
|
+
}
|
|
196
|
+
state = { ...state, inputExclusions, computedExclusions };
|
|
197
|
+
return updateStateWithFilter(state, state.filter);
|
|
198
|
+
}
|
|
199
|
+
function updateStateWithFilter(state, inputFilter) {
|
|
200
|
+
const { computedExclusions: exclusions } = state;
|
|
154
201
|
let isEnabledFilterDay = () => true;
|
|
155
|
-
|
|
156
|
-
|
|
202
|
+
let filter = null;
|
|
203
|
+
if (inputFilter || exclusions?.length) {
|
|
204
|
+
let enabledFilter;
|
|
205
|
+
if (inputFilter) {
|
|
206
|
+
filter = copyDateScheduleDateFilterConfig(inputFilter); // copy filter
|
|
207
|
+
if (exclusions?.length) {
|
|
208
|
+
enabledFilter = {
|
|
209
|
+
...filter,
|
|
210
|
+
ex: unique(mergeArrays([filter.ex, exclusions]))
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
enabledFilter = filter;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
enabledFilter = {
|
|
219
|
+
w: '89',
|
|
220
|
+
ex: exclusions
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
isEnabledFilterDay = dateScheduleDateFilter(enabledFilter);
|
|
224
|
+
}
|
|
225
|
+
state = { ...state, filter, isEnabledFilterDay };
|
|
226
|
+
// attempt to re-apply the initial selection state once filter is applied
|
|
227
|
+
if (state.initialSelectionState) {
|
|
228
|
+
state = updateStateWithInitialSelectionState(state, state.initialSelectionState);
|
|
229
|
+
}
|
|
230
|
+
// re-calculate the selection given the filter
|
|
231
|
+
const { inputStart, inputEnd } = state;
|
|
232
|
+
if (inputStart && inputEnd) {
|
|
233
|
+
state = updateStateWithChangedRange(state, { inputStart, inputEnd });
|
|
157
234
|
}
|
|
158
|
-
return
|
|
235
|
+
return state;
|
|
159
236
|
}
|
|
160
237
|
function updateStateWithDateScheduleRangeValue(state, change) {
|
|
161
238
|
const isSameValue = isSameDateScheduleRange(state.currentSelectionValue?.dateScheduleRange, change);
|
|
@@ -165,7 +242,7 @@ function updateStateWithDateScheduleRangeValue(state, change) {
|
|
|
165
242
|
else {
|
|
166
243
|
if (change != null) {
|
|
167
244
|
const nextState = { ...state, inputStart: change.start, inputEnd: change.end, selectedIndexes: new Set(change.ex) };
|
|
168
|
-
return updateStateWithChangedScheduleDays(finalizeNewCalendarScheduleSelectionState(nextState),
|
|
245
|
+
return updateStateWithChangedScheduleDays(finalizeNewCalendarScheduleSelectionState(nextState), expandDateScheduleDayCodes(change.w));
|
|
169
246
|
}
|
|
170
247
|
else {
|
|
171
248
|
return noSelectionCalendarScheduleSelectionState(state); // clear selection, retain disabled days
|
|
@@ -186,9 +263,24 @@ function updateStateWithChangedScheduleDays(state, change) {
|
|
|
186
263
|
}
|
|
187
264
|
function updateStateWithChangedDates(state, change) {
|
|
188
265
|
const { indexFactory, allowedDaysOfWeek, indexDayOfWeek } = state;
|
|
266
|
+
const { minDate, maxDate } = calendarScheduleMinAndMaxDate(state);
|
|
189
267
|
let selectedIndexes;
|
|
190
|
-
if (change.set) {
|
|
191
|
-
|
|
268
|
+
if (change.reset || change.selectAll != null || change.set) {
|
|
269
|
+
let set = change.set ?? [];
|
|
270
|
+
let selectAll = change.reset === true ? state.initialSelectionState : change.selectAll;
|
|
271
|
+
switch (selectAll) {
|
|
272
|
+
case 'all':
|
|
273
|
+
if (minDate != null && maxDate != null) {
|
|
274
|
+
const minIndex = indexFactory(minDate);
|
|
275
|
+
const maxIndex = indexFactory(maxDate);
|
|
276
|
+
set = range(minIndex, maxIndex);
|
|
277
|
+
}
|
|
278
|
+
break;
|
|
279
|
+
case 'none':
|
|
280
|
+
set = [];
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
selectedIndexes = new Set(iterableToArray(set).map(indexFactory));
|
|
192
284
|
}
|
|
193
285
|
else {
|
|
194
286
|
selectedIndexes = new Set(state.selectedIndexes);
|
|
@@ -214,22 +306,22 @@ function updateStateWithChangedDates(state, change) {
|
|
|
214
306
|
}
|
|
215
307
|
else {
|
|
216
308
|
// no selected days
|
|
217
|
-
return noSelectionCalendarScheduleSelectionState(
|
|
309
|
+
return noSelectionCalendarScheduleSelectionState(nextState);
|
|
218
310
|
}
|
|
219
311
|
}
|
|
220
312
|
function noSelectionCalendarScheduleSelectionState(state) {
|
|
221
313
|
return finalizeNewCalendarScheduleSelectionState({ ...state, selectedIndexes: new Set(), inputStart: null, inputEnd: null });
|
|
222
314
|
}
|
|
223
315
|
function updateStateWithChangedRange(state, change) {
|
|
224
|
-
const { inputStart: currentInputStart, inputEnd: currentInputEnd, indexFactory, minDate, maxDate } = state;
|
|
225
|
-
|
|
226
|
-
|
|
316
|
+
const { inputStart: currentInputStart, inputEnd: currentInputEnd, indexFactory, minDate, maxDate, filter, computeSelectionResultRelativeToFilter } = state;
|
|
317
|
+
let inputStart = startOfDay(change.inputStart);
|
|
318
|
+
let inputEnd = startOfDay(change.inputEnd);
|
|
227
319
|
const isValidRange = minDate != null || maxDate != null ? isDateInDateRangeFunction({ start: minDate ?? undefined, end: maxDate ?? undefined }) : () => true;
|
|
228
320
|
if (!isValidRange(inputStart) || !isValidRange(inputEnd) || (isSameDateDay(inputStart, currentInputStart) && isSameDateDay(inputEnd, currentInputEnd))) {
|
|
229
321
|
return state; // if no change, return the current state.
|
|
230
322
|
}
|
|
231
323
|
// retain all indexes that are within the new range
|
|
232
|
-
const minIndex = indexFactory(inputStart);
|
|
324
|
+
const minIndex = computeSelectionResultRelativeToFilter && filter?.start ? indexFactory(filter?.start) : indexFactory(inputStart);
|
|
233
325
|
const maxIndex = indexFactory(inputEnd) + 1;
|
|
234
326
|
const currentIndexes = Array.from(state.selectedIndexes);
|
|
235
327
|
const isInCurrentRange = isIndexNumberInIndexRangeFunction({ minIndex, maxIndex });
|
|
@@ -262,19 +354,30 @@ function isEnabledDayInCalendarScheduleSelectionState(state) {
|
|
|
262
354
|
};
|
|
263
355
|
}
|
|
264
356
|
function computeScheduleSelectionValue(state) {
|
|
265
|
-
const { scheduleDays, allowedDaysOfWeek, indexDayOfWeek } = state;
|
|
357
|
+
const { indexFactory, scheduleDays, allowedDaysOfWeek, indexDayOfWeek, computeSelectionResultRelativeToFilter, filter } = state;
|
|
266
358
|
const rangeAndExclusion = computeScheduleSelectionRangeAndExclusion(state);
|
|
267
359
|
if (rangeAndExclusion == null) {
|
|
268
360
|
return null;
|
|
269
361
|
}
|
|
270
|
-
const { start, end, excluded, dateBlockRange } = rangeAndExclusion;
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
362
|
+
const { start: rangeStart, end, excluded: allExcluded, dateBlockRange } = rangeAndExclusion;
|
|
363
|
+
let filterOffsetExcludedRange = [];
|
|
364
|
+
let indexOffset = dateBlockRange.i;
|
|
365
|
+
let start = rangeStart;
|
|
366
|
+
// If computeSelectionResultRelativeToFilter is true, then we need to offset the values to be relative to that start.
|
|
367
|
+
if (computeSelectionResultRelativeToFilter && filter?.start) {
|
|
368
|
+
start = filter.start;
|
|
369
|
+
const filterStartIndexOffset = indexFactory(rangeStart) - indexFactory(start);
|
|
370
|
+
filterOffsetExcludedRange = range(0, filterStartIndexOffset);
|
|
371
|
+
indexOffset = indexOffset - filterStartIndexOffset;
|
|
372
|
+
}
|
|
373
|
+
const excluded = computeSelectionResultRelativeToFilter
|
|
374
|
+
? allExcluded.filter((x) => {
|
|
375
|
+
const isExcludedIndex = allowedDaysOfWeek.has(indexDayOfWeek(x)); // ???
|
|
376
|
+
return isExcludedIndex;
|
|
377
|
+
})
|
|
378
|
+
: allExcluded;
|
|
379
|
+
const offsetExcluded = excluded.map((x) => x - indexOffset); // set to the proper offset
|
|
380
|
+
const ex = [...filterOffsetExcludedRange, ...offsetExcluded];
|
|
278
381
|
const w = dateScheduleEncodedWeek(scheduleDays);
|
|
279
382
|
const d = []; // "included" blocks are never used/calculated.
|
|
280
383
|
const dateScheduleRange = {
|
|
@@ -290,7 +393,7 @@ function computeScheduleSelectionValue(state) {
|
|
|
290
393
|
};
|
|
291
394
|
}
|
|
292
395
|
function computeScheduleSelectionRangeAndExclusion(state) {
|
|
293
|
-
const { isEnabledDay } = state;
|
|
396
|
+
const { isEnabledDay, isEnabledFilterDay } = state;
|
|
294
397
|
const dateFactory = dateBlockTimingDateFactory(state);
|
|
295
398
|
const dateBlockRange = computeCalendarScheduleSelectionDateBlockRange(state);
|
|
296
399
|
if (dateBlockRange == null) {
|
|
@@ -299,7 +402,7 @@ function computeScheduleSelectionRangeAndExclusion(state) {
|
|
|
299
402
|
const start = dateFactory(dateBlockRange.i);
|
|
300
403
|
const end = dateFactory(dateBlockRange.to);
|
|
301
404
|
const excluded = range(dateBlockRange.i, dateBlockRange.to + 1).filter((x) => {
|
|
302
|
-
const isExcludedIndex = !isEnabledDay(x);
|
|
405
|
+
const isExcludedIndex = !isEnabledDay(x) || !isEnabledFilterDay(x);
|
|
303
406
|
return isExcludedIndex;
|
|
304
407
|
});
|
|
305
408
|
const result = {
|
|
@@ -313,12 +416,8 @@ function computeScheduleSelectionRangeAndExclusion(state) {
|
|
|
313
416
|
function computeCalendarScheduleSelectionRange(state) {
|
|
314
417
|
const dateFactory = dateBlockTimingDateFactory(state);
|
|
315
418
|
const dateBlockRange = computeCalendarScheduleSelectionDateBlockRange(state);
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
319
|
-
else {
|
|
320
|
-
return undefined;
|
|
321
|
-
}
|
|
419
|
+
const dateRange = dateBlockRange != null ? { start: dateFactory(dateBlockRange.i), end: dateFactory(dateBlockRange.to) } : undefined;
|
|
420
|
+
return dateRange;
|
|
322
421
|
}
|
|
323
422
|
function computeCalendarScheduleSelectionDateBlockRange(state) {
|
|
324
423
|
const { indexFactory, inputStart, inputEnd, allowedDaysOfWeek, indexDayOfWeek, isEnabledDay, isEnabledFilterDay } = state;
|
|
@@ -821,6 +920,7 @@ class DbxFormCalendarDateScheduleRangeFieldComponent extends FieldType {
|
|
|
821
920
|
this._syncSub = new SubscriptionObject();
|
|
822
921
|
this._valueSub = new SubscriptionObject();
|
|
823
922
|
this._filterSub = new SubscriptionObject();
|
|
923
|
+
this._exclusionsSub = new SubscriptionObject();
|
|
824
924
|
this._formControlObs = new BehaviorSubject(undefined);
|
|
825
925
|
this.formControl$ = this._formControlObs.pipe(filterMaybe());
|
|
826
926
|
this.value$ = this.formControl$.pipe(switchMap((control) => control.valueChanges.pipe(startWith(control.value))), shareReplay(1));
|
|
@@ -846,6 +946,15 @@ class DbxFormCalendarDateScheduleRangeFieldComponent extends FieldType {
|
|
|
846
946
|
get filter() {
|
|
847
947
|
return this.props.filter;
|
|
848
948
|
}
|
|
949
|
+
get exclusions() {
|
|
950
|
+
return this.props.exclusions;
|
|
951
|
+
}
|
|
952
|
+
get initialSelectionState() {
|
|
953
|
+
return this.props.initialSelectionState;
|
|
954
|
+
}
|
|
955
|
+
get computeSelectionResultRelativeToFilter() {
|
|
956
|
+
return this.props.computeSelectionResultRelativeToFilter;
|
|
957
|
+
}
|
|
849
958
|
ngOnInit() {
|
|
850
959
|
this._formControlObs.next(this.formControl);
|
|
851
960
|
this._syncSub.subscription = this.value$.pipe(distinctUntilChanged(isSameDateScheduleRange)).subscribe((x) => {
|
|
@@ -854,17 +963,28 @@ class DbxFormCalendarDateScheduleRangeFieldComponent extends FieldType {
|
|
|
854
963
|
this._valueSub.subscription = this.dbxCalendarScheduleSelectionStore.currentDateScheduleRangeValue$.subscribe((x) => {
|
|
855
964
|
this.formControl.setValue(x);
|
|
856
965
|
});
|
|
857
|
-
const filter = this
|
|
966
|
+
const { filter, exclusions } = this;
|
|
858
967
|
if (filter != null) {
|
|
859
968
|
this._filterSub.subscription = this.dbxCalendarScheduleSelectionStore.setFilter(asObservable(filter));
|
|
860
969
|
}
|
|
970
|
+
if (exclusions != null) {
|
|
971
|
+
this._exclusionsSub.subscription = this.dbxCalendarScheduleSelectionStore.setExclusions(asObservable(exclusions));
|
|
972
|
+
}
|
|
973
|
+
if (this.initialSelectionState !== undefined) {
|
|
974
|
+
this.dbxCalendarScheduleSelectionStore.setInitialSelectionState(this.initialSelectionState);
|
|
975
|
+
}
|
|
976
|
+
if (this.computeSelectionResultRelativeToFilter != null) {
|
|
977
|
+
this.dbxCalendarScheduleSelectionStore.setComputeSelectionResultRelativeToFilter(this.computeSelectionResultRelativeToFilter);
|
|
978
|
+
}
|
|
979
|
+
// TODO: Also add ability to set min/max dates independent of the filter
|
|
861
980
|
}
|
|
862
981
|
ngOnDestroy() {
|
|
863
982
|
super.ngOnDestroy();
|
|
864
983
|
this._syncSub.destroy();
|
|
865
984
|
this._valueSub.destroy();
|
|
866
|
-
this._formControlObs.complete();
|
|
867
985
|
this._filterSub.destroy();
|
|
986
|
+
this._exclusionsSub.destroy();
|
|
987
|
+
this._formControlObs.complete();
|
|
868
988
|
}
|
|
869
989
|
}
|
|
870
990
|
DbxFormCalendarDateScheduleRangeFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: DbxFormCalendarDateScheduleRangeFieldComponent, deps: [{ token: i1$1.CompactContextStore, optional: true }, { token: DbxCalendarScheduleSelectionStore }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
|
|
@@ -1052,5 +1172,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
|
1052
1172
|
* Generated bundle index. Do not edit.
|
|
1053
1173
|
*/
|
|
1054
1174
|
|
|
1055
|
-
export { CalendarScheduleSelectionDayState, DEFAULT_SCHEDULE_SELECTION_CALENDAR_DATE_POPOVER_KEY, DbxCalendarScheduleSelectionStore, DbxCalendarScheduleSelectionStoreInjectionBlockDirective, DbxCalendarScheduleSelectionStoreProviderBlock, DbxFormCalendarDateScheduleRangeFieldComponent, DbxFormCalendarModule, DbxFormDateScheduleRangeFieldModule, DbxScheduleSelectionCalendarCellComponent, DbxScheduleSelectionCalendarComponent, DbxScheduleSelectionCalendarDateDaysComponent, DbxScheduleSelectionCalendarDateDaysFormComponent, DbxScheduleSelectionCalendarDateDialogButtonComponent, DbxScheduleSelectionCalendarDateDialogComponent, DbxScheduleSelectionCalendarDatePopoverButtonComponent, DbxScheduleSelectionCalendarDatePopoverComponent, DbxScheduleSelectionCalendarDatePopoverContentComponent, DbxScheduleSelectionCalendarDateRangeComponent, computeCalendarScheduleSelectionDateBlockRange, computeCalendarScheduleSelectionRange, computeScheduleSelectionRangeAndExclusion, computeScheduleSelectionValue, dateScheduleRangeField, dbxScheduleSelectionCalendarDateDaysFormDayFields, dbxScheduleSelectionCalendarDateDaysFormFields, defaultCalendarScheduleSelectionCellContentFactory, finalizeNewCalendarScheduleSelectionState, initialCalendarScheduleSelectionState, isEnabledDayInCalendarScheduleSelectionState, noSelectionCalendarScheduleSelectionState, provideCalendarScheduleSelectionStoreIfParentIsUnavailable, updateStateWithChangedDates, updateStateWithChangedRange, updateStateWithChangedScheduleDays, updateStateWithDateScheduleRangeValue, updateStateWithFilter };
|
|
1175
|
+
export { CalendarScheduleSelectionDayState, DEFAULT_SCHEDULE_SELECTION_CALENDAR_DATE_POPOVER_KEY, DbxCalendarScheduleSelectionStore, DbxCalendarScheduleSelectionStoreInjectionBlockDirective, DbxCalendarScheduleSelectionStoreProviderBlock, DbxFormCalendarDateScheduleRangeFieldComponent, DbxFormCalendarModule, DbxFormDateScheduleRangeFieldModule, DbxScheduleSelectionCalendarCellComponent, DbxScheduleSelectionCalendarComponent, DbxScheduleSelectionCalendarDateDaysComponent, DbxScheduleSelectionCalendarDateDaysFormComponent, DbxScheduleSelectionCalendarDateDialogButtonComponent, DbxScheduleSelectionCalendarDateDialogComponent, DbxScheduleSelectionCalendarDatePopoverButtonComponent, DbxScheduleSelectionCalendarDatePopoverComponent, DbxScheduleSelectionCalendarDatePopoverContentComponent, DbxScheduleSelectionCalendarDateRangeComponent, calendarScheduleMaxDate, calendarScheduleMinAndMaxDate, calendarScheduleMinDate, computeCalendarScheduleSelectionDateBlockRange, computeCalendarScheduleSelectionRange, computeScheduleSelectionRangeAndExclusion, computeScheduleSelectionValue, dateScheduleRangeField, dbxScheduleSelectionCalendarDateDaysFormDayFields, dbxScheduleSelectionCalendarDateDaysFormFields, defaultCalendarScheduleSelectionCellContentFactory, finalizeNewCalendarScheduleSelectionState, initialCalendarScheduleSelectionState, isEnabledDayInCalendarScheduleSelectionState, noSelectionCalendarScheduleSelectionState, provideCalendarScheduleSelectionStoreIfParentIsUnavailable, updateStateWithChangedDates, updateStateWithChangedRange, updateStateWithChangedScheduleDays, updateStateWithComputeSelectionResultRelativeToFilter, updateStateWithDateScheduleRangeValue, updateStateWithExclusions, updateStateWithFilter, updateStateWithInitialSelectionState };
|
|
1056
1176
|
//# sourceMappingURL=dereekb-dbx-form-calendar.mjs.map
|