@zambon-dev/ui 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -30,6 +30,73 @@ export declare enum FrameworkViewType {
|
|
|
30
30
|
/** A list/grid view (no data provider, no sub-views). */
|
|
31
31
|
List = "list"
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* What a details view's `visibleWhen` and `enabledWhen` conditions receive.
|
|
35
|
+
*
|
|
36
|
+
* A context object rather than positional arguments, so a field can be added later without
|
|
37
|
+
* breaking the conditions already written.
|
|
38
|
+
*/
|
|
39
|
+
export interface IDetailsViewContext<TEntity = any> {
|
|
40
|
+
/** The record the details tab shows: `null` while it loads, for a new record, or after a load error. */
|
|
41
|
+
readonly entity: TEntity | null;
|
|
42
|
+
/** The record's ID, or `undefined` for a new record. */
|
|
43
|
+
readonly entityID: number | undefined;
|
|
44
|
+
/** The details route, the parent of every view. */
|
|
45
|
+
readonly route: ActivatedRouteSnapshot;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Decides, per record, whether a details view is shown or available.
|
|
49
|
+
*
|
|
50
|
+
* It runs in an injection context, so it may call `inject()` -- a condition can depend on a
|
|
51
|
+
* feature flag, a setting or the signed-in user, not only on the record. It runs again every time
|
|
52
|
+
* the data provider emits the record, so a save or a status change updates the views at once.
|
|
53
|
+
* Return an `Observable` when the answer comes from somewhere asynchronous; the latest value wins.
|
|
54
|
+
* A condition that throws or errors counts as `false`.
|
|
55
|
+
*/
|
|
56
|
+
export type DetailsViewCondition<TEntity = any> = (context: IDetailsViewContext<TEntity>) => boolean | Observable<boolean>;
|
|
57
|
+
/**
|
|
58
|
+
* The route `data` that the framework reads from one view of a details route -- a child route of
|
|
59
|
+
* the route whose `data` holds `[FRAMEWORK_VIEW_TYPE]: FrameworkViewType.Details`.
|
|
60
|
+
*
|
|
61
|
+
* Usage in route config:
|
|
62
|
+
* ```ts
|
|
63
|
+
* children: [
|
|
64
|
+
* { path: '', component: MyFormComponent, data: { icon: 'fa-dice-d6', title: 'Button-Views-Details' } },
|
|
65
|
+
* {
|
|
66
|
+
* path: 'payments',
|
|
67
|
+
* component: MyPaymentsComponent,
|
|
68
|
+
* data: <IDetailsViewRouteData<IMyEntity>>{
|
|
69
|
+
* icon: 'fa-file-invoice-dollar',
|
|
70
|
+
* title: 'My-Button-Views-Payments',
|
|
71
|
+
* visibleWhen: ({ entity }: IDetailsViewContext<IMyEntity>) => entity?.isCustomer === true,
|
|
72
|
+
* },
|
|
73
|
+
* },
|
|
74
|
+
* ],
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export interface IDetailsViewRouteData<TEntity = any> {
|
|
78
|
+
/** Actions the user needs for the view to be listed. An empty list asks for none. */
|
|
79
|
+
allowedActions?: string[];
|
|
80
|
+
/** The API controller an audit-history view reads from. */
|
|
81
|
+
controllerName?: string;
|
|
82
|
+
/**
|
|
83
|
+
* When it returns `false`, the view is listed but cannot be chosen. While the first answer is
|
|
84
|
+
* pending the view is unavailable. Ignored on the first view, which every tab lands on.
|
|
85
|
+
*/
|
|
86
|
+
enabledWhen?: DetailsViewCondition<TEntity>;
|
|
87
|
+
/** Font Awesome icon class shown beside the view's label. */
|
|
88
|
+
icon?: string;
|
|
89
|
+
/** Leaves the route out of the views menu and the tab history. */
|
|
90
|
+
ignoreRoute?: boolean;
|
|
91
|
+
/** Translation key of the view's label. */
|
|
92
|
+
title?: string;
|
|
93
|
+
/**
|
|
94
|
+
* When it returns `false`, the view is left out of the views menu. While the first answer is
|
|
95
|
+
* pending the view is hidden, so it never appears only to vanish. Ignored on the first view,
|
|
96
|
+
* which every tab lands on.
|
|
97
|
+
*/
|
|
98
|
+
visibleWhen?: DetailsViewCondition<TEntity>;
|
|
99
|
+
}
|
|
33
100
|
export interface ITab {
|
|
34
101
|
clones: string[];
|
|
35
102
|
entityBaseUrl?: string;
|
|
@@ -631,11 +698,14 @@ export declare class ButtonViewsComponent extends BaseButton implements OnInit {
|
|
|
631
698
|
readonly detailsViewRoute: InputSignal<ActivatedRouteSnapshot | null>;
|
|
632
699
|
private baseUrlPath?;
|
|
633
700
|
private dataProviderService;
|
|
701
|
+
private hasViewStates;
|
|
702
|
+
private injector;
|
|
634
703
|
private isInternalNavigation;
|
|
635
704
|
private router;
|
|
636
705
|
private readonly selectedViewId;
|
|
637
706
|
private tabService;
|
|
638
707
|
private tabViewService;
|
|
708
|
+
private readonly viewStates;
|
|
639
709
|
protected get hasOptions(): boolean;
|
|
640
710
|
protected get isNewEntity(): boolean;
|
|
641
711
|
protected get selectedView(): IRibbonButtonOption | undefined;
|
|
@@ -644,13 +714,39 @@ export declare class ButtonViewsComponent extends BaseButton implements OnInit {
|
|
|
644
714
|
ngOnInit(): void;
|
|
645
715
|
protected onViewClicked(selectedOption: string | undefined): void;
|
|
646
716
|
/**
|
|
647
|
-
*
|
|
717
|
+
* Writes each view's state into the options: hidden when its `visibleWhen` said no, and
|
|
718
|
+
* disabled when it is the current view or its `enabledWhen` said no.
|
|
648
719
|
*
|
|
649
720
|
* The options are rebuilt rather than edited in place: the ribbon button takes the list as an
|
|
650
|
-
* input, so a field changed inside it is a change nothing can see.
|
|
721
|
+
* input, so a field changed inside it is a change nothing can see. An option whose state did not
|
|
722
|
+
* change keeps its identity, so the dropdown does not rebuild every row.
|
|
723
|
+
*/
|
|
724
|
+
private applyViewStates;
|
|
725
|
+
/**
|
|
726
|
+
* Marks the chosen view as the current one, which is how the dropdown greys its own entry out.
|
|
651
727
|
*/
|
|
652
728
|
private changeSelectedView;
|
|
729
|
+
/**
|
|
730
|
+
* Runs one condition for one record, as a stream of answers.
|
|
731
|
+
*
|
|
732
|
+
* A condition that throws, errors, or answers anything but `true` counts as `false`: a view whose
|
|
733
|
+
* condition is broken stays out of reach rather than showing where it should not.
|
|
734
|
+
*/
|
|
735
|
+
private evaluateCondition;
|
|
653
736
|
private getActiveOption;
|
|
737
|
+
/**
|
|
738
|
+
* Sends this tab back to its first view when the view it shows has been hidden or disabled --
|
|
739
|
+
* because the record changed under it, or because it was opened by a direct link.
|
|
740
|
+
*
|
|
741
|
+
* Only for the tab the router is showing: a detached tab keeps its subscriptions, and the
|
|
742
|
+
* navigation below always acts on the current tab.
|
|
743
|
+
*/
|
|
744
|
+
private leaveUnavailableView;
|
|
745
|
+
/**
|
|
746
|
+
* Answers every conditional view again each time the data provider emits the record, so a save
|
|
747
|
+
* or a status change shows, hides, enables or disables views at once.
|
|
748
|
+
*/
|
|
749
|
+
private watchViewConditions;
|
|
654
750
|
static ɵfac: i0.ɵɵFactoryDeclaration<ButtonViewsComponent, never>;
|
|
655
751
|
static ɵcmp: i0.ɵɵComponentDeclaration<ButtonViewsComponent, "framework-button-views", never, {
|
|
656
752
|
"detailsViewRoute": {
|