@dereekb/dbx-core 1.2.0 → 2.0.0
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/README.md +1 -1
- package/esm2020/lib/action/action.handler.mjs +3 -3
- package/esm2020/lib/action/action.holder.mjs +13 -4
- package/esm2020/lib/action/action.machine.mjs +12 -5
- package/esm2020/lib/action/action.mjs +37 -17
- package/esm2020/lib/action/action.module.mjs +11 -11
- package/esm2020/lib/action/action.reference.mjs +7 -0
- package/esm2020/lib/action/action.store.mjs +60 -23
- package/esm2020/lib/action/action.store.source.mjs +27 -13
- package/esm2020/lib/action/directive/auto/action.automodify.directive.mjs +5 -5
- package/esm2020/lib/action/directive/auto/action.autotrigger.directive.mjs +8 -7
- package/esm2020/lib/action/directive/auto/index.mjs +2 -2
- package/esm2020/lib/action/directive/context/action.directive.mjs +5 -5
- package/esm2020/lib/action/directive/debug/action.logger.directive.mjs +4 -4
- package/esm2020/lib/action/directive/map/action.map.working.disable.directive.mjs +5 -5
- package/esm2020/lib/action/directive/state/action.disabled.directive.mjs +7 -5
- package/esm2020/lib/action/directive/state/action.enforce.modified.directive.mjs +48 -0
- package/esm2020/lib/action/directive/state/action.handler.directive.mjs +5 -5
- package/esm2020/lib/action/directive/state/action.success.component.mjs +4 -4
- package/esm2020/lib/action/directive/state/action.success.directive.mjs +4 -4
- package/esm2020/lib/action/directive/state/action.value.directive.mjs +9 -7
- package/esm2020/lib/action/directive/state/action.value.stream.directive.mjs +80 -0
- package/esm2020/lib/action/directive/state/action.working.component.mjs +4 -4
- package/esm2020/lib/action/directive/state/index.mjs +2 -2
- package/esm2020/lib/action/index.mjs +2 -2
- package/esm2020/lib/button/action/action.button.directive.mjs +12 -11
- package/esm2020/lib/button/action/action.button.trigger.directive.mjs +4 -4
- package/esm2020/lib/button/button.directive.mjs +1 -1
- package/esm2020/lib/button/button.mjs +1 -1
- package/esm2020/lib/filter/action/action.filter.source.directive.mjs +4 -4
- package/fesm2015/dereekb-dbx-core.mjs +323 -240
- package/fesm2015/dereekb-dbx-core.mjs.map +1 -1
- package/fesm2020/dereekb-dbx-core.mjs +321 -238
- package/fesm2020/dereekb-dbx-core.mjs.map +1 -1
- package/lib/action/action.d.ts +14 -12
- package/lib/action/action.handler.d.ts +13 -5
- package/lib/action/action.holder.d.ts +9 -5
- package/lib/action/action.machine.d.ts +21 -8
- package/lib/action/action.module.d.ts +3 -3
- package/lib/action/action.reference.d.ts +11 -0
- package/lib/action/action.store.d.ts +33 -15
- package/lib/action/action.store.source.d.ts +20 -13
- package/lib/action/directive/auto/action.automodify.directive.d.ts +5 -4
- package/lib/action/directive/auto/action.autotrigger.directive.d.ts +6 -6
- package/lib/action/directive/auto/index.d.ts +1 -1
- package/lib/action/directive/context/action.directive.d.ts +3 -3
- package/lib/action/directive/debug/action.logger.directive.d.ts +3 -3
- package/lib/action/directive/map/action.map.working.disable.directive.d.ts +6 -6
- package/lib/action/directive/state/action.disabled.directive.d.ts +5 -4
- package/lib/action/directive/state/action.enforce.modified.directive.d.ts +19 -0
- package/lib/action/directive/state/action.handler.directive.d.ts +3 -3
- package/lib/action/directive/state/action.success.component.d.ts +3 -3
- package/lib/action/directive/state/action.success.directive.d.ts +3 -3
- package/lib/action/directive/state/action.value.directive.d.ts +3 -3
- package/lib/action/directive/state/action.value.stream.directive.d.ts +25 -0
- package/lib/action/directive/state/action.working.component.d.ts +3 -3
- package/lib/action/directive/state/index.d.ts +1 -1
- package/lib/action/index.d.ts +1 -1
- package/lib/button/action/action.button.directive.d.ts +4 -4
- package/lib/button/action/action.button.trigger.directive.d.ts +3 -3
- package/lib/button/button.d.ts +2 -2
- package/lib/button/button.directive.d.ts +2 -2
- package/lib/filter/action/action.filter.source.directive.d.ts +2 -2
- package/package.json +5 -4
- package/esm2020/lib/action/directive/auto/action.autotrigger.value.directive.mjs +0 -79
- package/esm2020/lib/action/directive/state/action.disabled.modified.directive.mjs +0 -35
- package/esm2020/lib/action/snackbar/index.mjs +0 -3
- package/esm2020/lib/action/snackbar/snackbar.mjs +0 -24
- package/lib/action/directive/auto/action.autotrigger.value.directive.d.ts +0 -25
- package/lib/action/directive/state/action.disabled.modified.directive.d.ts +0 -16
- package/lib/action/snackbar/index.d.ts +0 -1
- package/lib/action/snackbar/snackbar.d.ts +0 -50
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Directive, forwardRef, Host, Input,
|
|
2
|
+
import { Directive, Injectable, forwardRef, Host, Input, Optional, Component, NgModule, EventEmitter, Output, LOCALE_ID, Pipe, Inject, ViewChild, InjectionToken, Injector, ViewContainerRef } from '@angular/core';
|
|
3
3
|
import * as i1 from 'rxjs';
|
|
4
|
-
import { BehaviorSubject, combineLatest, Subject, interval, EMPTY, of, isObservable, delay as delay$1, filter as filter$1, startWith as startWith$1, switchMap as switchMap$1, shareReplay as shareReplay$1, first as first$1, Observable
|
|
4
|
+
import { BehaviorSubject, combineLatest, Subject, interval, EMPTY, of, isObservable, delay as delay$1, tap as tap$1, filter as filter$1, startWith as startWith$1, switchMap as switchMap$1, shareReplay as shareReplay$1, first as first$1, Observable } from 'rxjs';
|
|
5
5
|
import * as i1$3 from '@dereekb/rxjs';
|
|
6
|
-
import { SubscriptionObject, LockSet, filterMaybe, scanCount, combineLatestFromMapValuesObsFn, skipFirstMaybe, FilterSourceInstance, FilterSource, FilterSourceConnector, FilterMap } from '@dereekb/rxjs';
|
|
6
|
+
import { SubscriptionObject, LockSet, filterMaybe, LoadingStateType, beginLoading, idleLoadingState, errorResult, successResult, scanCount, combineLatestFromMapValuesObsFn, skipFirstMaybe, FilterSourceInstance, FilterSource, FilterSourceConnector, FilterMap } from '@dereekb/rxjs';
|
|
7
7
|
import { switchMap, first, distinctUntilChanged, filter, debounce, throttle, exhaustMap, mergeMap, map, shareReplay, withLatestFrom, startWith, tap, delay } from 'rxjs/operators';
|
|
8
8
|
import * as i1$4 from '@dereekb/util';
|
|
9
|
-
import { hasValueOrNotEmpty, BooleanStringKeyArrayUtilityInstance, reduceBooleansWithOrFn, getValueFromObjectOrGetter, expandTreeFunction, flattenTreeToArrayFunction, expandFlattenTreeFunction, mergeArrayIntoArray, objectFlatMergeMatrix, mergeArrays, filterMaybeValues, mergeObjects, mergeArrayOrValueIntoArray, DataIsExpiredError, DataDoesNotExistError, filterMaybeValuesFn, StorageObjectUtility, SHARED_MEMORY_STORAGE } from '@dereekb/util';
|
|
9
|
+
import { isDefinedAndNotFalse, hasValueOrNotEmpty, BooleanStringKeyArrayUtilityInstance, reduceBooleansWithOrFn, isUndefinedAndNotFalse, getValueFromObjectOrGetter, expandTreeFunction, flattenTreeToArrayFunction, expandFlattenTreeFunction, mergeArrayIntoArray, objectFlatMergeMatrix, mergeArrays, filterMaybeValues, mergeObjects, mergeArrayOrValueIntoArray, DataIsExpiredError, DataDoesNotExistError, filterMaybeValuesFn, StorageObjectUtility, SHARED_MEMORY_STORAGE } from '@dereekb/util';
|
|
10
10
|
import { ComponentStore } from '@ngrx/component-store';
|
|
11
11
|
import * as i2 from '@angular/common';
|
|
12
12
|
import { CommonModule, formatDate } from '@angular/common';
|
|
13
|
-
import ms from 'ms';
|
|
14
13
|
import * as i1$1 from '@angular/router';
|
|
15
14
|
import { NavigationStart, NavigationEnd } from '@angular/router';
|
|
16
15
|
import { isArray } from 'class-validator';
|
|
@@ -81,8 +80,10 @@ function pipeActionStore(source, pipeFn) {
|
|
|
81
80
|
function useActionStore(source, useFn) {
|
|
82
81
|
return source.store$.pipe(first()).subscribe(useFn);
|
|
83
82
|
}
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Service that wraps a ActionContextStoreSource.
|
|
85
|
+
*/
|
|
86
|
+
class DbxActionContextStoreSourceInstance {
|
|
86
87
|
constructor(source) {
|
|
87
88
|
this.source = source;
|
|
88
89
|
this.lockSet = new LockSet();
|
|
@@ -124,6 +125,9 @@ class ActionContextStoreSourceInstance {
|
|
|
124
125
|
get isModified$() {
|
|
125
126
|
return this.pipeStore(x => x.isModified$);
|
|
126
127
|
}
|
|
128
|
+
get canTrigger$() {
|
|
129
|
+
return this.pipeStore(x => x.canTrigger$);
|
|
130
|
+
}
|
|
127
131
|
get isModifiedAndCanTriggerUpdates$() {
|
|
128
132
|
return this.pipeStore(x => x.isModifiedAndCanTriggerUpdates$);
|
|
129
133
|
}
|
|
@@ -133,12 +137,21 @@ class ActionContextStoreSourceInstance {
|
|
|
133
137
|
get actionState$() {
|
|
134
138
|
return this.pipeStore(x => x.actionState$);
|
|
135
139
|
}
|
|
140
|
+
get loadingState$() {
|
|
141
|
+
return this.pipeStore(x => x.loadingState$);
|
|
142
|
+
}
|
|
143
|
+
get loadingStateType$() {
|
|
144
|
+
return this.pipeStore(x => x.loadingStateType$);
|
|
145
|
+
}
|
|
136
146
|
get isWorking$() {
|
|
137
147
|
return this.pipeStore(x => x.isWorking$);
|
|
138
148
|
}
|
|
139
149
|
get isSuccess$() {
|
|
140
150
|
return this.pipeStore(x => x.isSuccess$);
|
|
141
151
|
}
|
|
152
|
+
get disabledKeys$() {
|
|
153
|
+
return this.pipeStore(x => x.disabledKeys$);
|
|
154
|
+
}
|
|
142
155
|
get isDisabled$() {
|
|
143
156
|
return this.pipeStore(x => x.isDisabled$);
|
|
144
157
|
}
|
|
@@ -166,23 +179,23 @@ class ActionContextStoreSourceInstance {
|
|
|
166
179
|
reject(error) {
|
|
167
180
|
this.useStore((x) => x.reject(error));
|
|
168
181
|
}
|
|
169
|
-
|
|
170
|
-
this.useStore((x) => x.
|
|
182
|
+
resolve(value) {
|
|
183
|
+
this.useStore((x) => x.resolve(value));
|
|
171
184
|
}
|
|
172
185
|
reset() {
|
|
173
186
|
this.useStore((x) => x.reset());
|
|
174
187
|
}
|
|
175
188
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type:
|
|
179
|
-
type:
|
|
189
|
+
DbxActionContextStoreSourceInstance.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionContextStoreSourceInstance, deps: [{ token: ActionContextStoreSource }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
190
|
+
DbxActionContextStoreSourceInstance.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionContextStoreSourceInstance });
|
|
191
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionContextStoreSourceInstance, decorators: [{
|
|
192
|
+
type: Injectable
|
|
180
193
|
}], ctorParameters: function () { return [{ type: ActionContextStoreSource }]; } });
|
|
181
194
|
const actionContextStoreSourceInstanceFactory = (source) => {
|
|
182
|
-
return new
|
|
195
|
+
return new DbxActionContextStoreSourceInstance(source);
|
|
183
196
|
};
|
|
184
197
|
/**
|
|
185
|
-
* Provides an ActionContextStoreSource, as well as an
|
|
198
|
+
* Provides an ActionContextStoreSource, as well as an DbxActionContextStoreSourceInstance.
|
|
186
199
|
*/
|
|
187
200
|
function ProvideActionStoreSource(sourceType) {
|
|
188
201
|
return [{
|
|
@@ -190,7 +203,7 @@ function ProvideActionStoreSource(sourceType) {
|
|
|
190
203
|
useExisting: forwardRef(() => sourceType)
|
|
191
204
|
},
|
|
192
205
|
{
|
|
193
|
-
provide:
|
|
206
|
+
provide: DbxActionContextStoreSourceInstance,
|
|
194
207
|
useFactory: actionContextStoreSourceInstanceFactory,
|
|
195
208
|
deps: [ActionContextStoreSource]
|
|
196
209
|
}];
|
|
@@ -214,7 +227,7 @@ class DbxActionAutoModifyDirective extends AbstractSubscriptionDirective {
|
|
|
214
227
|
return this._autoModifyEnabled.value;
|
|
215
228
|
}
|
|
216
229
|
set autoModifyEnabled(autoModifyEnabled) {
|
|
217
|
-
this._autoModifyEnabled.next(autoModifyEnabled !==
|
|
230
|
+
this._autoModifyEnabled.next(autoModifyEnabled !== false);
|
|
218
231
|
}
|
|
219
232
|
ngOnInit() {
|
|
220
233
|
const obs = combineLatest([
|
|
@@ -234,14 +247,14 @@ class DbxActionAutoModifyDirective extends AbstractSubscriptionDirective {
|
|
|
234
247
|
});
|
|
235
248
|
}
|
|
236
249
|
}
|
|
237
|
-
DbxActionAutoModifyDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionAutoModifyDirective, deps: [{ token:
|
|
250
|
+
DbxActionAutoModifyDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionAutoModifyDirective, deps: [{ token: DbxActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
238
251
|
DbxActionAutoModifyDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionAutoModifyDirective, selector: "[dbxActionAutoModify]", inputs: { autoModifyEnabled: ["dbxActionAutoModify", "autoModifyEnabled"] }, usesInheritance: true, ngImport: i0 });
|
|
239
252
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionAutoModifyDirective, decorators: [{
|
|
240
253
|
type: Directive,
|
|
241
254
|
args: [{
|
|
242
255
|
selector: '[dbxActionAutoModify]',
|
|
243
256
|
}]
|
|
244
|
-
}], ctorParameters: function () { return [{ type:
|
|
257
|
+
}], ctorParameters: function () { return [{ type: DbxActionContextStoreSourceInstance, decorators: [{
|
|
245
258
|
type: Host
|
|
246
259
|
}] }]; }, propDecorators: { autoModifyEnabled: [{
|
|
247
260
|
type: Input,
|
|
@@ -253,7 +266,7 @@ const DEFAULT_THROTTLE_MS = 10 * 1000;
|
|
|
253
266
|
const DEFAULT_ERROR_THROTTLE_MS = 3 * 1000;
|
|
254
267
|
const MAX_ERRORS_TO_THROTTLE_ON = 6;
|
|
255
268
|
/**
|
|
256
|
-
*
|
|
269
|
+
* Directive that automatically triggers the action periodically when it is in a modified state.
|
|
257
270
|
*/
|
|
258
271
|
class DbxActionAutoTriggerDirective extends AbstractSubscriptionDirective {
|
|
259
272
|
constructor(source) {
|
|
@@ -305,7 +318,7 @@ class DbxActionAutoTriggerDirective extends AbstractSubscriptionDirective {
|
|
|
305
318
|
* Used in forms that are simple.
|
|
306
319
|
*/
|
|
307
320
|
set fastTrigger(fastTrigger) {
|
|
308
|
-
if (fastTrigger) {
|
|
321
|
+
if (isDefinedAndNotFalse(fastTrigger)) {
|
|
309
322
|
this.triggerDebounce = 200;
|
|
310
323
|
this.triggerThrottle = 500;
|
|
311
324
|
}
|
|
@@ -316,7 +329,7 @@ class DbxActionAutoTriggerDirective extends AbstractSubscriptionDirective {
|
|
|
316
329
|
* Used in forms that generally return a single value.
|
|
317
330
|
*/
|
|
318
331
|
set instantTrigger(instantTrigger) {
|
|
319
|
-
if (instantTrigger) {
|
|
332
|
+
if (isDefinedAndNotFalse(instantTrigger)) {
|
|
320
333
|
this.triggerDebounce = 10;
|
|
321
334
|
this.triggerThrottle = 0;
|
|
322
335
|
}
|
|
@@ -344,14 +357,14 @@ class DbxActionAutoTriggerDirective extends AbstractSubscriptionDirective {
|
|
|
344
357
|
});
|
|
345
358
|
}
|
|
346
359
|
}
|
|
347
|
-
DbxActionAutoTriggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionAutoTriggerDirective, deps: [{ token:
|
|
360
|
+
DbxActionAutoTriggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionAutoTriggerDirective, deps: [{ token: DbxActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
348
361
|
DbxActionAutoTriggerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionAutoTriggerDirective, selector: "dbxActionAutoTrigger, [dbxActionAutoTrigger]", inputs: { triggerEnabled: ["dbxActionAutoTrigger", "triggerEnabled"], triggerDebounce: "triggerDebounce", triggerThrottle: "triggerThrottle", triggerErrorThrottle: "triggerErrorThrottle", fastTrigger: "fastTrigger", instantTrigger: "instantTrigger", triggerLimit: "triggerLimit" }, usesInheritance: true, ngImport: i0 });
|
|
349
362
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionAutoTriggerDirective, decorators: [{
|
|
350
363
|
type: Directive,
|
|
351
364
|
args: [{
|
|
352
365
|
selector: 'dbxActionAutoTrigger, [dbxActionAutoTrigger]',
|
|
353
366
|
}]
|
|
354
|
-
}], ctorParameters: function () { return [{ type:
|
|
367
|
+
}], ctorParameters: function () { return [{ type: DbxActionContextStoreSourceInstance, decorators: [{
|
|
355
368
|
type: Host
|
|
356
369
|
}] }]; }, propDecorators: { triggerEnabled: [{
|
|
357
370
|
type: Input,
|
|
@@ -371,19 +384,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
|
|
|
371
384
|
}] } });
|
|
372
385
|
|
|
373
386
|
/**
|
|
374
|
-
* Directive that watches
|
|
387
|
+
* Directive that watches a value observable for changes and sets the new value and modified states as necessary.
|
|
375
388
|
*/
|
|
376
|
-
class
|
|
389
|
+
class dbxActionValueStreamDirective {
|
|
377
390
|
constructor(source) {
|
|
378
391
|
this.source = source;
|
|
379
392
|
this._valueObs = new BehaviorSubject(EMPTY);
|
|
380
393
|
this._isModifiedFn = new BehaviorSubject(undefined);
|
|
381
394
|
this._modifiedSub = new SubscriptionObject();
|
|
382
395
|
this._triggerSub = new SubscriptionObject();
|
|
383
|
-
this.modifiedValue$ = this._valueObs.pipe(switchMap((obs) => obs.pipe(withLatestFrom(this._isModifiedFn), mergeMap(([value,
|
|
396
|
+
this.modifiedValue$ = this._valueObs.pipe(switchMap((obs) => obs.pipe(withLatestFrom(this._isModifiedFn), mergeMap(([value, dbxActionValueStreamModified]) => {
|
|
384
397
|
let result;
|
|
385
|
-
if (
|
|
386
|
-
result =
|
|
398
|
+
if (dbxActionValueStreamModified) {
|
|
399
|
+
result = dbxActionValueStreamModified(value).pipe(map((isModified) => [isModified, value]));
|
|
387
400
|
}
|
|
388
401
|
else {
|
|
389
402
|
result = of([true, value]);
|
|
@@ -391,18 +404,18 @@ class DbxActionAutoTriggerValueDirective {
|
|
|
391
404
|
return result;
|
|
392
405
|
}), shareReplay(1))));
|
|
393
406
|
}
|
|
394
|
-
set
|
|
395
|
-
this._valueObs.next(
|
|
407
|
+
set dbxActionValueStream(dbxActionValueStream) {
|
|
408
|
+
this._valueObs.next(dbxActionValueStream);
|
|
396
409
|
}
|
|
397
|
-
set
|
|
398
|
-
if (requireNonEmpty) {
|
|
399
|
-
this.
|
|
410
|
+
set dbxActionValueStreamIsNotEmpty(requireNonEmpty) {
|
|
411
|
+
if (isDefinedAndNotFalse(requireNonEmpty)) {
|
|
412
|
+
this.dbxActionValueStreamModified = (value) => {
|
|
400
413
|
return of(hasValueOrNotEmpty(value));
|
|
401
414
|
};
|
|
402
415
|
}
|
|
403
416
|
}
|
|
404
|
-
set
|
|
405
|
-
this._isModifiedFn.next(
|
|
417
|
+
set dbxActionValueStreamModified(dbxActionValueStreamModified) {
|
|
418
|
+
this._isModifiedFn.next(dbxActionValueStreamModified);
|
|
406
419
|
}
|
|
407
420
|
ngOnInit() {
|
|
408
421
|
// Update Modified value.
|
|
@@ -410,87 +423,107 @@ class DbxActionAutoTriggerValueDirective {
|
|
|
410
423
|
this.source.setIsModified(isModified);
|
|
411
424
|
});
|
|
412
425
|
// Set the value on triggers.
|
|
413
|
-
this._triggerSub.subscription = this.source.triggered$.pipe(
|
|
414
|
-
|
|
426
|
+
this._triggerSub.subscription = this.source.triggered$.pipe(switchMap(_ => this.modifiedValue$)).subscribe(([isModified, value]) => {
|
|
427
|
+
if (isModified) {
|
|
428
|
+
this.source.readyValue(value);
|
|
429
|
+
}
|
|
415
430
|
});
|
|
416
431
|
}
|
|
417
432
|
ngOnDestroy() {
|
|
418
433
|
this.source.lockSet.onNextUnlock(() => {
|
|
419
|
-
this._isModifiedFn.complete();
|
|
420
434
|
this._valueObs.complete();
|
|
435
|
+
this._isModifiedFn.complete();
|
|
421
436
|
this._modifiedSub.destroy();
|
|
422
437
|
this._triggerSub.destroy();
|
|
423
438
|
});
|
|
424
439
|
}
|
|
425
440
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type:
|
|
441
|
+
dbxActionValueStreamDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: dbxActionValueStreamDirective, deps: [{ token: DbxActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
442
|
+
dbxActionValueStreamDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: dbxActionValueStreamDirective, selector: "[dbxActionValueStream]", inputs: { dbxActionValueStream: "dbxActionValueStream", dbxActionValueStreamIsNotEmpty: "dbxActionValueStreamIsNotEmpty", dbxActionValueStreamModified: "dbxActionValueStreamModified" }, ngImport: i0 });
|
|
443
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: dbxActionValueStreamDirective, decorators: [{
|
|
429
444
|
type: Directive,
|
|
430
445
|
args: [{
|
|
431
|
-
selector: '[
|
|
446
|
+
selector: '[dbxActionValueStream]',
|
|
432
447
|
}]
|
|
433
|
-
}], ctorParameters: function () { return [{ type:
|
|
448
|
+
}], ctorParameters: function () { return [{ type: DbxActionContextStoreSourceInstance, decorators: [{
|
|
434
449
|
type: Host
|
|
435
|
-
}] }]; }, propDecorators: {
|
|
436
|
-
type: Input
|
|
437
|
-
|
|
438
|
-
}], dbxActionAutoTriggerModifiedNonEmptyValue: [{
|
|
450
|
+
}] }]; }, propDecorators: { dbxActionValueStream: [{
|
|
451
|
+
type: Input
|
|
452
|
+
}], dbxActionValueStreamIsNotEmpty: [{
|
|
439
453
|
type: Input
|
|
440
|
-
}],
|
|
454
|
+
}], dbxActionValueStreamModified: [{
|
|
441
455
|
type: Input
|
|
442
456
|
}] } });
|
|
443
457
|
|
|
444
458
|
/**
|
|
445
459
|
* Used by ActionContextState to denote what state the action is in.
|
|
446
460
|
*/
|
|
447
|
-
var
|
|
448
|
-
(function (
|
|
461
|
+
var DbxActionState;
|
|
462
|
+
(function (DbxActionState) {
|
|
449
463
|
/**
|
|
450
464
|
* No action in progress. Waiting for the trigger.
|
|
451
465
|
*/
|
|
452
|
-
|
|
466
|
+
DbxActionState["IDLE"] = "idle";
|
|
453
467
|
/**
|
|
454
468
|
* Idle state that can be set to show that the source is not yet ready.
|
|
455
469
|
*/
|
|
456
|
-
|
|
470
|
+
DbxActionState["DISABLED"] = "disabled";
|
|
457
471
|
/**
|
|
458
472
|
* The action was triggered. We wait (and allow) the value to be updated.
|
|
459
473
|
*/
|
|
460
|
-
|
|
474
|
+
DbxActionState["TRIGGERED"] = "triggered";
|
|
461
475
|
/**
|
|
462
476
|
* The trigger was accepted and the value is updated. It should begin working immediately.
|
|
463
477
|
*
|
|
464
478
|
* ValueReady cannot be set until triggered is set.
|
|
465
479
|
*/
|
|
466
|
-
|
|
480
|
+
DbxActionState["VALUE_READY"] = "valueReady";
|
|
467
481
|
/**
|
|
468
482
|
* The action is in progress.
|
|
469
483
|
*/
|
|
470
|
-
|
|
484
|
+
DbxActionState["WORKING"] = "working";
|
|
471
485
|
/**
|
|
472
486
|
* The trigger, action, or value was rejected due to an error or other issue.
|
|
473
487
|
*
|
|
474
488
|
* An error may be specified optionally.
|
|
475
489
|
*/
|
|
476
|
-
|
|
490
|
+
DbxActionState["REJECTED"] = "rejected";
|
|
477
491
|
/**
|
|
478
|
-
* The action
|
|
492
|
+
* The action resolved without issue.
|
|
479
493
|
*/
|
|
480
|
-
|
|
481
|
-
})(
|
|
482
|
-
const DEFAULT_ACTION_DISABLED_KEY = '
|
|
494
|
+
DbxActionState["RESOLVED"] = "resolved";
|
|
495
|
+
})(DbxActionState || (DbxActionState = {}));
|
|
496
|
+
const DEFAULT_ACTION_DISABLED_KEY = 'dbx_action_disabled';
|
|
483
497
|
function isIdleActionState(actionState) {
|
|
484
498
|
switch (actionState) {
|
|
485
|
-
case
|
|
486
|
-
case
|
|
487
|
-
case
|
|
488
|
-
case
|
|
499
|
+
case DbxActionState.IDLE:
|
|
500
|
+
case DbxActionState.DISABLED:
|
|
501
|
+
case DbxActionState.REJECTED:
|
|
502
|
+
case DbxActionState.RESOLVED:
|
|
489
503
|
return true;
|
|
490
504
|
default:
|
|
491
505
|
return false;
|
|
492
506
|
}
|
|
493
507
|
}
|
|
508
|
+
function loadingStateTypeForActionState(actionState) {
|
|
509
|
+
let loadingStateType;
|
|
510
|
+
switch (actionState) {
|
|
511
|
+
case DbxActionState.RESOLVED:
|
|
512
|
+
loadingStateType = LoadingStateType.SUCCESS;
|
|
513
|
+
break;
|
|
514
|
+
case DbxActionState.REJECTED:
|
|
515
|
+
loadingStateType = LoadingStateType.ERROR;
|
|
516
|
+
break;
|
|
517
|
+
case DbxActionState.IDLE:
|
|
518
|
+
case DbxActionState.DISABLED:
|
|
519
|
+
loadingStateType = LoadingStateType.IDLE;
|
|
520
|
+
break;
|
|
521
|
+
default:
|
|
522
|
+
loadingStateType = LoadingStateType.LOADING;
|
|
523
|
+
break;
|
|
524
|
+
}
|
|
525
|
+
return loadingStateType;
|
|
526
|
+
}
|
|
494
527
|
|
|
495
528
|
function isActionContextEnabled(state) {
|
|
496
529
|
return BooleanStringKeyArrayUtilityInstance.isFalse(state.disabled);
|
|
@@ -505,13 +538,13 @@ function isWorkingActionState(actionState) {
|
|
|
505
538
|
return !isIdleActionState(actionState);
|
|
506
539
|
}
|
|
507
540
|
function canTriggerActionState(actionState) {
|
|
508
|
-
return actionState !==
|
|
541
|
+
return actionState !== DbxActionState.DISABLED && isIdleActionState(actionState);
|
|
509
542
|
}
|
|
510
543
|
function canTriggerAction(state) {
|
|
511
544
|
return isActionContextEnabled(state) && isIdleActionState(state.actionState);
|
|
512
545
|
}
|
|
513
546
|
function canReadyValue(state) {
|
|
514
|
-
return state.actionState ===
|
|
547
|
+
return state.actionState === DbxActionState.TRIGGERED;
|
|
515
548
|
}
|
|
516
549
|
function actionContextIsModifiedAndCanTrigger(state) {
|
|
517
550
|
// console.log('check: ', state, state.isModified, canTriggerAction(state));
|
|
@@ -520,20 +553,42 @@ function actionContextIsModifiedAndCanTrigger(state) {
|
|
|
520
553
|
function actionContextHasNoErrorAndIsModifiedAndCanTrigger(state) {
|
|
521
554
|
return !state.error && actionContextIsModifiedAndCanTrigger(state);
|
|
522
555
|
}
|
|
556
|
+
function loadingStateForActionContextState(state) {
|
|
557
|
+
let loadingState;
|
|
558
|
+
switch (state.actionState) {
|
|
559
|
+
case DbxActionState.RESOLVED:
|
|
560
|
+
loadingState = successResult(state.result);
|
|
561
|
+
break;
|
|
562
|
+
case DbxActionState.REJECTED:
|
|
563
|
+
loadingState = errorResult(state.error);
|
|
564
|
+
break;
|
|
565
|
+
case DbxActionState.IDLE:
|
|
566
|
+
case DbxActionState.DISABLED:
|
|
567
|
+
loadingState = idleLoadingState();
|
|
568
|
+
break;
|
|
569
|
+
default:
|
|
570
|
+
loadingState = beginLoading();
|
|
571
|
+
break;
|
|
572
|
+
}
|
|
573
|
+
return loadingState;
|
|
574
|
+
}
|
|
575
|
+
function loadingStateTypeForActionContextState(state) {
|
|
576
|
+
return loadingStateTypeForActionState(state.actionState);
|
|
577
|
+
}
|
|
523
578
|
const INITIAL_STATE = {
|
|
524
579
|
isModified: false,
|
|
525
|
-
actionState:
|
|
580
|
+
actionState: DbxActionState.IDLE
|
|
526
581
|
};
|
|
527
582
|
class ActionContextStore extends ComponentStore {
|
|
528
583
|
constructor() {
|
|
529
584
|
super({ ...INITIAL_STATE });
|
|
530
585
|
this.lockSet = new LockSet();
|
|
531
586
|
// MARK: Accessors
|
|
532
|
-
this.actionState$ = this.state$.pipe(map(x => isDisabledActionContextState(x) ?
|
|
587
|
+
this.actionState$ = this.state$.pipe(map(x => isDisabledActionContextState(x) ? DbxActionState.DISABLED : x.actionState), shareReplay(1));
|
|
533
588
|
/**
|
|
534
|
-
* Returns the current disabled reasons.
|
|
589
|
+
* Returns the current disabled reasons/keys.
|
|
535
590
|
*/
|
|
536
|
-
this.
|
|
591
|
+
this.disabledKeys$ = this.state$.pipe(map(x => [...x.disabled ?? []]), distinctUntilChanged(), shareReplay(1));
|
|
537
592
|
/**
|
|
538
593
|
* Maps the current state to true or not when the action state changes to/from disabled.
|
|
539
594
|
*/
|
|
@@ -545,19 +600,19 @@ class ActionContextStore extends ComponentStore {
|
|
|
545
600
|
/**
|
|
546
601
|
* Pipes true when triggered.
|
|
547
602
|
*/
|
|
548
|
-
this.triggered$ = this.afterDistinctActionState(
|
|
603
|
+
this.triggered$ = this.afterDistinctActionState(DbxActionState.TRIGGERED, () => true);
|
|
549
604
|
/**
|
|
550
605
|
* Pipes the readied value on ValueReady.
|
|
551
606
|
*/
|
|
552
|
-
this.valueReady$ = this.afterDistinctActionState(
|
|
607
|
+
this.valueReady$ = this.afterDistinctActionState(DbxActionState.VALUE_READY, x => x.value);
|
|
553
608
|
/**
|
|
554
609
|
* Pipes the error on the rejection state.
|
|
555
610
|
*/
|
|
556
|
-
this.rejected$ = this.afterDistinctActionState(
|
|
611
|
+
this.rejected$ = this.afterDistinctActionState(DbxActionState.REJECTED, x => x.error);
|
|
557
612
|
/**
|
|
558
613
|
* Pipes the result when the ActionState becomes working.
|
|
559
614
|
*/
|
|
560
|
-
this.working$ = this.afterDistinctActionState(
|
|
615
|
+
this.working$ = this.afterDistinctActionState(DbxActionState.WORKING, () => true);
|
|
561
616
|
/**
|
|
562
617
|
* Whether or not it is currently in a working state.
|
|
563
618
|
*/
|
|
@@ -569,11 +624,19 @@ class ActionContextStore extends ComponentStore {
|
|
|
569
624
|
/**
|
|
570
625
|
* Pipes the result when the ActionState becomes success.
|
|
571
626
|
*/
|
|
572
|
-
this.success$ = this.afterDistinctActionState(
|
|
627
|
+
this.success$ = this.afterDistinctActionState(DbxActionState.RESOLVED, x => x.result);
|
|
573
628
|
/**
|
|
574
629
|
* Whether or not it is currently in a success state.
|
|
575
630
|
*/
|
|
576
|
-
this.isSuccess$ = this.afterDistinctBoolean(x => x.actionState ===
|
|
631
|
+
this.isSuccess$ = this.afterDistinctBoolean(x => x.actionState === DbxActionState.RESOLVED);
|
|
632
|
+
/**
|
|
633
|
+
* Returns a loading state based on the current state.
|
|
634
|
+
*/
|
|
635
|
+
this.loadingState$ = this.afterDistinctLoadingStateTypeChange().pipe(map(x => loadingStateForActionContextState(x)), shareReplay(1));
|
|
636
|
+
/**
|
|
637
|
+
* Returns the current LoadingStateType based on the current state.
|
|
638
|
+
*/
|
|
639
|
+
this.loadingStateType$ = this.state$.pipe(map(x => loadingStateTypeForActionContextState(x)), distinctUntilChanged(), shareReplay(1));
|
|
577
640
|
/**
|
|
578
641
|
* Number of errors since last success.
|
|
579
642
|
*/
|
|
@@ -613,7 +676,7 @@ class ActionContextStore extends ComponentStore {
|
|
|
613
676
|
*/
|
|
614
677
|
this.setIsModified = this.updater((state, isModified) => ({
|
|
615
678
|
...state,
|
|
616
|
-
actionState: (state.actionState ===
|
|
679
|
+
actionState: (state.actionState === DbxActionState.RESOLVED) ? DbxActionState.IDLE : state.actionState,
|
|
617
680
|
isModified: isModified ?? true
|
|
618
681
|
}));
|
|
619
682
|
/**
|
|
@@ -622,28 +685,28 @@ class ActionContextStore extends ComponentStore {
|
|
|
622
685
|
* Will not fire if the action is disabled.
|
|
623
686
|
*/
|
|
624
687
|
this.trigger = this.updater((state) => canTriggerAction(state)
|
|
625
|
-
? ({ isModified: state.isModified, actionState:
|
|
688
|
+
? ({ isModified: state.isModified, actionState: DbxActionState.TRIGGERED, error: state.error, value: undefined })
|
|
626
689
|
: state);
|
|
627
690
|
/**
|
|
628
691
|
* Updates the value, setting value ready. The current result is cleared.
|
|
629
692
|
*/
|
|
630
693
|
this.readyValue = this.updater((state, value) => canReadyValue(state)
|
|
631
|
-
? ({ ...state, actionState:
|
|
694
|
+
? ({ ...state, actionState: DbxActionState.VALUE_READY, value, result: undefined })
|
|
632
695
|
: state);
|
|
633
696
|
/**
|
|
634
697
|
* Notifys the context that the action is in progress.
|
|
635
698
|
*/
|
|
636
|
-
this.startWorking = this.updater((state) => ({ ...state, actionState:
|
|
699
|
+
this.startWorking = this.updater((state) => ({ ...state, actionState: DbxActionState.WORKING }));
|
|
637
700
|
/**
|
|
638
701
|
* Triggers rejection of the action. The value is cleared.
|
|
639
702
|
*/
|
|
640
|
-
this.reject = this.updater((state, error) => ({ isModified: state.isModified, actionState:
|
|
703
|
+
this.reject = this.updater((state, error) => ({ isModified: state.isModified, actionState: DbxActionState.REJECTED, error, errorCount: (state.errorCount ?? 0) + 1, disabled: state.disabled }));
|
|
641
704
|
/**
|
|
642
705
|
* Updates the state to success, and optionally sets a result.
|
|
643
706
|
*
|
|
644
707
|
* Clears modified state, and any errors.
|
|
645
708
|
*/
|
|
646
|
-
this.
|
|
709
|
+
this.resolve = this.updater((state, result) => ({ isModified: false, actionState: DbxActionState.RESOLVED, value: state.value, result, error: undefined, disabled: state.disabled }));
|
|
647
710
|
/**
|
|
648
711
|
* Completely resets the store.
|
|
649
712
|
*/
|
|
@@ -655,9 +718,16 @@ class ActionContextStore extends ComponentStore {
|
|
|
655
718
|
return this.state$.pipe(map(x => fromState(x)), distinctUntilChanged(), shareReplay(1));
|
|
656
719
|
}
|
|
657
720
|
afterDistinctActionState(actionState, fromState) {
|
|
721
|
+
return this.afterDistinctActionStateChange().pipe(filter((x) => x.actionState === actionState), // Only pipe when the new action state matches.
|
|
722
|
+
map(x => fromState(x)), shareReplay(1));
|
|
723
|
+
}
|
|
724
|
+
afterDistinctActionStateChange() {
|
|
658
725
|
return this.state$.pipe(map((x) => ([x, x.actionState])), distinctUntilChanged((a, b) => a?.[1] === b?.[1]), // Filter out when the state remains the same.
|
|
659
|
-
|
|
660
|
-
|
|
726
|
+
map(x => x[0]), shareReplay(1));
|
|
727
|
+
}
|
|
728
|
+
afterDistinctLoadingStateTypeChange() {
|
|
729
|
+
return this.state$.pipe(map((x) => ([x, loadingStateForActionContextState(x)])), distinctUntilChanged((a, b) => a?.[1] === b?.[1]), // Filter out when the loading state remains the same.
|
|
730
|
+
map(x => x[0]), shareReplay(1));
|
|
661
731
|
}
|
|
662
732
|
// MARK: Cleanup
|
|
663
733
|
ngOnDestroy() {
|
|
@@ -676,7 +746,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
|
|
|
676
746
|
/**
|
|
677
747
|
* Abstract class that can either use SecondaryActionContextStoreSource or create it's own.
|
|
678
748
|
*/
|
|
679
|
-
class
|
|
749
|
+
class DbxActionContextBaseSource {
|
|
680
750
|
constructor(inputSource) {
|
|
681
751
|
this.inputSource = inputSource;
|
|
682
752
|
if (this.inputSource) {
|
|
@@ -686,7 +756,7 @@ class ActionContextBaseSource {
|
|
|
686
756
|
this._store = new ActionContextStore();
|
|
687
757
|
this._store$ = of(this._store);
|
|
688
758
|
}
|
|
689
|
-
this._instance = new
|
|
759
|
+
this._instance = new DbxActionContextStoreSourceInstance(this);
|
|
690
760
|
this.isModified$ = this._instance.isModified$;
|
|
691
761
|
this.triggered$ = this._instance.triggered$;
|
|
692
762
|
this.success$ = this._instance.success$;
|
|
@@ -718,12 +788,21 @@ class ActionContextBaseSource {
|
|
|
718
788
|
reset() {
|
|
719
789
|
this._instance.reset();
|
|
720
790
|
}
|
|
791
|
+
enable(key, enable) {
|
|
792
|
+
this._instance.enable(key, enable);
|
|
793
|
+
}
|
|
794
|
+
disable(key, disable) {
|
|
795
|
+
this._instance.disable(key, disable);
|
|
796
|
+
}
|
|
797
|
+
setIsModified(isModified) {
|
|
798
|
+
this._instance.setIsModified(isModified);
|
|
799
|
+
}
|
|
721
800
|
}
|
|
722
801
|
|
|
723
802
|
/**
|
|
724
803
|
* Provides an DbxActionContext.
|
|
725
804
|
*/
|
|
726
|
-
class DbxActionDirective extends
|
|
805
|
+
class DbxActionDirective extends DbxActionContextBaseSource {
|
|
727
806
|
constructor(inputSource) {
|
|
728
807
|
super(inputSource);
|
|
729
808
|
}
|
|
@@ -734,12 +813,12 @@ class DbxActionDirective extends ActionContextBaseSource {
|
|
|
734
813
|
}
|
|
735
814
|
}
|
|
736
815
|
DbxActionDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionDirective, deps: [{ token: SecondaryActionContextStoreSource, host: true, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
737
|
-
DbxActionDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionDirective, selector: "dbx-action,[dbxAction],dbx-action-context,[dbxActionContext]", providers: ProvideActionStoreSource(DbxActionDirective), exportAs: ["action"], usesInheritance: true, ngImport: i0 });
|
|
816
|
+
DbxActionDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionDirective, selector: "dbx-action,[dbxAction],dbx-action-context,[dbxActionContext]", providers: ProvideActionStoreSource(DbxActionDirective), exportAs: ["action", "dbxAction"], usesInheritance: true, ngImport: i0 });
|
|
738
817
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionDirective, decorators: [{
|
|
739
818
|
type: Directive,
|
|
740
819
|
args: [{
|
|
741
820
|
selector: 'dbx-action,[dbxAction],dbx-action-context,[dbxActionContext]',
|
|
742
|
-
exportAs: 'action',
|
|
821
|
+
exportAs: 'action,dbxAction',
|
|
743
822
|
providers: ProvideActionStoreSource(DbxActionDirective)
|
|
744
823
|
}]
|
|
745
824
|
}], ctorParameters: function () { return [{ type: SecondaryActionContextStoreSource, decorators: [{
|
|
@@ -796,14 +875,14 @@ class DbxActionContextLoggerDirective extends AbstractSubscriptionDirective {
|
|
|
796
875
|
});
|
|
797
876
|
}
|
|
798
877
|
}
|
|
799
|
-
DbxActionContextLoggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionContextLoggerDirective, deps: [{ token:
|
|
878
|
+
DbxActionContextLoggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionContextLoggerDirective, deps: [{ token: DbxActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
800
879
|
DbxActionContextLoggerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionContextLoggerDirective, selector: "[dbxActionLogger],[dbxActionContextLogger]", usesInheritance: true, ngImport: i0 });
|
|
801
880
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionContextLoggerDirective, decorators: [{
|
|
802
881
|
type: Directive,
|
|
803
882
|
args: [{
|
|
804
883
|
selector: '[dbxActionLogger],[dbxActionContextLogger]'
|
|
805
884
|
}]
|
|
806
|
-
}], ctorParameters: function () { return [{ type:
|
|
885
|
+
}], ctorParameters: function () { return [{ type: DbxActionContextStoreSourceInstance, decorators: [{
|
|
807
886
|
type: Host
|
|
808
887
|
}] }]; } });
|
|
809
888
|
|
|
@@ -955,7 +1034,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
|
|
|
955
1034
|
class ActionContextStoreSourceMap {
|
|
956
1035
|
}
|
|
957
1036
|
|
|
958
|
-
const DEFAULT_ACTION_MAP_WORKING_DISABLED_KEY = '
|
|
1037
|
+
const DEFAULT_ACTION_MAP_WORKING_DISABLED_KEY = 'action_map_working_disable';
|
|
959
1038
|
/**
|
|
960
1039
|
* Used to communicate with an dbxActionMap and set the ActionContextStore to be disabled if any other element in the map is working.
|
|
961
1040
|
*/
|
|
@@ -975,14 +1054,14 @@ class DbxActionMapWorkingDisableDirective extends AbstractSubscriptionDirective
|
|
|
975
1054
|
this.source.enable(this.disabledKey || DEFAULT_ACTION_MAP_WORKING_DISABLED_KEY);
|
|
976
1055
|
}
|
|
977
1056
|
}
|
|
978
|
-
DbxActionMapWorkingDisableDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionMapWorkingDisableDirective, deps: [{ token:
|
|
1057
|
+
DbxActionMapWorkingDisableDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionMapWorkingDisableDirective, deps: [{ token: DbxActionContextStoreSourceInstance, host: true }, { token: DbxActionContextMapDirective }], target: i0.ɵɵFactoryTarget.Directive });
|
|
979
1058
|
DbxActionMapWorkingDisableDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionMapWorkingDisableDirective, selector: "[dbxActionMapWorkingDisable]", inputs: { disabledKey: ["dbxActionMapWorkingDisable", "disabledKey"] }, usesInheritance: true, ngImport: i0 });
|
|
980
1059
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionMapWorkingDisableDirective, decorators: [{
|
|
981
1060
|
type: Directive,
|
|
982
1061
|
args: [{
|
|
983
1062
|
selector: '[dbxActionMapWorkingDisable]'
|
|
984
1063
|
}]
|
|
985
|
-
}], ctorParameters: function () { return [{ type:
|
|
1064
|
+
}], ctorParameters: function () { return [{ type: DbxActionContextStoreSourceInstance, decorators: [{
|
|
986
1065
|
type: Host
|
|
987
1066
|
}] }, { type: DbxActionContextMapDirective }]; }, propDecorators: { disabledKey: [{
|
|
988
1067
|
type: Input,
|
|
@@ -1014,55 +1093,26 @@ class DbxActionDisabledDirective extends AbstractSubscriptionDirective {
|
|
|
1014
1093
|
return this._disabled.value;
|
|
1015
1094
|
}
|
|
1016
1095
|
set disabled(disabled) {
|
|
1017
|
-
|
|
1096
|
+
const disable = isUndefinedAndNotFalse(disabled);
|
|
1097
|
+
this._disabled.next(disable);
|
|
1018
1098
|
}
|
|
1019
1099
|
}
|
|
1020
|
-
DbxActionDisabledDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionDisabledDirective, deps: [{ token:
|
|
1100
|
+
DbxActionDisabledDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionDisabledDirective, deps: [{ token: DbxActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1021
1101
|
DbxActionDisabledDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionDisabledDirective, selector: "[dbxActionDisabled]", inputs: { disabled: ["dbxActionDisabled", "disabled"] }, usesInheritance: true, ngImport: i0 });
|
|
1022
1102
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionDisabledDirective, decorators: [{
|
|
1023
1103
|
type: Directive,
|
|
1024
1104
|
args: [{
|
|
1025
1105
|
selector: '[dbxActionDisabled]'
|
|
1026
1106
|
}]
|
|
1027
|
-
}], ctorParameters: function () { return [{ type:
|
|
1107
|
+
}], ctorParameters: function () { return [{ type: DbxActionContextStoreSourceInstance, decorators: [{
|
|
1028
1108
|
type: Host
|
|
1029
1109
|
}] }]; }, propDecorators: { disabled: [{
|
|
1030
1110
|
type: Input,
|
|
1031
1111
|
args: ['dbxActionDisabled']
|
|
1032
1112
|
}] } });
|
|
1033
1113
|
|
|
1034
|
-
const APP_ACTION_DISABLED_UNTIL_MODIFIED_DIRECTIVE_KEY = 'dbx_action_is_not_modified';
|
|
1035
|
-
/**
|
|
1036
|
-
* Directive that sets the disabled state based on the current isModified state.
|
|
1037
|
-
*/
|
|
1038
|
-
class DbxActionDisabledUntilModifiedDirective extends AbstractSubscriptionDirective {
|
|
1039
|
-
constructor(source) {
|
|
1040
|
-
super();
|
|
1041
|
-
this.source = source;
|
|
1042
|
-
}
|
|
1043
|
-
ngOnInit() {
|
|
1044
|
-
this.sub = this.source.isModified$.subscribe((x) => {
|
|
1045
|
-
this.source.disable(APP_ACTION_DISABLED_UNTIL_MODIFIED_DIRECTIVE_KEY, !x);
|
|
1046
|
-
});
|
|
1047
|
-
}
|
|
1048
|
-
ngOnDestroy() {
|
|
1049
|
-
super.ngOnDestroy();
|
|
1050
|
-
this.source.enable(APP_ACTION_DISABLED_UNTIL_MODIFIED_DIRECTIVE_KEY);
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
DbxActionDisabledUntilModifiedDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionDisabledUntilModifiedDirective, deps: [{ token: ActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1054
|
-
DbxActionDisabledUntilModifiedDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionDisabledUntilModifiedDirective, selector: "[dbxActionDisabledUntilModified]", usesInheritance: true, ngImport: i0 });
|
|
1055
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionDisabledUntilModifiedDirective, decorators: [{
|
|
1056
|
-
type: Directive,
|
|
1057
|
-
args: [{
|
|
1058
|
-
selector: '[dbxActionDisabledUntilModified]'
|
|
1059
|
-
}]
|
|
1060
|
-
}], ctorParameters: function () { return [{ type: ActionContextStoreSourceInstance, decorators: [{
|
|
1061
|
-
type: Host
|
|
1062
|
-
}] }]; } });
|
|
1063
|
-
|
|
1064
1114
|
/**
|
|
1065
|
-
* WorkHandlerContextDelegate implementation using an
|
|
1115
|
+
* WorkHandlerContextDelegate implementation using an DbxActionContextStoreSourceInstance.
|
|
1066
1116
|
*/
|
|
1067
1117
|
class WorkHandlerContextSourceDelegate {
|
|
1068
1118
|
constructor(source) {
|
|
@@ -1072,7 +1122,7 @@ class WorkHandlerContextSourceDelegate {
|
|
|
1072
1122
|
this.source.startWorking();
|
|
1073
1123
|
}
|
|
1074
1124
|
success(result) {
|
|
1075
|
-
this.source.
|
|
1125
|
+
this.source.resolve(result);
|
|
1076
1126
|
}
|
|
1077
1127
|
reject(error) {
|
|
1078
1128
|
this.source.reject(error);
|
|
@@ -1221,7 +1271,7 @@ class DbxActionHandlerDirective extends AbstractSubscriptionDirective {
|
|
|
1221
1271
|
const context = handleWorkValueReadyFn({ handlerFunction, delegate: this._delegate })(value);
|
|
1222
1272
|
if (context) {
|
|
1223
1273
|
// Add the action to the lockSet for the source to prevent it from being destroyed until the action completes.
|
|
1224
|
-
this.source.lockSet.addLock('
|
|
1274
|
+
this.source.lockSet.addLock('dbxActionHandler', context.isComplete$.pipe(map(x => !x)));
|
|
1225
1275
|
}
|
|
1226
1276
|
})))).subscribe();
|
|
1227
1277
|
}
|
|
@@ -1231,14 +1281,14 @@ class DbxActionHandlerDirective extends AbstractSubscriptionDirective {
|
|
|
1231
1281
|
});
|
|
1232
1282
|
}
|
|
1233
1283
|
}
|
|
1234
|
-
DbxActionHandlerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionHandlerDirective, deps: [{ token:
|
|
1284
|
+
DbxActionHandlerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionHandlerDirective, deps: [{ token: DbxActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1235
1285
|
DbxActionHandlerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionHandlerDirective, selector: "[dbxActionHandler]", inputs: { handlerFunction: ["dbxActionHandler", "handlerFunction"] }, usesInheritance: true, ngImport: i0 });
|
|
1236
1286
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionHandlerDirective, decorators: [{
|
|
1237
1287
|
type: Directive,
|
|
1238
1288
|
args: [{
|
|
1239
1289
|
selector: '[dbxActionHandler]',
|
|
1240
1290
|
}]
|
|
1241
|
-
}], ctorParameters: function () { return [{ type:
|
|
1291
|
+
}], ctorParameters: function () { return [{ type: DbxActionContextStoreSourceInstance, decorators: [{
|
|
1242
1292
|
type: Host
|
|
1243
1293
|
}] }]; }, propDecorators: { handlerFunction: [{
|
|
1244
1294
|
type: Input,
|
|
@@ -1268,7 +1318,7 @@ class DbxActionSuccessComponent {
|
|
|
1268
1318
|
}), shareReplay(1));
|
|
1269
1319
|
}
|
|
1270
1320
|
}
|
|
1271
|
-
DbxActionSuccessComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionSuccessComponent, deps: [{ token:
|
|
1321
|
+
DbxActionSuccessComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionSuccessComponent, deps: [{ token: DbxActionContextStoreSourceInstance }], target: i0.ɵɵFactoryTarget.Component });
|
|
1272
1322
|
DbxActionSuccessComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionSuccessComponent, selector: "dbx-action-success", inputs: { hideAfter: "hideAfter" }, ngImport: i0, template: `
|
|
1273
1323
|
<ng-container *ngIf="show$ | async">
|
|
1274
1324
|
<ng-content></ng-content>
|
|
@@ -1284,7 +1334,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
|
|
|
1284
1334
|
</ng-container>
|
|
1285
1335
|
`
|
|
1286
1336
|
}]
|
|
1287
|
-
}], ctorParameters: function () { return [{ type:
|
|
1337
|
+
}], ctorParameters: function () { return [{ type: DbxActionContextStoreSourceInstance }]; }, propDecorators: { hideAfter: [{
|
|
1288
1338
|
type: Input
|
|
1289
1339
|
}] } });
|
|
1290
1340
|
|
|
@@ -1314,14 +1364,14 @@ class DbxActionSuccessDirective extends AbstractSubscriptionDirective {
|
|
|
1314
1364
|
this._successFunction.complete();
|
|
1315
1365
|
}
|
|
1316
1366
|
}
|
|
1317
|
-
DbxActionSuccessDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionSuccessDirective, deps: [{ token:
|
|
1367
|
+
DbxActionSuccessDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionSuccessDirective, deps: [{ token: DbxActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1318
1368
|
DbxActionSuccessDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionSuccessDirective, selector: "[dbxActionSuccess]", inputs: { successFunction: ["dbxActionSuccess", "successFunction"] }, usesInheritance: true, ngImport: i0 });
|
|
1319
1369
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionSuccessDirective, decorators: [{
|
|
1320
1370
|
type: Directive,
|
|
1321
1371
|
args: [{
|
|
1322
1372
|
selector: '[dbxActionSuccess]',
|
|
1323
1373
|
}]
|
|
1324
|
-
}], ctorParameters: function () { return [{ type:
|
|
1374
|
+
}], ctorParameters: function () { return [{ type: DbxActionContextStoreSourceInstance, decorators: [{
|
|
1325
1375
|
type: Host
|
|
1326
1376
|
}] }]; }, propDecorators: { successFunction: [{
|
|
1327
1377
|
type: Input,
|
|
@@ -1344,7 +1394,7 @@ class DbxActionValueDirective extends AbstractSubscriptionDirective {
|
|
|
1344
1394
|
return this._valueOrFunction.value;
|
|
1345
1395
|
}
|
|
1346
1396
|
set valueOrFunction(valueOrFunction) {
|
|
1347
|
-
this._valueOrFunction.next(valueOrFunction);
|
|
1397
|
+
this._valueOrFunction.next(valueOrFunction || undefined);
|
|
1348
1398
|
}
|
|
1349
1399
|
ngOnInit() {
|
|
1350
1400
|
this.sub = this.valueOrFunction$.pipe(switchMap(valueOrFunction => this.source.triggered$.pipe(tap(() => {
|
|
@@ -1353,18 +1403,20 @@ class DbxActionValueDirective extends AbstractSubscriptionDirective {
|
|
|
1353
1403
|
})))).subscribe();
|
|
1354
1404
|
}
|
|
1355
1405
|
ngOnDestroy() {
|
|
1356
|
-
|
|
1357
|
-
|
|
1406
|
+
this.source.lockSet.onNextUnlock(() => {
|
|
1407
|
+
super.ngOnDestroy();
|
|
1408
|
+
this._valueOrFunction.complete();
|
|
1409
|
+
});
|
|
1358
1410
|
}
|
|
1359
1411
|
}
|
|
1360
|
-
DbxActionValueDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionValueDirective, deps: [{ token:
|
|
1412
|
+
DbxActionValueDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionValueDirective, deps: [{ token: DbxActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1361
1413
|
DbxActionValueDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionValueDirective, selector: "[dbxActionValue]", inputs: { valueOrFunction: ["dbxActionValue", "valueOrFunction"] }, usesInheritance: true, ngImport: i0 });
|
|
1362
1414
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionValueDirective, decorators: [{
|
|
1363
1415
|
type: Directive,
|
|
1364
1416
|
args: [{
|
|
1365
1417
|
selector: '[dbxActionValue]',
|
|
1366
1418
|
}]
|
|
1367
|
-
}], ctorParameters: function () { return [{ type:
|
|
1419
|
+
}], ctorParameters: function () { return [{ type: DbxActionContextStoreSourceInstance, decorators: [{
|
|
1368
1420
|
type: Host
|
|
1369
1421
|
}] }]; }, propDecorators: { valueOrFunction: [{
|
|
1370
1422
|
type: Input,
|
|
@@ -1380,7 +1432,7 @@ class DbxActionWorkingComponent {
|
|
|
1380
1432
|
this.show$ = this.source.isWorking$;
|
|
1381
1433
|
}
|
|
1382
1434
|
}
|
|
1383
|
-
DbxActionWorkingComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionWorkingComponent, deps: [{ token:
|
|
1435
|
+
DbxActionWorkingComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionWorkingComponent, deps: [{ token: DbxActionContextStoreSourceInstance }], target: i0.ɵɵFactoryTarget.Component });
|
|
1384
1436
|
DbxActionWorkingComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionWorkingComponent, selector: "dbx-action-working", ngImport: i0, template: `
|
|
1385
1437
|
<ng-container *ngIf="show$ | async">
|
|
1386
1438
|
<ng-content></ng-content>
|
|
@@ -1396,45 +1448,68 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
|
|
|
1396
1448
|
</ng-container>
|
|
1397
1449
|
`
|
|
1398
1450
|
}]
|
|
1399
|
-
}], ctorParameters: function () { return [{ type:
|
|
1400
|
-
|
|
1401
|
-
const
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
}
|
|
1417
|
-
|
|
1418
|
-
(
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1451
|
+
}], ctorParameters: function () { return [{ type: DbxActionContextStoreSourceInstance }]; } });
|
|
1452
|
+
|
|
1453
|
+
const APP_ACTION_ENFORCE_MODIFIED_DIRECTIVE_KEY = 'dbx_action_enforce_modified';
|
|
1454
|
+
/**
|
|
1455
|
+
* Directive that toggles disabling an action if the action is not marked modified.
|
|
1456
|
+
*/
|
|
1457
|
+
class DbxActionEnforceModifiedDirective extends AbstractSubscriptionDirective {
|
|
1458
|
+
constructor(source) {
|
|
1459
|
+
super();
|
|
1460
|
+
this.source = source;
|
|
1461
|
+
this._enabled = new BehaviorSubject(true);
|
|
1462
|
+
}
|
|
1463
|
+
ngOnInit() {
|
|
1464
|
+
this.sub = combineLatest([this.source.isModified$, this._enabled]).pipe(delay$1(0)).subscribe(([modified, enableDirective]) => {
|
|
1465
|
+
const disable = enableDirective && !modified;
|
|
1466
|
+
this.source.disable(APP_ACTION_ENFORCE_MODIFIED_DIRECTIVE_KEY, disable);
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1469
|
+
ngOnDestroy() {
|
|
1470
|
+
super.ngOnDestroy();
|
|
1471
|
+
this._enabled.complete();
|
|
1472
|
+
this.source.enable(APP_ACTION_ENFORCE_MODIFIED_DIRECTIVE_KEY);
|
|
1473
|
+
}
|
|
1474
|
+
get enabled() {
|
|
1475
|
+
return this._enabled.value;
|
|
1476
|
+
}
|
|
1477
|
+
set enabled(enabled) {
|
|
1478
|
+
this._enabled.next(enabled ?? true);
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
DbxActionEnforceModifiedDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionEnforceModifiedDirective, deps: [{ token: DbxActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1482
|
+
DbxActionEnforceModifiedDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionEnforceModifiedDirective, selector: "[dbxActionEnforceModified]", inputs: { enabled: ["[dbxActionEnforceModified]", "enabled"] }, usesInheritance: true, ngImport: i0 });
|
|
1483
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionEnforceModifiedDirective, decorators: [{
|
|
1484
|
+
type: Directive,
|
|
1485
|
+
args: [{
|
|
1486
|
+
selector: '[dbxActionEnforceModified]'
|
|
1487
|
+
}]
|
|
1488
|
+
}], ctorParameters: function () { return [{ type: DbxActionContextStoreSourceInstance, decorators: [{
|
|
1489
|
+
type: Host
|
|
1490
|
+
}] }]; }, propDecorators: { enabled: [{
|
|
1491
|
+
type: Input,
|
|
1492
|
+
args: ['[dbxActionEnforceModified]']
|
|
1493
|
+
}] } });
|
|
1425
1494
|
|
|
1426
1495
|
/**
|
|
1427
1496
|
* Configurable machine that handles components of the ActionContextStore lifecycle.
|
|
1497
|
+
*
|
|
1498
|
+
* It can be configured to activate only once before cleaning itself up. It can be used directly as a DbxActionContextSourceReference in cases where it is created as a one-off action.
|
|
1428
1499
|
*/
|
|
1429
|
-
class
|
|
1500
|
+
class DbxActionContextMachine extends DbxActionContextBaseSource {
|
|
1430
1501
|
constructor(config, source) {
|
|
1431
1502
|
super(source);
|
|
1432
1503
|
this.config = config;
|
|
1433
1504
|
this._isShutdown = true;
|
|
1434
1505
|
this._handleValueReadySub = new SubscriptionObject();
|
|
1506
|
+
this._successSub = new SubscriptionObject();
|
|
1435
1507
|
// Handle Value Ready
|
|
1436
1508
|
this._handleValueReadySub.subscription = this.sourceInstance.valueReady$.subscribe((value) => {
|
|
1437
|
-
handleWorkValueReadyFn({
|
|
1509
|
+
handleWorkValueReadyFn({
|
|
1510
|
+
handlerFunction: config.handleValueReady,
|
|
1511
|
+
delegate: new WorkHandlerContextSourceDelegate(this.sourceInstance)
|
|
1512
|
+
})(value);
|
|
1438
1513
|
});
|
|
1439
1514
|
// If this is a one-time use, then destroy it after the first success comes through.
|
|
1440
1515
|
if (this.config.oneTimeUse) {
|
|
@@ -1443,12 +1518,13 @@ class ActionContextMachine extends ActionContextBaseSource {
|
|
|
1443
1518
|
});
|
|
1444
1519
|
}
|
|
1445
1520
|
if (this.config.onSuccess) {
|
|
1446
|
-
this.sourceInstance.success$.subscribe(this.config.onSuccess);
|
|
1521
|
+
this._successSub.subscription = this.sourceInstance.success$.subscribe(this.config.onSuccess);
|
|
1447
1522
|
}
|
|
1448
1523
|
}
|
|
1449
1524
|
destroy() {
|
|
1450
1525
|
super.destroy();
|
|
1451
1526
|
this._handleValueReadySub.destroy();
|
|
1527
|
+
this._successSub.destroy();
|
|
1452
1528
|
this._isShutdown = true;
|
|
1453
1529
|
}
|
|
1454
1530
|
get isShutdown() {
|
|
@@ -1460,11 +1536,11 @@ class DbxCoreActionModule {
|
|
|
1460
1536
|
}
|
|
1461
1537
|
DbxCoreActionModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxCoreActionModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1462
1538
|
DbxCoreActionModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxCoreActionModule, declarations: [DbxActionDirective, DbxActionContextMapDirective, DbxActionFromMapDirective, DbxActionMapSourceDirective,
|
|
1463
|
-
DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionHandlerDirective, DbxActionDisabledDirective,
|
|
1464
|
-
DbxActionAutoTriggerDirective,
|
|
1539
|
+
DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionHandlerDirective, DbxActionDisabledDirective, DbxActionEnforceModifiedDirective,
|
|
1540
|
+
DbxActionAutoTriggerDirective, dbxActionValueStreamDirective, DbxActionAutoModifyDirective, DbxActionValueDirective, DbxActionContextLoggerDirective,
|
|
1465
1541
|
DbxActionSuccessComponent, DbxActionSuccessDirective, DbxActionWorkingComponent], imports: [CommonModule], exports: [DbxActionDirective, DbxActionContextMapDirective, DbxActionFromMapDirective, DbxActionMapSourceDirective,
|
|
1466
|
-
DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionHandlerDirective, DbxActionDisabledDirective,
|
|
1467
|
-
DbxActionAutoTriggerDirective,
|
|
1542
|
+
DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionHandlerDirective, DbxActionDisabledDirective, DbxActionEnforceModifiedDirective,
|
|
1543
|
+
DbxActionAutoTriggerDirective, dbxActionValueStreamDirective, DbxActionAutoModifyDirective, DbxActionValueDirective, DbxActionContextLoggerDirective,
|
|
1468
1544
|
DbxActionSuccessComponent, DbxActionSuccessDirective, DbxActionWorkingComponent] });
|
|
1469
1545
|
DbxCoreActionModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxCoreActionModule, imports: [[
|
|
1470
1546
|
CommonModule
|
|
@@ -1477,19 +1553,70 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
|
|
|
1477
1553
|
],
|
|
1478
1554
|
declarations: [
|
|
1479
1555
|
DbxActionDirective, DbxActionContextMapDirective, DbxActionFromMapDirective, DbxActionMapSourceDirective,
|
|
1480
|
-
DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionHandlerDirective, DbxActionDisabledDirective,
|
|
1481
|
-
DbxActionAutoTriggerDirective,
|
|
1482
|
-
DbxActionSuccessComponent, DbxActionSuccessDirective, DbxActionWorkingComponent
|
|
1556
|
+
DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionHandlerDirective, DbxActionDisabledDirective, DbxActionEnforceModifiedDirective,
|
|
1557
|
+
DbxActionAutoTriggerDirective, dbxActionValueStreamDirective, DbxActionAutoModifyDirective, DbxActionValueDirective, DbxActionContextLoggerDirective,
|
|
1558
|
+
DbxActionSuccessComponent, DbxActionSuccessDirective, DbxActionWorkingComponent,
|
|
1483
1559
|
],
|
|
1484
1560
|
exports: [
|
|
1485
1561
|
DbxActionDirective, DbxActionContextMapDirective, DbxActionFromMapDirective, DbxActionMapSourceDirective,
|
|
1486
|
-
DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionHandlerDirective, DbxActionDisabledDirective,
|
|
1487
|
-
DbxActionAutoTriggerDirective,
|
|
1562
|
+
DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionHandlerDirective, DbxActionDisabledDirective, DbxActionEnforceModifiedDirective,
|
|
1563
|
+
DbxActionAutoTriggerDirective, dbxActionValueStreamDirective, DbxActionAutoModifyDirective, DbxActionValueDirective, DbxActionContextLoggerDirective,
|
|
1488
1564
|
DbxActionSuccessComponent, DbxActionSuccessDirective, DbxActionWorkingComponent
|
|
1489
1565
|
]
|
|
1490
1566
|
}]
|
|
1491
1567
|
}] });
|
|
1492
1568
|
|
|
1569
|
+
function makeDbxActionContextSourceReference(sourceInstance) {
|
|
1570
|
+
return {
|
|
1571
|
+
sourceInstance,
|
|
1572
|
+
destroy: () => 0
|
|
1573
|
+
};
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
/**
|
|
1577
|
+
* Convenience function used within observables for views that need to detect changes after a value changes.
|
|
1578
|
+
*
|
|
1579
|
+
* @param cdRef
|
|
1580
|
+
* @param timeout
|
|
1581
|
+
* @returns
|
|
1582
|
+
*/
|
|
1583
|
+
function tapDetectChanges(cdRef, timeout = 0) {
|
|
1584
|
+
return tap$1(() => setTimeout(() => safeDetectChanges(cdRef), timeout));
|
|
1585
|
+
}
|
|
1586
|
+
/**
|
|
1587
|
+
* Triggers a detection change on the input view as long as the view has not been destroyed.
|
|
1588
|
+
*
|
|
1589
|
+
* @param cdRef
|
|
1590
|
+
*/
|
|
1591
|
+
function safeDetectChanges(cdRef) {
|
|
1592
|
+
if (!cdRef.destroyed) {
|
|
1593
|
+
cdRef.detectChanges();
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
/**
|
|
1597
|
+
* Used to check an injected ElementRef that wraps an ng-content injection point whether or not any content was injected,
|
|
1598
|
+
* or more specifically if the parent component passed any target content to the child. This will still return true if
|
|
1599
|
+
* passed content is empty.
|
|
1600
|
+
*
|
|
1601
|
+
* TS:
|
|
1602
|
+
* @ViewChild('customLoading', { static: false }) customCustom: ElementRef;
|
|
1603
|
+
*
|
|
1604
|
+
* HTML:
|
|
1605
|
+
* <div #customContent>
|
|
1606
|
+
* <ng-content select="[content]"></ng-content>
|
|
1607
|
+
* </div>
|
|
1608
|
+
*/
|
|
1609
|
+
function checkNgContentWrapperHasContent(ref) {
|
|
1610
|
+
// https://github.com/angular/angular/issues/26083
|
|
1611
|
+
let hasContent = false;
|
|
1612
|
+
if (ref != null) {
|
|
1613
|
+
const childNodes = ref.nativeElement.childNodes;
|
|
1614
|
+
const hasChildNodes = childNodes && childNodes.length > 0;
|
|
1615
|
+
hasContent = Boolean(hasChildNodes);
|
|
1616
|
+
}
|
|
1617
|
+
return hasContent;
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1493
1620
|
class DbxButton {
|
|
1494
1621
|
}
|
|
1495
1622
|
function ProvideDbxButton(sourceType) {
|
|
@@ -1517,7 +1644,7 @@ class DbxActionButtonTriggerDirective extends AbstractSubscriptionDirective {
|
|
|
1517
1644
|
this.source.trigger();
|
|
1518
1645
|
}
|
|
1519
1646
|
}
|
|
1520
|
-
DbxActionButtonTriggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionButtonTriggerDirective, deps: [{ token: DbxButton, host: true }, { token:
|
|
1647
|
+
DbxActionButtonTriggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionButtonTriggerDirective, deps: [{ token: DbxButton, host: true }, { token: DbxActionContextStoreSourceInstance }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1521
1648
|
DbxActionButtonTriggerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionButtonTriggerDirective, selector: "[dbxActionButtonTrigger]", usesInheritance: true, ngImport: i0 });
|
|
1522
1649
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionButtonTriggerDirective, decorators: [{
|
|
1523
1650
|
type: Directive,
|
|
@@ -1526,27 +1653,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
|
|
|
1526
1653
|
}]
|
|
1527
1654
|
}], ctorParameters: function () { return [{ type: DbxButton, decorators: [{
|
|
1528
1655
|
type: Host
|
|
1529
|
-
}] }, { type:
|
|
1656
|
+
}] }, { type: DbxActionContextStoreSourceInstance }]; } });
|
|
1530
1657
|
|
|
1531
1658
|
/**
|
|
1532
1659
|
* Context used for linking a button to an ActionContext.
|
|
1533
1660
|
*/
|
|
1534
1661
|
class DbxActionButtonDirective extends DbxActionButtonTriggerDirective {
|
|
1535
|
-
constructor(button, source,
|
|
1662
|
+
constructor(button, source, cdRef) {
|
|
1536
1663
|
super(button, source);
|
|
1537
|
-
this.
|
|
1664
|
+
this.cdRef = cdRef;
|
|
1538
1665
|
this._workingSub = new SubscriptionObject();
|
|
1539
1666
|
this._disabledSub = new SubscriptionObject();
|
|
1540
1667
|
}
|
|
1541
1668
|
ngOnInit() {
|
|
1542
1669
|
super.ngOnInit();
|
|
1543
1670
|
this._workingSub.subscription = this.source.isWorking$.subscribe((working) => {
|
|
1544
|
-
|
|
1545
|
-
|
|
1671
|
+
this.button.working = working;
|
|
1672
|
+
safeDetectChanges(this.cdRef);
|
|
1546
1673
|
});
|
|
1547
1674
|
this._disabledSub.subscription = this.source.isDisabled$.subscribe((disabled) => {
|
|
1548
|
-
|
|
1549
|
-
|
|
1675
|
+
this.button.disabled = disabled;
|
|
1676
|
+
safeDetectChanges(this.cdRef);
|
|
1550
1677
|
});
|
|
1551
1678
|
}
|
|
1552
1679
|
ngOnDestroy() {
|
|
@@ -1555,7 +1682,7 @@ class DbxActionButtonDirective extends DbxActionButtonTriggerDirective {
|
|
|
1555
1682
|
this._disabledSub.destroy();
|
|
1556
1683
|
}
|
|
1557
1684
|
}
|
|
1558
|
-
DbxActionButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionButtonDirective, deps: [{ token: DbxButton, host: true }, { token:
|
|
1685
|
+
DbxActionButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionButtonDirective, deps: [{ token: DbxButton, host: true }, { token: DbxActionContextStoreSourceInstance }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1559
1686
|
DbxActionButtonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionButtonDirective, selector: "[dbxActionButton]", usesInheritance: true, ngImport: i0 });
|
|
1560
1687
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionButtonDirective, decorators: [{
|
|
1561
1688
|
type: Directive,
|
|
@@ -1564,7 +1691,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
|
|
|
1564
1691
|
}]
|
|
1565
1692
|
}], ctorParameters: function () { return [{ type: DbxButton, decorators: [{
|
|
1566
1693
|
type: Host
|
|
1567
|
-
}] }, { type:
|
|
1694
|
+
}] }, { type: DbxActionContextStoreSourceInstance }, { type: i0.ChangeDetectorRef }]; } });
|
|
1568
1695
|
|
|
1569
1696
|
const expandClickableAnchorLinkTreeNode = expandTreeFunction({
|
|
1570
1697
|
getChildren: (x) => x.children
|
|
@@ -2446,12 +2573,12 @@ class AbstractActionFilterSourceDirective extends AbstractFilterSourceDirective
|
|
|
2446
2573
|
}
|
|
2447
2574
|
}
|
|
2448
2575
|
AbstractActionFilterSourceDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AbstractActionFilterSourceDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
2449
|
-
AbstractActionFilterSourceDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: AbstractActionFilterSourceDirective, viewQueries: [{ propertyName: "filterAction", first: true, predicate:
|
|
2576
|
+
AbstractActionFilterSourceDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: AbstractActionFilterSourceDirective, viewQueries: [{ propertyName: "filterAction", first: true, predicate: DbxActionContextStoreSourceInstance, descendants: true, read: DbxActionContextStoreSourceInstance, static: true }], usesInheritance: true, ngImport: i0 });
|
|
2450
2577
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AbstractActionFilterSourceDirective, decorators: [{
|
|
2451
2578
|
type: Directive
|
|
2452
2579
|
}], propDecorators: { filterAction: [{
|
|
2453
2580
|
type: ViewChild,
|
|
2454
|
-
args: [
|
|
2581
|
+
args: [DbxActionContextStoreSourceInstance, { static: true, read: DbxActionContextStoreSourceInstance }]
|
|
2455
2582
|
}] } });
|
|
2456
2583
|
|
|
2457
2584
|
/**
|
|
@@ -3232,53 +3359,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
|
|
|
3232
3359
|
type: NgModule
|
|
3233
3360
|
}] });
|
|
3234
3361
|
|
|
3235
|
-
/**
|
|
3236
|
-
* Convenience function used within observables for views that need to detect changes after a value changes.
|
|
3237
|
-
*
|
|
3238
|
-
* @param cdRef
|
|
3239
|
-
* @param timeout
|
|
3240
|
-
* @returns
|
|
3241
|
-
*/
|
|
3242
|
-
function tapDetectChanges(cdRef, timeout = 0) {
|
|
3243
|
-
return tap$1(() => setTimeout(() => safeDetectChanges(cdRef), timeout));
|
|
3244
|
-
}
|
|
3245
|
-
/**
|
|
3246
|
-
* Triggers a detection change on the input view as long as the view has not been destroyed.
|
|
3247
|
-
*
|
|
3248
|
-
* @param cdRef
|
|
3249
|
-
*/
|
|
3250
|
-
function safeDetectChanges(cdRef) {
|
|
3251
|
-
if (!cdRef.destroyed) {
|
|
3252
|
-
cdRef.detectChanges();
|
|
3253
|
-
}
|
|
3254
|
-
}
|
|
3255
|
-
/**
|
|
3256
|
-
* Used to check an injected ElementRef that wraps an ng-content injection point whether or not any content was injected,
|
|
3257
|
-
* or more specifically if the parent component passed any target content to the child. This will still return true if
|
|
3258
|
-
* passed content is empty.
|
|
3259
|
-
*
|
|
3260
|
-
* TS:
|
|
3261
|
-
* @ViewChild('customLoading', { static: false }) customCustom: ElementRef;
|
|
3262
|
-
*
|
|
3263
|
-
* HTML:
|
|
3264
|
-
* <div #customContent>
|
|
3265
|
-
* <ng-content select="[content]"></ng-content>
|
|
3266
|
-
* </div>
|
|
3267
|
-
*/
|
|
3268
|
-
function checkNgContentWrapperHasContent(ref) {
|
|
3269
|
-
// https://github.com/angular/angular/issues/26083
|
|
3270
|
-
let hasContent = false;
|
|
3271
|
-
if (ref != null) {
|
|
3272
|
-
const childNodes = ref.nativeElement.childNodes;
|
|
3273
|
-
const hasChildNodes = childNodes && childNodes.length > 0;
|
|
3274
|
-
hasContent = Boolean(hasChildNodes);
|
|
3275
|
-
}
|
|
3276
|
-
return hasContent;
|
|
3277
|
-
}
|
|
3278
|
-
|
|
3279
3362
|
/**
|
|
3280
3363
|
* Generated bundle index. Do not edit.
|
|
3281
3364
|
*/
|
|
3282
3365
|
|
|
3283
|
-
export { APP_ACTION_DISABLED_DIRECTIVE_KEY,
|
|
3366
|
+
export { APP_ACTION_DISABLED_DIRECTIVE_KEY, APP_ACTION_ENFORCE_MODIFIED_DIRECTIVE_KEY, AbstractActionFilterSourceDirective, AbstractDbxAnchorDirective, AbstractDbxButtonDirective, AbstractDbxFilterMapInstanceDirective, AbstractDbxInjectedDirective, AbstractFilterSourceConnectorDirective, AbstractFilterSourceDirective, AbstractLockSetSubscriptionDirective, AbstractSubscriptionDirective, AbstractTransitionDirective, AbstractTransitionWatcherDirective, ActionContextStore, ActionContextStoreSource, ActionContextStoreSourceMap, AnchorType, DBX_INJECTED_COMPONENT_DATA, DEFAULT_ACTION_DISABLED_KEY, DEFAULT_ACTION_MAP_WORKING_DISABLED_KEY, DEFAULT_STORAGE_ACCESSOR_FACTORY_TOKEN, DEFAULT_STORAGE_OBJECT_TOKEN, DateDistancePipe, DateFormatDistancePipe, DateFromToTimePipe, DbxActionAutoModifyDirective, DbxActionAutoTriggerDirective, DbxActionButtonDirective, DbxActionButtonTriggerDirective, DbxActionContextBaseSource, DbxActionContextLoggerDirective, DbxActionContextMachine, DbxActionContextMapDirective, DbxActionContextMapDirectiveSourceInstance, DbxActionContextStoreSourceInstance, DbxActionDirective, DbxActionDisabledDirective, DbxActionEnforceModifiedDirective, DbxActionFromMapDirective, DbxActionHandlerDirective, DbxActionMapSourceDirective, DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionState, DbxActionSuccessComponent, DbxActionSuccessDirective, DbxActionValueDirective, DbxActionWorkingComponent, DbxAnchor, DbxAngularRouterService, DbxButton, DbxButtonDirective, DbxButtonSegueDirective, DbxCoreActionModule, DbxCoreAngularRouterSegueModule, DbxCoreButtonModule, DbxCoreFilterModule, DbxCoreUIRouterSegueModule, DbxDatePipeModule, DbxFilterMapDirective, DbxFilterMapSourceConnectorDirective, DbxFilterMapSourceDirective, DbxFilterSourceConnectorDirective, DbxFilterSourceDirective, DbxInjectedComponent, DbxInjectedComponentInstance, DbxInjectedComponentModule, DbxLoadingButtonDirective, DbxRouterService, DbxRouterTransitionEventType, DbxRouterTransitionService, DbxStorageModule, DbxUIRouterService, FullLocalStorageObject, InstantStorageAccessor, LimitedStorageAccessor, MemoryStorageObject, MinutesStringPipe, ProvideActionStoreSource, ProvideDbxAnchor, ProvideDbxButton, ProvideFilterSource, ProvideFilterSourceConnector, ProvideSecondaryActionStoreSource, SecondaryActionContextStoreSource, SimpleStorageAccessor, SimpleStorageAccessorFactory, StorageAccessor, StringStorageAccessor, StringifySimpleStorageAccessorConverter, TimeDistanceCountdownPipe, TimeDistancePipe, ToJsDatePipe, ToMinutesPipe, WorkHandlerContext, WorkHandlerContextSourceDelegate, WrapperSimpleStorageAccessorDelegate, actionContextHasNoErrorAndIsModifiedAndCanTrigger, actionContextIsModifiedAndCanTrigger, actionContextStoreSourceInstanceFactory, actionContextStoreSourcePipe, anchorTypeForAnchor, canReadyValue, canTriggerAction, canTriggerActionState, checkNgContentWrapperHasContent, dbxActionValueStreamDirective, defaultStorageObjectFactory, expandClickableAnchorLinkTree, expandClickableAnchorLinkTreeNode, expandClickableAnchorLinkTrees, filterTransitionEvent, filterTransitionSuccess, flattenExpandedClickableAnchorLinkTree, flattenExpandedClickableAnchorLinkTreeToLinks, handleWorkValueReadyFn, handleWorkValueReadyWithConfigFn, isActionContextDisabled, isActionContextEnabled, isDisabledActionContextState, isIdleActionState, isWorkingActionState, loadingStateForActionContextState, loadingStateTypeForActionContextState, loadingStateTypeForActionState, makeDbxActionContextSourceReference, mapRefStringObsToSegueRefObs, mergeDbxInjectedComponentConfigs, pipeActionStore, refStringToSegueRef, safeDetectChanges, successTransition, tapDetectChanges, useActionStore };
|
|
3284
3367
|
//# sourceMappingURL=dereekb-dbx-core.mjs.map
|