@dereekb/dbx-core 0.0.1
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 +7 -0
- package/dereekb-dbx-core.d.ts +5 -0
- package/esm2020/dereekb-dbx-core.mjs +5 -0
- package/esm2020/index.mjs +2 -0
- package/esm2020/lib/action/action.handler.mjs +140 -0
- package/esm2020/lib/action/action.holder.mjs +50 -0
- package/esm2020/lib/action/action.machine.mjs +37 -0
- package/esm2020/lib/action/action.mjs +51 -0
- package/esm2020/lib/action/action.module.mjs +38 -0
- package/esm2020/lib/action/action.store.mjs +188 -0
- package/esm2020/lib/action/action.store.source.mjs +149 -0
- package/esm2020/lib/action/directive/auto/action.automodify.directive.mjs +53 -0
- package/esm2020/lib/action/directive/auto/action.autotrigger.directive.mjs +131 -0
- package/esm2020/lib/action/directive/auto/action.autotrigger.value.directive.mjs +79 -0
- package/esm2020/lib/action/directive/auto/index.mjs +4 -0
- package/esm2020/lib/action/directive/context/action.component.mjs +18 -0
- package/esm2020/lib/action/directive/context/action.directive.mjs +33 -0
- package/esm2020/lib/action/directive/context/action.source.directive.mjs +40 -0
- package/esm2020/lib/action/directive/context/index.mjs +4 -0
- package/esm2020/lib/action/directive/debug/action.logger.directive.mjs +30 -0
- package/esm2020/lib/action/directive/debug/index.mjs +2 -0
- package/esm2020/lib/action/directive/index.mjs +6 -0
- package/esm2020/lib/action/directive/map/action.map.directive.mjs +74 -0
- package/esm2020/lib/action/directive/map/action.map.key.directive.mjs +40 -0
- package/esm2020/lib/action/directive/map/action.map.mjs +6 -0
- package/esm2020/lib/action/directive/map/action.map.source.directive.mjs +49 -0
- package/esm2020/lib/action/directive/map/action.map.working.disable.directive.mjs +41 -0
- package/esm2020/lib/action/directive/map/index.mjs +6 -0
- package/esm2020/lib/action/directive/state/action.disabled.directive.mjs +49 -0
- package/esm2020/lib/action/directive/state/action.disabled.modified.directive.mjs +35 -0
- package/esm2020/lib/action/directive/state/action.handler.directive.mjs +55 -0
- package/esm2020/lib/action/directive/state/action.success.component.mjs +50 -0
- package/esm2020/lib/action/directive/state/action.success.directive.mjs +48 -0
- package/esm2020/lib/action/directive/state/action.value.directive.mjs +52 -0
- package/esm2020/lib/action/directive/state/action.working.component.mjs +32 -0
- package/esm2020/lib/action/directive/state/index.mjs +8 -0
- package/esm2020/lib/action/index.mjs +10 -0
- package/esm2020/lib/action/snackbar/index.mjs +3 -0
- package/esm2020/lib/action/snackbar/snackbar.mjs +24 -0
- package/esm2020/lib/button/action/action.button.directive.mjs +46 -0
- package/esm2020/lib/button/action/action.button.trigger.directive.mjs +36 -0
- package/esm2020/lib/button/action/index.mjs +3 -0
- package/esm2020/lib/button/button.directive.mjs +109 -0
- package/esm2020/lib/button/button.loading.directive.mjs +43 -0
- package/esm2020/lib/button/button.mjs +9 -0
- package/esm2020/lib/button/button.module.mjs +40 -0
- package/esm2020/lib/button/index.mjs +7 -0
- package/esm2020/lib/button/router/button.segue.directive.mjs +43 -0
- package/esm2020/lib/button/router/index.mjs +2 -0
- package/esm2020/lib/index.mjs +9 -0
- package/esm2020/lib/injected/index.mjs +6 -0
- package/esm2020/lib/injected/injected.component.mjs +34 -0
- package/esm2020/lib/injected/injected.component.module.mjs +26 -0
- package/esm2020/lib/injected/injected.directive.mjs +32 -0
- package/esm2020/lib/injected/injected.instance.mjs +101 -0
- package/esm2020/lib/injected/injected.mjs +2 -0
- package/esm2020/lib/pipe/date/date.pipe.module.mjs +54 -0
- package/esm2020/lib/pipe/date/datedistance.pipe.mjs +42 -0
- package/esm2020/lib/pipe/date/dateformatdistance.pipe.mjs +37 -0
- package/esm2020/lib/pipe/date/datefromtoformat.pipe.mjs +35 -0
- package/esm2020/lib/pipe/date/index.mjs +9 -0
- package/esm2020/lib/pipe/date/minutesstring.pipe.mjs +32 -0
- package/esm2020/lib/pipe/date/timedistance.pipe.mjs +49 -0
- package/esm2020/lib/pipe/date/tojsdate.pipe.mjs +18 -0
- package/esm2020/lib/pipe/date/tominutes.pipe.mjs +17 -0
- package/esm2020/lib/pipe/index.mjs +2 -0
- package/esm2020/lib/router/anchor/anchor.directive.mjs +40 -0
- package/esm2020/lib/router/anchor/anchor.mjs +35 -0
- package/esm2020/lib/router/anchor/clickable.mjs +2 -0
- package/esm2020/lib/router/anchor/index.mjs +4 -0
- package/esm2020/lib/router/index.mjs +4 -0
- package/esm2020/lib/router/router/index.mjs +4 -0
- package/esm2020/lib/router/router/provider/angular/angular.router.service.mjs +51 -0
- package/esm2020/lib/router/router/provider/angular/angular.router.service.module.mjs +30 -0
- package/esm2020/lib/router/router/provider/angular/index.mjs +3 -0
- package/esm2020/lib/router/router/provider/index.mjs +3 -0
- package/esm2020/lib/router/router/provider/uirouter/index.mjs +3 -0
- package/esm2020/lib/router/router/provider/uirouter/uirouter.router.service.mjs +39 -0
- package/esm2020/lib/router/router/provider/uirouter/uirouter.router.service.module.mjs +31 -0
- package/esm2020/lib/router/router/service/index.mjs +3 -0
- package/esm2020/lib/router/router/service/router.service.mjs +6 -0
- package/esm2020/lib/router/router/service/router.transition.service.mjs +6 -0
- package/esm2020/lib/router/router/transition/index.mjs +3 -0
- package/esm2020/lib/router/router/transition/transition.mjs +12 -0
- package/esm2020/lib/router/router/transition/transition.watcher.directive.mjs +35 -0
- package/esm2020/lib/router/segue.mjs +8 -0
- package/esm2020/lib/storage/index.mjs +9 -0
- package/esm2020/lib/storage/storage.accessor.mjs +16 -0
- package/esm2020/lib/storage/storage.accessor.simple.factory.mjs +33 -0
- package/esm2020/lib/storage/storage.accessor.simple.mjs +161 -0
- package/esm2020/lib/storage/storage.accessor.string.mjs +50 -0
- package/esm2020/lib/storage/storage.di.mjs +4 -0
- package/esm2020/lib/storage/storage.module.mjs +37 -0
- package/esm2020/lib/storage/storage.object.localstorage.mjs +46 -0
- package/esm2020/lib/storage/storage.object.memory.mjs +17 -0
- package/esm2020/lib/subscription/index.mjs +2 -0
- package/esm2020/lib/subscription/subscription.directive.mjs +46 -0
- package/esm2020/lib/util/index.mjs +2 -0
- package/esm2020/lib/util/view.mjs +34 -0
- package/fesm2015/dereekb-dbx-core.mjs +2875 -0
- package/fesm2015/dereekb-dbx-core.mjs.map +1 -0
- package/fesm2020/dereekb-dbx-core.mjs +2856 -0
- package/fesm2020/dereekb-dbx-core.mjs.map +1 -0
- package/index.d.ts +1 -0
- package/lib/action/action.d.ts +43 -0
- package/lib/action/action.handler.d.ts +73 -0
- package/lib/action/action.holder.d.ts +28 -0
- package/lib/action/action.machine.d.ts +23 -0
- package/lib/action/action.module.d.ts +25 -0
- package/lib/action/action.store.d.ts +147 -0
- package/lib/action/action.store.source.d.ts +72 -0
- package/lib/action/directive/auto/action.automodify.directive.d.ts +15 -0
- package/lib/action/directive/auto/action.autotrigger.directive.d.ts +54 -0
- package/lib/action/directive/auto/action.autotrigger.value.directive.d.ts +25 -0
- package/lib/action/directive/auto/index.d.ts +3 -0
- package/lib/action/directive/context/action.component.d.ts +6 -0
- package/lib/action/directive/context/action.directive.d.ts +13 -0
- package/lib/action/directive/context/action.source.directive.d.ts +16 -0
- package/lib/action/directive/context/index.d.ts +3 -0
- package/lib/action/directive/debug/action.logger.directive.d.ts +14 -0
- package/lib/action/directive/debug/index.d.ts +1 -0
- package/lib/action/directive/index.d.ts +5 -0
- package/lib/action/directive/map/action.map.d.ts +13 -0
- package/lib/action/directive/map/action.map.directive.d.ts +35 -0
- package/lib/action/directive/map/action.map.key.directive.d.ts +20 -0
- package/lib/action/directive/map/action.map.source.directive.d.ts +20 -0
- package/lib/action/directive/map/action.map.working.disable.directive.d.ts +21 -0
- package/lib/action/directive/map/index.d.ts +5 -0
- package/lib/action/directive/state/action.disabled.directive.d.ts +20 -0
- package/lib/action/directive/state/action.disabled.modified.directive.d.ts +16 -0
- package/lib/action/directive/state/action.handler.directive.d.ts +22 -0
- package/lib/action/directive/state/action.success.component.d.ts +15 -0
- package/lib/action/directive/state/action.success.directive.d.ts +24 -0
- package/lib/action/directive/state/action.value.directive.d.ts +22 -0
- package/lib/action/directive/state/action.working.component.d.ts +12 -0
- package/lib/action/directive/state/index.d.ts +7 -0
- package/lib/action/index.d.ts +9 -0
- package/lib/action/snackbar/index.d.ts +1 -0
- package/lib/action/snackbar/snackbar.d.ts +50 -0
- package/lib/button/action/action.button.directive.d.ts +18 -0
- package/lib/button/action/action.button.trigger.directive.d.ts +17 -0
- package/lib/button/action/index.d.ts +2 -0
- package/lib/button/button.d.ts +26 -0
- package/lib/button/button.directive.d.ts +52 -0
- package/lib/button/button.loading.directive.d.ts +21 -0
- package/lib/button/button.module.d.ts +11 -0
- package/lib/button/index.d.ts +6 -0
- package/lib/button/router/button.segue.directive.d.ts +18 -0
- package/lib/button/router/index.d.ts +1 -0
- package/lib/index.d.ts +8 -0
- package/lib/injected/index.d.ts +5 -0
- package/lib/injected/injected.component.d.ts +15 -0
- package/lib/injected/injected.component.module.d.ts +8 -0
- package/lib/injected/injected.d.ts +26 -0
- package/lib/injected/injected.directive.d.ts +17 -0
- package/lib/injected/injected.instance.d.ts +29 -0
- package/lib/pipe/date/date.pipe.module.d.ts +13 -0
- package/lib/pipe/date/datedistance.pipe.d.ts +8 -0
- package/lib/pipe/date/dateformatdistance.pipe.d.ts +13 -0
- package/lib/pipe/date/datefromtoformat.pipe.d.ts +14 -0
- package/lib/pipe/date/index.d.ts +8 -0
- package/lib/pipe/date/minutesstring.pipe.d.ts +8 -0
- package/lib/pipe/date/timedistance.pipe.d.ts +13 -0
- package/lib/pipe/date/tojsdate.pipe.d.ts +9 -0
- package/lib/pipe/date/tominutes.pipe.d.ts +7 -0
- package/lib/pipe/index.d.ts +1 -0
- package/lib/router/anchor/anchor.d.ts +31 -0
- package/lib/router/anchor/anchor.directive.d.ts +20 -0
- package/lib/router/anchor/clickable.d.ts +17 -0
- package/lib/router/anchor/index.d.ts +3 -0
- package/lib/router/index.d.ts +3 -0
- package/lib/router/router/index.d.ts +3 -0
- package/lib/router/router/provider/angular/angular.router.service.d.ts +17 -0
- package/lib/router/router/provider/angular/angular.router.service.module.d.ts +8 -0
- package/lib/router/router/provider/angular/index.d.ts +2 -0
- package/lib/router/router/provider/index.d.ts +2 -0
- package/lib/router/router/provider/uirouter/index.d.ts +2 -0
- package/lib/router/router/provider/uirouter/uirouter.router.service.d.ts +19 -0
- package/lib/router/router/provider/uirouter/uirouter.router.service.module.d.ts +8 -0
- package/lib/router/router/service/index.d.ts +2 -0
- package/lib/router/router/service/router.service.d.ts +12 -0
- package/lib/router/router/service/router.transition.service.d.ts +11 -0
- package/lib/router/router/transition/index.d.ts +2 -0
- package/lib/router/router/transition/transition.d.ts +13 -0
- package/lib/router/router/transition/transition.watcher.directive.d.ts +18 -0
- package/lib/router/segue.d.ts +28 -0
- package/lib/storage/index.d.ts +8 -0
- package/lib/storage/storage.accessor.d.ts +35 -0
- package/lib/storage/storage.accessor.simple.d.ts +75 -0
- package/lib/storage/storage.accessor.simple.factory.d.ts +18 -0
- package/lib/storage/storage.accessor.string.d.ts +16 -0
- package/lib/storage/storage.di.d.ts +3 -0
- package/lib/storage/storage.module.d.ts +10 -0
- package/lib/storage/storage.object.localstorage.d.ts +16 -0
- package/lib/storage/storage.object.memory.d.ts +9 -0
- package/lib/subscription/index.d.ts +1 -0
- package/lib/subscription/subscription.directive.d.ts +25 -0
- package/lib/util/index.d.ts +1 -0
- package/lib/util/view.d.ts +22 -0
- package/package.json +52 -0
|
@@ -0,0 +1,2856 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Directive, forwardRef, Host, Input, Injectable, Optional, Component, NgModule, EventEmitter, Output, LOCALE_ID, Pipe, Inject, ViewContainerRef, ViewChild, InjectionToken } from '@angular/core';
|
|
3
|
+
import * as i1 from 'rxjs';
|
|
4
|
+
import { BehaviorSubject, combineLatest, Subject, interval, EMPTY, of, isObservable, Observable } from 'rxjs';
|
|
5
|
+
import { SubscriptionObject, LockSet, filterMaybe, scanCount, combineLatestFromMapValuesObsFn, skipFirstMaybe } from '@dereekb/rxjs';
|
|
6
|
+
import { switchMap, first, distinctUntilChanged, filter, debounce, throttle, exhaustMap, mergeMap, map, shareReplay, withLatestFrom, startWith, tap, delay } from 'rxjs/operators';
|
|
7
|
+
import * as i1$3 from '@dereekb/util';
|
|
8
|
+
import { hasValueOrNotEmpty, BooleanStringKeyArrayUtilityInstance, reduceBooleansWithOrFn, getValueFromObjectOrGetter, DataIsExpiredError, DataDoesNotExistError, filterMaybeValuesFn, StorageObjectUtility, SHARED_MEMORY_STORAGE } from '@dereekb/util';
|
|
9
|
+
import { ComponentStore } from '@ngrx/component-store';
|
|
10
|
+
import * as i2 from '@angular/common';
|
|
11
|
+
import { CommonModule, formatDate } from '@angular/common';
|
|
12
|
+
import ms from 'ms';
|
|
13
|
+
import * as i1$1 from '@angular/router';
|
|
14
|
+
import { NavigationStart, NavigationEnd } from '@angular/router';
|
|
15
|
+
import { isArray } from 'class-validator';
|
|
16
|
+
import * as i1$2 from '@uirouter/core';
|
|
17
|
+
import { addMinutes, isPast, formatDistance, isValid, formatDistanceToNow, startOfDay, isSameDay } from 'date-fns';
|
|
18
|
+
import { toJsDate, formatToTimeString, unixTimeNumberForNow, timeNumberHasExpired } from '@dereekb/date';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Abstract component that contains a SubscriptionObject and will clean it up automatically.
|
|
22
|
+
*/
|
|
23
|
+
class AbstractSubscriptionDirective {
|
|
24
|
+
constructor(subscription) {
|
|
25
|
+
this._subscriptionObject = new SubscriptionObject();
|
|
26
|
+
this.sub = subscription;
|
|
27
|
+
}
|
|
28
|
+
ngOnDestroy() {
|
|
29
|
+
this._subscriptionObject.destroy();
|
|
30
|
+
}
|
|
31
|
+
set sub(subscription) {
|
|
32
|
+
this._subscriptionObject.subscription = subscription;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
AbstractSubscriptionDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractSubscriptionDirective, deps: [{ token: i1.Subscription }], target: i0.ɵɵFactoryTarget.Directive });
|
|
36
|
+
AbstractSubscriptionDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: AbstractSubscriptionDirective, ngImport: i0 });
|
|
37
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractSubscriptionDirective, decorators: [{
|
|
38
|
+
type: Directive
|
|
39
|
+
}], ctorParameters: function () { return [{ type: i1.Subscription }]; } });
|
|
40
|
+
/**
|
|
41
|
+
* AbstractSubscriptionDirective extension that prevents the OnDestroy from occuring until the lockset is unlocked.
|
|
42
|
+
*/
|
|
43
|
+
class AbstractLockSetSubscriptionDirective extends AbstractSubscriptionDirective {
|
|
44
|
+
constructor() {
|
|
45
|
+
super(...arguments);
|
|
46
|
+
this.lockSet = new LockSet();
|
|
47
|
+
}
|
|
48
|
+
ngOnDestroy() {
|
|
49
|
+
this.lockSet.onNextUnlock(() => this.onLockSetDestroy());
|
|
50
|
+
}
|
|
51
|
+
onLockSetDestroy() {
|
|
52
|
+
super.ngOnDestroy();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
AbstractLockSetSubscriptionDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractLockSetSubscriptionDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
56
|
+
AbstractLockSetSubscriptionDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: AbstractLockSetSubscriptionDirective, usesInheritance: true, ngImport: i0 });
|
|
57
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractLockSetSubscriptionDirective, decorators: [{
|
|
58
|
+
type: Directive
|
|
59
|
+
}] });
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Source that provides a ActionContextStore observable.
|
|
63
|
+
*/
|
|
64
|
+
class ActionContextStoreSource {
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Secondary source. Used by DbNgxActionContextComponent to find secondary sources.
|
|
68
|
+
*/
|
|
69
|
+
class SecondaryActionContextStoreSource extends ActionContextStoreSource {
|
|
70
|
+
}
|
|
71
|
+
function actionContextStoreSourcePipe(obs) {
|
|
72
|
+
return obs.pipe(filterMaybe());
|
|
73
|
+
}
|
|
74
|
+
function pipeActionStore(source, pipeFn) {
|
|
75
|
+
return source.store$.pipe(switchMap(pipeFn));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Convenience function for subscribing to the input source once and using the provided store.
|
|
79
|
+
*/
|
|
80
|
+
function useActionStore(source, useFn) {
|
|
81
|
+
return source.store$.pipe(first()).subscribe(useFn);
|
|
82
|
+
}
|
|
83
|
+
// tslint:disable-next-line: directive-class-suffix
|
|
84
|
+
class ActionContextStoreSourceInstance {
|
|
85
|
+
constructor(source) {
|
|
86
|
+
this.source = source;
|
|
87
|
+
this.lockSet = new LockSet();
|
|
88
|
+
if (!source) {
|
|
89
|
+
throw new Error('Source is required.');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
ngOnDestroy() {
|
|
93
|
+
this.lockSet.destroyOnNextUnlock();
|
|
94
|
+
}
|
|
95
|
+
// MARK: Store
|
|
96
|
+
get store$() {
|
|
97
|
+
return this.source.store$;
|
|
98
|
+
}
|
|
99
|
+
pipeStore(pipeFn) {
|
|
100
|
+
return pipeActionStore(this.source, pipeFn);
|
|
101
|
+
}
|
|
102
|
+
useStore(useFn) {
|
|
103
|
+
return useActionStore(this.source, useFn);
|
|
104
|
+
}
|
|
105
|
+
get state$() {
|
|
106
|
+
return this.pipeStore(x => x.state$);
|
|
107
|
+
}
|
|
108
|
+
get triggered$() {
|
|
109
|
+
return this.pipeStore(x => x.triggered$);
|
|
110
|
+
}
|
|
111
|
+
get valueReady$() {
|
|
112
|
+
return this.pipeStore(x => x.valueReady$);
|
|
113
|
+
}
|
|
114
|
+
get success$() {
|
|
115
|
+
return this.pipeStore(x => x.success$);
|
|
116
|
+
}
|
|
117
|
+
get error$() {
|
|
118
|
+
return this.pipeStore(x => x.error$);
|
|
119
|
+
}
|
|
120
|
+
get rejected$() {
|
|
121
|
+
return this.pipeStore(x => x.rejected$);
|
|
122
|
+
}
|
|
123
|
+
get isModified$() {
|
|
124
|
+
return this.pipeStore(x => x.isModified$);
|
|
125
|
+
}
|
|
126
|
+
get isModifiedAndCanTriggerUpdates$() {
|
|
127
|
+
return this.pipeStore(x => x.isModifiedAndCanTriggerUpdates$);
|
|
128
|
+
}
|
|
129
|
+
get isModifiedAndCanTrigger$() {
|
|
130
|
+
return this.pipeStore(x => x.isModifiedAndCanTrigger$);
|
|
131
|
+
}
|
|
132
|
+
get actionState$() {
|
|
133
|
+
return this.pipeStore(x => x.actionState$);
|
|
134
|
+
}
|
|
135
|
+
get isWorking$() {
|
|
136
|
+
return this.pipeStore(x => x.isWorking$);
|
|
137
|
+
}
|
|
138
|
+
get isSuccess$() {
|
|
139
|
+
return this.pipeStore(x => x.isSuccess$);
|
|
140
|
+
}
|
|
141
|
+
get isDisabled$() {
|
|
142
|
+
return this.pipeStore(x => x.isDisabled$);
|
|
143
|
+
}
|
|
144
|
+
get errorCountSinceLastSuccess$() {
|
|
145
|
+
return this.pipeStore(x => x.errorCountSinceLastSuccess$);
|
|
146
|
+
}
|
|
147
|
+
enable(key, enable = true) {
|
|
148
|
+
this.disable(key, !enable);
|
|
149
|
+
}
|
|
150
|
+
disable(key, disable = true) {
|
|
151
|
+
this.useStore((x) => (disable) ? x.disable(key) : x.enable(key));
|
|
152
|
+
}
|
|
153
|
+
setIsModified(isModified) {
|
|
154
|
+
this.useStore((x) => x.setIsModified(isModified));
|
|
155
|
+
}
|
|
156
|
+
trigger() {
|
|
157
|
+
this.useStore((x) => x.trigger());
|
|
158
|
+
}
|
|
159
|
+
readyValue(value) {
|
|
160
|
+
this.useStore((x) => x.readyValue(value));
|
|
161
|
+
}
|
|
162
|
+
startWorking() {
|
|
163
|
+
this.useStore((x) => x.startWorking());
|
|
164
|
+
}
|
|
165
|
+
reject(error) {
|
|
166
|
+
this.useStore((x) => x.reject(error));
|
|
167
|
+
}
|
|
168
|
+
success(value) {
|
|
169
|
+
this.useStore((x) => x.success(value));
|
|
170
|
+
}
|
|
171
|
+
reset() {
|
|
172
|
+
this.useStore((x) => x.reset());
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
ActionContextStoreSourceInstance.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: ActionContextStoreSourceInstance, deps: [{ token: ActionContextStoreSource }], target: i0.ɵɵFactoryTarget.Directive });
|
|
176
|
+
ActionContextStoreSourceInstance.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: ActionContextStoreSourceInstance, ngImport: i0 });
|
|
177
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: ActionContextStoreSourceInstance, decorators: [{
|
|
178
|
+
type: Directive
|
|
179
|
+
}], ctorParameters: function () { return [{ type: ActionContextStoreSource }]; } });
|
|
180
|
+
const actionContextStoreSourceInstanceFactory = (source) => {
|
|
181
|
+
return new ActionContextStoreSourceInstance(source);
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Provides an ActionContextStoreSource, as well as an ActionContextStoreSourceInstance.
|
|
185
|
+
*/
|
|
186
|
+
function ProvideActionStoreSource(sourceType) {
|
|
187
|
+
return [{
|
|
188
|
+
provide: ActionContextStoreSource,
|
|
189
|
+
useExisting: forwardRef(() => sourceType)
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
provide: ActionContextStoreSourceInstance,
|
|
193
|
+
useFactory: actionContextStoreSourceInstanceFactory,
|
|
194
|
+
deps: [ActionContextStoreSource]
|
|
195
|
+
}];
|
|
196
|
+
}
|
|
197
|
+
function ProvideSecondaryActionStoreSource(sourceType) {
|
|
198
|
+
return [{
|
|
199
|
+
provide: SecondaryActionContextStoreSource,
|
|
200
|
+
useExisting: forwardRef(() => sourceType)
|
|
201
|
+
},
|
|
202
|
+
...ProvideActionStoreSource(sourceType)
|
|
203
|
+
];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
class DbNgxActionAutoModifyDirective extends AbstractSubscriptionDirective {
|
|
207
|
+
constructor(source) {
|
|
208
|
+
super();
|
|
209
|
+
this.source = source;
|
|
210
|
+
this._autoModifyEnabled = new BehaviorSubject(true);
|
|
211
|
+
}
|
|
212
|
+
get autoModifyEnabled() {
|
|
213
|
+
return this._autoModifyEnabled.value;
|
|
214
|
+
}
|
|
215
|
+
set autoModifyEnabled(autoModifyEnabled) {
|
|
216
|
+
this._autoModifyEnabled.next(autoModifyEnabled !== 'false');
|
|
217
|
+
}
|
|
218
|
+
ngOnInit() {
|
|
219
|
+
const obs = combineLatest([
|
|
220
|
+
this._autoModifyEnabled.pipe(distinctUntilChanged()),
|
|
221
|
+
this.source.isModified$.pipe(filter(x => !x)) // Only when not modified send a value.
|
|
222
|
+
]);
|
|
223
|
+
this.sub = obs.subscribe(([autoModifyEnabled, isModified]) => {
|
|
224
|
+
if (autoModifyEnabled && !isModified) {
|
|
225
|
+
this.source.setIsModified(true);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
ngOnDestroy() {
|
|
230
|
+
this.source.lockSet.onNextUnlock(() => {
|
|
231
|
+
super.ngOnDestroy();
|
|
232
|
+
this._autoModifyEnabled.complete();
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
DbNgxActionAutoModifyDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionAutoModifyDirective, deps: [{ token: ActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
237
|
+
DbNgxActionAutoModifyDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxActionAutoModifyDirective, selector: "[dbxActionAutoModify]", inputs: { autoModifyEnabled: ["dbxActionAutoModify", "autoModifyEnabled"] }, usesInheritance: true, ngImport: i0 });
|
|
238
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionAutoModifyDirective, decorators: [{
|
|
239
|
+
type: Directive,
|
|
240
|
+
args: [{
|
|
241
|
+
selector: '[dbxActionAutoModify]',
|
|
242
|
+
}]
|
|
243
|
+
}], ctorParameters: function () { return [{ type: ActionContextStoreSourceInstance, decorators: [{
|
|
244
|
+
type: Host
|
|
245
|
+
}] }]; }, propDecorators: { autoModifyEnabled: [{
|
|
246
|
+
type: Input,
|
|
247
|
+
args: ['dbxActionAutoModify']
|
|
248
|
+
}] } });
|
|
249
|
+
|
|
250
|
+
const DEFAULT_DEBOUNCE_MS = 2 * 1000;
|
|
251
|
+
const DEFAULT_THROTTLE_MS = 10 * 1000;
|
|
252
|
+
const DEFAULT_ERROR_THROTTLE_MS = 3 * 1000;
|
|
253
|
+
const MAX_ERRORS_TO_THROTTLE_ON = 6;
|
|
254
|
+
/**
|
|
255
|
+
* Extension of DbNgxActionTransitionSafetyDirective that automatically triggers the action periodically when it is in a modified state.
|
|
256
|
+
*/
|
|
257
|
+
class DbNgxActionAutoTriggerDirective extends AbstractSubscriptionDirective {
|
|
258
|
+
constructor(source) {
|
|
259
|
+
super();
|
|
260
|
+
this.source = source;
|
|
261
|
+
this._triggerEnabled = new BehaviorSubject(true);
|
|
262
|
+
this.triggerDebounce = DEFAULT_DEBOUNCE_MS;
|
|
263
|
+
this.triggerThrottle = DEFAULT_THROTTLE_MS;
|
|
264
|
+
this.triggerErrorThrottle = DEFAULT_ERROR_THROTTLE_MS;
|
|
265
|
+
this.maxErrorsForThrottle = MAX_ERRORS_TO_THROTTLE_ON;
|
|
266
|
+
this._triggerLimit = new BehaviorSubject(undefined);
|
|
267
|
+
this._trigger = new Subject();
|
|
268
|
+
this._triggerCount = 0;
|
|
269
|
+
this._errorCount$ = this.source.errorCountSinceLastSuccess$;
|
|
270
|
+
this._triggerCount$ = this.source.isModifiedAndCanTriggerUpdates$.pipe(filter(() => this.isEnabled), filter((x) => x), debounce(() => interval(this.triggerDebounce)), throttle(() => this._errorCount$.pipe(first(), exhaustMap((count) => interval(this.triggerThrottle + (Math.min(count, this.maxErrorsForThrottle) * this.triggerErrorThrottle)))), { leading: true, trailing: true }),
|
|
271
|
+
// Check again for the "trailing" piece.
|
|
272
|
+
filter(() => this.isEnabled), mergeMap(() => this.source.isModifiedAndCanTrigger$.pipe(first())), filter((x) => x), map(() => this._triggerCount += 1), shareReplay(1));
|
|
273
|
+
/**
|
|
274
|
+
* Observable for the trigger mechanism.
|
|
275
|
+
*/
|
|
276
|
+
this.triggerCount$ = this._triggerEnabled.pipe(switchMap((enabled) => {
|
|
277
|
+
if (enabled) {
|
|
278
|
+
return this._triggerCount$;
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
return EMPTY;
|
|
282
|
+
}
|
|
283
|
+
}));
|
|
284
|
+
this._isTriggerLimited$ = combineLatest([this.triggerCount$, this._triggerLimit]).pipe(map(([triggerCount, limit]) => [triggerCount, ((limit) ? (triggerCount > limit) : false)]), shareReplay(1));
|
|
285
|
+
this.isTriggerLimited$ = this._isTriggerLimited$.pipe(map(x => x[1]));
|
|
286
|
+
this.trigger$ = this._isTriggerLimited$.pipe(filter(x => !x[1]), distinctUntilChanged((a, b) => a[0] === b[0]), // Only trigger when the count changes.
|
|
287
|
+
map(() => undefined));
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* How much to throttle the auto-triggering.
|
|
291
|
+
*/
|
|
292
|
+
get triggerEnabled() {
|
|
293
|
+
return this._triggerEnabled.value;
|
|
294
|
+
}
|
|
295
|
+
set triggerEnabled(triggerEnabled) {
|
|
296
|
+
triggerEnabled = triggerEnabled !== false; // Default to true
|
|
297
|
+
if (this.triggerEnabled !== triggerEnabled) {
|
|
298
|
+
this._triggerEnabled.next(triggerEnabled);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Optional input to override both triggerDebounce and triggerThrottle.
|
|
303
|
+
*
|
|
304
|
+
* Used in forms that are simple.
|
|
305
|
+
*/
|
|
306
|
+
set fastTrigger(fastTrigger) {
|
|
307
|
+
if (fastTrigger) {
|
|
308
|
+
this.triggerDebounce = 200;
|
|
309
|
+
this.triggerThrottle = 500;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Optional input to override both triggerDebounce and triggerThrottle to be 0.
|
|
314
|
+
*
|
|
315
|
+
* Used in forms that generally return a single value.
|
|
316
|
+
*/
|
|
317
|
+
set instantTrigger(instantTrigger) {
|
|
318
|
+
if (instantTrigger) {
|
|
319
|
+
this.triggerDebounce = 10;
|
|
320
|
+
this.triggerThrottle = 0;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
get triggerLimit() {
|
|
324
|
+
return this._triggerLimit.value;
|
|
325
|
+
}
|
|
326
|
+
set triggerLimit(triggerLimit) {
|
|
327
|
+
triggerLimit = triggerLimit || 0;
|
|
328
|
+
this._triggerLimit.next(triggerLimit);
|
|
329
|
+
}
|
|
330
|
+
get isEnabled() {
|
|
331
|
+
return this.triggerEnabled !== false;
|
|
332
|
+
}
|
|
333
|
+
ngOnInit() {
|
|
334
|
+
this.sub = this.trigger$.subscribe(() => {
|
|
335
|
+
this.source.trigger();
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
ngOnDestroy() {
|
|
339
|
+
this.source.lockSet.onNextUnlock(() => {
|
|
340
|
+
super.ngOnDestroy();
|
|
341
|
+
this._trigger.complete();
|
|
342
|
+
this._triggerLimit.complete();
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
DbNgxActionAutoTriggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionAutoTriggerDirective, deps: [{ token: ActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
347
|
+
DbNgxActionAutoTriggerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxActionAutoTriggerDirective, selector: "[dbxActionAutoTrigger]", inputs: { triggerEnabled: ["dbxActionAutoTrigger", "triggerEnabled"], triggerDebounce: "triggerDebounce", triggerThrottle: "triggerThrottle", triggerErrorThrottle: "triggerErrorThrottle", fastTrigger: "fastTrigger", instantTrigger: "instantTrigger", triggerLimit: "triggerLimit" }, usesInheritance: true, ngImport: i0 });
|
|
348
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionAutoTriggerDirective, decorators: [{
|
|
349
|
+
type: Directive,
|
|
350
|
+
args: [{
|
|
351
|
+
selector: '[dbxActionAutoTrigger]',
|
|
352
|
+
}]
|
|
353
|
+
}], ctorParameters: function () { return [{ type: ActionContextStoreSourceInstance, decorators: [{
|
|
354
|
+
type: Host
|
|
355
|
+
}] }]; }, propDecorators: { triggerEnabled: [{
|
|
356
|
+
type: Input,
|
|
357
|
+
args: ['dbxActionAutoTrigger']
|
|
358
|
+
}], triggerDebounce: [{
|
|
359
|
+
type: Input
|
|
360
|
+
}], triggerThrottle: [{
|
|
361
|
+
type: Input
|
|
362
|
+
}], triggerErrorThrottle: [{
|
|
363
|
+
type: Input
|
|
364
|
+
}], fastTrigger: [{
|
|
365
|
+
type: Input
|
|
366
|
+
}], instantTrigger: [{
|
|
367
|
+
type: Input
|
|
368
|
+
}], triggerLimit: [{
|
|
369
|
+
type: Input
|
|
370
|
+
}] } });
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Directive that watches an observable for changes and sets the new value and modified states as necessary.
|
|
374
|
+
*/
|
|
375
|
+
class DbNgxActionAutoTriggerValueDirective {
|
|
376
|
+
constructor(source) {
|
|
377
|
+
this.source = source;
|
|
378
|
+
this._valueObs = new BehaviorSubject(EMPTY);
|
|
379
|
+
this._isModifiedFn = new BehaviorSubject(undefined);
|
|
380
|
+
this._modifiedSub = new SubscriptionObject();
|
|
381
|
+
this._triggerSub = new SubscriptionObject();
|
|
382
|
+
this.modifiedValue$ = this._valueObs.pipe(switchMap((obs) => obs.pipe(withLatestFrom(this._isModifiedFn), mergeMap(([value, dbxActionAutoTriggerModified]) => {
|
|
383
|
+
let result;
|
|
384
|
+
if (dbxActionAutoTriggerModified) {
|
|
385
|
+
result = dbxActionAutoTriggerModified(value).pipe(map((isModified) => [isModified, value]));
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
result = of([true, value]);
|
|
389
|
+
}
|
|
390
|
+
return result;
|
|
391
|
+
}), shareReplay(1))));
|
|
392
|
+
}
|
|
393
|
+
set dbxActionAutoTriggerValue(dbxActionAutoTriggerValue) {
|
|
394
|
+
this._valueObs.next(dbxActionAutoTriggerValue);
|
|
395
|
+
}
|
|
396
|
+
set dbxActionAutoTriggerModifiedNonEmptyValue(requireNonEmpty) {
|
|
397
|
+
if (requireNonEmpty) {
|
|
398
|
+
this.dbxActionAutoTriggerModified = (value) => {
|
|
399
|
+
return of(hasValueOrNotEmpty(value));
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
set dbxActionAutoTriggerModified(dbxActionAutoTriggerModified) {
|
|
404
|
+
this._isModifiedFn.next(dbxActionAutoTriggerModified);
|
|
405
|
+
}
|
|
406
|
+
ngOnInit() {
|
|
407
|
+
// Update Modified value.
|
|
408
|
+
this._modifiedSub.subscription = this.modifiedValue$.subscribe(([isModified, value]) => {
|
|
409
|
+
this.source.setIsModified(isModified);
|
|
410
|
+
});
|
|
411
|
+
// Set the value on triggers.
|
|
412
|
+
this._triggerSub.subscription = this.source.triggered$.pipe(mergeMap(x => this.modifiedValue$)).subscribe(([isModified, value]) => {
|
|
413
|
+
this.source.readyValue(value);
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
ngOnDestroy() {
|
|
417
|
+
this.source.lockSet.onNextUnlock(() => {
|
|
418
|
+
this._isModifiedFn.complete();
|
|
419
|
+
this._valueObs.complete();
|
|
420
|
+
this._modifiedSub.destroy();
|
|
421
|
+
this._triggerSub.destroy();
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
DbNgxActionAutoTriggerValueDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionAutoTriggerValueDirective, deps: [{ token: ActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
426
|
+
DbNgxActionAutoTriggerValueDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxActionAutoTriggerValueDirective, selector: "[dbxActionAutoTriggerValue]", inputs: { dbxActionAutoTriggerValue: "dbxActionAutoTriggerValue", dbxActionAutoTriggerModifiedNonEmptyValue: "dbxActionAutoTriggerModifiedNonEmptyValue", dbxActionAutoTriggerModified: "dbxActionAutoTriggerModified" }, ngImport: i0 });
|
|
427
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionAutoTriggerValueDirective, decorators: [{
|
|
428
|
+
type: Directive,
|
|
429
|
+
args: [{
|
|
430
|
+
selector: '[dbxActionAutoTriggerValue]',
|
|
431
|
+
}]
|
|
432
|
+
}], ctorParameters: function () { return [{ type: ActionContextStoreSourceInstance, decorators: [{
|
|
433
|
+
type: Host
|
|
434
|
+
}] }]; }, propDecorators: { dbxActionAutoTriggerValue: [{
|
|
435
|
+
type: Input,
|
|
436
|
+
args: ['dbxActionAutoTriggerValue']
|
|
437
|
+
}], dbxActionAutoTriggerModifiedNonEmptyValue: [{
|
|
438
|
+
type: Input
|
|
439
|
+
}], dbxActionAutoTriggerModified: [{
|
|
440
|
+
type: Input
|
|
441
|
+
}] } });
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Used by ActionContextState to denote what state the action is in.
|
|
445
|
+
*/
|
|
446
|
+
var ActionState;
|
|
447
|
+
(function (ActionState) {
|
|
448
|
+
/**
|
|
449
|
+
* No action in progress. Waiting for the trigger.
|
|
450
|
+
*/
|
|
451
|
+
ActionState["Idle"] = "idle";
|
|
452
|
+
/**
|
|
453
|
+
* Idle state that can be set to show that the source is not yet ready.
|
|
454
|
+
*/
|
|
455
|
+
ActionState["Disabled"] = "disabled";
|
|
456
|
+
/**
|
|
457
|
+
* The action was triggered. We wait (and allow) the value to be updated.
|
|
458
|
+
*/
|
|
459
|
+
ActionState["Triggered"] = "triggered";
|
|
460
|
+
/**
|
|
461
|
+
* The trigger was accepted and the value is updated. It should begin working immediately.
|
|
462
|
+
*
|
|
463
|
+
* ValueReady cannot be set until triggered is set.
|
|
464
|
+
*/
|
|
465
|
+
ActionState["ValueReady"] = "valueReady";
|
|
466
|
+
/**
|
|
467
|
+
* The action is in progress.
|
|
468
|
+
*/
|
|
469
|
+
ActionState["Working"] = "working";
|
|
470
|
+
/**
|
|
471
|
+
* The trigger, action, or value was rejected due to an error or other issue.
|
|
472
|
+
*
|
|
473
|
+
* An error may be specified optionally.
|
|
474
|
+
*/
|
|
475
|
+
ActionState["Rejected"] = "rejected";
|
|
476
|
+
/**
|
|
477
|
+
* The action was successful.
|
|
478
|
+
*/
|
|
479
|
+
ActionState["Success"] = "success";
|
|
480
|
+
})(ActionState || (ActionState = {}));
|
|
481
|
+
const DEFAULT_ACTION_DISABLED_KEY = 'default';
|
|
482
|
+
function isIdleActionState(actionState) {
|
|
483
|
+
switch (actionState) {
|
|
484
|
+
case ActionState.Idle:
|
|
485
|
+
case ActionState.Disabled:
|
|
486
|
+
case ActionState.Rejected:
|
|
487
|
+
case ActionState.Success:
|
|
488
|
+
return true;
|
|
489
|
+
default:
|
|
490
|
+
return false;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
function isActionContextEnabled(state) {
|
|
495
|
+
return BooleanStringKeyArrayUtilityInstance.isFalse(state.disabled);
|
|
496
|
+
}
|
|
497
|
+
function isActionContextDisabled(state) {
|
|
498
|
+
return BooleanStringKeyArrayUtilityInstance.isTrue(state.disabled);
|
|
499
|
+
}
|
|
500
|
+
function isDisabledActionContextState(state) {
|
|
501
|
+
return isIdleActionState(state.actionState) && isActionContextDisabled(state);
|
|
502
|
+
}
|
|
503
|
+
function isWorkingActionState(actionState) {
|
|
504
|
+
return !isIdleActionState(actionState);
|
|
505
|
+
}
|
|
506
|
+
function canTriggerActionState(actionState) {
|
|
507
|
+
return actionState !== ActionState.Disabled && isIdleActionState(actionState);
|
|
508
|
+
}
|
|
509
|
+
function canTriggerAction(state) {
|
|
510
|
+
return isActionContextEnabled(state) && isIdleActionState(state.actionState);
|
|
511
|
+
}
|
|
512
|
+
function canReadyValue(state) {
|
|
513
|
+
return state.actionState === ActionState.Triggered;
|
|
514
|
+
}
|
|
515
|
+
function actionContextIsModifiedAndCanTrigger(state) {
|
|
516
|
+
// console.log('check: ', state, state.isModified, canTriggerAction(state));
|
|
517
|
+
return state.isModified && canTriggerAction(state);
|
|
518
|
+
}
|
|
519
|
+
function actionContextHasNoErrorAndIsModifiedAndCanTrigger(state) {
|
|
520
|
+
return !state.error && actionContextIsModifiedAndCanTrigger(state);
|
|
521
|
+
}
|
|
522
|
+
const INITIAL_STATE = {
|
|
523
|
+
isModified: false,
|
|
524
|
+
actionState: ActionState.Idle
|
|
525
|
+
};
|
|
526
|
+
class ActionContextStore extends ComponentStore {
|
|
527
|
+
constructor() {
|
|
528
|
+
super({ ...INITIAL_STATE });
|
|
529
|
+
this.lockSet = new LockSet();
|
|
530
|
+
// MARK: Accessors
|
|
531
|
+
this.actionState$ = this.state$.pipe(map(x => isDisabledActionContextState(x) ? ActionState.Disabled : x.actionState), shareReplay(1));
|
|
532
|
+
/**
|
|
533
|
+
* Returns the current disabled reasons.
|
|
534
|
+
*/
|
|
535
|
+
this.disabled$ = this.state$.pipe(map(x => [...x.disabled ?? []]), distinctUntilChanged(), shareReplay(1));
|
|
536
|
+
/**
|
|
537
|
+
* Maps the current state to true or not when the action state changes to/from disabled.
|
|
538
|
+
*/
|
|
539
|
+
this.isDisabled$ = this.state$.pipe(map(isDisabledActionContextState), distinctUntilChanged(), shareReplay(1));
|
|
540
|
+
/**
|
|
541
|
+
* Pipes when idle but modified.
|
|
542
|
+
*/
|
|
543
|
+
this.isModified$ = this.afterDistinctBoolean(x => x.isModified);
|
|
544
|
+
/**
|
|
545
|
+
* Pipes true when triggered.
|
|
546
|
+
*/
|
|
547
|
+
this.triggered$ = this.afterDistinctActionState(ActionState.Triggered, () => true);
|
|
548
|
+
/**
|
|
549
|
+
* Pipes the readied value on ValueReady.
|
|
550
|
+
*/
|
|
551
|
+
this.valueReady$ = this.afterDistinctActionState(ActionState.ValueReady, x => x.value);
|
|
552
|
+
/**
|
|
553
|
+
* Pipes the error on the rejection state.
|
|
554
|
+
*/
|
|
555
|
+
this.rejected$ = this.afterDistinctActionState(ActionState.Rejected, x => x.error);
|
|
556
|
+
/**
|
|
557
|
+
* Pipes the result when the ActionState becomes working.
|
|
558
|
+
*/
|
|
559
|
+
this.working$ = this.afterDistinctActionState(ActionState.Working, () => true);
|
|
560
|
+
/**
|
|
561
|
+
* Whether or not it is currently in a working state.
|
|
562
|
+
*/
|
|
563
|
+
this.isWorking$ = this.afterDistinctBoolean(x => isWorkingActionState(x.actionState));
|
|
564
|
+
/**
|
|
565
|
+
* Pipes the current error.
|
|
566
|
+
*/
|
|
567
|
+
this.error$ = this.state$.pipe(map(x => x.error), distinctUntilChanged(), shareReplay(1));
|
|
568
|
+
/**
|
|
569
|
+
* Pipes the result when the ActionState becomes success.
|
|
570
|
+
*/
|
|
571
|
+
this.success$ = this.afterDistinctActionState(ActionState.Success, x => x.result);
|
|
572
|
+
/**
|
|
573
|
+
* Whether or not it is currently in a success state.
|
|
574
|
+
*/
|
|
575
|
+
this.isSuccess$ = this.afterDistinctBoolean(x => x.actionState === ActionState.Success);
|
|
576
|
+
/**
|
|
577
|
+
* Number of errors since last success.
|
|
578
|
+
*/
|
|
579
|
+
this.errorCountSinceLastSuccess$ = this.isSuccess$.pipe(startWith(false), distinctUntilChanged(), switchMap(() => this.error$.pipe(filterMaybe(), scanCount(), startWith(0))), shareReplay(1));
|
|
580
|
+
/**
|
|
581
|
+
* Whether or not the state can be triggered.
|
|
582
|
+
*/
|
|
583
|
+
this.canTrigger$ = this.state$.pipe(map(canTriggerAction), distinctUntilChanged(), shareReplay(1));
|
|
584
|
+
/**
|
|
585
|
+
* Pipe that maps whether or not this is modified and can be triggered.
|
|
586
|
+
*
|
|
587
|
+
* Updates every state update instead of when the value changes.
|
|
588
|
+
*/
|
|
589
|
+
this.isModifiedAndCanTriggerUpdates$ = this.state$.pipe(map((x) => actionContextIsModifiedAndCanTrigger(x), shareReplay(1)));
|
|
590
|
+
/**
|
|
591
|
+
* Whether or not it can be triggered and modified.
|
|
592
|
+
*/
|
|
593
|
+
this.isModifiedAndCanTrigger$ = this.isModifiedAndCanTriggerUpdates$.pipe(distinctUntilChanged());
|
|
594
|
+
this.hasNoErrorAndIsModifiedAndCanTrigger$ = this.state$.pipe(map((x) => actionContextHasNoErrorAndIsModifiedAndCanTrigger(x)), distinctUntilChanged(), shareReplay(1));
|
|
595
|
+
// MARK: State Changes
|
|
596
|
+
/**
|
|
597
|
+
* Adds a disabled reason.
|
|
598
|
+
*/
|
|
599
|
+
this.disable = this.updater((state, key) => ({
|
|
600
|
+
...state,
|
|
601
|
+
disabled: BooleanStringKeyArrayUtilityInstance.insert(state.disabled, (key ?? DEFAULT_ACTION_DISABLED_KEY))
|
|
602
|
+
}));
|
|
603
|
+
/**
|
|
604
|
+
* Removes a disabled reason.
|
|
605
|
+
*/
|
|
606
|
+
this.enable = this.updater((state, key) => ({
|
|
607
|
+
...state,
|
|
608
|
+
disabled: BooleanStringKeyArrayUtilityInstance.remove(state.disabled, (key ?? DEFAULT_ACTION_DISABLED_KEY))
|
|
609
|
+
}));
|
|
610
|
+
/**
|
|
611
|
+
* Triggers the modified state, if not disabled.
|
|
612
|
+
*/
|
|
613
|
+
this.setIsModified = this.updater((state, isModified) => ({
|
|
614
|
+
...state,
|
|
615
|
+
actionState: (state.actionState === ActionState.Success) ? ActionState.Idle : state.actionState,
|
|
616
|
+
isModified: isModified ?? true
|
|
617
|
+
}));
|
|
618
|
+
/**
|
|
619
|
+
* Triggers the action if the state is currently not idle. The current state is cleared, but the error is retained (as we may need the error from the previous attempt).
|
|
620
|
+
*
|
|
621
|
+
* Will not fire if the action is disabled.
|
|
622
|
+
*/
|
|
623
|
+
this.trigger = this.updater((state) => canTriggerAction(state)
|
|
624
|
+
? ({ isModified: state.isModified, actionState: ActionState.Triggered, error: state.error, value: undefined })
|
|
625
|
+
: state);
|
|
626
|
+
/**
|
|
627
|
+
* Updates the value, setting value ready. The current result is cleared.
|
|
628
|
+
*/
|
|
629
|
+
this.readyValue = this.updater((state, value) => canReadyValue(state)
|
|
630
|
+
? ({ ...state, actionState: ActionState.ValueReady, value, result: undefined })
|
|
631
|
+
: state);
|
|
632
|
+
/**
|
|
633
|
+
* Notifys the context that the action is in progress.
|
|
634
|
+
*/
|
|
635
|
+
this.startWorking = this.updater((state) => ({ ...state, actionState: ActionState.Working }));
|
|
636
|
+
/**
|
|
637
|
+
* Triggers rejection of the action. The value is cleared.
|
|
638
|
+
*/
|
|
639
|
+
this.reject = this.updater((state, error) => ({ isModified: state.isModified, actionState: ActionState.Rejected, error, errorCount: (state.errorCount ?? 0) + 1 }));
|
|
640
|
+
/**
|
|
641
|
+
* Updates the state to success, and optionally sets a result.
|
|
642
|
+
*
|
|
643
|
+
* Clears modified state, and any errors.
|
|
644
|
+
*/
|
|
645
|
+
this.success = this.updater((state, result) => ({ isModified: false, actionState: ActionState.Success, value: state.value, result, error: undefined }));
|
|
646
|
+
/**
|
|
647
|
+
* Completely resets the store.
|
|
648
|
+
*/
|
|
649
|
+
this.reset = this.updater((state) => ({ ...INITIAL_STATE }));
|
|
650
|
+
this.lockSet.addLock('working', this.isWorking$);
|
|
651
|
+
}
|
|
652
|
+
// MARK: Utility
|
|
653
|
+
afterDistinctBoolean(fromState) {
|
|
654
|
+
return this.state$.pipe(map(x => fromState(x)), distinctUntilChanged(), shareReplay(1));
|
|
655
|
+
}
|
|
656
|
+
afterDistinctActionState(actionState, fromState) {
|
|
657
|
+
return this.state$.pipe(map((x) => ([x, x.actionState])), distinctUntilChanged((a, b) => a?.[1] === b?.[1]), // Filter out when the state remains the same.
|
|
658
|
+
filter(([x, y]) => y === actionState), // Only pipe when the action state matches.
|
|
659
|
+
map(x => fromState(x[0])), shareReplay(1));
|
|
660
|
+
}
|
|
661
|
+
// MARK: Cleanup
|
|
662
|
+
ngOnDestroy() {
|
|
663
|
+
// Wait for any actions to complete before destroying.
|
|
664
|
+
this.lockSet.onNextUnlock(() => {
|
|
665
|
+
super.ngOnDestroy();
|
|
666
|
+
}, 2000);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
ActionContextStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: ActionContextStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
670
|
+
ActionContextStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: ActionContextStore });
|
|
671
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: ActionContextStore, decorators: [{
|
|
672
|
+
type: Injectable
|
|
673
|
+
}], ctorParameters: function () { return []; } });
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* Abstract class that can either use SecondaryActionContextStoreSource or create it's own.
|
|
677
|
+
*/
|
|
678
|
+
class ActionContextBaseSource {
|
|
679
|
+
constructor(inputSource) {
|
|
680
|
+
this.inputSource = inputSource;
|
|
681
|
+
if (this.inputSource) {
|
|
682
|
+
this._store$ = this.inputSource.store$;
|
|
683
|
+
}
|
|
684
|
+
else {
|
|
685
|
+
this._store = new ActionContextStore();
|
|
686
|
+
this._store$ = of(this._store);
|
|
687
|
+
}
|
|
688
|
+
this._instance = new ActionContextStoreSourceInstance(this);
|
|
689
|
+
this.isModified$ = this._instance.isModified$;
|
|
690
|
+
this.triggered$ = this._instance.triggered$;
|
|
691
|
+
this.success$ = this._instance.success$;
|
|
692
|
+
}
|
|
693
|
+
destroy() {
|
|
694
|
+
if (this._store) {
|
|
695
|
+
this._store.ngOnDestroy();
|
|
696
|
+
this._instance.ngOnDestroy();
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
get lockSet() {
|
|
700
|
+
return this._instance.lockSet;
|
|
701
|
+
}
|
|
702
|
+
get sourceInstance() {
|
|
703
|
+
return this._instance;
|
|
704
|
+
}
|
|
705
|
+
get store$() {
|
|
706
|
+
return this._store$;
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* Use to trigger the action directly.
|
|
710
|
+
*/
|
|
711
|
+
trigger() {
|
|
712
|
+
this._instance.trigger();
|
|
713
|
+
}
|
|
714
|
+
readyValue(value) {
|
|
715
|
+
this._instance.readyValue(value);
|
|
716
|
+
}
|
|
717
|
+
reset() {
|
|
718
|
+
this._instance.reset();
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Provides an DbNgxActionContext.
|
|
724
|
+
*/
|
|
725
|
+
class DbNgxActionContextDirective extends ActionContextBaseSource {
|
|
726
|
+
constructor(inputSource) {
|
|
727
|
+
super(inputSource);
|
|
728
|
+
}
|
|
729
|
+
ngOnDestroy() {
|
|
730
|
+
this.lockSet.destroyOnNextUnlock(() => {
|
|
731
|
+
this.destroy();
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
DbNgxActionContextDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionContextDirective, deps: [{ token: SecondaryActionContextStoreSource, host: true, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
736
|
+
DbNgxActionContextDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxActionContextDirective, selector: "[dbxActionContext]", providers: ProvideActionStoreSource(DbNgxActionContextDirective), exportAs: ["action"], usesInheritance: true, ngImport: i0 });
|
|
737
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionContextDirective, decorators: [{
|
|
738
|
+
type: Directive,
|
|
739
|
+
args: [{
|
|
740
|
+
selector: '[dbxActionContext]',
|
|
741
|
+
exportAs: 'action',
|
|
742
|
+
providers: ProvideActionStoreSource(DbNgxActionContextDirective)
|
|
743
|
+
}]
|
|
744
|
+
}], ctorParameters: function () { return [{ type: SecondaryActionContextStoreSource, decorators: [{
|
|
745
|
+
type: Optional
|
|
746
|
+
}, {
|
|
747
|
+
type: Host
|
|
748
|
+
}] }]; } });
|
|
749
|
+
|
|
750
|
+
class DbNgxActionComponent extends DbNgxActionContextDirective {
|
|
751
|
+
}
|
|
752
|
+
DbNgxActionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
753
|
+
DbNgxActionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxActionComponent, selector: "dbx-action", providers: ProvideActionStoreSource(DbNgxActionComponent), exportAs: ["action"], usesInheritance: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true });
|
|
754
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionComponent, decorators: [{
|
|
755
|
+
type: Component,
|
|
756
|
+
args: [{
|
|
757
|
+
selector: 'dbx-action',
|
|
758
|
+
exportAs: 'action',
|
|
759
|
+
template: '<ng-content></ng-content>',
|
|
760
|
+
providers: ProvideActionStoreSource(DbNgxActionComponent)
|
|
761
|
+
}]
|
|
762
|
+
}] });
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* Directive that provides a DbNgxActionSourceDirective that is passed in.
|
|
766
|
+
*/
|
|
767
|
+
class DbNgxActionSourceDirective {
|
|
768
|
+
constructor() {
|
|
769
|
+
this._source = new BehaviorSubject(undefined);
|
|
770
|
+
this.store$ = this._source.pipe(filterMaybe(), switchMap((x) => actionContextStoreSourcePipe(x.store$)));
|
|
771
|
+
}
|
|
772
|
+
ngOnDestroy() {
|
|
773
|
+
this._source.complete();
|
|
774
|
+
}
|
|
775
|
+
get source() {
|
|
776
|
+
return this._source.value;
|
|
777
|
+
}
|
|
778
|
+
set source(source) {
|
|
779
|
+
if (source && !source.store$) {
|
|
780
|
+
throw new Error('Invalid source passed to dbxActionSource.');
|
|
781
|
+
}
|
|
782
|
+
this._source.next(source);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
DbNgxActionSourceDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionSourceDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
786
|
+
DbNgxActionSourceDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxActionSourceDirective, selector: "[dbxActionSource]", inputs: { source: ["dbxActionSource", "source"] }, providers: ProvideSecondaryActionStoreSource(DbNgxActionSourceDirective), ngImport: i0 });
|
|
787
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionSourceDirective, decorators: [{
|
|
788
|
+
type: Directive,
|
|
789
|
+
args: [{
|
|
790
|
+
selector: '[dbxActionSource]',
|
|
791
|
+
providers: ProvideSecondaryActionStoreSource(DbNgxActionSourceDirective)
|
|
792
|
+
}]
|
|
793
|
+
}], propDecorators: { source: [{
|
|
794
|
+
type: Input,
|
|
795
|
+
args: ['dbxActionSource']
|
|
796
|
+
}] } });
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* Prints out the current state to the console. Useful for debugging.
|
|
800
|
+
*/
|
|
801
|
+
class DbNgxActionContextLoggerDirective extends AbstractSubscriptionDirective {
|
|
802
|
+
constructor(source) {
|
|
803
|
+
super();
|
|
804
|
+
this.source = source;
|
|
805
|
+
}
|
|
806
|
+
ngOnInit() {
|
|
807
|
+
this.sub = this.source.state$.subscribe((state) => {
|
|
808
|
+
console.log('State: ', state);
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
DbNgxActionContextLoggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionContextLoggerDirective, deps: [{ token: ActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
813
|
+
DbNgxActionContextLoggerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxActionContextLoggerDirective, selector: "[dbxActionContextLogger]", usesInheritance: true, ngImport: i0 });
|
|
814
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionContextLoggerDirective, decorators: [{
|
|
815
|
+
type: Directive,
|
|
816
|
+
args: [{
|
|
817
|
+
selector: '[dbxActionContextLogger]'
|
|
818
|
+
}]
|
|
819
|
+
}], ctorParameters: function () { return [{ type: ActionContextStoreSourceInstance, decorators: [{
|
|
820
|
+
type: Host
|
|
821
|
+
}] }]; } });
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* Context used for providing actions based on the action key.
|
|
825
|
+
*
|
|
826
|
+
* This is useful for passing action contexts around via the providers instead of explicit injection.
|
|
827
|
+
*/
|
|
828
|
+
class DbNgxActionContextMapDirective {
|
|
829
|
+
constructor() {
|
|
830
|
+
this._map = new BehaviorSubject(new Map());
|
|
831
|
+
this.map$ = this._map.asObservable();
|
|
832
|
+
this.areAnyWorking$ = this.checkAnyAre(x => x.isWorking$, false);
|
|
833
|
+
}
|
|
834
|
+
get map() {
|
|
835
|
+
return this._map.value;
|
|
836
|
+
}
|
|
837
|
+
sourceForKey(key) {
|
|
838
|
+
return new DbNgxActionContextMapDirectiveSourceInstance(this, key);
|
|
839
|
+
}
|
|
840
|
+
addStoreSource(key, source) {
|
|
841
|
+
if (this.map.has(key)) {
|
|
842
|
+
throw new Error(`Key already existed for "${key}" in map. Ensure the previous store is removed before setting another.`);
|
|
843
|
+
}
|
|
844
|
+
else if (!source) {
|
|
845
|
+
throw new Error('addStoreSource requires a source.');
|
|
846
|
+
}
|
|
847
|
+
this.map.set(key, source);
|
|
848
|
+
this._map.next(this.map);
|
|
849
|
+
}
|
|
850
|
+
removeStore(key) {
|
|
851
|
+
if (!this.map.delete(key)) {
|
|
852
|
+
console.warn('removeStore called and no value was found.');
|
|
853
|
+
}
|
|
854
|
+
this._map.next(this.map);
|
|
855
|
+
}
|
|
856
|
+
ngOnDestroy() {
|
|
857
|
+
this._map.complete();
|
|
858
|
+
}
|
|
859
|
+
// MARK: Utility
|
|
860
|
+
checkAnyAre(mapFn, emptyArrayValue = false) {
|
|
861
|
+
return this.reduceFromAllSources(mapFn, reduceBooleansWithOrFn(emptyArrayValue));
|
|
862
|
+
}
|
|
863
|
+
reduceFromAllSources(mapFn, reduceFn) {
|
|
864
|
+
return this.fromAllSources(mapFn).pipe(map(reduceFn));
|
|
865
|
+
}
|
|
866
|
+
fromAllSources(mapFn) {
|
|
867
|
+
return this.map$.pipe(switchMap(combineLatestFromMapValuesObsFn((x) => x.store$.pipe(switchMap(mapFn)))));
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
DbNgxActionContextMapDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionContextMapDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
871
|
+
DbNgxActionContextMapDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxActionContextMapDirective, selector: "[dbxActionContextMap]", providers: [], exportAs: ["actionMap"], ngImport: i0 });
|
|
872
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionContextMapDirective, decorators: [{
|
|
873
|
+
type: Directive,
|
|
874
|
+
args: [{
|
|
875
|
+
selector: '[dbxActionContextMap]',
|
|
876
|
+
exportAs: 'actionMap',
|
|
877
|
+
providers: [],
|
|
878
|
+
}]
|
|
879
|
+
}], ctorParameters: function () { return []; } });
|
|
880
|
+
class DbNgxActionContextMapDirectiveSourceInstance {
|
|
881
|
+
constructor(parent, key) {
|
|
882
|
+
this.parent = parent;
|
|
883
|
+
this.key = key;
|
|
884
|
+
this._source$ = this.parent.map$.pipe(map(x => x.get(this.key)), distinctUntilChanged());
|
|
885
|
+
this._store$ = this._source$.pipe(switchMap((x) => x?.store$ ?? of(undefined)), shareReplay(1));
|
|
886
|
+
this.store$ = actionContextStoreSourcePipe(this._store$);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* Directive that provides a ActionContextStoreSource using the input key and DbNgxActionContextMapDirective.
|
|
892
|
+
*/
|
|
893
|
+
class DbNgxActionFromMapDirective {
|
|
894
|
+
constructor(_map) {
|
|
895
|
+
this._map = _map;
|
|
896
|
+
this._key = new BehaviorSubject(undefined);
|
|
897
|
+
this.store$ = this._key.pipe(filterMaybe(), switchMap((x) => this._map.sourceForKey(x).store$));
|
|
898
|
+
}
|
|
899
|
+
ngOnDestroy() {
|
|
900
|
+
this._key.complete();
|
|
901
|
+
}
|
|
902
|
+
get key() {
|
|
903
|
+
return this._key.value;
|
|
904
|
+
}
|
|
905
|
+
set key(key) {
|
|
906
|
+
this._key.next(key);
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
DbNgxActionFromMapDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionFromMapDirective, deps: [{ token: DbNgxActionContextMapDirective }], target: i0.ɵɵFactoryTarget.Directive });
|
|
910
|
+
DbNgxActionFromMapDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxActionFromMapDirective, selector: "[dbxActionFromMap]", inputs: { key: ["dbxActionFromMap", "key"] }, providers: ProvideSecondaryActionStoreSource(DbNgxActionFromMapDirective), ngImport: i0 });
|
|
911
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionFromMapDirective, decorators: [{
|
|
912
|
+
type: Directive,
|
|
913
|
+
args: [{
|
|
914
|
+
selector: '[dbxActionFromMap]',
|
|
915
|
+
providers: ProvideSecondaryActionStoreSource(DbNgxActionFromMapDirective)
|
|
916
|
+
}]
|
|
917
|
+
}], ctorParameters: function () { return [{ type: DbNgxActionContextMapDirective }]; }, propDecorators: { key: [{
|
|
918
|
+
type: Input,
|
|
919
|
+
args: ['dbxActionFromMap']
|
|
920
|
+
}] } });
|
|
921
|
+
|
|
922
|
+
/**
|
|
923
|
+
* Used to communicate with an dbxActionMap and set the ActionContextStore to the store based on the key.
|
|
924
|
+
*/
|
|
925
|
+
class DbNgxActionMapSourceDirective {
|
|
926
|
+
constructor(source, _map) {
|
|
927
|
+
this.source = source;
|
|
928
|
+
this._map = _map;
|
|
929
|
+
}
|
|
930
|
+
ngOnDestroy() {
|
|
931
|
+
this._removeFromToStore();
|
|
932
|
+
}
|
|
933
|
+
set key(key) {
|
|
934
|
+
if (this._key !== key) {
|
|
935
|
+
this._removeFromToStore();
|
|
936
|
+
}
|
|
937
|
+
this._key = key;
|
|
938
|
+
this._addToStore();
|
|
939
|
+
}
|
|
940
|
+
_addToStore() {
|
|
941
|
+
if (this._key) {
|
|
942
|
+
this._map.addStoreSource(this._key, this.source);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
_removeFromToStore() {
|
|
946
|
+
if (this._key) {
|
|
947
|
+
this._map.removeStore(this._key);
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
DbNgxActionMapSourceDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionMapSourceDirective, deps: [{ token: ActionContextStoreSource, host: true }, { token: DbNgxActionContextMapDirective }], target: i0.ɵɵFactoryTarget.Directive });
|
|
952
|
+
DbNgxActionMapSourceDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxActionMapSourceDirective, selector: "[dbxActionMapSource]", inputs: { key: ["dbxActionMapSource", "key"] }, ngImport: i0 });
|
|
953
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionMapSourceDirective, decorators: [{
|
|
954
|
+
type: Directive,
|
|
955
|
+
args: [{
|
|
956
|
+
selector: '[dbxActionMapSource]'
|
|
957
|
+
}]
|
|
958
|
+
}], ctorParameters: function () { return [{ type: ActionContextStoreSource, decorators: [{
|
|
959
|
+
type: Host
|
|
960
|
+
}] }, { type: DbNgxActionContextMapDirective }]; }, propDecorators: { key: [{
|
|
961
|
+
type: Input,
|
|
962
|
+
args: ['dbxActionMapSource']
|
|
963
|
+
}] } });
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* Map that returns sources for ActionKey values.
|
|
967
|
+
*/
|
|
968
|
+
class ActionContextStoreSourceMap {
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
const DEFAULT_ACTION_MAP_WORKING_DISABLED_KEY = '';
|
|
972
|
+
/**
|
|
973
|
+
* Used to communicate with an dbxActionMap and set the ActionContextStore to be disabled if any other element in the map is working.
|
|
974
|
+
*/
|
|
975
|
+
class DbNgxActionMapWorkingDisableDirective extends AbstractSubscriptionDirective {
|
|
976
|
+
constructor(source, _map) {
|
|
977
|
+
super();
|
|
978
|
+
this.source = source;
|
|
979
|
+
this._map = _map;
|
|
980
|
+
}
|
|
981
|
+
ngOnInit() {
|
|
982
|
+
this.sub = this._map.areAnyWorking$.subscribe((x) => {
|
|
983
|
+
this.source.disable(this.disabledKey || DEFAULT_ACTION_MAP_WORKING_DISABLED_KEY, x);
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
ngOnDestroy() {
|
|
987
|
+
super.ngOnDestroy();
|
|
988
|
+
this.source.enable(this.disabledKey || DEFAULT_ACTION_MAP_WORKING_DISABLED_KEY);
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
DbNgxActionMapWorkingDisableDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionMapWorkingDisableDirective, deps: [{ token: ActionContextStoreSourceInstance, host: true }, { token: DbNgxActionContextMapDirective }], target: i0.ɵɵFactoryTarget.Directive });
|
|
992
|
+
DbNgxActionMapWorkingDisableDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxActionMapWorkingDisableDirective, selector: "[dbxActionMapWorkingDisable]", inputs: { disabledKey: ["dbxActionMapWorkingDisable", "disabledKey"] }, usesInheritance: true, ngImport: i0 });
|
|
993
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionMapWorkingDisableDirective, decorators: [{
|
|
994
|
+
type: Directive,
|
|
995
|
+
args: [{
|
|
996
|
+
selector: '[dbxActionMapWorkingDisable]'
|
|
997
|
+
}]
|
|
998
|
+
}], ctorParameters: function () { return [{ type: ActionContextStoreSourceInstance, decorators: [{
|
|
999
|
+
type: Host
|
|
1000
|
+
}] }, { type: DbNgxActionContextMapDirective }]; }, propDecorators: { disabledKey: [{
|
|
1001
|
+
type: Input,
|
|
1002
|
+
args: ['dbxActionMapWorkingDisable']
|
|
1003
|
+
}] } });
|
|
1004
|
+
|
|
1005
|
+
const APP_ACTION_DISABLED_DIRECTIVE_KEY = 'dbx_action_disabled';
|
|
1006
|
+
/**
|
|
1007
|
+
* Directive that allows disabling an action using the inputs.
|
|
1008
|
+
*/
|
|
1009
|
+
class DbNgxActionDisabledDirective extends AbstractSubscriptionDirective {
|
|
1010
|
+
constructor(source) {
|
|
1011
|
+
super();
|
|
1012
|
+
this.source = source;
|
|
1013
|
+
this._disabled = new BehaviorSubject(false);
|
|
1014
|
+
this.disabled$ = this._disabled.pipe(distinctUntilChanged());
|
|
1015
|
+
}
|
|
1016
|
+
ngOnInit() {
|
|
1017
|
+
this.sub = this.disabled$.subscribe((x) => {
|
|
1018
|
+
this.source.disable(APP_ACTION_DISABLED_DIRECTIVE_KEY, x);
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
ngOnDestroy() {
|
|
1022
|
+
super.ngOnDestroy();
|
|
1023
|
+
this._disabled.complete();
|
|
1024
|
+
this.source.enable(APP_ACTION_DISABLED_DIRECTIVE_KEY);
|
|
1025
|
+
}
|
|
1026
|
+
get disabled() {
|
|
1027
|
+
return this._disabled.value;
|
|
1028
|
+
}
|
|
1029
|
+
set disabled(disabled) {
|
|
1030
|
+
this._disabled.next(disabled);
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
DbNgxActionDisabledDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionDisabledDirective, deps: [{ token: ActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1034
|
+
DbNgxActionDisabledDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxActionDisabledDirective, selector: "[dbxActionDisabled]", inputs: { disabled: ["dbxActionDisabled", "disabled"] }, usesInheritance: true, ngImport: i0 });
|
|
1035
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionDisabledDirective, decorators: [{
|
|
1036
|
+
type: Directive,
|
|
1037
|
+
args: [{
|
|
1038
|
+
selector: '[dbxActionDisabled]'
|
|
1039
|
+
}]
|
|
1040
|
+
}], ctorParameters: function () { return [{ type: ActionContextStoreSourceInstance, decorators: [{
|
|
1041
|
+
type: Host
|
|
1042
|
+
}] }]; }, propDecorators: { disabled: [{
|
|
1043
|
+
type: Input,
|
|
1044
|
+
args: ['dbxActionDisabled']
|
|
1045
|
+
}] } });
|
|
1046
|
+
|
|
1047
|
+
const APP_ACTION_DISABLED_UNTIL_MODIFIED_DIRECTIVE_KEY = 'dbx_action_is_not_modified';
|
|
1048
|
+
/**
|
|
1049
|
+
* Directive that sets the disabled state based on the current isModified state.
|
|
1050
|
+
*/
|
|
1051
|
+
class DbNgxActionDisabledUntilModifiedDirective extends AbstractSubscriptionDirective {
|
|
1052
|
+
constructor(source) {
|
|
1053
|
+
super();
|
|
1054
|
+
this.source = source;
|
|
1055
|
+
}
|
|
1056
|
+
ngOnInit() {
|
|
1057
|
+
this.sub = this.source.isModified$.subscribe((x) => {
|
|
1058
|
+
this.source.disable(APP_ACTION_DISABLED_UNTIL_MODIFIED_DIRECTIVE_KEY, !x);
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
ngOnDestroy() {
|
|
1062
|
+
super.ngOnDestroy();
|
|
1063
|
+
this.source.enable(APP_ACTION_DISABLED_UNTIL_MODIFIED_DIRECTIVE_KEY);
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
DbNgxActionDisabledUntilModifiedDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionDisabledUntilModifiedDirective, deps: [{ token: ActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1067
|
+
DbNgxActionDisabledUntilModifiedDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxActionDisabledUntilModifiedDirective, selector: "[dbxActionDisabledUntilModified]", usesInheritance: true, ngImport: i0 });
|
|
1068
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionDisabledUntilModifiedDirective, decorators: [{
|
|
1069
|
+
type: Directive,
|
|
1070
|
+
args: [{
|
|
1071
|
+
selector: '[dbxActionDisabledUntilModified]'
|
|
1072
|
+
}]
|
|
1073
|
+
}], ctorParameters: function () { return [{ type: ActionContextStoreSourceInstance, decorators: [{
|
|
1074
|
+
type: Host
|
|
1075
|
+
}] }]; } });
|
|
1076
|
+
|
|
1077
|
+
/**
|
|
1078
|
+
* WorkHandlerContextDelegate implementation using an ActionContextStoreSourceInstance.
|
|
1079
|
+
*/
|
|
1080
|
+
class WorkHandlerContextSourceDelegate {
|
|
1081
|
+
constructor(source) {
|
|
1082
|
+
this.source = source;
|
|
1083
|
+
}
|
|
1084
|
+
startWorking() {
|
|
1085
|
+
this.source.startWorking();
|
|
1086
|
+
}
|
|
1087
|
+
success(result) {
|
|
1088
|
+
this.source.success(result);
|
|
1089
|
+
}
|
|
1090
|
+
reject(error) {
|
|
1091
|
+
this.source.reject(error);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
/**
|
|
1095
|
+
* Used by DbNgxActionHandlerDirective when handling a function.
|
|
1096
|
+
*/
|
|
1097
|
+
class WorkHandlerContext {
|
|
1098
|
+
constructor(value, delegate) {
|
|
1099
|
+
this.value = value;
|
|
1100
|
+
this.delegate = delegate;
|
|
1101
|
+
this._done = false;
|
|
1102
|
+
this._doneActionBegan = false;
|
|
1103
|
+
this._actionBegan = new BehaviorSubject(false);
|
|
1104
|
+
this._isComplete = new BehaviorSubject(false);
|
|
1105
|
+
// Schedule to cleanup self once isComplete is true.
|
|
1106
|
+
this._isComplete.subscribe((done) => {
|
|
1107
|
+
if (done) {
|
|
1108
|
+
this.destroy();
|
|
1109
|
+
}
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
get actionBegan() {
|
|
1113
|
+
return this._doneActionBegan ?? this._actionBegan.value;
|
|
1114
|
+
}
|
|
1115
|
+
get actionBegan$() {
|
|
1116
|
+
return this._done ? of(this._doneActionBegan) : this._actionBegan.asObservable();
|
|
1117
|
+
}
|
|
1118
|
+
get isComplete() {
|
|
1119
|
+
return this._done || this._isComplete.value;
|
|
1120
|
+
}
|
|
1121
|
+
get isComplete$() {
|
|
1122
|
+
return this._done ? of(true) : this._isComplete.asObservable();
|
|
1123
|
+
}
|
|
1124
|
+
/**
|
|
1125
|
+
* Begins working using an observable.
|
|
1126
|
+
*/
|
|
1127
|
+
startWorkingWithObservable(actionObs) {
|
|
1128
|
+
this.startWorking();
|
|
1129
|
+
actionObs.pipe(first()).subscribe((actionResult) => {
|
|
1130
|
+
this.success(actionResult);
|
|
1131
|
+
}, (error) => {
|
|
1132
|
+
const message = error.message ?? error.code ?? undefined;
|
|
1133
|
+
this.reject((message) ? ({ message }) : undefined);
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
/**
|
|
1137
|
+
* Notifies the system that the action has begun.
|
|
1138
|
+
*/
|
|
1139
|
+
startWorking() {
|
|
1140
|
+
this._setWorking();
|
|
1141
|
+
this.delegate.startWorking();
|
|
1142
|
+
}
|
|
1143
|
+
/**
|
|
1144
|
+
* Sets success on the action.
|
|
1145
|
+
*/
|
|
1146
|
+
success(result) {
|
|
1147
|
+
this._setComplete();
|
|
1148
|
+
this.delegate.success(result);
|
|
1149
|
+
}
|
|
1150
|
+
/**
|
|
1151
|
+
* Sets rejected on the action.
|
|
1152
|
+
*/
|
|
1153
|
+
reject(error) {
|
|
1154
|
+
this._setComplete();
|
|
1155
|
+
this.delegate.reject(error);
|
|
1156
|
+
}
|
|
1157
|
+
destroy() {
|
|
1158
|
+
this._doneActionBegan = this.actionBegan;
|
|
1159
|
+
this._done = true;
|
|
1160
|
+
// Delay to prevent error.
|
|
1161
|
+
setTimeout(() => {
|
|
1162
|
+
this._actionBegan.complete();
|
|
1163
|
+
this._isComplete.complete();
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1166
|
+
_setWorking() {
|
|
1167
|
+
if (this.actionBegan) {
|
|
1168
|
+
throw new Error('Action already has been triggered for this context.');
|
|
1169
|
+
}
|
|
1170
|
+
this._actionBegan.next(true);
|
|
1171
|
+
}
|
|
1172
|
+
_setComplete() {
|
|
1173
|
+
if (this.isComplete) {
|
|
1174
|
+
throw new Error('Action has already been marked as completed.');
|
|
1175
|
+
}
|
|
1176
|
+
this._isComplete.next(true);
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Creates a function that uses a provider to always handle new values.
|
|
1181
|
+
*/
|
|
1182
|
+
function handleWorkValueReadyWithConfigFn(providerFn) {
|
|
1183
|
+
return (value) => {
|
|
1184
|
+
const config = providerFn(value);
|
|
1185
|
+
return handleWorkValueReadyFn(config)(value);
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
/**
|
|
1189
|
+
* Creates a function that handles the incoming value and creates a WorkHandlerContext.
|
|
1190
|
+
*/
|
|
1191
|
+
function handleWorkValueReadyFn({ handlerFunction, delegate }) {
|
|
1192
|
+
return (value) => {
|
|
1193
|
+
const handler = new WorkHandlerContext(value, delegate);
|
|
1194
|
+
let fnResult;
|
|
1195
|
+
try {
|
|
1196
|
+
fnResult = handlerFunction(value, handler);
|
|
1197
|
+
}
|
|
1198
|
+
catch (e) {
|
|
1199
|
+
console.error('Action encountered an unexpected error.', e);
|
|
1200
|
+
handler.reject(e);
|
|
1201
|
+
return;
|
|
1202
|
+
}
|
|
1203
|
+
if (!handler.isComplete) {
|
|
1204
|
+
if (fnResult && isObservable(fnResult)) {
|
|
1205
|
+
if (handler.actionBegan) {
|
|
1206
|
+
throw new Error('Action already marked as begun from handlerFunction result. Either return an observable or use the handler directly.');
|
|
1207
|
+
}
|
|
1208
|
+
handler.startWorkingWithObservable(fnResult);
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
return handler;
|
|
1212
|
+
};
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
/**
|
|
1216
|
+
* Context used for defining a function that performs an action using the input function on ValueReady.
|
|
1217
|
+
*/
|
|
1218
|
+
class DbNgxActionHandlerDirective extends AbstractSubscriptionDirective {
|
|
1219
|
+
constructor(source) {
|
|
1220
|
+
super();
|
|
1221
|
+
this.source = source;
|
|
1222
|
+
this._handlerFunction = new BehaviorSubject(undefined);
|
|
1223
|
+
this.handlerFunction$ = this._handlerFunction.pipe(filterMaybe(), shareReplay(1));
|
|
1224
|
+
this._delegate = new WorkHandlerContextSourceDelegate(this.source);
|
|
1225
|
+
}
|
|
1226
|
+
get handlerFunction() {
|
|
1227
|
+
return this._handlerFunction.value;
|
|
1228
|
+
}
|
|
1229
|
+
set handlerFunction(handlerFunction) {
|
|
1230
|
+
this._handlerFunction.next(handlerFunction);
|
|
1231
|
+
}
|
|
1232
|
+
ngOnInit() {
|
|
1233
|
+
this.sub = this.handlerFunction$.pipe(switchMap(handlerFunction => this.source.valueReady$.pipe(map((x) => [handlerFunction, x]), tap(([handlerFunction, value]) => {
|
|
1234
|
+
const context = handleWorkValueReadyFn({ handlerFunction, delegate: this._delegate })(value);
|
|
1235
|
+
if (context) {
|
|
1236
|
+
// Add the action to the lockSet for the source to prevent it from being destroyed until the action completes.
|
|
1237
|
+
this.source.lockSet.addLock('actionhandler', context.isComplete$.pipe(map(x => !x)));
|
|
1238
|
+
}
|
|
1239
|
+
})))).subscribe();
|
|
1240
|
+
}
|
|
1241
|
+
ngOnDestroy() {
|
|
1242
|
+
this.source.lockSet.onNextUnlock(() => {
|
|
1243
|
+
super.ngOnDestroy();
|
|
1244
|
+
});
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
DbNgxActionHandlerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionHandlerDirective, deps: [{ token: ActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1248
|
+
DbNgxActionHandlerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxActionHandlerDirective, selector: "[dbxActionHandler]", inputs: { handlerFunction: ["dbxActionHandler", "handlerFunction"] }, usesInheritance: true, ngImport: i0 });
|
|
1249
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionHandlerDirective, decorators: [{
|
|
1250
|
+
type: Directive,
|
|
1251
|
+
args: [{
|
|
1252
|
+
selector: '[dbxActionHandler]',
|
|
1253
|
+
}]
|
|
1254
|
+
}], ctorParameters: function () { return [{ type: ActionContextStoreSourceInstance, decorators: [{
|
|
1255
|
+
type: Host
|
|
1256
|
+
}] }]; }, propDecorators: { handlerFunction: [{
|
|
1257
|
+
type: Input,
|
|
1258
|
+
args: ['dbxActionHandler']
|
|
1259
|
+
}] } });
|
|
1260
|
+
|
|
1261
|
+
/**
|
|
1262
|
+
* Displays the input content when success is set.
|
|
1263
|
+
*
|
|
1264
|
+
* Can be configured to show for a limited time afterwards, etc.
|
|
1265
|
+
*/
|
|
1266
|
+
class DbNgxActionSuccessComponent {
|
|
1267
|
+
constructor(source) {
|
|
1268
|
+
this.source = source;
|
|
1269
|
+
this.show$ = this.source.isSuccess$.pipe(exhaustMap((success) => {
|
|
1270
|
+
if (success) {
|
|
1271
|
+
if (this.hideAfter) {
|
|
1272
|
+
return of(false).pipe(delay(this.hideAfter), startWith(true));
|
|
1273
|
+
}
|
|
1274
|
+
else {
|
|
1275
|
+
return of(true);
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
else {
|
|
1279
|
+
return of(false);
|
|
1280
|
+
}
|
|
1281
|
+
}), shareReplay(1));
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
DbNgxActionSuccessComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionSuccessComponent, deps: [{ token: ActionContextStoreSourceInstance }], target: i0.ɵɵFactoryTarget.Component });
|
|
1285
|
+
DbNgxActionSuccessComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxActionSuccessComponent, selector: "dbx-action-success", inputs: { hideAfter: "hideAfter" }, ngImport: i0, template: `
|
|
1286
|
+
<ng-container *ngIf="show$ | async">
|
|
1287
|
+
<ng-content></ng-content>
|
|
1288
|
+
</ng-container>
|
|
1289
|
+
`, isInline: true, directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "async": i2.AsyncPipe } });
|
|
1290
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionSuccessComponent, decorators: [{
|
|
1291
|
+
type: Component,
|
|
1292
|
+
args: [{
|
|
1293
|
+
selector: 'dbx-action-success',
|
|
1294
|
+
template: `
|
|
1295
|
+
<ng-container *ngIf="show$ | async">
|
|
1296
|
+
<ng-content></ng-content>
|
|
1297
|
+
</ng-container>
|
|
1298
|
+
`
|
|
1299
|
+
}]
|
|
1300
|
+
}], ctorParameters: function () { return [{ type: ActionContextStoreSourceInstance }]; }, propDecorators: { hideAfter: [{
|
|
1301
|
+
type: Input
|
|
1302
|
+
}] } });
|
|
1303
|
+
|
|
1304
|
+
/**
|
|
1305
|
+
* Directive that executes a function on ActionContextStore Success.
|
|
1306
|
+
*/
|
|
1307
|
+
class DbNgxActionSuccessDirective extends AbstractSubscriptionDirective {
|
|
1308
|
+
constructor(source) {
|
|
1309
|
+
super();
|
|
1310
|
+
this.source = source;
|
|
1311
|
+
this._successFunction = new BehaviorSubject(undefined);
|
|
1312
|
+
this.successFunction$ = this._successFunction.pipe(filterMaybe(), shareReplay(1));
|
|
1313
|
+
}
|
|
1314
|
+
get successFunction() {
|
|
1315
|
+
return this._successFunction.value;
|
|
1316
|
+
}
|
|
1317
|
+
set successFunction(successFunction) {
|
|
1318
|
+
this._successFunction.next(successFunction);
|
|
1319
|
+
}
|
|
1320
|
+
ngOnInit() {
|
|
1321
|
+
this.sub = this.successFunction$.pipe(switchMap(successFunction => this.source.success$.pipe(map(x => ([successFunction, x])), tap(([successFn, result]) => {
|
|
1322
|
+
successFn(result);
|
|
1323
|
+
})))).subscribe();
|
|
1324
|
+
}
|
|
1325
|
+
ngOnDestroy() {
|
|
1326
|
+
super.ngOnDestroy();
|
|
1327
|
+
this._successFunction.complete();
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
DbNgxActionSuccessDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionSuccessDirective, deps: [{ token: ActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1331
|
+
DbNgxActionSuccessDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxActionSuccessDirective, selector: "[dbxActionSuccess]", inputs: { successFunction: ["dbxActionSuccess", "successFunction"] }, usesInheritance: true, ngImport: i0 });
|
|
1332
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionSuccessDirective, decorators: [{
|
|
1333
|
+
type: Directive,
|
|
1334
|
+
args: [{
|
|
1335
|
+
selector: '[dbxActionSuccess]',
|
|
1336
|
+
}]
|
|
1337
|
+
}], ctorParameters: function () { return [{ type: ActionContextStoreSourceInstance, decorators: [{
|
|
1338
|
+
type: Host
|
|
1339
|
+
}] }]; }, propDecorators: { successFunction: [{
|
|
1340
|
+
type: Input,
|
|
1341
|
+
args: ['dbxActionSuccess']
|
|
1342
|
+
}] } });
|
|
1343
|
+
|
|
1344
|
+
/**
|
|
1345
|
+
* Directive that provides a default value when triggered.
|
|
1346
|
+
*
|
|
1347
|
+
* No value is required, allowing the directive to automatically call readyValue with undefined.
|
|
1348
|
+
*/
|
|
1349
|
+
class DbNgxActionValueDirective extends AbstractSubscriptionDirective {
|
|
1350
|
+
constructor(source) {
|
|
1351
|
+
super();
|
|
1352
|
+
this.source = source;
|
|
1353
|
+
this._valueOrFunction = new BehaviorSubject(undefined);
|
|
1354
|
+
this.valueOrFunction$ = this._valueOrFunction.pipe(filterMaybe(), shareReplay(1));
|
|
1355
|
+
}
|
|
1356
|
+
get valueOrFunction() {
|
|
1357
|
+
return this._valueOrFunction.value;
|
|
1358
|
+
}
|
|
1359
|
+
set valueOrFunction(valueOrFunction) {
|
|
1360
|
+
this._valueOrFunction.next(valueOrFunction);
|
|
1361
|
+
}
|
|
1362
|
+
ngOnInit() {
|
|
1363
|
+
this.sub = this.valueOrFunction$.pipe(switchMap(valueOrFunction => this.source.triggered$.pipe(tap(() => {
|
|
1364
|
+
const value = getValueFromObjectOrGetter(valueOrFunction);
|
|
1365
|
+
this.source.readyValue(value);
|
|
1366
|
+
})))).subscribe();
|
|
1367
|
+
}
|
|
1368
|
+
ngOnDestroy() {
|
|
1369
|
+
super.ngOnDestroy();
|
|
1370
|
+
this._valueOrFunction.complete();
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
DbNgxActionValueDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionValueDirective, deps: [{ token: ActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1374
|
+
DbNgxActionValueDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxActionValueDirective, selector: "[dbxActionValue]", inputs: { valueOrFunction: ["dbxActionValue", "valueOrFunction"] }, usesInheritance: true, ngImport: i0 });
|
|
1375
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionValueDirective, decorators: [{
|
|
1376
|
+
type: Directive,
|
|
1377
|
+
args: [{
|
|
1378
|
+
selector: '[dbxActionValue]',
|
|
1379
|
+
}]
|
|
1380
|
+
}], ctorParameters: function () { return [{ type: ActionContextStoreSourceInstance, decorators: [{
|
|
1381
|
+
type: Host
|
|
1382
|
+
}] }]; }, propDecorators: { valueOrFunction: [{
|
|
1383
|
+
type: Input,
|
|
1384
|
+
args: ['dbxActionValue']
|
|
1385
|
+
}] } });
|
|
1386
|
+
|
|
1387
|
+
/**
|
|
1388
|
+
* Displays the input content when working is set.
|
|
1389
|
+
*/
|
|
1390
|
+
class DbNgxActionWorkingComponent {
|
|
1391
|
+
constructor(source) {
|
|
1392
|
+
this.source = source;
|
|
1393
|
+
this.show$ = this.source.isWorking$;
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
DbNgxActionWorkingComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionWorkingComponent, deps: [{ token: ActionContextStoreSourceInstance }], target: i0.ɵɵFactoryTarget.Component });
|
|
1397
|
+
DbNgxActionWorkingComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxActionWorkingComponent, selector: "dbx-action-working", ngImport: i0, template: `
|
|
1398
|
+
<ng-container *ngIf="show$ | async">
|
|
1399
|
+
<ng-content></ng-content>
|
|
1400
|
+
</ng-container>
|
|
1401
|
+
`, isInline: true, directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "async": i2.AsyncPipe } });
|
|
1402
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionWorkingComponent, decorators: [{
|
|
1403
|
+
type: Component,
|
|
1404
|
+
args: [{
|
|
1405
|
+
selector: 'dbx-action-working',
|
|
1406
|
+
template: `
|
|
1407
|
+
<ng-container *ngIf="show$ | async">
|
|
1408
|
+
<ng-content></ng-content>
|
|
1409
|
+
</ng-container>
|
|
1410
|
+
`
|
|
1411
|
+
}]
|
|
1412
|
+
}], ctorParameters: function () { return [{ type: ActionContextStoreSourceInstance }]; } });
|
|
1413
|
+
|
|
1414
|
+
const DEFAULT_SNACKBAR_DIRECTIVE_DURATION = ms('4s');
|
|
1415
|
+
const DEFAULT_SNACKBAR_UNDO_DIRECTIVE_DURATION = ms('30s');
|
|
1416
|
+
var ActionSnackbarDefaultType;
|
|
1417
|
+
(function (ActionSnackbarDefaultType) {
|
|
1418
|
+
ActionSnackbarDefaultType["NONE"] = "none";
|
|
1419
|
+
ActionSnackbarDefaultType["CREATE"] = "create";
|
|
1420
|
+
ActionSnackbarDefaultType["SAVE"] = "save";
|
|
1421
|
+
ActionSnackbarDefaultType["DELETE"] = "delete";
|
|
1422
|
+
ActionSnackbarDefaultType["MERGE"] = "merge";
|
|
1423
|
+
ActionSnackbarDefaultType["SEND"] = "send";
|
|
1424
|
+
ActionSnackbarDefaultType["CANCEL"] = "cancel";
|
|
1425
|
+
ActionSnackbarDefaultType["RESTORE"] = "restore";
|
|
1426
|
+
ActionSnackbarDefaultType["REFRESH"] = "refresh";
|
|
1427
|
+
ActionSnackbarDefaultType["MARK_READ"] = "read";
|
|
1428
|
+
ActionSnackbarDefaultType["MARK_UNREAD"] = "unread";
|
|
1429
|
+
})(ActionSnackbarDefaultType || (ActionSnackbarDefaultType = {}));
|
|
1430
|
+
var ActionSnackbarEventType;
|
|
1431
|
+
(function (ActionSnackbarEventType) {
|
|
1432
|
+
ActionSnackbarEventType[ActionSnackbarEventType["WORKING"] = 0] = "WORKING";
|
|
1433
|
+
ActionSnackbarEventType[ActionSnackbarEventType["SUCCESS"] = 1] = "SUCCESS";
|
|
1434
|
+
ActionSnackbarEventType[ActionSnackbarEventType["REJECTED"] = 2] = "REJECTED";
|
|
1435
|
+
})(ActionSnackbarEventType || (ActionSnackbarEventType = {}));
|
|
1436
|
+
|
|
1437
|
+
// export * from './snackbar.directive';
|
|
1438
|
+
|
|
1439
|
+
/**
|
|
1440
|
+
* Configurable machine that handles components of the ActionContextStore lifecycle.
|
|
1441
|
+
*/
|
|
1442
|
+
class ActionContextMachine extends ActionContextBaseSource {
|
|
1443
|
+
constructor(config, source) {
|
|
1444
|
+
super(source);
|
|
1445
|
+
this.config = config;
|
|
1446
|
+
this._isShutdown = true;
|
|
1447
|
+
this._handleValueReadySub = new SubscriptionObject();
|
|
1448
|
+
// Handle Value Ready
|
|
1449
|
+
this._handleValueReadySub.subscription = this.sourceInstance.valueReady$.subscribe((value) => {
|
|
1450
|
+
handleWorkValueReadyFn({ handlerFunction: config.handleValueReady, delegate: new WorkHandlerContextSourceDelegate(this.sourceInstance) })(value);
|
|
1451
|
+
});
|
|
1452
|
+
// If this is a one-time use, then destroy it after the first success comes through.
|
|
1453
|
+
if (this.config.oneTimeUse) {
|
|
1454
|
+
this.sourceInstance.success$.pipe(first(), delay(1000)).subscribe(() => {
|
|
1455
|
+
this.destroy();
|
|
1456
|
+
});
|
|
1457
|
+
}
|
|
1458
|
+
if (this.config.onSuccess) {
|
|
1459
|
+
this.sourceInstance.success$.subscribe(this.config.onSuccess);
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
destroy() {
|
|
1463
|
+
super.destroy();
|
|
1464
|
+
this._handleValueReadySub.destroy();
|
|
1465
|
+
this._isShutdown = true;
|
|
1466
|
+
}
|
|
1467
|
+
get isShutdown() {
|
|
1468
|
+
return this._isShutdown;
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
class DbNgxCoreActionModule {
|
|
1473
|
+
}
|
|
1474
|
+
DbNgxCoreActionModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxCoreActionModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1475
|
+
DbNgxCoreActionModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxCoreActionModule, declarations: [DbNgxActionComponent, DbNgxActionContextDirective, DbNgxActionContextMapDirective, DbNgxActionFromMapDirective, DbNgxActionMapSourceDirective,
|
|
1476
|
+
DbNgxActionMapWorkingDisableDirective, DbNgxActionSourceDirective, DbNgxActionHandlerDirective, DbNgxActionDisabledDirective, DbNgxActionDisabledUntilModifiedDirective,
|
|
1477
|
+
DbNgxActionAutoTriggerDirective, DbNgxActionAutoTriggerValueDirective, DbNgxActionAutoModifyDirective, DbNgxActionValueDirective, DbNgxActionContextLoggerDirective,
|
|
1478
|
+
DbNgxActionSuccessComponent, DbNgxActionSuccessDirective, DbNgxActionWorkingComponent], imports: [CommonModule], exports: [DbNgxActionComponent, DbNgxActionContextDirective, DbNgxActionContextMapDirective, DbNgxActionFromMapDirective, DbNgxActionMapSourceDirective,
|
|
1479
|
+
DbNgxActionMapWorkingDisableDirective, DbNgxActionSourceDirective, DbNgxActionHandlerDirective, DbNgxActionDisabledDirective, DbNgxActionDisabledUntilModifiedDirective,
|
|
1480
|
+
DbNgxActionAutoTriggerDirective, DbNgxActionAutoTriggerValueDirective, DbNgxActionAutoModifyDirective, DbNgxActionValueDirective, DbNgxActionContextLoggerDirective,
|
|
1481
|
+
DbNgxActionSuccessComponent, DbNgxActionSuccessDirective, DbNgxActionWorkingComponent] });
|
|
1482
|
+
DbNgxCoreActionModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxCoreActionModule, imports: [[
|
|
1483
|
+
CommonModule
|
|
1484
|
+
]] });
|
|
1485
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxCoreActionModule, decorators: [{
|
|
1486
|
+
type: NgModule,
|
|
1487
|
+
args: [{
|
|
1488
|
+
imports: [
|
|
1489
|
+
CommonModule
|
|
1490
|
+
],
|
|
1491
|
+
declarations: [
|
|
1492
|
+
DbNgxActionComponent, DbNgxActionContextDirective, DbNgxActionContextMapDirective, DbNgxActionFromMapDirective, DbNgxActionMapSourceDirective,
|
|
1493
|
+
DbNgxActionMapWorkingDisableDirective, DbNgxActionSourceDirective, DbNgxActionHandlerDirective, DbNgxActionDisabledDirective, DbNgxActionDisabledUntilModifiedDirective,
|
|
1494
|
+
DbNgxActionAutoTriggerDirective, DbNgxActionAutoTriggerValueDirective, DbNgxActionAutoModifyDirective, DbNgxActionValueDirective, DbNgxActionContextLoggerDirective,
|
|
1495
|
+
DbNgxActionSuccessComponent, DbNgxActionSuccessDirective, DbNgxActionWorkingComponent
|
|
1496
|
+
],
|
|
1497
|
+
exports: [
|
|
1498
|
+
DbNgxActionComponent, DbNgxActionContextDirective, DbNgxActionContextMapDirective, DbNgxActionFromMapDirective, DbNgxActionMapSourceDirective,
|
|
1499
|
+
DbNgxActionMapWorkingDisableDirective, DbNgxActionSourceDirective, DbNgxActionHandlerDirective, DbNgxActionDisabledDirective, DbNgxActionDisabledUntilModifiedDirective,
|
|
1500
|
+
DbNgxActionAutoTriggerDirective, DbNgxActionAutoTriggerValueDirective, DbNgxActionAutoModifyDirective, DbNgxActionValueDirective, DbNgxActionContextLoggerDirective,
|
|
1501
|
+
DbNgxActionSuccessComponent, DbNgxActionSuccessDirective, DbNgxActionWorkingComponent
|
|
1502
|
+
]
|
|
1503
|
+
}]
|
|
1504
|
+
}] });
|
|
1505
|
+
|
|
1506
|
+
class DbNgxButton {
|
|
1507
|
+
}
|
|
1508
|
+
function ProvideDbNgxButton(sourceType) {
|
|
1509
|
+
return [{
|
|
1510
|
+
provide: DbNgxButton,
|
|
1511
|
+
useExisting: sourceType
|
|
1512
|
+
}];
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
/**
|
|
1516
|
+
* Context used for linking a button to an ActionContext and only look for triggers.
|
|
1517
|
+
*/
|
|
1518
|
+
class DbNgxActionButtonTriggerDirective extends AbstractSubscriptionDirective {
|
|
1519
|
+
constructor(button, source) {
|
|
1520
|
+
super();
|
|
1521
|
+
this.button = button;
|
|
1522
|
+
this.source = source;
|
|
1523
|
+
}
|
|
1524
|
+
ngOnInit() {
|
|
1525
|
+
this.sub = this.button.clicked$.subscribe(() => {
|
|
1526
|
+
this._buttonClicked();
|
|
1527
|
+
});
|
|
1528
|
+
}
|
|
1529
|
+
_buttonClicked() {
|
|
1530
|
+
this.source.trigger();
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
DbNgxActionButtonTriggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionButtonTriggerDirective, deps: [{ token: DbNgxButton, host: true }, { token: ActionContextStoreSourceInstance }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1534
|
+
DbNgxActionButtonTriggerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxActionButtonTriggerDirective, selector: "[dbxActionButtonTrigger]", usesInheritance: true, ngImport: i0 });
|
|
1535
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionButtonTriggerDirective, decorators: [{
|
|
1536
|
+
type: Directive,
|
|
1537
|
+
args: [{
|
|
1538
|
+
selector: '[dbxActionButtonTrigger]'
|
|
1539
|
+
}]
|
|
1540
|
+
}], ctorParameters: function () { return [{ type: DbNgxButton, decorators: [{
|
|
1541
|
+
type: Host
|
|
1542
|
+
}] }, { type: ActionContextStoreSourceInstance }]; } });
|
|
1543
|
+
|
|
1544
|
+
/**
|
|
1545
|
+
* Context used for linking a button to an ActionContext.
|
|
1546
|
+
*/
|
|
1547
|
+
class DbNgxActionButtonDirective extends DbNgxActionButtonTriggerDirective {
|
|
1548
|
+
constructor(button, source, ngZone) {
|
|
1549
|
+
super(button, source);
|
|
1550
|
+
this.ngZone = ngZone;
|
|
1551
|
+
this._workingSub = new SubscriptionObject();
|
|
1552
|
+
this._disabledSub = new SubscriptionObject();
|
|
1553
|
+
}
|
|
1554
|
+
ngOnInit() {
|
|
1555
|
+
super.ngOnInit();
|
|
1556
|
+
this._workingSub.subscription = this.source.isWorking$.subscribe((working) => {
|
|
1557
|
+
// console.log('Working: ', working);
|
|
1558
|
+
this.ngZone.run(() => this.button.working = working);
|
|
1559
|
+
});
|
|
1560
|
+
this._disabledSub.subscription = this.source.isDisabled$.subscribe((disabled) => {
|
|
1561
|
+
// console.log('Disabled: ', disabled);
|
|
1562
|
+
this.ngZone.run(() => this.button.disabled = disabled);
|
|
1563
|
+
});
|
|
1564
|
+
}
|
|
1565
|
+
ngOnDestroy() {
|
|
1566
|
+
super.ngOnDestroy();
|
|
1567
|
+
this._workingSub.destroy();
|
|
1568
|
+
this._disabledSub.destroy();
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
DbNgxActionButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionButtonDirective, deps: [{ token: DbNgxButton, host: true }, { token: ActionContextStoreSourceInstance }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1572
|
+
DbNgxActionButtonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxActionButtonDirective, selector: "[dbxActionButton]", usesInheritance: true, ngImport: i0 });
|
|
1573
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxActionButtonDirective, decorators: [{
|
|
1574
|
+
type: Directive,
|
|
1575
|
+
args: [{
|
|
1576
|
+
selector: '[dbxActionButton]'
|
|
1577
|
+
}]
|
|
1578
|
+
}], ctorParameters: function () { return [{ type: DbNgxButton, decorators: [{
|
|
1579
|
+
type: Host
|
|
1580
|
+
}] }, { type: ActionContextStoreSourceInstance }, { type: i0.NgZone }]; } });
|
|
1581
|
+
|
|
1582
|
+
var AnchorType;
|
|
1583
|
+
(function (AnchorType) {
|
|
1584
|
+
AnchorType[AnchorType["None"] = 0] = "None";
|
|
1585
|
+
AnchorType[AnchorType["Clickable"] = 1] = "Clickable";
|
|
1586
|
+
AnchorType[AnchorType["Sref"] = 2] = "Sref";
|
|
1587
|
+
AnchorType[AnchorType["Href"] = 3] = "Href";
|
|
1588
|
+
AnchorType[AnchorType["Disabled"] = 4] = "Disabled";
|
|
1589
|
+
})(AnchorType || (AnchorType = {}));
|
|
1590
|
+
function anchorTypeForAnchor(anchor, disabled) {
|
|
1591
|
+
let type = AnchorType.Disabled;
|
|
1592
|
+
if (!disabled && anchor) {
|
|
1593
|
+
if (anchor.disabled) {
|
|
1594
|
+
type = AnchorType.Disabled;
|
|
1595
|
+
}
|
|
1596
|
+
else if (anchor.ref) {
|
|
1597
|
+
type = AnchorType.Sref;
|
|
1598
|
+
}
|
|
1599
|
+
else if (anchor.onClick) {
|
|
1600
|
+
type = AnchorType.Clickable;
|
|
1601
|
+
}
|
|
1602
|
+
else if (anchor.url) {
|
|
1603
|
+
type = AnchorType.Href;
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
return type;
|
|
1607
|
+
}
|
|
1608
|
+
class DbNgxAnchor {
|
|
1609
|
+
}
|
|
1610
|
+
function ProvideDbNgxAnchor(sourceType) {
|
|
1611
|
+
return [{
|
|
1612
|
+
provide: DbNgxAnchor,
|
|
1613
|
+
useExisting: sourceType
|
|
1614
|
+
}];
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
/**
|
|
1618
|
+
* Abstract anchor directive.
|
|
1619
|
+
*/
|
|
1620
|
+
class AbstractDbNgxAnchorDirective {
|
|
1621
|
+
constructor() {
|
|
1622
|
+
this._disabled = new BehaviorSubject(false);
|
|
1623
|
+
this._anchor = new BehaviorSubject(undefined);
|
|
1624
|
+
this.disabled$ = this._disabled.asObservable();
|
|
1625
|
+
this.anchor$ = this._anchor.pipe(skipFirstMaybe(), distinctUntilChanged(), shareReplay(1));
|
|
1626
|
+
this.type$ = combineLatest([this.disabled$, this.anchor$]).pipe(map(([disabled, anchor]) => anchorTypeForAnchor(anchor, disabled)), distinctUntilChanged(), shareReplay(1));
|
|
1627
|
+
}
|
|
1628
|
+
get anchor() {
|
|
1629
|
+
return this._anchor.value;
|
|
1630
|
+
}
|
|
1631
|
+
set anchor(anchor) {
|
|
1632
|
+
this._anchor.next(anchor);
|
|
1633
|
+
}
|
|
1634
|
+
get disabled() {
|
|
1635
|
+
return this._disabled.value;
|
|
1636
|
+
}
|
|
1637
|
+
set disabled(disabled) {
|
|
1638
|
+
this._disabled.next(disabled);
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
AbstractDbNgxAnchorDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractDbNgxAnchorDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1642
|
+
AbstractDbNgxAnchorDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: AbstractDbNgxAnchorDirective, inputs: { anchor: "anchor", disabled: "disabled" }, ngImport: i0 });
|
|
1643
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractDbNgxAnchorDirective, decorators: [{
|
|
1644
|
+
type: Directive
|
|
1645
|
+
}], propDecorators: { anchor: [{
|
|
1646
|
+
type: Input
|
|
1647
|
+
}], disabled: [{
|
|
1648
|
+
type: Input
|
|
1649
|
+
}] } });
|
|
1650
|
+
|
|
1651
|
+
var DbNgxRouterTransitionEventType;
|
|
1652
|
+
(function (DbNgxRouterTransitionEventType) {
|
|
1653
|
+
/**
|
|
1654
|
+
* A transition started.
|
|
1655
|
+
*/
|
|
1656
|
+
DbNgxRouterTransitionEventType["START"] = "start";
|
|
1657
|
+
/**
|
|
1658
|
+
* A transition ended.
|
|
1659
|
+
*/
|
|
1660
|
+
DbNgxRouterTransitionEventType["SUCCESS"] = "ended";
|
|
1661
|
+
})(DbNgxRouterTransitionEventType || (DbNgxRouterTransitionEventType = {}));
|
|
1662
|
+
|
|
1663
|
+
/**
|
|
1664
|
+
* AngularRouter implementation of DbNgxRouterService and DbNgxRouterTransitionService.
|
|
1665
|
+
*/
|
|
1666
|
+
class DbNgxAngularRouterService {
|
|
1667
|
+
constructor(router, activatedRoute) {
|
|
1668
|
+
this.router = router;
|
|
1669
|
+
this.activatedRoute = activatedRoute;
|
|
1670
|
+
this.transitions$ = this.router.events.pipe(map((x) => {
|
|
1671
|
+
let event;
|
|
1672
|
+
if (x instanceof NavigationStart) {
|
|
1673
|
+
event = {
|
|
1674
|
+
type: DbNgxRouterTransitionEventType.START
|
|
1675
|
+
};
|
|
1676
|
+
}
|
|
1677
|
+
else if (x instanceof NavigationEnd) {
|
|
1678
|
+
event = {
|
|
1679
|
+
type: DbNgxRouterTransitionEventType.SUCCESS
|
|
1680
|
+
};
|
|
1681
|
+
}
|
|
1682
|
+
return event;
|
|
1683
|
+
}), filterMaybe());
|
|
1684
|
+
}
|
|
1685
|
+
go(segueRef) {
|
|
1686
|
+
let ref = segueRef.ref;
|
|
1687
|
+
if (isArray(ref)) {
|
|
1688
|
+
return this.router.navigate(ref, {
|
|
1689
|
+
...segueRef.refOptions,
|
|
1690
|
+
queryParams: segueRef.refParams
|
|
1691
|
+
});
|
|
1692
|
+
}
|
|
1693
|
+
else {
|
|
1694
|
+
return this.router.navigateByUrl(ref, {
|
|
1695
|
+
...segueRef.refOptions
|
|
1696
|
+
});
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
DbNgxAngularRouterService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxAngularRouterService, deps: [{ token: i1$1.Router }, { token: i1$1.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1701
|
+
DbNgxAngularRouterService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxAngularRouterService });
|
|
1702
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxAngularRouterService, decorators: [{
|
|
1703
|
+
type: Injectable
|
|
1704
|
+
}], ctorParameters: function () { return [{ type: i1$1.Router }, { type: i1$1.ActivatedRoute }]; } });
|
|
1705
|
+
|
|
1706
|
+
/**
|
|
1707
|
+
* Router service definition that can route the app and provide routing details.
|
|
1708
|
+
*/
|
|
1709
|
+
class DbNgxRouterService {
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
/**
|
|
1713
|
+
* Router service definition that provides high level information about router transitions.
|
|
1714
|
+
*/
|
|
1715
|
+
class DbNgxRouterTransitionService {
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
class DbNgxCoreAngularRouterSegueModule {
|
|
1719
|
+
static forRoot() {
|
|
1720
|
+
return {
|
|
1721
|
+
ngModule: DbNgxCoreAngularRouterSegueModule,
|
|
1722
|
+
providers: [
|
|
1723
|
+
DbNgxAngularRouterService,
|
|
1724
|
+
{
|
|
1725
|
+
provide: DbNgxRouterService,
|
|
1726
|
+
useExisting: DbNgxAngularRouterService
|
|
1727
|
+
},
|
|
1728
|
+
{
|
|
1729
|
+
provide: DbNgxRouterTransitionService,
|
|
1730
|
+
useExisting: DbNgxAngularRouterService
|
|
1731
|
+
}
|
|
1732
|
+
]
|
|
1733
|
+
};
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
DbNgxCoreAngularRouterSegueModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxCoreAngularRouterSegueModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1737
|
+
DbNgxCoreAngularRouterSegueModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxCoreAngularRouterSegueModule });
|
|
1738
|
+
DbNgxCoreAngularRouterSegueModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxCoreAngularRouterSegueModule });
|
|
1739
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxCoreAngularRouterSegueModule, decorators: [{
|
|
1740
|
+
type: NgModule,
|
|
1741
|
+
args: [{}]
|
|
1742
|
+
}] });
|
|
1743
|
+
|
|
1744
|
+
/**
|
|
1745
|
+
* UIRouter implementation of DbNgxRouterService and DbNgxRouterTransitionService.
|
|
1746
|
+
*/
|
|
1747
|
+
class DbNgxUIRouterService {
|
|
1748
|
+
constructor(state, transitionService, uiRouterGlobals) {
|
|
1749
|
+
this.state = state;
|
|
1750
|
+
this.transitionService = transitionService;
|
|
1751
|
+
this.uiRouterGlobals = uiRouterGlobals;
|
|
1752
|
+
this._transitions = new Subject();
|
|
1753
|
+
this.transitions$ = this._transitions.asObservable();
|
|
1754
|
+
const emitTransition = (type) => {
|
|
1755
|
+
this._transitions.next({
|
|
1756
|
+
type
|
|
1757
|
+
});
|
|
1758
|
+
};
|
|
1759
|
+
this.transitionService.onStart({}, () => {
|
|
1760
|
+
emitTransition(DbNgxRouterTransitionEventType.START);
|
|
1761
|
+
});
|
|
1762
|
+
this.transitionService.onSuccess({}, () => {
|
|
1763
|
+
emitTransition(DbNgxRouterTransitionEventType.SUCCESS);
|
|
1764
|
+
});
|
|
1765
|
+
}
|
|
1766
|
+
go(segueRef) {
|
|
1767
|
+
const params = { ...this.uiRouterGlobals.current.params, ...segueRef.refParams };
|
|
1768
|
+
return this.state.go(segueRef.ref, params, segueRef.refOptions).then(_ => true).catch(_ => false);
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
DbNgxUIRouterService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxUIRouterService, deps: [{ token: i1$2.StateService }, { token: i1$2.TransitionService }, { token: i1$2.UIRouterGlobals }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1772
|
+
DbNgxUIRouterService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxUIRouterService });
|
|
1773
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxUIRouterService, decorators: [{
|
|
1774
|
+
type: Injectable
|
|
1775
|
+
}], ctorParameters: function () { return [{ type: i1$2.StateService }, { type: i1$2.TransitionService }, { type: i1$2.UIRouterGlobals }]; } });
|
|
1776
|
+
|
|
1777
|
+
class DbNgxCoreUIRouterSegueModule {
|
|
1778
|
+
static forRoot() {
|
|
1779
|
+
return {
|
|
1780
|
+
ngModule: DbNgxCoreUIRouterSegueModule,
|
|
1781
|
+
providers: [
|
|
1782
|
+
DbNgxUIRouterService,
|
|
1783
|
+
{
|
|
1784
|
+
provide: DbNgxRouterService,
|
|
1785
|
+
useExisting: DbNgxUIRouterService
|
|
1786
|
+
},
|
|
1787
|
+
{
|
|
1788
|
+
provide: DbNgxRouterTransitionService,
|
|
1789
|
+
useExisting: DbNgxUIRouterService
|
|
1790
|
+
}
|
|
1791
|
+
]
|
|
1792
|
+
};
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
DbNgxCoreUIRouterSegueModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxCoreUIRouterSegueModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1796
|
+
DbNgxCoreUIRouterSegueModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxCoreUIRouterSegueModule });
|
|
1797
|
+
DbNgxCoreUIRouterSegueModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxCoreUIRouterSegueModule });
|
|
1798
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxCoreUIRouterSegueModule, decorators: [{
|
|
1799
|
+
type: NgModule,
|
|
1800
|
+
args: [{}]
|
|
1801
|
+
}] });
|
|
1802
|
+
|
|
1803
|
+
/**
|
|
1804
|
+
* Abstract directive that listens to onSuccess transition events and runs a function.
|
|
1805
|
+
*/
|
|
1806
|
+
class AbstractTransitionWatcherDirective {
|
|
1807
|
+
constructor(dbNgxRouterTransitionService, ngZone) {
|
|
1808
|
+
this.dbNgxRouterTransitionService = dbNgxRouterTransitionService;
|
|
1809
|
+
this.ngZone = ngZone;
|
|
1810
|
+
this._transitionSub = new SubscriptionObject();
|
|
1811
|
+
}
|
|
1812
|
+
ngOnInit() {
|
|
1813
|
+
this._transitionSub.subscription = this.dbNgxRouterTransitionService.transitions$.pipe(filter(x => x.type === DbNgxRouterTransitionEventType.SUCCESS)).subscribe(() => {
|
|
1814
|
+
this.updateForSuccessfulTransition();
|
|
1815
|
+
});
|
|
1816
|
+
}
|
|
1817
|
+
ngOnDestroy() {
|
|
1818
|
+
this._transitionSub.destroy();
|
|
1819
|
+
}
|
|
1820
|
+
// MARK: Action
|
|
1821
|
+
zoneUpdateForSuccessfulTransition() {
|
|
1822
|
+
this.ngZone.run(() => this.updateForSuccessfulTransition());
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
AbstractTransitionWatcherDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractTransitionWatcherDirective, deps: [{ token: DbNgxRouterTransitionService }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1826
|
+
AbstractTransitionWatcherDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: AbstractTransitionWatcherDirective, ngImport: i0 });
|
|
1827
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractTransitionWatcherDirective, decorators: [{
|
|
1828
|
+
type: Directive
|
|
1829
|
+
}], ctorParameters: function () { return [{ type: DbNgxRouterTransitionService }, { type: i0.NgZone }]; } });
|
|
1830
|
+
|
|
1831
|
+
function refStringToSegueRef(ref, options) {
|
|
1832
|
+
return { ...options, ref };
|
|
1833
|
+
}
|
|
1834
|
+
function mapRefStringObsToSegueRefObs(obs, options) {
|
|
1835
|
+
return obs.pipe(map(x => refStringToSegueRef(x, options)));
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
// MARK: Button Directives
|
|
1839
|
+
class DbNgxButtonSegueDirective extends AbstractSubscriptionDirective {
|
|
1840
|
+
constructor(dbxButton, dbxRouterService) {
|
|
1841
|
+
super();
|
|
1842
|
+
this.dbxButton = dbxButton;
|
|
1843
|
+
this.dbxRouterService = dbxRouterService;
|
|
1844
|
+
this._segueRef = new BehaviorSubject(undefined);
|
|
1845
|
+
this.segueRef$ = this._segueRef.pipe(filterMaybe(), distinctUntilChanged(), shareReplay(1));
|
|
1846
|
+
}
|
|
1847
|
+
get segueRef() {
|
|
1848
|
+
return this._segueRef.value;
|
|
1849
|
+
}
|
|
1850
|
+
set segueRef(segueRef) {
|
|
1851
|
+
this._segueRef.next(segueRef);
|
|
1852
|
+
}
|
|
1853
|
+
ngOnInit() {
|
|
1854
|
+
this.sub = this.segueRef$.pipe(switchMap(segueRef => this.dbxButton.clicked$.pipe(tap(() => {
|
|
1855
|
+
this.dbxRouterService.go(segueRef);
|
|
1856
|
+
})))).subscribe();
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
DbNgxButtonSegueDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxButtonSegueDirective, deps: [{ token: DbNgxButton }, { token: DbNgxRouterService }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1860
|
+
DbNgxButtonSegueDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxButtonSegueDirective, selector: "[dbxButtonSegue]", inputs: { segueRef: ["dbxButtonSegue", "segueRef"] }, usesInheritance: true, ngImport: i0 });
|
|
1861
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxButtonSegueDirective, decorators: [{
|
|
1862
|
+
type: Directive,
|
|
1863
|
+
args: [{
|
|
1864
|
+
selector: '[dbxButtonSegue]'
|
|
1865
|
+
}]
|
|
1866
|
+
}], ctorParameters: function () { return [{ type: DbNgxButton }, { type: DbNgxRouterService }]; }, propDecorators: { segueRef: [{
|
|
1867
|
+
type: Input,
|
|
1868
|
+
args: ['dbxButtonSegue']
|
|
1869
|
+
}] } });
|
|
1870
|
+
|
|
1871
|
+
/**
|
|
1872
|
+
* Abstract button component.
|
|
1873
|
+
*/
|
|
1874
|
+
class AbstractDbNgxButtonDirective extends AbstractSubscriptionDirective {
|
|
1875
|
+
constructor() {
|
|
1876
|
+
super();
|
|
1877
|
+
this._disabled = new BehaviorSubject(false);
|
|
1878
|
+
this._working = new BehaviorSubject(false);
|
|
1879
|
+
this.disabled$ = this._disabled.asObservable();
|
|
1880
|
+
this.working$ = this._working.asObservable();
|
|
1881
|
+
this.buttonClick = new EventEmitter();
|
|
1882
|
+
this.clicked$ = this.buttonClick.asObservable();
|
|
1883
|
+
/**
|
|
1884
|
+
* Pre-interceptor button click.
|
|
1885
|
+
*/
|
|
1886
|
+
this._buttonClick = new Subject();
|
|
1887
|
+
this._buttonInterceptor = new BehaviorSubject(undefined);
|
|
1888
|
+
}
|
|
1889
|
+
get disabled() {
|
|
1890
|
+
return this._disabled.value;
|
|
1891
|
+
}
|
|
1892
|
+
set disabled(disabled) {
|
|
1893
|
+
this._disabled.next(disabled);
|
|
1894
|
+
}
|
|
1895
|
+
get working() {
|
|
1896
|
+
return this._working.value;
|
|
1897
|
+
}
|
|
1898
|
+
set working(working) {
|
|
1899
|
+
this._working.next(working);
|
|
1900
|
+
}
|
|
1901
|
+
ngOnInit() {
|
|
1902
|
+
this.sub = this._buttonClick.pipe(switchMap(() => this._buttonInterceptor.pipe(switchMap((x) => {
|
|
1903
|
+
if (x) {
|
|
1904
|
+
return x.interceptButtonClick().pipe(first());
|
|
1905
|
+
}
|
|
1906
|
+
else {
|
|
1907
|
+
return of(true);
|
|
1908
|
+
}
|
|
1909
|
+
}), filter((x) => Boolean(x)) // Ignore false values.
|
|
1910
|
+
))).subscribe(() => {
|
|
1911
|
+
this._forceButtonClicked();
|
|
1912
|
+
});
|
|
1913
|
+
}
|
|
1914
|
+
ngOnDestroy() {
|
|
1915
|
+
super.ngOnDestroy();
|
|
1916
|
+
this._disabled.complete();
|
|
1917
|
+
this._working.complete();
|
|
1918
|
+
this._buttonClick.complete();
|
|
1919
|
+
this._buttonInterceptor.complete();
|
|
1920
|
+
}
|
|
1921
|
+
/**
|
|
1922
|
+
* Sets the button interceptor. If any interceptor is already set, it is replaced.
|
|
1923
|
+
*/
|
|
1924
|
+
setButtonInterceptor(interceptor) {
|
|
1925
|
+
this._buttonInterceptor.next(interceptor);
|
|
1926
|
+
}
|
|
1927
|
+
/**
|
|
1928
|
+
* Main function to use for handling clicks on the button.
|
|
1929
|
+
*/
|
|
1930
|
+
clickButton() {
|
|
1931
|
+
if (!this.disabled) {
|
|
1932
|
+
this._buttonClick.next();
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
/**
|
|
1936
|
+
* Forces a button click. Skips the interceptors if any are configured.
|
|
1937
|
+
*/
|
|
1938
|
+
_forceButtonClicked() {
|
|
1939
|
+
this.buttonClick.emit();
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
AbstractDbNgxButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractDbNgxButtonDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1943
|
+
AbstractDbNgxButtonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: AbstractDbNgxButtonDirective, inputs: { disabled: "disabled", working: "working", icon: "icon", text: "text" }, outputs: { buttonClick: "buttonClick" }, usesInheritance: true, ngImport: i0 });
|
|
1944
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractDbNgxButtonDirective, decorators: [{
|
|
1945
|
+
type: Directive
|
|
1946
|
+
}], ctorParameters: function () { return []; }, propDecorators: { disabled: [{
|
|
1947
|
+
type: Input
|
|
1948
|
+
}], working: [{
|
|
1949
|
+
type: Input
|
|
1950
|
+
}], icon: [{
|
|
1951
|
+
type: Input
|
|
1952
|
+
}], text: [{
|
|
1953
|
+
type: Input
|
|
1954
|
+
}], buttonClick: [{
|
|
1955
|
+
type: Output
|
|
1956
|
+
}] } });
|
|
1957
|
+
// MARK: Implementation
|
|
1958
|
+
/**
|
|
1959
|
+
* Provides an DbNgxButton directive.
|
|
1960
|
+
*/
|
|
1961
|
+
class DbNgxButtonDirective extends AbstractDbNgxButtonDirective {
|
|
1962
|
+
}
|
|
1963
|
+
DbNgxButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxButtonDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
1964
|
+
DbNgxButtonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxButtonDirective, selector: "[dbxButton]", providers: ProvideDbNgxButton(DbNgxButtonDirective), exportAs: ["dbxButton"], usesInheritance: true, ngImport: i0 });
|
|
1965
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxButtonDirective, decorators: [{
|
|
1966
|
+
type: Directive,
|
|
1967
|
+
args: [{
|
|
1968
|
+
selector: '[dbxButton]',
|
|
1969
|
+
exportAs: 'dbxButton',
|
|
1970
|
+
providers: ProvideDbNgxButton(DbNgxButtonDirective)
|
|
1971
|
+
}]
|
|
1972
|
+
}] });
|
|
1973
|
+
|
|
1974
|
+
/**
|
|
1975
|
+
* Context used for linking a button to a LoadingContext.
|
|
1976
|
+
*
|
|
1977
|
+
* It will be set working when the context is set loading.
|
|
1978
|
+
*/
|
|
1979
|
+
class DbNgxLoadingButtonDirective extends AbstractSubscriptionDirective {
|
|
1980
|
+
constructor(button, ngZone) {
|
|
1981
|
+
super();
|
|
1982
|
+
this.button = button;
|
|
1983
|
+
this.ngZone = ngZone;
|
|
1984
|
+
}
|
|
1985
|
+
/**
|
|
1986
|
+
* Sets a LoadingContext that is watched for the loading state.
|
|
1987
|
+
*/
|
|
1988
|
+
set context(context) {
|
|
1989
|
+
let subscription;
|
|
1990
|
+
if (context) {
|
|
1991
|
+
subscription = context.stream$.subscribe((x) => {
|
|
1992
|
+
this.ngZone.run(() => this.button.working = x.loading);
|
|
1993
|
+
});
|
|
1994
|
+
}
|
|
1995
|
+
this.sub = subscription;
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
DbNgxLoadingButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxLoadingButtonDirective, deps: [{ token: DbNgxButton, host: true }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1999
|
+
DbNgxLoadingButtonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxLoadingButtonDirective, selector: "[dbxLoadingButton]", inputs: { context: ["dbxLoadingButton", "context"] }, usesInheritance: true, ngImport: i0 });
|
|
2000
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxLoadingButtonDirective, decorators: [{
|
|
2001
|
+
type: Directive,
|
|
2002
|
+
args: [{
|
|
2003
|
+
selector: '[dbxLoadingButton]'
|
|
2004
|
+
}]
|
|
2005
|
+
}], ctorParameters: function () { return [{ type: DbNgxButton, decorators: [{
|
|
2006
|
+
type: Host
|
|
2007
|
+
}] }, { type: i0.NgZone }]; }, propDecorators: { context: [{
|
|
2008
|
+
type: Input,
|
|
2009
|
+
args: ['dbxLoadingButton']
|
|
2010
|
+
}] } });
|
|
2011
|
+
|
|
2012
|
+
class DbNgxCoreButtonModule {
|
|
2013
|
+
}
|
|
2014
|
+
DbNgxCoreButtonModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxCoreButtonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2015
|
+
DbNgxCoreButtonModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxCoreButtonModule, declarations: [DbNgxButtonDirective,
|
|
2016
|
+
DbNgxLoadingButtonDirective,
|
|
2017
|
+
DbNgxActionButtonTriggerDirective,
|
|
2018
|
+
DbNgxActionButtonDirective,
|
|
2019
|
+
DbNgxButtonSegueDirective], exports: [DbNgxButtonDirective,
|
|
2020
|
+
DbNgxLoadingButtonDirective,
|
|
2021
|
+
DbNgxActionButtonTriggerDirective,
|
|
2022
|
+
DbNgxActionButtonDirective,
|
|
2023
|
+
DbNgxButtonSegueDirective] });
|
|
2024
|
+
DbNgxCoreButtonModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxCoreButtonModule, imports: [[]] });
|
|
2025
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxCoreButtonModule, decorators: [{
|
|
2026
|
+
type: NgModule,
|
|
2027
|
+
args: [{
|
|
2028
|
+
imports: [],
|
|
2029
|
+
declarations: [
|
|
2030
|
+
DbNgxButtonDirective,
|
|
2031
|
+
DbNgxLoadingButtonDirective,
|
|
2032
|
+
DbNgxActionButtonTriggerDirective,
|
|
2033
|
+
DbNgxActionButtonDirective,
|
|
2034
|
+
DbNgxButtonSegueDirective
|
|
2035
|
+
],
|
|
2036
|
+
exports: [
|
|
2037
|
+
DbNgxButtonDirective,
|
|
2038
|
+
DbNgxLoadingButtonDirective,
|
|
2039
|
+
DbNgxActionButtonTriggerDirective,
|
|
2040
|
+
DbNgxActionButtonDirective,
|
|
2041
|
+
DbNgxButtonSegueDirective
|
|
2042
|
+
],
|
|
2043
|
+
}]
|
|
2044
|
+
}] });
|
|
2045
|
+
|
|
2046
|
+
/**
|
|
2047
|
+
* Pipe that takes in a date and number of minutes and outputs a formatted date.
|
|
2048
|
+
*/
|
|
2049
|
+
class DateFromToTimePipe {
|
|
2050
|
+
constructor(locale) {
|
|
2051
|
+
this.locale = locale;
|
|
2052
|
+
}
|
|
2053
|
+
transform(input, format, minutes) {
|
|
2054
|
+
return DateFromToTimePipe.formatFromTo(input, format, minutes, this.locale);
|
|
2055
|
+
}
|
|
2056
|
+
static formatFromTo(input, format, minutes, locale) {
|
|
2057
|
+
if (input) {
|
|
2058
|
+
const date = toJsDate(input);
|
|
2059
|
+
const endDate = addMinutes(date, minutes);
|
|
2060
|
+
const dateString = formatDate(date, format, locale);
|
|
2061
|
+
return dateString + ' - ' + formatToTimeString(endDate);
|
|
2062
|
+
}
|
|
2063
|
+
return undefined;
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
DateFromToTimePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DateFromToTimePipe, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Pipe });
|
|
2067
|
+
DateFromToTimePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DateFromToTimePipe, name: "dateFromPlusTo" });
|
|
2068
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DateFromToTimePipe, decorators: [{
|
|
2069
|
+
type: Pipe,
|
|
2070
|
+
args: [{ name: 'dateFromPlusTo' }]
|
|
2071
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2072
|
+
type: Inject,
|
|
2073
|
+
args: [LOCALE_ID]
|
|
2074
|
+
}] }]; } });
|
|
2075
|
+
|
|
2076
|
+
class MinutesStringPipe {
|
|
2077
|
+
transform(input) {
|
|
2078
|
+
const minutes = Number(input);
|
|
2079
|
+
if (input != null && !isNaN(minutes)) {
|
|
2080
|
+
if (minutes > 3600) {
|
|
2081
|
+
const unrounded = minutes / 3600;
|
|
2082
|
+
const days = Math.ceil(unrounded);
|
|
2083
|
+
return ((unrounded !== days) ? '~' : '') + days + ' days';
|
|
2084
|
+
}
|
|
2085
|
+
else if (minutes > 180) {
|
|
2086
|
+
const unrounded = minutes / 60;
|
|
2087
|
+
const hours = Math.ceil(unrounded);
|
|
2088
|
+
return ((unrounded !== hours) ? '~' : '') + hours + ' hours';
|
|
2089
|
+
}
|
|
2090
|
+
else {
|
|
2091
|
+
return minutes + ' minutes';
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
else {
|
|
2095
|
+
return undefined;
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
MinutesStringPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: MinutesStringPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
2100
|
+
MinutesStringPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: MinutesStringPipe, name: "minutesString", pure: false });
|
|
2101
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: MinutesStringPipe, decorators: [{
|
|
2102
|
+
type: Pipe,
|
|
2103
|
+
args: [{ name: 'minutesString', pure: false }]
|
|
2104
|
+
}] });
|
|
2105
|
+
|
|
2106
|
+
class ToJsDatePipe {
|
|
2107
|
+
static toJsDate(input) {
|
|
2108
|
+
return (input) ? toJsDate(input) : undefined;
|
|
2109
|
+
}
|
|
2110
|
+
transform(input) {
|
|
2111
|
+
return ToJsDatePipe.toJsDate(input);
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
ToJsDatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: ToJsDatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
2115
|
+
ToJsDatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: ToJsDatePipe, name: "toJsDate" });
|
|
2116
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: ToJsDatePipe, decorators: [{
|
|
2117
|
+
type: Pipe,
|
|
2118
|
+
args: [{ name: 'toJsDate' }]
|
|
2119
|
+
}] });
|
|
2120
|
+
|
|
2121
|
+
class TimeDistanceCountdownPipe {
|
|
2122
|
+
transform(input, soonString = 'Soon', unavailable = 'Not Available') {
|
|
2123
|
+
if (input) {
|
|
2124
|
+
const from = ToJsDatePipe.toJsDate(input);
|
|
2125
|
+
if (isPast(from)) {
|
|
2126
|
+
return soonString;
|
|
2127
|
+
}
|
|
2128
|
+
else {
|
|
2129
|
+
const to = new Date();
|
|
2130
|
+
return formatDistance(from, to, {
|
|
2131
|
+
addSuffix: true
|
|
2132
|
+
});
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
else {
|
|
2136
|
+
return unavailable;
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
TimeDistanceCountdownPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: TimeDistanceCountdownPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
2141
|
+
TimeDistanceCountdownPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: TimeDistanceCountdownPipe, name: "timeCountdownDistance", pure: false });
|
|
2142
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: TimeDistanceCountdownPipe, decorators: [{
|
|
2143
|
+
type: Pipe,
|
|
2144
|
+
args: [{ name: 'timeCountdownDistance', pure: false }]
|
|
2145
|
+
}] });
|
|
2146
|
+
class TimeDistancePipe {
|
|
2147
|
+
transform(input, to = new Date(), unavailable = 'Not Available') {
|
|
2148
|
+
if (input) {
|
|
2149
|
+
const from = ToJsDatePipe.toJsDate(input);
|
|
2150
|
+
return formatDistance(from, to, {
|
|
2151
|
+
addSuffix: true
|
|
2152
|
+
});
|
|
2153
|
+
}
|
|
2154
|
+
else {
|
|
2155
|
+
return unavailable;
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
TimeDistancePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: TimeDistancePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
2160
|
+
TimeDistancePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: TimeDistancePipe, name: "timeDistance", pure: false });
|
|
2161
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: TimeDistancePipe, decorators: [{
|
|
2162
|
+
type: Pipe,
|
|
2163
|
+
args: [{ name: 'timeDistance', pure: false }]
|
|
2164
|
+
}] });
|
|
2165
|
+
|
|
2166
|
+
class ToMinutesPipe {
|
|
2167
|
+
transform(milliseconds) {
|
|
2168
|
+
if (milliseconds) {
|
|
2169
|
+
return Math.floor(milliseconds / (60 * 1000));
|
|
2170
|
+
}
|
|
2171
|
+
return milliseconds;
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
ToMinutesPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: ToMinutesPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
2175
|
+
ToMinutesPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: ToMinutesPipe, name: "toMinutes" });
|
|
2176
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: ToMinutesPipe, decorators: [{
|
|
2177
|
+
type: Pipe,
|
|
2178
|
+
args: [{ name: 'toMinutes' }]
|
|
2179
|
+
}] });
|
|
2180
|
+
|
|
2181
|
+
/**
|
|
2182
|
+
* Pipe that takes in a date and appends the distance to it in parenthesis.
|
|
2183
|
+
*/
|
|
2184
|
+
class DateFormatDistancePipe {
|
|
2185
|
+
constructor(locale) {
|
|
2186
|
+
this.locale = locale;
|
|
2187
|
+
}
|
|
2188
|
+
transform(input, format, includeSeconds = false) {
|
|
2189
|
+
if (input) {
|
|
2190
|
+
const date = toJsDate(input);
|
|
2191
|
+
if (isValid(date)) {
|
|
2192
|
+
const dateString = formatDate(date, format, this.locale);
|
|
2193
|
+
const distance = formatDistanceToNow(date, {
|
|
2194
|
+
includeSeconds,
|
|
2195
|
+
addSuffix: true
|
|
2196
|
+
});
|
|
2197
|
+
return `${dateString} (${distance})`;
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
return undefined;
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
DateFormatDistancePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DateFormatDistancePipe, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Pipe });
|
|
2204
|
+
DateFormatDistancePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DateFormatDistancePipe, name: "dateFormatDistance", pure: false });
|
|
2205
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DateFormatDistancePipe, decorators: [{
|
|
2206
|
+
type: Pipe,
|
|
2207
|
+
args: [{ name: 'dateFormatDistance', pure: false }]
|
|
2208
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2209
|
+
type: Inject,
|
|
2210
|
+
args: [LOCALE_ID]
|
|
2211
|
+
}] }]; } });
|
|
2212
|
+
|
|
2213
|
+
class DateDistancePipe {
|
|
2214
|
+
transform(input, to, unavailable = 'Not Available') {
|
|
2215
|
+
if (input) {
|
|
2216
|
+
const defaultTo = !to;
|
|
2217
|
+
if (defaultTo) {
|
|
2218
|
+
to = new Date();
|
|
2219
|
+
}
|
|
2220
|
+
const from = ToJsDatePipe.toJsDate(input);
|
|
2221
|
+
const fromStart = startOfDay(from);
|
|
2222
|
+
const toStart = startOfDay(to);
|
|
2223
|
+
if (isSameDay(fromStart, toStart)) {
|
|
2224
|
+
let text;
|
|
2225
|
+
if (defaultTo || isSameDay(from, new Date())) {
|
|
2226
|
+
text = 'Today';
|
|
2227
|
+
}
|
|
2228
|
+
else {
|
|
2229
|
+
text = 'Same Day';
|
|
2230
|
+
}
|
|
2231
|
+
return text;
|
|
2232
|
+
}
|
|
2233
|
+
else {
|
|
2234
|
+
return formatDistance(fromStart, toStart, {
|
|
2235
|
+
addSuffix: true
|
|
2236
|
+
});
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
else {
|
|
2240
|
+
return unavailable;
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
DateDistancePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DateDistancePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
2245
|
+
DateDistancePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DateDistancePipe, name: "dateDistance", pure: false });
|
|
2246
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DateDistancePipe, decorators: [{
|
|
2247
|
+
type: Pipe,
|
|
2248
|
+
args: [{ name: 'dateDistance', pure: false }]
|
|
2249
|
+
}] });
|
|
2250
|
+
|
|
2251
|
+
class DbNgxDatePipeModule {
|
|
2252
|
+
}
|
|
2253
|
+
DbNgxDatePipeModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxDatePipeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2254
|
+
DbNgxDatePipeModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxDatePipeModule, declarations: [DateFromToTimePipe,
|
|
2255
|
+
DateFormatDistancePipe,
|
|
2256
|
+
MinutesStringPipe,
|
|
2257
|
+
TimeDistanceCountdownPipe,
|
|
2258
|
+
TimeDistancePipe,
|
|
2259
|
+
DateDistancePipe,
|
|
2260
|
+
ToJsDatePipe,
|
|
2261
|
+
ToMinutesPipe], exports: [DateFromToTimePipe,
|
|
2262
|
+
DateFormatDistancePipe,
|
|
2263
|
+
MinutesStringPipe,
|
|
2264
|
+
TimeDistanceCountdownPipe,
|
|
2265
|
+
TimeDistancePipe,
|
|
2266
|
+
DateDistancePipe,
|
|
2267
|
+
ToJsDatePipe,
|
|
2268
|
+
ToMinutesPipe] });
|
|
2269
|
+
DbNgxDatePipeModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxDatePipeModule });
|
|
2270
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxDatePipeModule, decorators: [{
|
|
2271
|
+
type: NgModule,
|
|
2272
|
+
args: [{
|
|
2273
|
+
exports: [
|
|
2274
|
+
DateFromToTimePipe,
|
|
2275
|
+
DateFormatDistancePipe,
|
|
2276
|
+
MinutesStringPipe,
|
|
2277
|
+
TimeDistanceCountdownPipe,
|
|
2278
|
+
TimeDistancePipe,
|
|
2279
|
+
DateDistancePipe,
|
|
2280
|
+
ToJsDatePipe,
|
|
2281
|
+
ToMinutesPipe
|
|
2282
|
+
],
|
|
2283
|
+
declarations: [
|
|
2284
|
+
DateFromToTimePipe,
|
|
2285
|
+
DateFormatDistancePipe,
|
|
2286
|
+
MinutesStringPipe,
|
|
2287
|
+
TimeDistanceCountdownPipe,
|
|
2288
|
+
TimeDistancePipe,
|
|
2289
|
+
DateDistancePipe,
|
|
2290
|
+
ToJsDatePipe,
|
|
2291
|
+
ToMinutesPipe
|
|
2292
|
+
]
|
|
2293
|
+
}]
|
|
2294
|
+
}] });
|
|
2295
|
+
|
|
2296
|
+
/**
|
|
2297
|
+
* Instance used by components to inject content based on the configuration into the view.
|
|
2298
|
+
*/
|
|
2299
|
+
class DbNgxInjectedComponentInstance {
|
|
2300
|
+
constructor() {
|
|
2301
|
+
this._subscriptionObject = new SubscriptionObject();
|
|
2302
|
+
this._config = new BehaviorSubject(undefined);
|
|
2303
|
+
this._template = new BehaviorSubject(undefined);
|
|
2304
|
+
this._content = new BehaviorSubject(undefined);
|
|
2305
|
+
this._componentRef = new BehaviorSubject(undefined);
|
|
2306
|
+
this.config$ = this._config.pipe(distinctUntilChanged());
|
|
2307
|
+
this.template$ = this._template.pipe(distinctUntilChanged());
|
|
2308
|
+
this.content$ = this._content.pipe(filterMaybe(), distinctUntilChanged(), shareReplay(1));
|
|
2309
|
+
}
|
|
2310
|
+
get config() {
|
|
2311
|
+
return this._config.value;
|
|
2312
|
+
}
|
|
2313
|
+
set config(config) {
|
|
2314
|
+
this._config.next(config);
|
|
2315
|
+
}
|
|
2316
|
+
get template() {
|
|
2317
|
+
return this._template.value;
|
|
2318
|
+
}
|
|
2319
|
+
set template(template) {
|
|
2320
|
+
this._template.next(template);
|
|
2321
|
+
}
|
|
2322
|
+
get content() {
|
|
2323
|
+
return this._content.value;
|
|
2324
|
+
}
|
|
2325
|
+
set content(content) {
|
|
2326
|
+
this._content.next(content);
|
|
2327
|
+
}
|
|
2328
|
+
get componentRef() {
|
|
2329
|
+
return this._componentRef.value;
|
|
2330
|
+
}
|
|
2331
|
+
set componentRef(componentRef) {
|
|
2332
|
+
this._componentRef.next(componentRef);
|
|
2333
|
+
}
|
|
2334
|
+
init() {
|
|
2335
|
+
// Wait until the first of either of the two inputs comes in as not defined, and then emit.
|
|
2336
|
+
// We filter the first maybe here between the two items.
|
|
2337
|
+
const configTemplateObs = combineLatest([this.config$, this.template$]).pipe(map(([config, template]) => {
|
|
2338
|
+
if (config || template) {
|
|
2339
|
+
return {
|
|
2340
|
+
config,
|
|
2341
|
+
template
|
|
2342
|
+
};
|
|
2343
|
+
}
|
|
2344
|
+
else {
|
|
2345
|
+
return undefined;
|
|
2346
|
+
}
|
|
2347
|
+
}), skipFirstMaybe());
|
|
2348
|
+
this._subscriptionObject.subscription = combineLatest([configTemplateObs, this.content$]).subscribe(([inputConfig, content]) => {
|
|
2349
|
+
const { config, template } = inputConfig ?? {};
|
|
2350
|
+
this._reset(content);
|
|
2351
|
+
if (config) {
|
|
2352
|
+
this._initComponent(config, content);
|
|
2353
|
+
}
|
|
2354
|
+
else if (template) {
|
|
2355
|
+
this._initTemplate(template, content);
|
|
2356
|
+
}
|
|
2357
|
+
});
|
|
2358
|
+
}
|
|
2359
|
+
destroy() {
|
|
2360
|
+
this._config.complete();
|
|
2361
|
+
this._template.complete();
|
|
2362
|
+
this._content.complete();
|
|
2363
|
+
this._componentRef.complete();
|
|
2364
|
+
}
|
|
2365
|
+
_initComponent(config, content) {
|
|
2366
|
+
content.clear();
|
|
2367
|
+
const { init, injector, componentClass } = config;
|
|
2368
|
+
const componentRef = content.createComponent(componentClass, { injector });
|
|
2369
|
+
const instance = componentRef.instance;
|
|
2370
|
+
if (init) {
|
|
2371
|
+
init(instance);
|
|
2372
|
+
}
|
|
2373
|
+
this.componentRef = componentRef;
|
|
2374
|
+
}
|
|
2375
|
+
_initTemplate(config, content) {
|
|
2376
|
+
content.clear();
|
|
2377
|
+
const { templateRef, viewRef } = config;
|
|
2378
|
+
if (templateRef) {
|
|
2379
|
+
content.createEmbeddedView(templateRef);
|
|
2380
|
+
// TODO: Figure out if these items need to be destroyed or not when this item is destroyed. If so, we need a reference to destroy.
|
|
2381
|
+
}
|
|
2382
|
+
else if (viewRef) {
|
|
2383
|
+
content.insert(viewRef);
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
_reset(content) {
|
|
2387
|
+
if (this.componentRef) {
|
|
2388
|
+
content.clear();
|
|
2389
|
+
this.componentRef = undefined;
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
/**
|
|
2395
|
+
* Abstract directive that injects content based on the configuration into the view.
|
|
2396
|
+
*/
|
|
2397
|
+
class AbstractDbNgxInjectedDirective {
|
|
2398
|
+
constructor() {
|
|
2399
|
+
this._instance = new DbNgxInjectedComponentInstance();
|
|
2400
|
+
}
|
|
2401
|
+
ngOnInit() {
|
|
2402
|
+
this._instance.init();
|
|
2403
|
+
}
|
|
2404
|
+
ngOnDestroy() {
|
|
2405
|
+
this._instance.destroy();
|
|
2406
|
+
}
|
|
2407
|
+
setConfig(config) {
|
|
2408
|
+
this._instance.config = config;
|
|
2409
|
+
}
|
|
2410
|
+
setTemplate(template) {
|
|
2411
|
+
this._instance.template = template;
|
|
2412
|
+
}
|
|
2413
|
+
setContent(content) {
|
|
2414
|
+
this._instance.content = content;
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
AbstractDbNgxInjectedDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractDbNgxInjectedDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2418
|
+
AbstractDbNgxInjectedDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: AbstractDbNgxInjectedDirective, ngImport: i0 });
|
|
2419
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractDbNgxInjectedDirective, decorators: [{
|
|
2420
|
+
type: Directive
|
|
2421
|
+
}] });
|
|
2422
|
+
|
|
2423
|
+
/**
|
|
2424
|
+
* Component that injects content based on the configuration into the view.
|
|
2425
|
+
*/
|
|
2426
|
+
class DbNgxInjectedComponent extends AbstractDbNgxInjectedDirective {
|
|
2427
|
+
set config(config) {
|
|
2428
|
+
this.setConfig(config);
|
|
2429
|
+
}
|
|
2430
|
+
set template(template) {
|
|
2431
|
+
this.setTemplate(template);
|
|
2432
|
+
}
|
|
2433
|
+
set content(content) {
|
|
2434
|
+
this.setContent(content);
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
DbNgxInjectedComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxInjectedComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
2438
|
+
DbNgxInjectedComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: DbNgxInjectedComponent, selector: "dbx-injected-content, [dbx-injected-content]", inputs: { config: "config", template: "template" }, viewQueries: [{ propertyName: "content", first: true, predicate: ["content"], descendants: true, read: ViewContainerRef, static: true }], usesInheritance: true, ngImport: i0, template: `<ng-template #content></ng-template>`, isInline: true });
|
|
2439
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxInjectedComponent, decorators: [{
|
|
2440
|
+
type: Component,
|
|
2441
|
+
args: [{
|
|
2442
|
+
selector: 'dbx-injected-content, [dbx-injected-content]',
|
|
2443
|
+
template: `<ng-template #content></ng-template>`
|
|
2444
|
+
}]
|
|
2445
|
+
}], propDecorators: { config: [{
|
|
2446
|
+
type: Input
|
|
2447
|
+
}], template: [{
|
|
2448
|
+
type: Input
|
|
2449
|
+
}], content: [{
|
|
2450
|
+
type: ViewChild,
|
|
2451
|
+
args: ['content', { static: true, read: ViewContainerRef }]
|
|
2452
|
+
}] } });
|
|
2453
|
+
|
|
2454
|
+
class DbNgxInjectedComponentModule {
|
|
2455
|
+
}
|
|
2456
|
+
DbNgxInjectedComponentModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxInjectedComponentModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2457
|
+
DbNgxInjectedComponentModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxInjectedComponentModule, declarations: [DbNgxInjectedComponent], imports: [CommonModule], exports: [DbNgxInjectedComponent] });
|
|
2458
|
+
DbNgxInjectedComponentModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxInjectedComponentModule, imports: [[
|
|
2459
|
+
CommonModule
|
|
2460
|
+
]] });
|
|
2461
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbNgxInjectedComponentModule, decorators: [{
|
|
2462
|
+
type: NgModule,
|
|
2463
|
+
args: [{
|
|
2464
|
+
imports: [
|
|
2465
|
+
CommonModule
|
|
2466
|
+
],
|
|
2467
|
+
declarations: [
|
|
2468
|
+
DbNgxInjectedComponent
|
|
2469
|
+
],
|
|
2470
|
+
exports: [
|
|
2471
|
+
DbNgxInjectedComponent
|
|
2472
|
+
],
|
|
2473
|
+
}]
|
|
2474
|
+
}] });
|
|
2475
|
+
|
|
2476
|
+
class StringifySimpleStorageAccessorConverter {
|
|
2477
|
+
stringifyValue(value) {
|
|
2478
|
+
return JSON.stringify(value);
|
|
2479
|
+
}
|
|
2480
|
+
parseValue(data) {
|
|
2481
|
+
return JSON.parse(data);
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
class WrapperSimpleStorageAccessorDelegate {
|
|
2485
|
+
constructor(_delegate, _converter) {
|
|
2486
|
+
this._delegate = _delegate;
|
|
2487
|
+
this._converter = _converter;
|
|
2488
|
+
}
|
|
2489
|
+
get(key) {
|
|
2490
|
+
return this._delegate.get(key);
|
|
2491
|
+
}
|
|
2492
|
+
set(key, value) {
|
|
2493
|
+
return this._delegate.set(key, value);
|
|
2494
|
+
}
|
|
2495
|
+
remove(key) {
|
|
2496
|
+
return this._delegate.remove(key);
|
|
2497
|
+
}
|
|
2498
|
+
clear() {
|
|
2499
|
+
return this._delegate.clear();
|
|
2500
|
+
}
|
|
2501
|
+
all(prefix) {
|
|
2502
|
+
return this._delegate.all(prefix);
|
|
2503
|
+
}
|
|
2504
|
+
allKeys(prefix) {
|
|
2505
|
+
return this._delegate.allKeys(prefix);
|
|
2506
|
+
}
|
|
2507
|
+
stringifyValue(value) {
|
|
2508
|
+
return this._converter.stringifyValue(value);
|
|
2509
|
+
}
|
|
2510
|
+
parseValue(data) {
|
|
2511
|
+
return this._converter.parseValue(data);
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
/**
|
|
2515
|
+
* LimitedStorageAccessor implementation that uses a Delegate
|
|
2516
|
+
*/
|
|
2517
|
+
class SimpleStorageAccessor {
|
|
2518
|
+
constructor(_delegate, config) {
|
|
2519
|
+
this._delegate = _delegate;
|
|
2520
|
+
const prefix = config.prefix;
|
|
2521
|
+
const prefixSplitter = config.prefixSplitter ?? SimpleStorageAccessor.PREFIX_SPLITTER;
|
|
2522
|
+
this.assertValidStorageKeyPrefix(prefix, prefixSplitter);
|
|
2523
|
+
const fullPrefix = `${prefix}${prefixSplitter}`;
|
|
2524
|
+
this._config = {
|
|
2525
|
+
...config,
|
|
2526
|
+
prefixSplitter,
|
|
2527
|
+
fullPrefix
|
|
2528
|
+
};
|
|
2529
|
+
}
|
|
2530
|
+
// MARK: LimitedStorageAccessor
|
|
2531
|
+
get(inputKey) {
|
|
2532
|
+
const storeKey = this.makeStorageKey(inputKey);
|
|
2533
|
+
return this._delegate.get(storeKey).pipe(map((storedData) => {
|
|
2534
|
+
if (storedData) {
|
|
2535
|
+
const readStoredData = this.readStoredData(storedData);
|
|
2536
|
+
if (!readStoredData.expired) {
|
|
2537
|
+
return readStoredData.convertedData;
|
|
2538
|
+
}
|
|
2539
|
+
else {
|
|
2540
|
+
throw new DataIsExpiredError(readStoredData);
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2543
|
+
else {
|
|
2544
|
+
throw new DataDoesNotExistError();
|
|
2545
|
+
}
|
|
2546
|
+
}));
|
|
2547
|
+
}
|
|
2548
|
+
set(inputKey, inputValue) {
|
|
2549
|
+
const storeKey = this.makeStorageKey(inputKey);
|
|
2550
|
+
const storeData = this.buildStoredData(inputValue);
|
|
2551
|
+
const data = JSON.stringify(storeData);
|
|
2552
|
+
return this._delegate.set(storeKey, data);
|
|
2553
|
+
}
|
|
2554
|
+
remove(key) {
|
|
2555
|
+
const storeKey = this.makeStorageKey(key);
|
|
2556
|
+
return this._delegate.remove(storeKey);
|
|
2557
|
+
}
|
|
2558
|
+
all() {
|
|
2559
|
+
return this._delegate.all(this._config.fullPrefix).pipe(map((allStoredData) => {
|
|
2560
|
+
return allStoredData.map((storedData) => {
|
|
2561
|
+
const readStoredData = this.readStoredData(storedData);
|
|
2562
|
+
if (!readStoredData.expired) {
|
|
2563
|
+
return readStoredData.convertedData;
|
|
2564
|
+
}
|
|
2565
|
+
else {
|
|
2566
|
+
return null;
|
|
2567
|
+
}
|
|
2568
|
+
}).filter(filterMaybeValuesFn);
|
|
2569
|
+
}));
|
|
2570
|
+
}
|
|
2571
|
+
allKeys() {
|
|
2572
|
+
return this._delegate.allKeys(this._config.fullPrefix).pipe(map((keys) => keys.map(x => this.decodeStorageKey(x))));
|
|
2573
|
+
}
|
|
2574
|
+
clear() {
|
|
2575
|
+
return this._delegate.clear();
|
|
2576
|
+
}
|
|
2577
|
+
// MARK: Stored Values
|
|
2578
|
+
readStoredData(storedDataString) {
|
|
2579
|
+
const storedData = JSON.parse(storedDataString);
|
|
2580
|
+
const expired = this.isExpiredStoredData(storedData);
|
|
2581
|
+
const convertedData = this._delegate.parseValue(storedData.data);
|
|
2582
|
+
return {
|
|
2583
|
+
...storedData,
|
|
2584
|
+
expired,
|
|
2585
|
+
convertedData
|
|
2586
|
+
};
|
|
2587
|
+
}
|
|
2588
|
+
buildStoredData(value) {
|
|
2589
|
+
return {
|
|
2590
|
+
storedAt: unixTimeNumberForNow(),
|
|
2591
|
+
data: this.stringifyValue(value)
|
|
2592
|
+
};
|
|
2593
|
+
}
|
|
2594
|
+
isExpiredStoredData(storeData) {
|
|
2595
|
+
const expiresIn = this._config.expiresIn;
|
|
2596
|
+
if (expiresIn) {
|
|
2597
|
+
if (storeData.storedAt) {
|
|
2598
|
+
return timeNumberHasExpired(storeData.storedAt, expiresIn);
|
|
2599
|
+
}
|
|
2600
|
+
return true;
|
|
2601
|
+
}
|
|
2602
|
+
else {
|
|
2603
|
+
return false;
|
|
2604
|
+
}
|
|
2605
|
+
}
|
|
2606
|
+
// MARK: Internal
|
|
2607
|
+
assertValidStorageKeyPrefix(prefix, prefixSplitter) {
|
|
2608
|
+
if (!prefixSplitter) {
|
|
2609
|
+
throw new Error('Invalid storage key prefix splitter. Must be defined and not empty.');
|
|
2610
|
+
}
|
|
2611
|
+
if (!this.isValidStorageKeyPrefix(prefix, prefixSplitter)) {
|
|
2612
|
+
throw new Error('Invalid storage key prefix.');
|
|
2613
|
+
}
|
|
2614
|
+
}
|
|
2615
|
+
isValidStorageKeyPrefix(prefix, prefixSpltter) {
|
|
2616
|
+
return Boolean(prefix && prefix.indexOf(prefixSpltter) === -1);
|
|
2617
|
+
}
|
|
2618
|
+
makeStorageKey(key) {
|
|
2619
|
+
return `${this._config.prefix}${this._config.prefixSplitter}${String(key)}`;
|
|
2620
|
+
}
|
|
2621
|
+
isKeyOfAccessor(storageKey) {
|
|
2622
|
+
return storageKey.startsWith(this._config.fullPrefix);
|
|
2623
|
+
}
|
|
2624
|
+
decodeStorageKey(storageKey) {
|
|
2625
|
+
const split = storageKey.split(this._config.prefixSplitter, 2);
|
|
2626
|
+
return split[1];
|
|
2627
|
+
}
|
|
2628
|
+
stringifyValue(value) {
|
|
2629
|
+
return this._delegate.stringifyValue(value);
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
SimpleStorageAccessor.PREFIX_SPLITTER = '::';
|
|
2633
|
+
|
|
2634
|
+
/**
|
|
2635
|
+
* Simple StorageAccessor implementation that wraps a FullStorageObject.
|
|
2636
|
+
*/
|
|
2637
|
+
class StringStorageAccessor {
|
|
2638
|
+
constructor(_storage) {
|
|
2639
|
+
this._storage = _storage;
|
|
2640
|
+
}
|
|
2641
|
+
get(key) {
|
|
2642
|
+
return new Observable((x) => {
|
|
2643
|
+
const value = this._storage.getItem(key);
|
|
2644
|
+
x.next(value);
|
|
2645
|
+
x.complete();
|
|
2646
|
+
});
|
|
2647
|
+
}
|
|
2648
|
+
set(key, value) {
|
|
2649
|
+
return new Observable((x) => {
|
|
2650
|
+
this._storage.setItem(key, value);
|
|
2651
|
+
x.next();
|
|
2652
|
+
x.complete();
|
|
2653
|
+
});
|
|
2654
|
+
}
|
|
2655
|
+
remove(key) {
|
|
2656
|
+
return new Observable((x) => {
|
|
2657
|
+
this._storage.removeItem(key);
|
|
2658
|
+
x.next();
|
|
2659
|
+
x.complete();
|
|
2660
|
+
});
|
|
2661
|
+
}
|
|
2662
|
+
clear() {
|
|
2663
|
+
const removed = this._storage.removeAll();
|
|
2664
|
+
return new Observable((x) => {
|
|
2665
|
+
x.next(removed);
|
|
2666
|
+
x.complete();
|
|
2667
|
+
});
|
|
2668
|
+
}
|
|
2669
|
+
all() {
|
|
2670
|
+
return this.allKeys().pipe(map(x => x.map(y => this._storage.getItem(y))), shareReplay(1));
|
|
2671
|
+
}
|
|
2672
|
+
allKeys() {
|
|
2673
|
+
return new Observable((x) => {
|
|
2674
|
+
const result = StorageObjectUtility.allKeysFromStorageObject(this._storage);
|
|
2675
|
+
x.next(result);
|
|
2676
|
+
x.complete();
|
|
2677
|
+
});
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
|
|
2681
|
+
const DEFAULT_STORAGE_OBJECT_TOKEN = new InjectionToken('DEFAULT_STORAGE_OBJECT');
|
|
2682
|
+
const DEFAULT_STORAGE_ACCESSOR_FACTORY_TOKEN = new InjectionToken('DEFAULT_STORAGE_ACCESSOR_FACTORY');
|
|
2683
|
+
|
|
2684
|
+
/**
|
|
2685
|
+
* Used for building SimpleStorageAccessor instances from SimpleStorageAccessorConfig.
|
|
2686
|
+
*/
|
|
2687
|
+
class SimpleStorageAccessorFactory {
|
|
2688
|
+
constructor(storageObject) {
|
|
2689
|
+
this.storageObject = storageObject;
|
|
2690
|
+
}
|
|
2691
|
+
createStorageAccessor(config) {
|
|
2692
|
+
const storage = config.storage ?? new StringStorageAccessor(this.storageObject);
|
|
2693
|
+
const converter = config.converter ?? new StringifySimpleStorageAccessorConverter();
|
|
2694
|
+
const delegate = new WrapperSimpleStorageAccessorDelegate(storage, converter);
|
|
2695
|
+
const accessorConfig = {
|
|
2696
|
+
prefix: config.prefix
|
|
2697
|
+
};
|
|
2698
|
+
return new SimpleStorageAccessor(delegate, accessorConfig);
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
SimpleStorageAccessorFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: SimpleStorageAccessorFactory, deps: [{ token: DEFAULT_STORAGE_OBJECT_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2702
|
+
SimpleStorageAccessorFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: SimpleStorageAccessorFactory });
|
|
2703
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: SimpleStorageAccessorFactory, decorators: [{
|
|
2704
|
+
type: Injectable
|
|
2705
|
+
}], ctorParameters: function () { return [{ type: i1$3.FullStorageObject, decorators: [{
|
|
2706
|
+
type: Inject,
|
|
2707
|
+
args: [DEFAULT_STORAGE_OBJECT_TOKEN]
|
|
2708
|
+
}] }]; } });
|
|
2709
|
+
|
|
2710
|
+
/**
|
|
2711
|
+
* Stored object accessor that can get/set/remove via a key, or be cleared entirely.
|
|
2712
|
+
*/
|
|
2713
|
+
class LimitedStorageAccessor {
|
|
2714
|
+
}
|
|
2715
|
+
/**
|
|
2716
|
+
* LimitedStorageAccessor extension that has knowledge of all stored keys.
|
|
2717
|
+
*/
|
|
2718
|
+
class StorageAccessor extends LimitedStorageAccessor {
|
|
2719
|
+
}
|
|
2720
|
+
/**
|
|
2721
|
+
* StorageAccessor-like object that has immediate/synchronous functionality for get/set.
|
|
2722
|
+
*/
|
|
2723
|
+
class InstantStorageAccessor {
|
|
2724
|
+
}
|
|
2725
|
+
|
|
2726
|
+
/**
|
|
2727
|
+
* StorageObject using LocalStorage.
|
|
2728
|
+
*/
|
|
2729
|
+
class FullLocalStorageObject {
|
|
2730
|
+
constructor(_localStorage) {
|
|
2731
|
+
this._localStorage = _localStorage;
|
|
2732
|
+
}
|
|
2733
|
+
get isPersistant() {
|
|
2734
|
+
return true;
|
|
2735
|
+
}
|
|
2736
|
+
get isAvailable() {
|
|
2737
|
+
const test = '_T_E_S_T_';
|
|
2738
|
+
try {
|
|
2739
|
+
// Tests setting and removing an item. These will throw an
|
|
2740
|
+
// exception if the localstorage is not available
|
|
2741
|
+
this._localStorage.setItem(test, test);
|
|
2742
|
+
this._localStorage.removeItem(test);
|
|
2743
|
+
return true;
|
|
2744
|
+
}
|
|
2745
|
+
catch (e) {
|
|
2746
|
+
return false;
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
get length() {
|
|
2750
|
+
return this._localStorage.length;
|
|
2751
|
+
}
|
|
2752
|
+
getItem(key) {
|
|
2753
|
+
return this._localStorage.getItem(key);
|
|
2754
|
+
}
|
|
2755
|
+
setItem(key, item) {
|
|
2756
|
+
this._localStorage.setItem(key, item);
|
|
2757
|
+
}
|
|
2758
|
+
removeItem(key) {
|
|
2759
|
+
this._localStorage.removeItem(key);
|
|
2760
|
+
}
|
|
2761
|
+
key(index) {
|
|
2762
|
+
return this._localStorage.key(index);
|
|
2763
|
+
}
|
|
2764
|
+
removeAll() {
|
|
2765
|
+
const keys = StorageObjectUtility.allKeysFromStorageObject(this);
|
|
2766
|
+
keys.forEach(x => this.removeItem(x));
|
|
2767
|
+
return keys;
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
|
|
2771
|
+
/**
|
|
2772
|
+
* FullStorageObject implementation that uses a localstorage that entirely resides in memory.
|
|
2773
|
+
*/
|
|
2774
|
+
class MemoryStorageObject extends FullLocalStorageObject {
|
|
2775
|
+
get isLastingStorage() {
|
|
2776
|
+
return false;
|
|
2777
|
+
}
|
|
2778
|
+
get isAvailable() {
|
|
2779
|
+
return true;
|
|
2780
|
+
}
|
|
2781
|
+
constructor() {
|
|
2782
|
+
super(SHARED_MEMORY_STORAGE);
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
|
|
2786
|
+
function defaultStorageObjectFactory() {
|
|
2787
|
+
let storageObject = new FullLocalStorageObject(localStorage);
|
|
2788
|
+
if (!storageObject.isAvailable) {
|
|
2789
|
+
storageObject = new MemoryStorageObject();
|
|
2790
|
+
}
|
|
2791
|
+
return storageObject;
|
|
2792
|
+
}
|
|
2793
|
+
class AppStorageModule {
|
|
2794
|
+
static forRoot() {
|
|
2795
|
+
return {
|
|
2796
|
+
ngModule: AppStorageModule,
|
|
2797
|
+
providers: [{
|
|
2798
|
+
provide: DEFAULT_STORAGE_OBJECT_TOKEN,
|
|
2799
|
+
useFactory: defaultStorageObjectFactory
|
|
2800
|
+
}, {
|
|
2801
|
+
provide: DEFAULT_STORAGE_ACCESSOR_FACTORY_TOKEN,
|
|
2802
|
+
useClass: SimpleStorageAccessorFactory
|
|
2803
|
+
}, {
|
|
2804
|
+
provide: SimpleStorageAccessorFactory,
|
|
2805
|
+
useExisting: DEFAULT_STORAGE_ACCESSOR_FACTORY_TOKEN
|
|
2806
|
+
}]
|
|
2807
|
+
};
|
|
2808
|
+
}
|
|
2809
|
+
}
|
|
2810
|
+
AppStorageModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AppStorageModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2811
|
+
AppStorageModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AppStorageModule });
|
|
2812
|
+
AppStorageModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AppStorageModule });
|
|
2813
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AppStorageModule, decorators: [{
|
|
2814
|
+
type: NgModule
|
|
2815
|
+
}] });
|
|
2816
|
+
|
|
2817
|
+
/**
|
|
2818
|
+
* Triggers a detection change on the input view as long as the view has not been destroyed.
|
|
2819
|
+
*
|
|
2820
|
+
* @param cdRef
|
|
2821
|
+
*/
|
|
2822
|
+
function safeDetectChanges(cdRef) {
|
|
2823
|
+
if (!cdRef.destroyed) {
|
|
2824
|
+
cdRef.detectChanges();
|
|
2825
|
+
}
|
|
2826
|
+
}
|
|
2827
|
+
/**
|
|
2828
|
+
* Used to check an injected ElementRef that wraps an ng-content injection point whether or not any content was injected,
|
|
2829
|
+
* or more specifically if the parent component passed any target content to the child. This will still return true if
|
|
2830
|
+
* passed content is empty.
|
|
2831
|
+
*
|
|
2832
|
+
* TS:
|
|
2833
|
+
* @ViewChild('customLoading', { static: false }) customCustom: ElementRef;
|
|
2834
|
+
*
|
|
2835
|
+
* HTML:
|
|
2836
|
+
* <div #customContent>
|
|
2837
|
+
* <ng-content select="[content]"></ng-content>
|
|
2838
|
+
* </div>
|
|
2839
|
+
*/
|
|
2840
|
+
function checkNgContentWrapperHasContent(ref) {
|
|
2841
|
+
// https://github.com/angular/angular/issues/26083
|
|
2842
|
+
let hasContent = false;
|
|
2843
|
+
if (ref != null) {
|
|
2844
|
+
const childNodes = ref.nativeElement.childNodes;
|
|
2845
|
+
const hasChildNodes = childNodes && childNodes.length > 0;
|
|
2846
|
+
hasContent = Boolean(hasChildNodes);
|
|
2847
|
+
}
|
|
2848
|
+
return hasContent;
|
|
2849
|
+
}
|
|
2850
|
+
|
|
2851
|
+
/**
|
|
2852
|
+
* Generated bundle index. Do not edit.
|
|
2853
|
+
*/
|
|
2854
|
+
|
|
2855
|
+
export { APP_ACTION_DISABLED_DIRECTIVE_KEY, APP_ACTION_DISABLED_UNTIL_MODIFIED_DIRECTIVE_KEY, AbstractDbNgxAnchorDirective, AbstractDbNgxButtonDirective, AbstractDbNgxInjectedDirective, AbstractLockSetSubscriptionDirective, AbstractSubscriptionDirective, AbstractTransitionWatcherDirective, ActionContextBaseSource, ActionContextMachine, ActionContextStore, ActionContextStoreSource, ActionContextStoreSourceInstance, ActionContextStoreSourceMap, ActionSnackbarDefaultType, ActionSnackbarEventType, ActionState, AnchorType, AppStorageModule, DEFAULT_ACTION_DISABLED_KEY, DEFAULT_ACTION_MAP_WORKING_DISABLED_KEY, DEFAULT_SNACKBAR_DIRECTIVE_DURATION, DEFAULT_SNACKBAR_UNDO_DIRECTIVE_DURATION, DEFAULT_STORAGE_ACCESSOR_FACTORY_TOKEN, DEFAULT_STORAGE_OBJECT_TOKEN, DateDistancePipe, DateFormatDistancePipe, DateFromToTimePipe, DbNgxActionAutoModifyDirective, DbNgxActionAutoTriggerDirective, DbNgxActionAutoTriggerValueDirective, DbNgxActionButtonDirective, DbNgxActionButtonTriggerDirective, DbNgxActionComponent, DbNgxActionContextDirective, DbNgxActionContextLoggerDirective, DbNgxActionContextMapDirective, DbNgxActionContextMapDirectiveSourceInstance, DbNgxActionDisabledDirective, DbNgxActionDisabledUntilModifiedDirective, DbNgxActionFromMapDirective, DbNgxActionHandlerDirective, DbNgxActionMapSourceDirective, DbNgxActionMapWorkingDisableDirective, DbNgxActionSourceDirective, DbNgxActionSuccessComponent, DbNgxActionSuccessDirective, DbNgxActionValueDirective, DbNgxActionWorkingComponent, DbNgxAnchor, DbNgxAngularRouterService, DbNgxButton, DbNgxButtonDirective, DbNgxButtonSegueDirective, DbNgxCoreActionModule, DbNgxCoreAngularRouterSegueModule, DbNgxCoreButtonModule, DbNgxCoreUIRouterSegueModule, DbNgxDatePipeModule, DbNgxInjectedComponent, DbNgxInjectedComponentInstance, DbNgxInjectedComponentModule, DbNgxLoadingButtonDirective, DbNgxRouterService, DbNgxRouterTransitionEventType, DbNgxRouterTransitionService, DbNgxUIRouterService, FullLocalStorageObject, InstantStorageAccessor, LimitedStorageAccessor, MemoryStorageObject, MinutesStringPipe, ProvideActionStoreSource, ProvideDbNgxAnchor, ProvideDbNgxButton, ProvideSecondaryActionStoreSource, SecondaryActionContextStoreSource, SimpleStorageAccessor, SimpleStorageAccessorFactory, StorageAccessor, StringStorageAccessor, StringifySimpleStorageAccessorConverter, TimeDistanceCountdownPipe, TimeDistancePipe, ToJsDatePipe, ToMinutesPipe, WorkHandlerContext, WorkHandlerContextSourceDelegate, WrapperSimpleStorageAccessorDelegate, actionContextHasNoErrorAndIsModifiedAndCanTrigger, actionContextIsModifiedAndCanTrigger, actionContextStoreSourceInstanceFactory, actionContextStoreSourcePipe, anchorTypeForAnchor, canReadyValue, canTriggerAction, canTriggerActionState, checkNgContentWrapperHasContent, defaultStorageObjectFactory, handleWorkValueReadyFn, handleWorkValueReadyWithConfigFn, isActionContextDisabled, isActionContextEnabled, isDisabledActionContextState, isIdleActionState, isWorkingActionState, mapRefStringObsToSegueRefObs, pipeActionStore, refStringToSegueRef, safeDetectChanges, useActionStore };
|
|
2856
|
+
//# sourceMappingURL=dereekb-dbx-core.mjs.map
|