@zambon-dev/ui 1.2.2 → 1.4.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/CHANGELOG.md +40 -0
- package/fesm2022/zambon-dev-ui-framework.mjs +76 -11
- package/fesm2022/zambon-dev-ui-framework.mjs.map +1 -1
- package/fesm2022/zambon-dev-ui-shared.mjs +205 -35
- package/fesm2022/zambon-dev-ui-shared.mjs.map +1 -1
- package/i18n/shared/operations-history/en.json +15 -0
- package/i18n/shared/operations-history/pt.json +15 -0
- package/package.json +1 -1
- package/types/zambon-dev-ui-framework.d.ts +98 -2
- package/types/zambon-dev-ui-shared.d.ts +132 -2
package/CHANGELOG.md
CHANGED
|
@@ -23,6 +23,46 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
23
23
|
|
|
24
24
|
### ⚠ Breaking Changes / Migration
|
|
25
25
|
|
|
26
|
+
## [1.4.0] - 2026-10-31
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
- **The audit shows an operation's changes as a diff.** The change details list each field with
|
|
31
|
+
its label and its value before and after. Changed values are marked in red and green, with +/−
|
|
32
|
+
markers and screen-reader text, so the change does not rely on colour alone. Dates, numbers and
|
|
33
|
+
booleans follow the user's locale. The details open on the fields the operation changed; **Show
|
|
34
|
+
all fields** lists the rest of the record, with the key and audit columns grouped apart. That
|
|
35
|
+
needs ZWebAPI 1.17 or later, which rebuilds the whole record; against an older backend the
|
|
36
|
+
changed fields still show and the option is off.
|
|
37
|
+
- **Each operation in the list says how many fields it changed.**
|
|
38
|
+
- **`OPERATIONS_HISTORY_FIELD_LABEL` labels the audited fields.** The default turns `NomeCompleto`
|
|
39
|
+
into "Nome completo". Provide a function to use the application's own field labels or
|
|
40
|
+
translation keys.
|
|
41
|
+
|
|
42
|
+
### Deprecated
|
|
43
|
+
|
|
44
|
+
- **`shared-operations-history-modal`'s `oldValues` and `newValues` inputs.** Bind `operation`
|
|
45
|
+
instead. The operations list's `selectedOldValues` and `selectedNewValues` give way to
|
|
46
|
+
`selectedOperation` likewise.
|
|
47
|
+
|
|
48
|
+
### Fixed
|
|
49
|
+
|
|
50
|
+
- **Selecting an operation with no stored values no longer throws.** The operations list parsed an
|
|
51
|
+
empty string as JSON.
|
|
52
|
+
|
|
53
|
+
## [1.3.0] - 2026-10-31
|
|
54
|
+
|
|
55
|
+
### Added
|
|
56
|
+
|
|
57
|
+
- **A details view can depend on the record.** A view's route `data` takes `visibleWhen`, which
|
|
58
|
+
lists the view only for the records it accepts, and `enabledWhen`, which lists it for all of them
|
|
59
|
+
but lets it be chosen only for those. Both receive the record, its ID and the details route, may
|
|
60
|
+
call `inject()`, and may answer with an `Observable`. They run again on every record the data
|
|
61
|
+
provider emits, so a status change updates the Views menu at once. When the view on screen
|
|
62
|
+
becomes hidden or disabled, the tab goes back to its first view. `IDetailsViewRouteData` types a
|
|
63
|
+
view's route `data`, and [the details views guide](../../docs/guides/details-views.md) lists
|
|
64
|
+
every key.
|
|
65
|
+
|
|
26
66
|
## [1.2.2] - 2026-10-30
|
|
27
67
|
|
|
28
68
|
### Fixed
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
|
-
import { ApplicationRef, Component, EventEmitter, Inject, Injectable, InjectionToken, Input, NgModule, Output, ViewChild, afterEveryRender, computed, effect, forwardRef, inject, input, model, output, signal, viewChild } from "@angular/core";
|
|
2
|
+
import { ApplicationRef, Component, EventEmitter, Inject, Injectable, InjectionToken, Injector, Input, NgModule, Output, ViewChild, afterEveryRender, computed, effect, forwardRef, inject, input, model, output, runInInjectionContext, signal, viewChild } from "@angular/core";
|
|
3
3
|
import { toObservable, toSignal } from "@angular/core/rxjs-interop";
|
|
4
4
|
import * as i2 from "@zambon-dev/ui/library";
|
|
5
5
|
import { ButtonComponent as ButtonComponent$1, DataGridConfigsProvider, DataGridDataset, DataProviderService, DateValidators, DisplayControls, FormService, GroupContainerComponent, ModalComponent, MultiEditorComponent, MultiEditorDataset, MultiSelectComponent, MultiSelectResultDataset, RibbonButtonComponent, RibbonComponent, RibbonGroupChild, RibbonGroupComponent, RouterFormatter } from "@zambon-dev/ui/library";
|
|
6
|
-
import { ReplaySubject, Subject, filter, map, of, skip, startWith, switchMap, take, takeUntil, tap, throwError } from "rxjs";
|
|
6
|
+
import { ReplaySubject, Subject, catchError, combineLatest, filter, isObservable, map, of, skip, startWith, switchMap, take, takeUntil, tap, throwError } from "rxjs";
|
|
7
7
|
import { __decorate } from "tslib";
|
|
8
8
|
import * as i1$1 from "@angular/common";
|
|
9
9
|
import { NgClass, NgTemplateOutlet } from "@angular/common";
|
|
@@ -2976,11 +2976,14 @@ var ButtonViewsComponent = class ButtonViewsComponent extends BaseButton {
|
|
|
2976
2976
|
detailsViewRoute = input(null, ...ngDevMode ? [{ debugName: "detailsViewRoute" }] : /* istanbul ignore next */ []);
|
|
2977
2977
|
baseUrlPath;
|
|
2978
2978
|
dataProviderService = inject(DataProviderService, { optional: true });
|
|
2979
|
+
hasViewStates = false;
|
|
2980
|
+
injector = inject(Injector);
|
|
2979
2981
|
isInternalNavigation = false;
|
|
2980
2982
|
router = inject(Router);
|
|
2981
2983
|
selectedViewId = signal(void 0, ...ngDevMode ? [{ debugName: "selectedViewId" }] : /* istanbul ignore next */ []);
|
|
2982
2984
|
tabService = inject(TabService);
|
|
2983
2985
|
tabViewService = inject(TabViewService);
|
|
2986
|
+
viewStates = /* @__PURE__ */ new Map();
|
|
2984
2987
|
get hasOptions() {
|
|
2985
2988
|
return this.options().some((option) => (option.isVisible ?? true) && (option.allowedActions === void 0 || option.allowedActions.length === 0 || option.isAccessAllowed === true || option.isAccessAllowed === void 0 && option.allowedActions?.length > 0));
|
|
2986
2989
|
}
|
|
@@ -3002,23 +3005,38 @@ var ButtonViewsComponent = class ButtonViewsComponent extends BaseButton {
|
|
|
3002
3005
|
ngOnInit() {
|
|
3003
3006
|
const detailsViewRoute = this.detailsViewRoute();
|
|
3004
3007
|
if (detailsViewRoute) {
|
|
3005
|
-
|
|
3008
|
+
const viewRoutes = detailsViewRoute.routeConfig?.children?.filter((route) => !!route.data && route.data["ignoreRoute"] !== true) ?? [];
|
|
3009
|
+
this.options.set(viewRoutes.map((route) => {
|
|
3006
3010
|
const data = route.data ?? {};
|
|
3007
3011
|
const option = {
|
|
3008
3012
|
id: route.path ?? "",
|
|
3009
3013
|
isDisabled: false,
|
|
3010
3014
|
isVisible: true,
|
|
3011
|
-
label: data
|
|
3015
|
+
label: data.title ?? ""
|
|
3012
3016
|
};
|
|
3013
|
-
const icon = data
|
|
3017
|
+
const icon = data.icon;
|
|
3014
3018
|
if (icon) option.icon = icon;
|
|
3015
|
-
const allowedActions = data
|
|
3019
|
+
const allowedActions = data.allowedActions;
|
|
3016
3020
|
if (allowedActions && allowedActions.length > 0) option.allowedActions = allowedActions;
|
|
3017
3021
|
return option;
|
|
3018
|
-
})
|
|
3022
|
+
}));
|
|
3023
|
+
const conditionalViews = viewRoutes.slice(1).map((route) => {
|
|
3024
|
+
const data = route.data ?? {};
|
|
3025
|
+
return {
|
|
3026
|
+
enabledWhen: data.enabledWhen,
|
|
3027
|
+
id: route.path ?? "",
|
|
3028
|
+
visibleWhen: data.visibleWhen
|
|
3029
|
+
};
|
|
3030
|
+
}).filter((view) => !!view.visibleWhen || !!view.enabledWhen);
|
|
3031
|
+
conditionalViews.forEach((view) => this.viewStates.set(view.id, {
|
|
3032
|
+
isEnabled: !view.enabledWhen,
|
|
3033
|
+
isVisible: !view.visibleWhen
|
|
3034
|
+
}));
|
|
3035
|
+
this.applyViewStates();
|
|
3019
3036
|
const url = RouteHelper.getRouteURL(detailsViewRoute);
|
|
3020
3037
|
this.baseUrlPath = url;
|
|
3021
3038
|
if ((detailsViewRoute.children[0]?.url?.map((segment) => segment.path)?.join("/") ?? "") === this.defaultViewId) this.changeSelectedView(this.defaultViewId);
|
|
3039
|
+
if (conditionalViews.length > 0) this.watchViewConditions(detailsViewRoute, conditionalViews);
|
|
3022
3040
|
}
|
|
3023
3041
|
this.router.events.pipe(filter((event) => event instanceof NavigationEnd), takeUntil(this.destroy$)).subscribe((event) => {
|
|
3024
3042
|
if (this.detailsViewRoute()) {
|
|
@@ -3030,6 +3048,7 @@ var ButtonViewsComponent = class ButtonViewsComponent extends BaseButton {
|
|
|
3030
3048
|
if (!this.isInternalNavigation) {
|
|
3031
3049
|
if (this.selectedViewId() !== activeViewId) this.changeSelectedView(activeViewId);
|
|
3032
3050
|
} else this.isInternalNavigation = false;
|
|
3051
|
+
this.leaveUnavailableView();
|
|
3033
3052
|
}
|
|
3034
3053
|
}
|
|
3035
3054
|
});
|
|
@@ -3046,19 +3065,65 @@ var ButtonViewsComponent = class ButtonViewsComponent extends BaseButton {
|
|
|
3046
3065
|
this.tabService.replaceCurrentTabSubView(this.baseUrlPath, tab);
|
|
3047
3066
|
}
|
|
3048
3067
|
}
|
|
3068
|
+
applyViewStates() {
|
|
3069
|
+
const selectedViewId = this.selectedViewId();
|
|
3070
|
+
this.options.update((options) => options.map((option) => {
|
|
3071
|
+
const state = this.viewStates.get(option.id);
|
|
3072
|
+
const isVisible = state?.isVisible ?? true;
|
|
3073
|
+
const isDisabled = option.id === selectedViewId || !(state?.isEnabled ?? true);
|
|
3074
|
+
return option.isVisible === isVisible && option.isDisabled === isDisabled ? option : {
|
|
3075
|
+
...option,
|
|
3076
|
+
isDisabled,
|
|
3077
|
+
isVisible
|
|
3078
|
+
};
|
|
3079
|
+
}));
|
|
3080
|
+
}
|
|
3049
3081
|
changeSelectedView(viewId) {
|
|
3050
3082
|
this.selectedViewId.set(viewId);
|
|
3051
3083
|
this.tabViewService.setActiveView(viewId ?? "");
|
|
3052
|
-
this.
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3084
|
+
this.applyViewStates();
|
|
3085
|
+
}
|
|
3086
|
+
evaluateCondition(condition, detailsViewRoute, entity) {
|
|
3087
|
+
if (!condition) return of(true);
|
|
3088
|
+
try {
|
|
3089
|
+
const result = runInInjectionContext(this.injector, () => condition({
|
|
3090
|
+
entity,
|
|
3091
|
+
entityID: this.dataProviderService?.entityID,
|
|
3092
|
+
route: detailsViewRoute
|
|
3093
|
+
}));
|
|
3094
|
+
return (isObservable(result) ? result : of(result)).pipe(map((answer) => answer === true), catchError(() => of(false)));
|
|
3095
|
+
} catch {
|
|
3096
|
+
return of(false);
|
|
3097
|
+
}
|
|
3056
3098
|
}
|
|
3057
3099
|
getActiveOption(url) {
|
|
3058
3100
|
const option = url.replace(this.baseUrlPath ?? "", "").substring(1);
|
|
3059
3101
|
if (this.options().some((o) => o.id === option)) return option;
|
|
3060
3102
|
return this.defaultViewId;
|
|
3061
3103
|
}
|
|
3104
|
+
leaveUnavailableView() {
|
|
3105
|
+
const selectedViewId = this.selectedViewId();
|
|
3106
|
+
if (!this.hasViewStates || selectedViewId === void 0 || selectedViewId === this.defaultViewId) return;
|
|
3107
|
+
const state = this.viewStates.get(selectedViewId);
|
|
3108
|
+
if (!state || state.isVisible && state.isEnabled) return;
|
|
3109
|
+
const currentRoute = RouteHelper.getRouteByData(this.router.routerState.root.snapshot, FRAMEWORK_VIEW_TYPE, FrameworkViewType.Details);
|
|
3110
|
+
if (!currentRoute || currentRoute.routeConfig !== this.detailsViewRoute()?.routeConfig || RouteHelper.getRouteURL(currentRoute) !== this.baseUrlPath) return;
|
|
3111
|
+
this.onViewClicked(this.defaultViewId);
|
|
3112
|
+
}
|
|
3113
|
+
watchViewConditions(detailsViewRoute, conditionalViews) {
|
|
3114
|
+
(this.dataProviderService?.getModel$() ?? of(null)).pipe(switchMap((entity) => combineLatest(conditionalViews.map((view) => combineLatest([this.evaluateCondition(view.visibleWhen, detailsViewRoute, entity), this.evaluateCondition(view.enabledWhen, detailsViewRoute, entity)]).pipe(map(([isVisible, isEnabled]) => ({
|
|
3115
|
+
id: view.id,
|
|
3116
|
+
state: {
|
|
3117
|
+
isEnabled,
|
|
3118
|
+
isVisible
|
|
3119
|
+
}
|
|
3120
|
+
})))))), takeUntil(this.destroy$)).subscribe((answers) => {
|
|
3121
|
+
answers.forEach((answer) => this.viewStates.set(answer.id, answer.state));
|
|
3122
|
+
this.hasViewStates = true;
|
|
3123
|
+
this.applyViewStates();
|
|
3124
|
+
this.leaveUnavailableView();
|
|
3125
|
+
});
|
|
3126
|
+
}
|
|
3062
3127
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
3063
3128
|
minVersion: "12.0.0",
|
|
3064
3129
|
version: "22.2.0",
|