@yuuvis/client-framework 2.0.11 → 2.0.13
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/fesm2022/yuuvis-client-framework-autocomplete.mjs +2 -2
- package/fesm2022/yuuvis-client-framework-autocomplete.mjs.map +1 -1
- package/fesm2022/yuuvis-client-framework-common.mjs +3 -5
- package/fesm2022/yuuvis-client-framework-common.mjs.map +1 -1
- package/fesm2022/yuuvis-client-framework-datepicker.mjs +4 -4
- package/fesm2022/yuuvis-client-framework-datepicker.mjs.map +1 -1
- package/fesm2022/yuuvis-client-framework-forms.mjs +103 -55
- package/fesm2022/yuuvis-client-framework-forms.mjs.map +1 -1
- package/fesm2022/yuuvis-client-framework-icons.mjs +1 -0
- package/fesm2022/yuuvis-client-framework-icons.mjs.map +1 -1
- package/fesm2022/yuuvis-client-framework-metadata-form-defaults.mjs +1 -1
- package/fesm2022/yuuvis-client-framework-metadata-form-defaults.mjs.map +1 -1
- package/fesm2022/yuuvis-client-framework-object-form.mjs +1 -1
- package/fesm2022/yuuvis-client-framework-object-form.mjs.map +1 -1
- package/fesm2022/yuuvis-client-framework-pagination.mjs +3 -0
- package/fesm2022/yuuvis-client-framework-pagination.mjs.map +1 -1
- package/fesm2022/yuuvis-client-framework-widget-grid.mjs +924 -0
- package/fesm2022/yuuvis-client-framework-widget-grid.mjs.map +1 -0
- package/forms/lib/elements/number-range/number-range.component.d.ts +2 -1
- package/icons/lib/icon.service.d.ts +1 -0
- package/lib/assets/i18n/de.json +22 -3
- package/lib/assets/i18n/en.json +24 -5
- package/package.json +10 -5
- package/pagination/lib/pagination.component.d.ts +3 -0
- package/widget-grid/README.md +48 -0
- package/widget-grid/index.d.ts +7 -0
- package/widget-grid/lib/widget-grid-event.service.d.ts +10 -0
- package/widget-grid/lib/widget-grid-registry.service.d.ts +80 -0
- package/widget-grid/lib/widget-grid-workspaces/widget-grid-workspaces.component.d.ts +51 -0
- package/widget-grid/lib/widget-grid-workspaces/widget-grid-workspaces.interface.d.ts +16 -0
- package/widget-grid/lib/widget-grid-workspaces/workspace-edit/workspace-edit.component.d.ts +10 -0
- package/widget-grid/lib/widget-grid.component.d.ts +51 -0
- package/widget-grid/lib/widget-grid.interface.d.ts +50 -0
- package/widget-grid/lib/widget-grid.module.d.ts +8 -0
- package/widget-grid/lib/widget-grid.service.d.ts +45 -0
- package/widget-grid/lib/widget-grid.utils.d.ts +18 -0
- package/widget-grid/lib/widget-picker/widget-picker.component.d.ts +38 -0
- package/widget-grid/lib/widgets/noop/noop.component.d.ts +7 -0
|
@@ -0,0 +1,924 @@
|
|
|
1
|
+
import * as i1 from '@angular/common';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { Injectable, Input, Component, inject, input, effect, output, viewChild, TemplateRef, computed, signal, untracked, NgModule } from '@angular/core';
|
|
5
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
6
|
+
import { MAT_DIALOG_DATA, MatDialogRef, MatDialog } from '@angular/material/dialog';
|
|
7
|
+
import * as i4$2 from '@angular/material/icon';
|
|
8
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
9
|
+
import * as i3 from '@yuuvis/client-core';
|
|
10
|
+
import { TranslateService, TranslateModule } from '@yuuvis/client-core';
|
|
11
|
+
import { GridsterItemComponent, DisplayGrid, GridType, GridsterComponent } from 'angular-gridster2';
|
|
12
|
+
import * as i4 from 'ng-dynamic-component';
|
|
13
|
+
import { DynamicIoModule } from 'ng-dynamic-component';
|
|
14
|
+
import { ReplaySubject, Subject } from 'rxjs';
|
|
15
|
+
import * as i4$1 from '@angular/forms';
|
|
16
|
+
import { FormControl, ReactiveFormsModule, FormBuilder, Validators } from '@angular/forms';
|
|
17
|
+
import * as i5 from '@angular/material/button';
|
|
18
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
19
|
+
import { DialogComponent, ConfirmService } from '@yuuvis/client-framework/common';
|
|
20
|
+
import { SignalComponentIoModule } from 'ng-dynamic-component/signal-component-io';
|
|
21
|
+
import { YmtButtonDirective } from '@yuuvis/material';
|
|
22
|
+
import * as i3$1 from '@angular/material/list';
|
|
23
|
+
import { MatListModule } from '@angular/material/list';
|
|
24
|
+
import * as i1$1 from '@angular/material/form-field';
|
|
25
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
26
|
+
import * as i2 from '@angular/material/input';
|
|
27
|
+
import { MatInputModule } from '@angular/material/input';
|
|
28
|
+
import * as i4$3 from '@angular/material/menu';
|
|
29
|
+
import { MatMenuModule } from '@angular/material/menu';
|
|
30
|
+
import { TranslateModule as TranslateModule$1 } from '@ngx-translate/core';
|
|
31
|
+
|
|
32
|
+
class WidgetGridEventService {
|
|
33
|
+
constructor() {
|
|
34
|
+
this.widgetGridEventSource = new ReplaySubject();
|
|
35
|
+
this.widgetEvents$ = this.widgetGridEventSource.asObservable();
|
|
36
|
+
}
|
|
37
|
+
trigger(evt) {
|
|
38
|
+
this.widgetGridEventSource.next(evt);
|
|
39
|
+
}
|
|
40
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: WidgetGridEventService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
41
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: WidgetGridEventService, providedIn: 'root' }); }
|
|
42
|
+
}
|
|
43
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: WidgetGridEventService, decorators: [{
|
|
44
|
+
type: Injectable,
|
|
45
|
+
args: [{
|
|
46
|
+
providedIn: 'root',
|
|
47
|
+
}]
|
|
48
|
+
}] });
|
|
49
|
+
|
|
50
|
+
class NoopComponent {
|
|
51
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: NoopComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
52
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.12", type: NoopComponent, isStandalone: true, selector: "yuv-noop", inputs: { widgetConfig: "widgetConfig" }, ngImport: i0, template: "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 0 24 24\" width=\"24px\" fill=\"#000000\"><path d=\"M0 0h24v24H0V0z\" fill=\"none\"/><circle cx=\"15.5\" cy=\"9.5\" r=\"1.5\"/><circle cx=\"8.5\" cy=\"9.5\" r=\"1.5\"/><path d=\"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm0-6c-2.33 0-4.32 1.45-5.12 3.5h1.67c.69-1.19 1.97-2 3.45-2s2.75.81 3.45 2h1.67c-.8-2.05-2.79-3.5-5.12-3.5z\"/></svg>", styles: [":host{height:100%;display:flex;flex-flow:column;align-items:center;justify-content:center;padding:var(--ymt-spacing-m);background-color:var(--panel-background);opacity:.7}:host svg{width:48px;height:48px;fill:var(--text-color-caption)}:host span{margin-top:var(--ymt-spacing-m)}\n"] }); }
|
|
53
|
+
}
|
|
54
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: NoopComponent, decorators: [{
|
|
55
|
+
type: Component,
|
|
56
|
+
args: [{ selector: 'yuv-noop', template: "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 0 24 24\" width=\"24px\" fill=\"#000000\"><path d=\"M0 0h24v24H0V0z\" fill=\"none\"/><circle cx=\"15.5\" cy=\"9.5\" r=\"1.5\"/><circle cx=\"8.5\" cy=\"9.5\" r=\"1.5\"/><path d=\"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm0-6c-2.33 0-4.32 1.45-5.12 3.5h1.67c.69-1.19 1.97-2 3.45-2s2.75.81 3.45 2h1.67c-.8-2.05-2.79-3.5-5.12-3.5z\"/></svg>", styles: [":host{height:100%;display:flex;flex-flow:column;align-items:center;justify-content:center;padding:var(--ymt-spacing-m);background-color:var(--panel-background);opacity:.7}:host svg{width:48px;height:48px;fill:var(--text-color-caption)}:host span{margin-top:var(--ymt-spacing-m)}\n"] }]
|
|
57
|
+
}], propDecorators: { widgetConfig: [{
|
|
58
|
+
type: Input
|
|
59
|
+
}] } });
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* This service provides the list of widgets that could be added
|
|
63
|
+
* to a widget grid. You could use it to register your own
|
|
64
|
+
* widgets.
|
|
65
|
+
*/
|
|
66
|
+
class WidgetGridRegistry {
|
|
67
|
+
constructor() {
|
|
68
|
+
this.translate = inject(TranslateService);
|
|
69
|
+
/**
|
|
70
|
+
* List of pre-registered widgets provided out-of-the-box
|
|
71
|
+
* by the widget grid module
|
|
72
|
+
*/
|
|
73
|
+
this.registeredWidgets = [];
|
|
74
|
+
/**
|
|
75
|
+
* Buckets are collection of widget references.
|
|
76
|
+
* You can put any widget registered gloabally into a bucket. Later on you can grab
|
|
77
|
+
* widgets from a certain bucket. This enables apps to structure their widgets when e.g.
|
|
78
|
+
* using multiple widget grids with their own set of available widgets.
|
|
79
|
+
*/
|
|
80
|
+
this.widgetBuckets = {};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get the noop component. This component will be rendered in
|
|
84
|
+
* the grid tile if not matching widget could be found in the
|
|
85
|
+
* list of registered widgets. It will show some kind of 'not
|
|
86
|
+
* found' message and provide the controls to remove that none
|
|
87
|
+
* existing component from the widget grid.
|
|
88
|
+
* @returns NoopComponent
|
|
89
|
+
*/
|
|
90
|
+
getNoopWidget() {
|
|
91
|
+
return {
|
|
92
|
+
id: 'noop',
|
|
93
|
+
label: this.translate.instant('yuv.widget-grid.widget.noop.label'),
|
|
94
|
+
widgetComponent: NoopComponent,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Setup components are the administrative part of a widget. They
|
|
99
|
+
* are used to set up a widget. Not all the widgets will have a setup
|
|
100
|
+
* component.
|
|
101
|
+
* @param widgetName The widgets name
|
|
102
|
+
* @returns The setup component of a widget. Throws error if there
|
|
103
|
+
* is not widget registered with the given name
|
|
104
|
+
*/
|
|
105
|
+
getWidgetSetupComponent(widgetName) {
|
|
106
|
+
const widget = this.registeredWidgets.find((w) => w.id === widgetName);
|
|
107
|
+
if (!widget)
|
|
108
|
+
throw Error('Widget setup component not found');
|
|
109
|
+
return widget.setupComponent;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Get the component for a widget. This is the component that will
|
|
113
|
+
* be rendered in a grid tile.
|
|
114
|
+
* @param widgetName The widgets name
|
|
115
|
+
* @returns The widget component or noop component if there is
|
|
116
|
+
* no component registered with the given name
|
|
117
|
+
*/
|
|
118
|
+
getWidgetComponent(widgetName) {
|
|
119
|
+
const widget = this.registeredWidgets.find((w) => w.id === widgetName);
|
|
120
|
+
if (!widget)
|
|
121
|
+
console.error('Widget component not found');
|
|
122
|
+
return widget?.widgetComponent || NoopComponent;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Adds a new widget to the list of registered widgets. That way
|
|
126
|
+
* you can create custom widgets that are then available to be
|
|
127
|
+
* added to a users widget grid.
|
|
128
|
+
* @param widget The widget to be registered
|
|
129
|
+
* @param bucket List of buckets to register to. If a bucket does
|
|
130
|
+
* not exist it'll be created.
|
|
131
|
+
*/
|
|
132
|
+
registerGridWidget(widget, buckets) {
|
|
133
|
+
const existingWidget = this.registeredWidgets.find((w) => w.id === widget.id);
|
|
134
|
+
if (!existingWidget)
|
|
135
|
+
this.registeredWidgets.push(widget);
|
|
136
|
+
if (buckets?.length) {
|
|
137
|
+
buckets.forEach((b) => {
|
|
138
|
+
this._addToBucket(b, widget.id);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Register a collection of widgets
|
|
144
|
+
* @param widgets The widgets to be registered
|
|
145
|
+
* @param bucket List of buckets to register to. If a bucket does
|
|
146
|
+
* not exist it'll be created.
|
|
147
|
+
*/
|
|
148
|
+
registerGridWidgets(widgets, buckets) {
|
|
149
|
+
const alreadyRegisteredWidgetNames = this.registeredWidgets.map((w) => w.id);
|
|
150
|
+
const widgetsToRegister = widgets.filter((w) => !alreadyRegisteredWidgetNames.includes(w.id));
|
|
151
|
+
this.registeredWidgets = [...this.registeredWidgets, ...widgetsToRegister];
|
|
152
|
+
if (buckets?.length) {
|
|
153
|
+
buckets.forEach((b) => widgets.forEach((w) => this._addToBucket(b, w.id)));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
_addToBucket(bucket, widgetName) {
|
|
157
|
+
if (!this.widgetBuckets[bucket])
|
|
158
|
+
this.widgetBuckets[bucket] = [];
|
|
159
|
+
this.widgetBuckets[bucket].push(widgetName);
|
|
160
|
+
}
|
|
161
|
+
removeRegisteredWidget(id) {
|
|
162
|
+
this.registeredWidgets = this.registeredWidgets.filter((w) => w.id !== id);
|
|
163
|
+
}
|
|
164
|
+
clearRegisteredWidget() {
|
|
165
|
+
this.registeredWidgets = [];
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Get registered widgets. This list could be narrowed down by a list
|
|
169
|
+
* of buckets. Buckets are lists of registered widgets registered for
|
|
170
|
+
* a certain key (the buckets name).
|
|
171
|
+
* @param buckets name of buckets to restrict the widgets to
|
|
172
|
+
* @returns Array of grid widgets
|
|
173
|
+
*/
|
|
174
|
+
getRegisteredWidgets(buckets) {
|
|
175
|
+
if (buckets?.length) {
|
|
176
|
+
// buckets may contain wildcards ...
|
|
177
|
+
// grab all buckets matching the wildcards
|
|
178
|
+
const matchedBuckets = {};
|
|
179
|
+
buckets.forEach((b) => {
|
|
180
|
+
if (b.match(/[*?]/)) {
|
|
181
|
+
// bucket has a pattern
|
|
182
|
+
Object.keys(this.widgetBuckets).forEach((wb) => {
|
|
183
|
+
if (this._wildcardMatch(wb, b))
|
|
184
|
+
matchedBuckets[wb] = 0;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
else
|
|
188
|
+
matchedBuckets[b] = 0;
|
|
189
|
+
});
|
|
190
|
+
const bucketWidgetNames = {};
|
|
191
|
+
Object.keys(matchedBuckets).forEach((b) => this.widgetBuckets[b].forEach((widgetName) => {
|
|
192
|
+
bucketWidgetNames[widgetName] = 0;
|
|
193
|
+
}));
|
|
194
|
+
const widgetNames = Object.keys(bucketWidgetNames);
|
|
195
|
+
return this.registeredWidgets.filter((w) => widgetNames.includes(w.id));
|
|
196
|
+
}
|
|
197
|
+
else
|
|
198
|
+
return this.registeredWidgets;
|
|
199
|
+
// return this.registeredWidgets.filter((w: GridWidget) => {
|
|
200
|
+
// return !buckets || buckets.includes(w.name)
|
|
201
|
+
// });
|
|
202
|
+
}
|
|
203
|
+
_wildcardMatch(text, pattern) {
|
|
204
|
+
const regexPattern = new RegExp('^' + pattern.replace(/\?/g, '.').replace(/\*/g, '.*') + '$');
|
|
205
|
+
return regexPattern.test(text);
|
|
206
|
+
}
|
|
207
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: WidgetGridRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
208
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: WidgetGridRegistry, providedIn: 'root' }); }
|
|
209
|
+
}
|
|
210
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: WidgetGridRegistry, decorators: [{
|
|
211
|
+
type: Injectable,
|
|
212
|
+
args: [{
|
|
213
|
+
providedIn: 'root',
|
|
214
|
+
}]
|
|
215
|
+
}] });
|
|
216
|
+
|
|
217
|
+
class WidgetGridUtils {
|
|
218
|
+
static { this.PREF_FUNCTION = 'Function'; }
|
|
219
|
+
static { this.PREF_RANGEVALUE = 'RangeValue'; }
|
|
220
|
+
/**
|
|
221
|
+
* Takes a `WidgetGridItemConfig` and stringifies it. The challenge
|
|
222
|
+
* here is that callback functions should also be stringified.
|
|
223
|
+
* @param gridItemConfig the config object
|
|
224
|
+
*/
|
|
225
|
+
static gridConfigStringify(o) {
|
|
226
|
+
return JSON.stringify(o, (key, value) => {
|
|
227
|
+
if (typeof value === 'function') {
|
|
228
|
+
return `/${WidgetGridUtils.PREF_FUNCTION}(${value.toString()})/`;
|
|
229
|
+
}
|
|
230
|
+
return value;
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Takes a string stringified with `gridConfigStringify()` and parses it
|
|
235
|
+
* to output a proper WidgetGridItemConfig.
|
|
236
|
+
* @param stringifiedConfig stringified widget grid config
|
|
237
|
+
*/
|
|
238
|
+
static gridConfigParse(stringifiedConfig) {
|
|
239
|
+
return JSON.parse(stringifiedConfig, function (key, value) {
|
|
240
|
+
if (typeof value === 'string' &&
|
|
241
|
+
value.startsWith(`/${WidgetGridUtils.PREF_FUNCTION}(`) &&
|
|
242
|
+
// value.startsWith('/Function(') &&
|
|
243
|
+
value.endsWith(')/')) {
|
|
244
|
+
value = value.substring(WidgetGridUtils.PREF_FUNCTION.length + 2, value.length - 2);
|
|
245
|
+
return (0, eval)('(' + value + ')');
|
|
246
|
+
}
|
|
247
|
+
return value;
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
static uuid() {
|
|
251
|
+
return WidgetGridUtils._p8() + WidgetGridUtils._p8(true) + WidgetGridUtils._p8(true) + WidgetGridUtils._p8();
|
|
252
|
+
}
|
|
253
|
+
static _p8(s) {
|
|
254
|
+
const p = (Math.random().toString(16) + '000000000').substr(2, 8);
|
|
255
|
+
return s ? `-${p.substr(0, 4)}-${p.substr(4, 4)}` : p;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Service managing a widget grid. Also includes a set of labels that will be
|
|
261
|
+
* used by the grid and its widgets. Default labels are provided out of the
|
|
262
|
+
* box. But if you want to use custom ones or add i18n you could overwrite
|
|
263
|
+
* them. The grid as well as the widgets will use those labels or fall back
|
|
264
|
+
* to their default ones. If you are developing own widgets you should
|
|
265
|
+
* consider using those labels as well.
|
|
266
|
+
*/
|
|
267
|
+
class WidgetGridService {
|
|
268
|
+
constructor(widgetGridRegistry) {
|
|
269
|
+
this.widgetGridRegistry = widgetGridRegistry;
|
|
270
|
+
this.widgetGrid = [];
|
|
271
|
+
this.widgetGridSource = new ReplaySubject();
|
|
272
|
+
this.widgetGrid$ = this.widgetGridSource.asObservable();
|
|
273
|
+
this.widgetGridUpdateSource = new Subject();
|
|
274
|
+
/**
|
|
275
|
+
* Emitted when the widget grid has been updated
|
|
276
|
+
*/
|
|
277
|
+
this.widgetGridUpdate$ = this.widgetGridUpdateSource.asObservable();
|
|
278
|
+
this.addItemSize = {
|
|
279
|
+
rows: 2,
|
|
280
|
+
cols: 3,
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
setWidgetGrid(gridItemConfig) {
|
|
284
|
+
if (gridItemConfig) {
|
|
285
|
+
// create actual widget grid from widget grid config
|
|
286
|
+
this.widgetGrid = [...gridItemConfig].map((gic) => {
|
|
287
|
+
const cmp = this.widgetGridRegistry.getWidgetComponent(gic.widgetName);
|
|
288
|
+
const gc = {
|
|
289
|
+
...gic,
|
|
290
|
+
widget: cmp,
|
|
291
|
+
widgetConfigMap: {
|
|
292
|
+
widgetConfig: cmp === NoopComponent
|
|
293
|
+
? {
|
|
294
|
+
widgetName: gic.widgetName,
|
|
295
|
+
}
|
|
296
|
+
: gic.widgetConfig,
|
|
297
|
+
},
|
|
298
|
+
};
|
|
299
|
+
return gc;
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
this.widgetGrid = [];
|
|
304
|
+
}
|
|
305
|
+
this.widgetGridSource.next(this.widgetGrid);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Update config of an existing widget
|
|
309
|
+
* @param widgetId ID of the widget to be updated
|
|
310
|
+
* @param setupWidgetConfig The updated configuration for that widget
|
|
311
|
+
*/
|
|
312
|
+
updateWidget(widgetId, setupWidgetConfig) {
|
|
313
|
+
const gridWidget = this.widgetGrid.find((w) => w.id === widgetId);
|
|
314
|
+
if (gridWidget && setupWidgetConfig) {
|
|
315
|
+
gridWidget.widgetConfig = setupWidgetConfig;
|
|
316
|
+
gridWidget.widgetConfigMap = { widgetConfig: setupWidgetConfig };
|
|
317
|
+
}
|
|
318
|
+
this.widgetGridSource.next(this.widgetGrid);
|
|
319
|
+
this.widgetGridUpdateSource.next(widgetId);
|
|
320
|
+
}
|
|
321
|
+
replaceWidget(widgetId, widgetName, setupWidgetConfig) {
|
|
322
|
+
const gridWidgetIndex = this.widgetGrid.findIndex((w) => w.id === widgetId);
|
|
323
|
+
if (gridWidgetIndex !== -1) {
|
|
324
|
+
const w = {
|
|
325
|
+
...this.widgetGrid[gridWidgetIndex],
|
|
326
|
+
...{
|
|
327
|
+
widgetName,
|
|
328
|
+
widgetConfig: setupWidgetConfig || {},
|
|
329
|
+
widget: this.widgetGridRegistry.getWidgetComponent(widgetName),
|
|
330
|
+
widgetConfigMap: { widgetConfig: setupWidgetConfig || {} },
|
|
331
|
+
},
|
|
332
|
+
};
|
|
333
|
+
this.widgetGrid[gridWidgetIndex] = w;
|
|
334
|
+
this.widgetGridSource.next(this.widgetGrid);
|
|
335
|
+
this.widgetGridUpdateSource.next(widgetId);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Add a new grid item to the widget grid.
|
|
340
|
+
* @param widgetName The name of the grid item to be added
|
|
341
|
+
* @param setupWidgetConfig
|
|
342
|
+
*/
|
|
343
|
+
addWidget(widgetName, setupWidgetConfig) {
|
|
344
|
+
const gridWidget = {
|
|
345
|
+
id: WidgetGridUtils.uuid(),
|
|
346
|
+
widgetName,
|
|
347
|
+
widgetConfig: setupWidgetConfig,
|
|
348
|
+
widget: this.widgetGridRegistry.getWidgetComponent(widgetName),
|
|
349
|
+
widgetConfigMap: { widgetConfig: setupWidgetConfig },
|
|
350
|
+
x: 0,
|
|
351
|
+
y: 0,
|
|
352
|
+
rows: this.addItemSize.rows,
|
|
353
|
+
cols: this.addItemSize.cols,
|
|
354
|
+
};
|
|
355
|
+
this.widgetGrid.push(gridWidget);
|
|
356
|
+
this.widgetGridSource.next(this.widgetGrid);
|
|
357
|
+
this.widgetGridUpdateSource.next(gridWidget.id);
|
|
358
|
+
}
|
|
359
|
+
removeWidget(gridItemId) {
|
|
360
|
+
const idx = this.widgetGrid.findIndex((w) => w.id === gridItemId);
|
|
361
|
+
this.widgetGrid.splice(idx, 1);
|
|
362
|
+
this.widgetGridSource.next(this.widgetGrid);
|
|
363
|
+
this.widgetGridUpdateSource.next(gridItemId);
|
|
364
|
+
}
|
|
365
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: WidgetGridService, deps: [{ token: WidgetGridRegistry }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
366
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: WidgetGridService }); }
|
|
367
|
+
}
|
|
368
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: WidgetGridService, decorators: [{
|
|
369
|
+
type: Injectable
|
|
370
|
+
}], ctorParameters: () => [{ type: WidgetGridRegistry }] });
|
|
371
|
+
|
|
372
|
+
class WidgetPickerComponent {
|
|
373
|
+
#widgetGridRegistry;
|
|
374
|
+
#widgetGridService;
|
|
375
|
+
#dialogData;
|
|
376
|
+
#dialogRef;
|
|
377
|
+
#pickerDataEffect;
|
|
378
|
+
constructor() {
|
|
379
|
+
this.#widgetGridRegistry = inject(WidgetGridRegistry);
|
|
380
|
+
this.#widgetGridService = inject(WidgetGridService);
|
|
381
|
+
this.#dialogData = inject(MAT_DIALOG_DATA);
|
|
382
|
+
this.#dialogRef = inject((MatDialogRef));
|
|
383
|
+
this.pickerFormControl = new FormControl();
|
|
384
|
+
this.widgetConfigMap = {};
|
|
385
|
+
this.widgetConfigDirty = false;
|
|
386
|
+
this.registeredWidgets = [];
|
|
387
|
+
this.setupWidgetDynamicOutputs = {
|
|
388
|
+
widgetConfigChange: (widgetConfig) => {
|
|
389
|
+
this.onSetupConfigChange(widgetConfig);
|
|
390
|
+
},
|
|
391
|
+
widgetConfigStateChange: (s) => {
|
|
392
|
+
this.widgetConfigState = s || undefined;
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
this.pickerData = input(this.#dialogData.pickerData);
|
|
396
|
+
this.#pickerDataEffect = effect(() => {
|
|
397
|
+
const pd = this.pickerData();
|
|
398
|
+
if (pd) {
|
|
399
|
+
const gridWidget = this.#widgetGridRegistry.getRegisteredWidgets().find((w) => w.id === pd.widgetName);
|
|
400
|
+
this.selectedWidget = gridWidget?.setupComponent ? gridWidget : undefined;
|
|
401
|
+
this.widgetConfigMap = pd.widgetConfigMap || {};
|
|
402
|
+
this.widgetId = pd.widgetId;
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
/**
|
|
406
|
+
* Collection of buckets to load available widgets from. Wildcards are also posssible:
|
|
407
|
+
* `[buckets]="['app.default', '*.public.*', 'app.no?.widgets']"`
|
|
408
|
+
*
|
|
409
|
+
* `*` represents any character 0-n times
|
|
410
|
+
* `?` represents exactly one character
|
|
411
|
+
*/
|
|
412
|
+
this.buckets = input(this.#dialogData.buckets);
|
|
413
|
+
this.picked = output();
|
|
414
|
+
this.canceled = output();
|
|
415
|
+
this.pickerFormControl.valueChanges.pipe(takeUntilDestroyed()).subscribe((widgets) => {
|
|
416
|
+
if (widgets.length)
|
|
417
|
+
this.pick(widgets[0]);
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
pick(widget) {
|
|
421
|
+
if (widget?.setupComponent) {
|
|
422
|
+
// if the selected widget has a setup component, we'll continue ...
|
|
423
|
+
this.selectedWidget = widget?.setupComponent ? widget : undefined;
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
if (this.widgetId) {
|
|
427
|
+
// update existing widget
|
|
428
|
+
this.#widgetGridService.replaceWidget(this.widgetId, widget.id);
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
this.#widgetGridService.addWidget(widget.id);
|
|
432
|
+
}
|
|
433
|
+
this.picked.emit();
|
|
434
|
+
this.#dialogRef.close();
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
onSetupConfigChange(setupConfig) {
|
|
438
|
+
this.widgetConfigDirty = !!setupConfig;
|
|
439
|
+
this.setupWidgetConfig = setupConfig;
|
|
440
|
+
}
|
|
441
|
+
setupComponentSave() {
|
|
442
|
+
// TODO: save/emit config
|
|
443
|
+
if (this.widgetId && this.selectedWidget) {
|
|
444
|
+
if (this.pickerData()?.widgetName !== this.selectedWidget.id) {
|
|
445
|
+
this.#widgetGridService.replaceWidget(this.widgetId, this.selectedWidget.id, this.setupWidgetConfig);
|
|
446
|
+
}
|
|
447
|
+
else {
|
|
448
|
+
this.#widgetGridService.updateWidget(this.widgetId, this.setupWidgetConfig);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
this.#widgetGridService.addWidget(this.selectedWidget.id, this.setupWidgetConfig);
|
|
453
|
+
}
|
|
454
|
+
this.picked.emit();
|
|
455
|
+
this.#dialogRef.close();
|
|
456
|
+
}
|
|
457
|
+
setupComponentCancel() {
|
|
458
|
+
this.reset();
|
|
459
|
+
}
|
|
460
|
+
cancel() {
|
|
461
|
+
this.canceled.emit();
|
|
462
|
+
this.#dialogRef.close();
|
|
463
|
+
}
|
|
464
|
+
reset() {
|
|
465
|
+
this.selectedWidget = undefined;
|
|
466
|
+
this.setupWidgetConfig = undefined;
|
|
467
|
+
}
|
|
468
|
+
ngOnInit() {
|
|
469
|
+
this.registeredWidgets = this.#widgetGridRegistry.getRegisteredWidgets(this.buckets());
|
|
470
|
+
}
|
|
471
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: WidgetPickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
472
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.12", type: WidgetPickerComponent, isStandalone: true, selector: "yuv-widget-picker", inputs: { pickerData: { classPropertyName: "pickerData", publicName: "pickerData", isSignal: true, isRequired: false, transformFunction: null }, buckets: { classPropertyName: "buckets", publicName: "buckets", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { picked: "picked", canceled: "canceled" }, ngImport: i0, template: "<yuv-dialog [headertitel]=\"selectedWidget ? selectedWidget.label : ('yuv.widget-grid.widget-picker.title' | translate)\">\n <!-- <header class=\"dark\" [ngClass]=\"{ listing: !selectedWidget }\">\n @if (selectedWidget) {\n <button mat-icon-button (click)=\"reset()\"><mat-icon>back</mat-icon></button>\n }\n <div class=\"title\">{{ selectedWidget ? selectedWidget.label : ('yuv.widget-grid.widget-picker.title' | translate) }}</div>\n <button mat-icon-button (click)=\"cancel()\"><mat-icon>clear</mat-icon></button>\n </header> -->\n\n <main class=\"{{ !selectedWidget ? 'widget-listing' : 'widget-setup' }}\">\n @if (!selectedWidget) {\n <mat-selection-list role=\"list\" [formControl]=\"pickerFormControl\" [multiple]=\"false\" [hideSingleSelectionIndicator]=\"true\">\n <!-- list of avalable widgets -->\n @for (w of registeredWidgets; track $index) {\n <mat-list-option [value]=\"w\">\n {{ w.label }}\n </mat-list-option>\n } @empty {\n <div class=\"empty\">\n {{ 'yuv.widget-grid.widget-picker.empty' | translate }}\n </div>\n }\n </mat-selection-list>\n } @else {\n <div class=\"component\">\n <ng-container\n *ngComponentOutlet=\"selectedWidget!.setupComponent!; ndcDynamicInputs: widgetConfigMap; ndcDynamicOutputs: setupWidgetDynamicOutputs\"\n ></ng-container>\n </div>\n }\n </main>\n <footer>\n @if (selectedWidget) {\n <button ymtButton=\"secondary\" (click)=\"setupComponentCancel()\">{{ 'yuv.widget-grid.button.cancel' | translate }}</button>\n <button ymtButton=\"primary\" [disabled]=\"!widgetConfigDirty || widgetConfigState === 'INVALID'\" (click)=\"setupComponentSave()\">\n {{ 'yuv.widget-grid.button.save' | translate }}\n </button>\n } @else {\n <button ymtButton=\"secondary\" (click)=\"cancel()\">{{ 'yuv.widget-grid.button.cancel' | translate }}</button>\n }\n </footer>\n</yuv-dialog>\n", styles: [":host .empty{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%}:host main.widget-setup{height:100%;display:grid;grid-template-rows:1fr auto;grid-template-columns:1fr;grid-template-areas:\"component\" \"buttons\"}:host main.widget-listing .widget{padding:var(--app-pane-padding);border-bottom:1px solid var(--panel-divider-color);cursor:pointer}:host main.widget-listing .widget:hover{background-color:var(--item-focus-background-color)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletContent", "ngComponentOutletNgModule", "ngComponentOutletNgModuleFactory"], exportAs: ["ngComponentOutlet"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: DialogComponent, selector: "yuv-dialog", inputs: ["headertitel"] }, { kind: "directive", type: YmtButtonDirective, selector: "button[ymtButton], a[ymtButton]", inputs: ["ymtButton", "disabled", "aria-disabled", "disableRipple", "disabledInteractive", "button-size"] }, { kind: "ngmodule", type: MatListModule }, { kind: "component", type: i3$1.MatSelectionList, selector: "mat-selection-list", inputs: ["color", "compareWith", "multiple", "hideSingleSelectionIndicator", "disabled"], outputs: ["selectionChange"], exportAs: ["matSelectionList"] }, { kind: "component", type: i3$1.MatListOption, selector: "mat-list-option", inputs: ["togglePosition", "checkboxPosition", "color", "value", "selected"], outputs: ["selectedChange"], exportAs: ["matListOption"] }, { kind: "ngmodule", type: DynamicIoModule }, { kind: "directive", type: i4.ComponentOutletInjectorDirective, selector: "[ngComponentOutlet]", exportAs: ["ndcComponentOutletInjector"] }, { kind: "directive", type: i4.ComponentOutletIoDirective, selector: "[ngComponentOutletNdcDynamicInputs],[ngComponentOutletNdcDynamicOutputs]", inputs: ["ngComponentOutletNdcDynamicInputs", "ngComponentOutletNdcDynamicOutputs"], exportAs: ["ndcDynamicIo"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i4$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: SignalComponentIoModule }] }); }
|
|
473
|
+
}
|
|
474
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: WidgetPickerComponent, decorators: [{
|
|
475
|
+
type: Component,
|
|
476
|
+
args: [{ selector: 'yuv-widget-picker', imports: [
|
|
477
|
+
CommonModule,
|
|
478
|
+
MatButtonModule,
|
|
479
|
+
TranslateModule,
|
|
480
|
+
MatIconModule,
|
|
481
|
+
DialogComponent,
|
|
482
|
+
YmtButtonDirective,
|
|
483
|
+
MatListModule,
|
|
484
|
+
DynamicIoModule,
|
|
485
|
+
ReactiveFormsModule,
|
|
486
|
+
SignalComponentIoModule
|
|
487
|
+
], template: "<yuv-dialog [headertitel]=\"selectedWidget ? selectedWidget.label : ('yuv.widget-grid.widget-picker.title' | translate)\">\n <!-- <header class=\"dark\" [ngClass]=\"{ listing: !selectedWidget }\">\n @if (selectedWidget) {\n <button mat-icon-button (click)=\"reset()\"><mat-icon>back</mat-icon></button>\n }\n <div class=\"title\">{{ selectedWidget ? selectedWidget.label : ('yuv.widget-grid.widget-picker.title' | translate) }}</div>\n <button mat-icon-button (click)=\"cancel()\"><mat-icon>clear</mat-icon></button>\n </header> -->\n\n <main class=\"{{ !selectedWidget ? 'widget-listing' : 'widget-setup' }}\">\n @if (!selectedWidget) {\n <mat-selection-list role=\"list\" [formControl]=\"pickerFormControl\" [multiple]=\"false\" [hideSingleSelectionIndicator]=\"true\">\n <!-- list of avalable widgets -->\n @for (w of registeredWidgets; track $index) {\n <mat-list-option [value]=\"w\">\n {{ w.label }}\n </mat-list-option>\n } @empty {\n <div class=\"empty\">\n {{ 'yuv.widget-grid.widget-picker.empty' | translate }}\n </div>\n }\n </mat-selection-list>\n } @else {\n <div class=\"component\">\n <ng-container\n *ngComponentOutlet=\"selectedWidget!.setupComponent!; ndcDynamicInputs: widgetConfigMap; ndcDynamicOutputs: setupWidgetDynamicOutputs\"\n ></ng-container>\n </div>\n }\n </main>\n <footer>\n @if (selectedWidget) {\n <button ymtButton=\"secondary\" (click)=\"setupComponentCancel()\">{{ 'yuv.widget-grid.button.cancel' | translate }}</button>\n <button ymtButton=\"primary\" [disabled]=\"!widgetConfigDirty || widgetConfigState === 'INVALID'\" (click)=\"setupComponentSave()\">\n {{ 'yuv.widget-grid.button.save' | translate }}\n </button>\n } @else {\n <button ymtButton=\"secondary\" (click)=\"cancel()\">{{ 'yuv.widget-grid.button.cancel' | translate }}</button>\n }\n </footer>\n</yuv-dialog>\n", styles: [":host .empty{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%}:host main.widget-setup{height:100%;display:grid;grid-template-rows:1fr auto;grid-template-columns:1fr;grid-template-areas:\"component\" \"buttons\"}:host main.widget-listing .widget{padding:var(--app-pane-padding);border-bottom:1px solid var(--panel-divider-color);cursor:pointer}:host main.widget-listing .widget:hover{background-color:var(--item-focus-background-color)}\n"] }]
|
|
488
|
+
}], ctorParameters: () => [] });
|
|
489
|
+
|
|
490
|
+
class YuvWidgetGridComponent {
|
|
491
|
+
#dialog;
|
|
492
|
+
#widgetGridService;
|
|
493
|
+
#widgetGridEventService;
|
|
494
|
+
#gridConfigEffect;
|
|
495
|
+
#editModeEffect;
|
|
496
|
+
#gridItemConfigEffect;
|
|
497
|
+
constructor() {
|
|
498
|
+
this.#dialog = inject(MatDialog);
|
|
499
|
+
this.#widgetGridService = inject(WidgetGridService);
|
|
500
|
+
this.#widgetGridEventService = inject(WidgetGridEventService);
|
|
501
|
+
this.gridsterItems = viewChild.required(GridsterItemComponent);
|
|
502
|
+
this.widgetPicker = viewChild.required('widgetPicker', { read: TemplateRef });
|
|
503
|
+
this.options = {
|
|
504
|
+
gridType: GridType.Fit,
|
|
505
|
+
displayGrid: DisplayGrid.None,
|
|
506
|
+
pushItems: false,
|
|
507
|
+
outerMargin: false,
|
|
508
|
+
swap: false,
|
|
509
|
+
draggable: {
|
|
510
|
+
enabled: false,
|
|
511
|
+
ignoreContent: true,
|
|
512
|
+
dragHandleClass: 'dragHandle'
|
|
513
|
+
},
|
|
514
|
+
resizable: {
|
|
515
|
+
enabled: false
|
|
516
|
+
},
|
|
517
|
+
itemChangeCallback: (gridsterItem, gridsterItemComponent) => {
|
|
518
|
+
this.emitChange();
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
this.gridConfig = input();
|
|
522
|
+
this.#gridConfigEffect = effect(() => {
|
|
523
|
+
const cfg = this.gridConfig();
|
|
524
|
+
if (cfg?.rows) {
|
|
525
|
+
this.options.minRows = cfg.rows;
|
|
526
|
+
this.options.maxRows = cfg.rows;
|
|
527
|
+
}
|
|
528
|
+
if (cfg?.columns) {
|
|
529
|
+
this.options.minCols = cfg.columns;
|
|
530
|
+
this.options.maxCols = cfg.columns;
|
|
531
|
+
}
|
|
532
|
+
if (cfg?.gap) {
|
|
533
|
+
this.options.margin = cfg.gap;
|
|
534
|
+
}
|
|
535
|
+
this.#widgetGridService.addItemSize = {
|
|
536
|
+
cols: cfg?.newItemWidth || 1,
|
|
537
|
+
rows: cfg?.newItemHeight || 1
|
|
538
|
+
};
|
|
539
|
+
});
|
|
540
|
+
/**
|
|
541
|
+
* Whether or not to enable edit mode. In edit mode controls
|
|
542
|
+
* for editing existing tiles and creating new ones are shown.
|
|
543
|
+
* This mode also enables positioning and resizing of the tiles.
|
|
544
|
+
*/
|
|
545
|
+
this.editMode = input(false);
|
|
546
|
+
this.#editModeEffect = effect(() => {
|
|
547
|
+
const e = this.editMode();
|
|
548
|
+
this.options.draggable.enabled = !!e;
|
|
549
|
+
this.options.resizable.enabled = !!e;
|
|
550
|
+
this.options.displayGrid = e ? DisplayGrid.Always : DisplayGrid.None;
|
|
551
|
+
if (this.options.api && this.options.api.optionsChanged) {
|
|
552
|
+
this.options.api.optionsChanged();
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
this.gridItemConfig = input(undefined);
|
|
556
|
+
this.#gridItemConfigEffect = effect(() => {
|
|
557
|
+
this.#widgetGridService.setWidgetGrid(this.gridItemConfig());
|
|
558
|
+
});
|
|
559
|
+
/**
|
|
560
|
+
* Collection of buckets to load available widgets from. Wildcards are also posssible:
|
|
561
|
+
* `[buckets]="['app.default', '*.public.*', 'app.no?.widgets']"`
|
|
562
|
+
*
|
|
563
|
+
* `*` represents any character 0-n times
|
|
564
|
+
* `?` represents exactly one character
|
|
565
|
+
*/
|
|
566
|
+
this.buckets = input(undefined);
|
|
567
|
+
// @Input() buckets?: string[];
|
|
568
|
+
/**
|
|
569
|
+
* Emitted when the grid has been changed
|
|
570
|
+
*/
|
|
571
|
+
this.gridChange = output();
|
|
572
|
+
this.gridItemEvent = output();
|
|
573
|
+
/**
|
|
574
|
+
* Emitted when the widget picker is opened or closed in edit mode
|
|
575
|
+
*/
|
|
576
|
+
this.widgetPickerOpen = output();
|
|
577
|
+
this.widgetGrid = [];
|
|
578
|
+
this.#widgetGridService.widgetGrid$.pipe(takeUntilDestroyed()).subscribe((widgetGrid) => {
|
|
579
|
+
this.widgetGrid = widgetGrid;
|
|
580
|
+
});
|
|
581
|
+
this.#widgetGridEventService.widgetEvents$.pipe(takeUntilDestroyed()).subscribe((evt) => {
|
|
582
|
+
this.gridItemEvent.emit(evt);
|
|
583
|
+
});
|
|
584
|
+
this.#widgetGridService.widgetGridUpdate$.pipe(takeUntilDestroyed()).subscribe((_) => {
|
|
585
|
+
this.emitChange();
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
openWidgetPicker(item) {
|
|
589
|
+
if (item) {
|
|
590
|
+
// open setup component for selected grid item
|
|
591
|
+
this.widgetPickerData = {
|
|
592
|
+
widgetName: item.widgetName,
|
|
593
|
+
widgetConfigMap: item.widgetConfigMap,
|
|
594
|
+
widgetId: item.id
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
else {
|
|
598
|
+
this.widgetPickerData = undefined;
|
|
599
|
+
}
|
|
600
|
+
this.widgetPickerOpen.emit(true);
|
|
601
|
+
this.#dialog
|
|
602
|
+
.open(this.widgetPicker(), {
|
|
603
|
+
data: {
|
|
604
|
+
pickerData: this.widgetPickerData,
|
|
605
|
+
buckets: this.buckets()
|
|
606
|
+
}
|
|
607
|
+
})
|
|
608
|
+
.afterClosed()
|
|
609
|
+
.subscribe(() => this.widgetPickerOpen.emit(false));
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Removes a widget from the grid
|
|
613
|
+
* @param item The widget to be removed
|
|
614
|
+
*/
|
|
615
|
+
removeItem(item) {
|
|
616
|
+
this.#widgetGridService.removeWidget(item.id);
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Add a new widget to the grid by opening the widget picker
|
|
620
|
+
*/
|
|
621
|
+
addItem() {
|
|
622
|
+
this.openWidgetPicker();
|
|
623
|
+
}
|
|
624
|
+
emitChange() {
|
|
625
|
+
const mapped = [];
|
|
626
|
+
this.widgetGrid.forEach((i) => {
|
|
627
|
+
const m = { ...i };
|
|
628
|
+
delete m['widget'];
|
|
629
|
+
delete m['widgetConfigMap'];
|
|
630
|
+
mapped.push(m);
|
|
631
|
+
});
|
|
632
|
+
this.gridChange.emit(mapped);
|
|
633
|
+
}
|
|
634
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: YuvWidgetGridComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
635
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.12", type: YuvWidgetGridComponent, isStandalone: true, selector: "yuv-widget-grid", inputs: { gridConfig: { classPropertyName: "gridConfig", publicName: "gridConfig", isSignal: true, isRequired: false, transformFunction: null }, editMode: { classPropertyName: "editMode", publicName: "editMode", isSignal: true, isRequired: false, transformFunction: null }, gridItemConfig: { classPropertyName: "gridItemConfig", publicName: "gridItemConfig", isSignal: true, isRequired: false, transformFunction: null }, buckets: { classPropertyName: "buckets", publicName: "buckets", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { gridChange: "gridChange", gridItemEvent: "gridItemEvent", widgetPickerOpen: "widgetPickerOpen" }, host: { properties: { "class.widget-grid-edit": "editMode()" } }, providers: [WidgetGridService], viewQueries: [{ propertyName: "gridsterItems", first: true, predicate: GridsterItemComponent, descendants: true, isSignal: true }, { propertyName: "widgetPicker", first: true, predicate: ["widgetPicker"], descendants: true, read: TemplateRef, isSignal: true }], ngImport: i0, template: "@if (editMode()) {\n <button class=\"fab\" mat-fab [attr.aria-label]=\"'yuv.widget-grid.widget.add.label' | translate\" (click)=\"addItem()\">\n <mat-icon>add</mat-icon>\n </button>\n}\n\n@if (widgetGrid.length === 0 && !editMode()) {\n <div class=\"empty\">\n <p>{{ 'yuv.widget-grid.empty' | translate }}</p>\n <!-- <button ymtButton=\"primary\" (click)=\"editMode.set(true)\">{{'yuv.widget-grid.empty.create' | translate}}</button> -->\n </div>\n} @else {\n <gridster [options]=\"options\">\n @for (item of widgetGrid; track item.id) {\n <gridster-item [item]=\"item\">\n @if (editMode()) {\n <div class=\"toolbar\">\n <!-- drag handle -->\n <mat-icon class=\"dragHandle ymt-icon--size-s\">drag_indicator</mat-icon>\n <!-- edit -->\n <button mat-icon-button (click)=\"openWidgetPicker(item)\"><mat-icon class=\"ymt-icon--size-s\">edit</mat-icon></button>\n <!-- remove -->\n <button mat-icon-button (click)=\"removeItem(item)\"><mat-icon class=\"ymt-icon--size-s\">clear</mat-icon></button>\n </div>\n }\n <div class=\"cmp\">\n <ng-container *ngComponentOutlet=\"item.widget; ndcDynamicInputs: item.widgetConfigMap\"></ng-container>\n </div>\n </gridster-item>\n }\n </gridster>\n}\n<ng-template #widgetPicker>\n <yuv-widget-picker [pickerData]=\"widgetPickerData\" [buckets]=\"buckets()\"></yuv-widget-picker>\n</ng-template>\n", styles: [":host{position:relative}:host .fab{position:absolute;inset-inline-end:var(--ymt-spacing-m);inset-block-end:var(--ymt-spacing-m);z-index:100}:host .cmp{height:100%}:host.widget-grid-edit gridster-item{outline:1px solid var(--ymt-outline);outline-offset:-1px}:host .empty{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--ymt-on-surface);font:var(--ymt-font-body-medium)}:host .empty p{padding:var(--ymt-spacing-m);max-width:45ch;text-align:center}:host gridster{background-color:transparent}:host gridster ::ng-deep .gridster-column,:host gridster ::ng-deep .gridster-row{border-color:var(--ymt-outline-variant);transition:none}:host gridster-item{transition:none;background-color:transparent}:host gridster-item .toolbar{position:absolute;z-index:1;background-color:var(--ymt-brand);right:0;top:var(--ymt-spacing-xs);padding:var(--ymt-spacing-xs);gap:var(--ymt-spacing-s);display:flex;flex-flow:row nowrap;align-items:center}:host gridster-item .dragHandle{color:var(--ymt-on-brand);display:flex;flex-flow:column;align-items:center;justify-content:center;padding:0 var(--ymt-spacing-s);cursor:move}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletContent", "ngComponentOutletNgModule", "ngComponentOutletNgModuleFactory"], exportAs: ["ngComponentOutlet"] }, { kind: "ngmodule", type: DynamicIoModule }, { kind: "directive", type: i4.ComponentOutletInjectorDirective, selector: "[ngComponentOutlet]", exportAs: ["ndcComponentOutletInjector"] }, { kind: "directive", type: i4.ComponentOutletIoDirective, selector: "[ngComponentOutletNdcDynamicInputs],[ngComponentOutletNdcDynamicOutputs]", inputs: ["ngComponentOutletNdcDynamicInputs", "ngComponentOutletNdcDynamicOutputs"], exportAs: ["ndcDynamicIo"] }, { kind: "ngmodule", type: SignalComponentIoModule }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }, { kind: "component", type: GridsterComponent, selector: "gridster", inputs: ["options"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i4$2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i5.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { kind: "component", type: i5.MatFabButton, selector: "button[mat-fab]", inputs: ["extended"], exportAs: ["matButton"] }, { kind: "component", type: WidgetPickerComponent, selector: "yuv-widget-picker", inputs: ["pickerData", "buckets"], outputs: ["picked", "canceled"] }, { kind: "component", type: GridsterItemComponent, selector: "gridster-item", inputs: ["item"], outputs: ["itemInit", "itemChange", "itemResize"] }] }); }
|
|
636
|
+
}
|
|
637
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: YuvWidgetGridComponent, decorators: [{
|
|
638
|
+
type: Component,
|
|
639
|
+
args: [{ selector: 'yuv-widget-grid', imports: [
|
|
640
|
+
CommonModule,
|
|
641
|
+
DynamicIoModule,
|
|
642
|
+
SignalComponentIoModule,
|
|
643
|
+
TranslateModule,
|
|
644
|
+
GridsterComponent,
|
|
645
|
+
MatIconModule,
|
|
646
|
+
YmtButtonDirective,
|
|
647
|
+
MatButtonModule,
|
|
648
|
+
WidgetPickerComponent,
|
|
649
|
+
GridsterItemComponent
|
|
650
|
+
], providers: [WidgetGridService], host: { '[class.widget-grid-edit]': 'editMode()' }, template: "@if (editMode()) {\n <button class=\"fab\" mat-fab [attr.aria-label]=\"'yuv.widget-grid.widget.add.label' | translate\" (click)=\"addItem()\">\n <mat-icon>add</mat-icon>\n </button>\n}\n\n@if (widgetGrid.length === 0 && !editMode()) {\n <div class=\"empty\">\n <p>{{ 'yuv.widget-grid.empty' | translate }}</p>\n <!-- <button ymtButton=\"primary\" (click)=\"editMode.set(true)\">{{'yuv.widget-grid.empty.create' | translate}}</button> -->\n </div>\n} @else {\n <gridster [options]=\"options\">\n @for (item of widgetGrid; track item.id) {\n <gridster-item [item]=\"item\">\n @if (editMode()) {\n <div class=\"toolbar\">\n <!-- drag handle -->\n <mat-icon class=\"dragHandle ymt-icon--size-s\">drag_indicator</mat-icon>\n <!-- edit -->\n <button mat-icon-button (click)=\"openWidgetPicker(item)\"><mat-icon class=\"ymt-icon--size-s\">edit</mat-icon></button>\n <!-- remove -->\n <button mat-icon-button (click)=\"removeItem(item)\"><mat-icon class=\"ymt-icon--size-s\">clear</mat-icon></button>\n </div>\n }\n <div class=\"cmp\">\n <ng-container *ngComponentOutlet=\"item.widget; ndcDynamicInputs: item.widgetConfigMap\"></ng-container>\n </div>\n </gridster-item>\n }\n </gridster>\n}\n<ng-template #widgetPicker>\n <yuv-widget-picker [pickerData]=\"widgetPickerData\" [buckets]=\"buckets()\"></yuv-widget-picker>\n</ng-template>\n", styles: [":host{position:relative}:host .fab{position:absolute;inset-inline-end:var(--ymt-spacing-m);inset-block-end:var(--ymt-spacing-m);z-index:100}:host .cmp{height:100%}:host.widget-grid-edit gridster-item{outline:1px solid var(--ymt-outline);outline-offset:-1px}:host .empty{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--ymt-on-surface);font:var(--ymt-font-body-medium)}:host .empty p{padding:var(--ymt-spacing-m);max-width:45ch;text-align:center}:host gridster{background-color:transparent}:host gridster ::ng-deep .gridster-column,:host gridster ::ng-deep .gridster-row{border-color:var(--ymt-outline-variant);transition:none}:host gridster-item{transition:none;background-color:transparent}:host gridster-item .toolbar{position:absolute;z-index:1;background-color:var(--ymt-brand);right:0;top:var(--ymt-spacing-xs);padding:var(--ymt-spacing-xs);gap:var(--ymt-spacing-s);display:flex;flex-flow:row nowrap;align-items:center}:host gridster-item .dragHandle{color:var(--ymt-on-brand);display:flex;flex-flow:column;align-items:center;justify-content:center;padding:0 var(--ymt-spacing-s);cursor:move}\n"] }]
|
|
651
|
+
}], ctorParameters: () => [] });
|
|
652
|
+
|
|
653
|
+
class WorkspaceEditComponent {
|
|
654
|
+
constructor() {
|
|
655
|
+
this.dialogRef = inject((MatDialogRef));
|
|
656
|
+
this.workspaceForm = input.required();
|
|
657
|
+
this.workspaceSubmit = output();
|
|
658
|
+
}
|
|
659
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: WorkspaceEditComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
660
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.12", type: WorkspaceEditComponent, isStandalone: true, selector: "yuv-workspace-edit", inputs: { workspaceForm: { classPropertyName: "workspaceForm", publicName: "workspaceForm", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { workspaceSubmit: "workspaceSubmit" }, ngImport: i0, template: "<yuv-dialog [headertitel]=\"'yuv.widget-grid.workspaces.edit.title' | translate\">\n <main>\n <form id=\"workspaceEditForm\" [formGroup]=\"workspaceForm()\" (ngSubmit)=\"workspaceSubmit.emit()\">\n <mat-form-field class=\"yuv-form-field\">\n <mat-label>{{ 'yuv.widget-grid.workspaces.workspace.label' | translate }}</mat-label>\n <input matInput formControlName=\"label\" />\n </mat-form-field>\n </form>\n </main>\n <footer>\n <button ymtButton=\"secondary\" type=\"button\" (click)=\"dialogRef.close()\">\n {{ 'yuv.widget-grid.workspaces.edit.cancel' | translate }}\n </button>\n <button ymtButton=\"primary\" form=\"workspaceEditForm\" type=\"submit\" [disabled]=\"workspaceForm().invalid\">\n {{ 'yuv.widget-grid.workspaces.edit.save' | translate }}\n </button>\n </footer>\n</yuv-dialog>\n", styles: [":host main{padding:var(--ymt-spacing-m)}:host mat-form-field{width:100%}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: DialogComponent, selector: "yuv-dialog", inputs: ["headertitel"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i1$1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i1$1.MatLabel, selector: "mat-label" }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i2.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "directive", type: YmtButtonDirective, selector: "button[ymtButton], a[ymtButton]", inputs: ["ymtButton", "disabled", "aria-disabled", "disableRipple", "disabledInteractive", "button-size"] }, { kind: "ngmodule", type: TranslateModule$1 }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i4$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i4$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i4$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i4$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i4$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }] }); }
|
|
661
|
+
}
|
|
662
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: WorkspaceEditComponent, decorators: [{
|
|
663
|
+
type: Component,
|
|
664
|
+
args: [{ selector: 'yuv-workspace-edit', imports: [CommonModule, DialogComponent, MatFormFieldModule,
|
|
665
|
+
MatInputModule,
|
|
666
|
+
YmtButtonDirective,
|
|
667
|
+
TranslateModule$1,
|
|
668
|
+
ReactiveFormsModule], template: "<yuv-dialog [headertitel]=\"'yuv.widget-grid.workspaces.edit.title' | translate\">\n <main>\n <form id=\"workspaceEditForm\" [formGroup]=\"workspaceForm()\" (ngSubmit)=\"workspaceSubmit.emit()\">\n <mat-form-field class=\"yuv-form-field\">\n <mat-label>{{ 'yuv.widget-grid.workspaces.workspace.label' | translate }}</mat-label>\n <input matInput formControlName=\"label\" />\n </mat-form-field>\n </form>\n </main>\n <footer>\n <button ymtButton=\"secondary\" type=\"button\" (click)=\"dialogRef.close()\">\n {{ 'yuv.widget-grid.workspaces.edit.cancel' | translate }}\n </button>\n <button ymtButton=\"primary\" form=\"workspaceEditForm\" type=\"submit\" [disabled]=\"workspaceForm().invalid\">\n {{ 'yuv.widget-grid.workspaces.edit.save' | translate }}\n </button>\n </footer>\n</yuv-dialog>\n", styles: [":host main{padding:var(--ymt-spacing-m)}:host mat-form-field{width:100%}\n"] }]
|
|
669
|
+
}] });
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Component for managing multiple widget grids in so called workspaces.
|
|
673
|
+
* Each workspace can have its own configuration and widgets. The user can
|
|
674
|
+
* switch between workspaces to use or edit the widgets in the current workspace.
|
|
675
|
+
*/
|
|
676
|
+
class YuvWidgetGridWorkspacesComponent {
|
|
677
|
+
constructor() {
|
|
678
|
+
this.#dialog = inject(MatDialog);
|
|
679
|
+
this.#fb = inject(FormBuilder);
|
|
680
|
+
this.#confirm = inject(ConfirmService);
|
|
681
|
+
this.translate = inject(TranslateService);
|
|
682
|
+
this.#DEFAULT_WORKSPACE_OPTIONS = {
|
|
683
|
+
gridConfig: {
|
|
684
|
+
columns: 10,
|
|
685
|
+
rows: 10
|
|
686
|
+
}
|
|
687
|
+
};
|
|
688
|
+
this.workspaceForm = this.#fb.group({
|
|
689
|
+
id: [''],
|
|
690
|
+
label: ['', Validators.required]
|
|
691
|
+
});
|
|
692
|
+
this.options = input(this.#DEFAULT_WORKSPACE_OPTIONS);
|
|
693
|
+
this._workspaceOptions = computed(() => ({
|
|
694
|
+
gridConfig: {
|
|
695
|
+
...this.#DEFAULT_WORKSPACE_OPTIONS.gridConfig,
|
|
696
|
+
...(this.options().gridConfig || {})
|
|
697
|
+
}
|
|
698
|
+
}));
|
|
699
|
+
this.workspaceConfig = input(undefined);
|
|
700
|
+
this._workspaceConfig = signal(undefined);
|
|
701
|
+
this.#workspaceConfigEffect = effect(() => {
|
|
702
|
+
const wsc = this.workspaceConfig();
|
|
703
|
+
untracked(() => {
|
|
704
|
+
this._workspaceConfig.set(wsc);
|
|
705
|
+
this.#updateOriginalWorkspaceConfig();
|
|
706
|
+
if (wsc?.currentWorkspace) {
|
|
707
|
+
this.setWorkspace(wsc.currentWorkspace, true);
|
|
708
|
+
}
|
|
709
|
+
});
|
|
710
|
+
});
|
|
711
|
+
/**
|
|
712
|
+
* Collection of buckets to load available widgets from. Wildcards are also posssible:
|
|
713
|
+
* `[buckets]="['app.default', '*.public.*', 'app.no?.widgets']"`
|
|
714
|
+
*
|
|
715
|
+
* `*` represents any character 0-n times
|
|
716
|
+
* `?` represents exactly one character
|
|
717
|
+
*/
|
|
718
|
+
this.buckets = input(undefined);
|
|
719
|
+
this.configChange = output();
|
|
720
|
+
this.gridItemEvent = output();
|
|
721
|
+
this.editModeChange = output();
|
|
722
|
+
this.editMode = signal(false);
|
|
723
|
+
// currently selected workspace
|
|
724
|
+
this.workspace = signal(undefined);
|
|
725
|
+
this.#workspaceEffect = effect(() => {
|
|
726
|
+
const ws = this.workspace();
|
|
727
|
+
untracked(() => {
|
|
728
|
+
this.gridItemConfig.set(ws ? JSON.parse(JSON.stringify(ws.grid)) : undefined);
|
|
729
|
+
});
|
|
730
|
+
});
|
|
731
|
+
this.gridItemConfig = signal(undefined);
|
|
732
|
+
}
|
|
733
|
+
#dialog;
|
|
734
|
+
#fb;
|
|
735
|
+
#confirm;
|
|
736
|
+
#DEFAULT_WORKSPACE_OPTIONS;
|
|
737
|
+
get workspaceLabelControl() {
|
|
738
|
+
return this.workspaceForm.get('label');
|
|
739
|
+
}
|
|
740
|
+
#workspaceConfigEffect;
|
|
741
|
+
// persist the last 'accepted' workspace config to be able to revert changes
|
|
742
|
+
#originalWidgetGridWorkspaceConfig;
|
|
743
|
+
#workspaceEffect;
|
|
744
|
+
setWorkspace(id, silent = false) {
|
|
745
|
+
const workspace = this._workspaceConfig()?.workspaces.find((w) => w.id === id);
|
|
746
|
+
if (workspace) {
|
|
747
|
+
this.workspace.set(workspace);
|
|
748
|
+
this._workspaceConfig.update((cfg) => ({
|
|
749
|
+
...cfg,
|
|
750
|
+
currentWorkspace: id
|
|
751
|
+
}));
|
|
752
|
+
this.workspaceForm.patchValue({ label: workspace.label, id: workspace.id });
|
|
753
|
+
this.#updateOriginalWorkspaceConfig();
|
|
754
|
+
}
|
|
755
|
+
else {
|
|
756
|
+
this.workspace.set(undefined);
|
|
757
|
+
}
|
|
758
|
+
if (!silent)
|
|
759
|
+
this.emitConfigChange();
|
|
760
|
+
}
|
|
761
|
+
openWorkspaceDialog(create, tplRef) {
|
|
762
|
+
if (create) {
|
|
763
|
+
this.workspaceForm.reset();
|
|
764
|
+
}
|
|
765
|
+
this.workspaceDialogRef = this.#dialog.open(tplRef);
|
|
766
|
+
}
|
|
767
|
+
saveWorkspace() {
|
|
768
|
+
let cfg = this._workspaceConfig();
|
|
769
|
+
if (!cfg) {
|
|
770
|
+
cfg = {
|
|
771
|
+
workspaces: []
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
const isNewWorkspace = !this.workspaceForm.value.id;
|
|
775
|
+
if (isNewWorkspace) {
|
|
776
|
+
const newWorkspace = {
|
|
777
|
+
id: WidgetGridUtils.uuid(),
|
|
778
|
+
label: this.workspaceForm.value.label,
|
|
779
|
+
grid: []
|
|
780
|
+
};
|
|
781
|
+
this._workspaceConfig.set({
|
|
782
|
+
...cfg,
|
|
783
|
+
workspaces: [...cfg.workspaces, newWorkspace],
|
|
784
|
+
currentWorkspace: newWorkspace.id
|
|
785
|
+
});
|
|
786
|
+
this.workspace.set(newWorkspace);
|
|
787
|
+
this.workspaceForm.patchValue({ id: newWorkspace.id, label: newWorkspace.label });
|
|
788
|
+
}
|
|
789
|
+
else {
|
|
790
|
+
const existingIndex = cfg.workspaces.findIndex((w) => w.id === this.workspaceForm.value.id);
|
|
791
|
+
if (existingIndex === -1) {
|
|
792
|
+
const updatedWorkspace = cfg.workspaces[existingIndex];
|
|
793
|
+
updatedWorkspace.label = this.workspaceForm.value.label;
|
|
794
|
+
const workspaces = cfg.workspaces;
|
|
795
|
+
workspaces[existingIndex] = updatedWorkspace;
|
|
796
|
+
this._workspaceConfig.set({
|
|
797
|
+
...cfg,
|
|
798
|
+
workspaces
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
else {
|
|
802
|
+
// workspace label may have changed
|
|
803
|
+
cfg.workspaces[existingIndex].label = this.workspaceForm.value.label;
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
this.workspaceDialogRef?.close();
|
|
807
|
+
this.emitConfigChange();
|
|
808
|
+
}
|
|
809
|
+
#updateOriginalWorkspaceConfig() {
|
|
810
|
+
this.#originalWidgetGridWorkspaceConfig = WidgetGridUtils.gridConfigStringify(this.workspaceConfig());
|
|
811
|
+
}
|
|
812
|
+
onGridEvent(e) {
|
|
813
|
+
this.gridItemEvent.emit(e);
|
|
814
|
+
}
|
|
815
|
+
onGridChange(grid) {
|
|
816
|
+
const ws = this.workspace();
|
|
817
|
+
if (ws) {
|
|
818
|
+
ws.grid = grid;
|
|
819
|
+
const wsc = this._workspaceConfig();
|
|
820
|
+
const idx = wsc ? wsc.workspaces.findIndex((w) => w.id === ws.id) : -1;
|
|
821
|
+
if (idx > -1) {
|
|
822
|
+
const wgw = this._workspaceConfig()?.workspaces || [];
|
|
823
|
+
wgw[idx] = ws;
|
|
824
|
+
this._workspaceConfig.update((curr) => ({
|
|
825
|
+
...curr,
|
|
826
|
+
workspaces: wgw
|
|
827
|
+
}));
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
// emit current changes and reset original workspace config internally
|
|
832
|
+
persistWorkspaceConfig() {
|
|
833
|
+
this.saveWorkspace();
|
|
834
|
+
// this.#updateOriginalWorkspaceConfig();
|
|
835
|
+
// this.emitConfigChange();
|
|
836
|
+
this.editMode.set(false);
|
|
837
|
+
}
|
|
838
|
+
revertWorkspaceConfig() {
|
|
839
|
+
if (this.#originalWidgetGridWorkspaceConfig) {
|
|
840
|
+
this._workspaceConfig.set(WidgetGridUtils.gridConfigParse(this.#originalWidgetGridWorkspaceConfig));
|
|
841
|
+
}
|
|
842
|
+
const cws = this.workspaceConfig()?.currentWorkspace;
|
|
843
|
+
if (cws)
|
|
844
|
+
this.setWorkspace(cws, true);
|
|
845
|
+
this.editMode.set(false);
|
|
846
|
+
}
|
|
847
|
+
deleteCurrentWorkspace() {
|
|
848
|
+
const wsc = this._workspaceConfig();
|
|
849
|
+
const ws = this.workspace();
|
|
850
|
+
if (ws && wsc) {
|
|
851
|
+
const idx = wsc.workspaces.findIndex((w) => w.id === ws.id);
|
|
852
|
+
if (idx > -1) {
|
|
853
|
+
this.#confirm
|
|
854
|
+
.confirm({
|
|
855
|
+
message: this.translate.instant('yuv.widget-grid.workspaces.workspace.delete.confirm.message', {
|
|
856
|
+
label: ws.label
|
|
857
|
+
})
|
|
858
|
+
})
|
|
859
|
+
.subscribe((confirmed) => {
|
|
860
|
+
if (!confirmed)
|
|
861
|
+
return;
|
|
862
|
+
const workspaces = wsc.workspaces;
|
|
863
|
+
workspaces.splice(idx, 1);
|
|
864
|
+
// pick another workspace if the current one is deleted
|
|
865
|
+
const newCurrentWorkspace = workspaces.length > 0 ? workspaces[0] : undefined;
|
|
866
|
+
this._workspaceConfig.set({
|
|
867
|
+
...wsc,
|
|
868
|
+
workspaces,
|
|
869
|
+
currentWorkspace: newCurrentWorkspace?.id
|
|
870
|
+
});
|
|
871
|
+
this.workspace.set(newCurrentWorkspace);
|
|
872
|
+
this.emitConfigChange();
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
emitConfigChange() {
|
|
878
|
+
this.configChange.emit(this._workspaceConfig());
|
|
879
|
+
}
|
|
880
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: YuvWidgetGridWorkspacesComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
881
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.12", type: YuvWidgetGridWorkspacesComponent, isStandalone: true, selector: "yuv-widget-grid-workspaces", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, workspaceConfig: { classPropertyName: "workspaceConfig", publicName: "workspaceConfig", isSignal: true, isRequired: false, transformFunction: null }, buckets: { classPropertyName: "buckets", publicName: "buckets", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { configChange: "configChange", gridItemEvent: "gridItemEvent", editModeChange: "editModeChange" }, ngImport: i0, template: "@let ws = workspace();\n\n<div class=\"toolbar\">\n @if (ws) {\n <button mat-mini-fab [disabled]=\"editMode()\" (click)=\"openWorkspaceDialog(true, tplWworkspaceEdit)\"><mat-icon>add</mat-icon></button>\n\n @let workspaces = _workspaceConfig()?.workspaces || [];\n @if (workspaces.length > 1) {\n <button mat-icon-button [disabled]=\"editMode()\" [matMenuTriggerFor]=\"workspacePickerMenu\"><mat-icon>menu</mat-icon></button>\n\n <mat-menu #workspacePickerMenu=\"matMenu\">\n @for (ws of workspaces; track ws.id) {\n <button mat-menu-item (click)=\"setWorkspace(ws.id)\">{{ ws.label }}</button>\n }\n </mat-menu>\n }\n\n @if (!editMode()) {\n <h2 class=\"label\">{{ ws.label }}</h2>\n <button mat-icon-button [matMenuTriggerFor]=\"workspaceMenu\"><mat-icon>more_vert</mat-icon></button>\n <mat-menu #workspaceMenu=\"matMenu\">\n <button mat-menu-item (click)=\"editMode.set(!editMode())\">{{ 'yuv.widget-grid.workspaces.workspace.menu.edit' | translate }}</button>\n <button mat-menu-item (click)=\"deleteCurrentWorkspace()\">{{ 'yuv.widget-grid.workspaces.workspace.menu.delete' | translate }}</button>\n </mat-menu>\n } @else {\n <input type=\"text\" class=\"label\" [formControl]=\"workspaceLabelControl\" />\n <button ymtButton=\"secondary\" (click)=\"revertWorkspaceConfig()\">\n {{ 'yuv.widget-grid.workspaces.editMode.cancel' | translate }}\n </button>\n <button ymtButton=\"primary\" (click)=\"persistWorkspaceConfig()\">\n {{ 'yuv.widget-grid.workspaces.editMode.save' | translate }}\n </button>\n }\n }\n</div>\n\n@if (ws) {\n <yuv-widget-grid\n [gridConfig]=\"_workspaceOptions().gridConfig\"\n [gridItemConfig]=\"gridItemConfig()\"\n [buckets]=\"buckets()\"\n [editMode]=\"editMode()\"\n (gridChange)=\"onGridChange($event)\"\n (gridItemEvent)=\"onGridEvent($event)\"\n >\n </yuv-widget-grid>\n} @else {\n <div class=\"empty\">\n <p>{{ 'yuv.widget-grid.workspaces.empty' | translate }}</p>\n <button ymtButton=\"primary\" (click)=\"openWorkspaceDialog(true, tplWworkspaceEdit)\">\n {{ 'yuv.widget-grid.workspaces.empty.button.create' | translate }}\n </button>\n </div>\n}\n\n<ng-template #tplWworkspaceEdit>\n <yuv-workspace-edit [workspaceForm]=\"workspaceForm\" (workspaceSubmit)=\"saveWorkspace()\"></yuv-workspace-edit>\n</ng-template>\n", styles: [":host{display:flex;flex-direction:column;height:100%}:host .toolbar{display:flex;flex-direction:row;align-items:center;gap:var(--ymt-spacing-m)}:host .toolbar .label{flex:1;font:var(--ymt-font-headline-medium);letter-spacing:var(--ymt-font-headline-medium-tracking);margin-inline:0;margin-block:.75em;padding-inline:.25em 0;padding-block:.25em}:host .toolbar input.label{border:0;background-color:transparent;outline:1px solid var(--ymt-outline)}:host yuv-widget-grid{flex:1}:host>.empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: YuvWidgetGridComponent, selector: "yuv-widget-grid", inputs: ["gridConfig", "editMode", "gridItemConfig", "buckets"], outputs: ["gridChange", "gridItemEvent", "widgetPickerOpen"] }, { kind: "directive", type: YmtButtonDirective, selector: "button[ymtButton], a[ymtButton]", inputs: ["ymtButton", "disabled", "aria-disabled", "disableRipple", "disabledInteractive", "button-size"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i4$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i4$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i5.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { kind: "component", type: i5.MatMiniFabButton, selector: "button[mat-mini-fab]", exportAs: ["matButton"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i4$2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "ngmodule", type: MatMenuModule }, { kind: "component", type: i4$3.MatMenu, selector: "mat-menu", inputs: ["backdropClass", "aria-label", "aria-labelledby", "aria-describedby", "xPosition", "yPosition", "overlapTrigger", "hasBackdrop", "class", "classList"], outputs: ["closed", "close"], exportAs: ["matMenu"] }, { kind: "component", type: i4$3.MatMenuItem, selector: "[mat-menu-item]", inputs: ["role", "disabled", "disableRipple"], exportAs: ["matMenuItem"] }, { kind: "directive", type: i4$3.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", inputs: ["mat-menu-trigger-for", "matMenuTriggerFor", "matMenuTriggerData", "matMenuTriggerRestoreFocus"], outputs: ["menuOpened", "onMenuOpen", "menuClosed", "onMenuClose"], exportAs: ["matMenuTrigger"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }, { kind: "component", type: WorkspaceEditComponent, selector: "yuv-workspace-edit", inputs: ["workspaceForm"], outputs: ["workspaceSubmit"] }] }); }
|
|
882
|
+
}
|
|
883
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: YuvWidgetGridWorkspacesComponent, decorators: [{
|
|
884
|
+
type: Component,
|
|
885
|
+
args: [{ selector: 'yuv-widget-grid-workspaces', imports: [
|
|
886
|
+
CommonModule,
|
|
887
|
+
YuvWidgetGridComponent,
|
|
888
|
+
YmtButtonDirective,
|
|
889
|
+
ReactiveFormsModule,
|
|
890
|
+
MatInputModule,
|
|
891
|
+
MatButtonModule,
|
|
892
|
+
MatIconModule,
|
|
893
|
+
MatFormFieldModule,
|
|
894
|
+
MatMenuModule,
|
|
895
|
+
TranslateModule,
|
|
896
|
+
WorkspaceEditComponent
|
|
897
|
+
], template: "@let ws = workspace();\n\n<div class=\"toolbar\">\n @if (ws) {\n <button mat-mini-fab [disabled]=\"editMode()\" (click)=\"openWorkspaceDialog(true, tplWworkspaceEdit)\"><mat-icon>add</mat-icon></button>\n\n @let workspaces = _workspaceConfig()?.workspaces || [];\n @if (workspaces.length > 1) {\n <button mat-icon-button [disabled]=\"editMode()\" [matMenuTriggerFor]=\"workspacePickerMenu\"><mat-icon>menu</mat-icon></button>\n\n <mat-menu #workspacePickerMenu=\"matMenu\">\n @for (ws of workspaces; track ws.id) {\n <button mat-menu-item (click)=\"setWorkspace(ws.id)\">{{ ws.label }}</button>\n }\n </mat-menu>\n }\n\n @if (!editMode()) {\n <h2 class=\"label\">{{ ws.label }}</h2>\n <button mat-icon-button [matMenuTriggerFor]=\"workspaceMenu\"><mat-icon>more_vert</mat-icon></button>\n <mat-menu #workspaceMenu=\"matMenu\">\n <button mat-menu-item (click)=\"editMode.set(!editMode())\">{{ 'yuv.widget-grid.workspaces.workspace.menu.edit' | translate }}</button>\n <button mat-menu-item (click)=\"deleteCurrentWorkspace()\">{{ 'yuv.widget-grid.workspaces.workspace.menu.delete' | translate }}</button>\n </mat-menu>\n } @else {\n <input type=\"text\" class=\"label\" [formControl]=\"workspaceLabelControl\" />\n <button ymtButton=\"secondary\" (click)=\"revertWorkspaceConfig()\">\n {{ 'yuv.widget-grid.workspaces.editMode.cancel' | translate }}\n </button>\n <button ymtButton=\"primary\" (click)=\"persistWorkspaceConfig()\">\n {{ 'yuv.widget-grid.workspaces.editMode.save' | translate }}\n </button>\n }\n }\n</div>\n\n@if (ws) {\n <yuv-widget-grid\n [gridConfig]=\"_workspaceOptions().gridConfig\"\n [gridItemConfig]=\"gridItemConfig()\"\n [buckets]=\"buckets()\"\n [editMode]=\"editMode()\"\n (gridChange)=\"onGridChange($event)\"\n (gridItemEvent)=\"onGridEvent($event)\"\n >\n </yuv-widget-grid>\n} @else {\n <div class=\"empty\">\n <p>{{ 'yuv.widget-grid.workspaces.empty' | translate }}</p>\n <button ymtButton=\"primary\" (click)=\"openWorkspaceDialog(true, tplWworkspaceEdit)\">\n {{ 'yuv.widget-grid.workspaces.empty.button.create' | translate }}\n </button>\n </div>\n}\n\n<ng-template #tplWworkspaceEdit>\n <yuv-workspace-edit [workspaceForm]=\"workspaceForm\" (workspaceSubmit)=\"saveWorkspace()\"></yuv-workspace-edit>\n</ng-template>\n", styles: [":host{display:flex;flex-direction:column;height:100%}:host .toolbar{display:flex;flex-direction:row;align-items:center;gap:var(--ymt-spacing-m)}:host .toolbar .label{flex:1;font:var(--ymt-font-headline-medium);letter-spacing:var(--ymt-font-headline-medium-tracking);margin-inline:0;margin-block:.75em;padding-inline:.25em 0;padding-block:.25em}:host .toolbar input.label{border:0;background-color:transparent;outline:1px solid var(--ymt-outline)}:host yuv-widget-grid{flex:1}:host>.empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center}\n"] }]
|
|
898
|
+
}] });
|
|
899
|
+
|
|
900
|
+
const cmp = [
|
|
901
|
+
YuvWidgetGridComponent,
|
|
902
|
+
YuvWidgetGridWorkspacesComponent
|
|
903
|
+
];
|
|
904
|
+
class YuvWidgetGridModule {
|
|
905
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: YuvWidgetGridModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
906
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.12", ngImport: i0, type: YuvWidgetGridModule, imports: [YuvWidgetGridComponent,
|
|
907
|
+
YuvWidgetGridWorkspacesComponent], exports: [YuvWidgetGridComponent,
|
|
908
|
+
YuvWidgetGridWorkspacesComponent] }); }
|
|
909
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: YuvWidgetGridModule, imports: [cmp] }); }
|
|
910
|
+
}
|
|
911
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: YuvWidgetGridModule, decorators: [{
|
|
912
|
+
type: NgModule,
|
|
913
|
+
args: [{
|
|
914
|
+
imports: [cmp],
|
|
915
|
+
exports: [cmp]
|
|
916
|
+
}]
|
|
917
|
+
}] });
|
|
918
|
+
|
|
919
|
+
/**
|
|
920
|
+
* Generated bundle index. Do not edit.
|
|
921
|
+
*/
|
|
922
|
+
|
|
923
|
+
export { WidgetGridRegistry, WidgetGridService, YuvWidgetGridComponent, YuvWidgetGridModule, YuvWidgetGridWorkspacesComponent };
|
|
924
|
+
//# sourceMappingURL=yuuvis-client-framework-widget-grid.mjs.map
|