@acorex/layout 3.0.66 → 4.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. package/acorex-layout.d.ts +1 -2
  2. package/esm2020/acorex-layout.mjs +5 -0
  3. package/esm2020/lib/widget-board/editors/widget-size-editor/widget-size.editor.mjs +46 -0
  4. package/esm2020/lib/widget-board/editors/widget-size-editor/widget-size.module.mjs +21 -0
  5. package/esm2020/lib/widget-board/widget-board.component.mjs +441 -0
  6. package/esm2020/lib/widget-board/widget-board.module.mjs +111 -0
  7. package/esm2020/lib/widget-board/widget-config.component.mjs +82 -0
  8. package/esm2020/lib/widget-board/widget-host.component.mjs +290 -0
  9. package/esm2020/lib/widget-board/widget-save.component.mjs +79 -0
  10. package/esm2020/lib/widget-board/widget.class.mjs +127 -0
  11. package/esm2020/public-api.mjs +7 -0
  12. package/fesm2015/acorex-layout.mjs +1166 -0
  13. package/fesm2015/acorex-layout.mjs.map +1 -0
  14. package/fesm2020/acorex-layout.mjs +1159 -0
  15. package/fesm2020/acorex-layout.mjs.map +1 -0
  16. package/lib/widget-board/editors/widget-size-editor/widget-size.editor.d.ts +3 -0
  17. package/lib/widget-board/editors/widget-size-editor/widget-size.module.d.ts +8 -0
  18. package/lib/widget-board/widget-board.component.d.ts +3 -0
  19. package/lib/widget-board/widget-board.module.d.ts +12 -0
  20. package/lib/widget-board/widget-config.component.d.ts +3 -0
  21. package/lib/widget-board/widget-host.component.d.ts +3 -0
  22. package/lib/widget-board/widget-save.component.d.ts +3 -0
  23. package/lib/widget-board/widget.class.d.ts +3 -0
  24. package/package.json +23 -13
  25. package/acorex-layout.metadata.json +0 -1
  26. package/bundles/acorex-layout.umd.js +0 -1487
  27. package/bundles/acorex-layout.umd.js.map +0 -1
  28. package/bundles/acorex-layout.umd.min.js +0 -16
  29. package/bundles/acorex-layout.umd.min.js.map +0 -1
  30. package/esm2015/acorex-layout.js +0 -7
  31. package/esm2015/lib/widget-board/editors/widget-size-editor/widget-size.editor.js +0 -49
  32. package/esm2015/lib/widget-board/editors/widget-size-editor/widget-size.module.js +0 -19
  33. package/esm2015/lib/widget-board/widget-board.component.js +0 -468
  34. package/esm2015/lib/widget-board/widget-board.module.js +0 -67
  35. package/esm2015/lib/widget-board/widget-config.component.js +0 -86
  36. package/esm2015/lib/widget-board/widget-host.component.js +0 -323
  37. package/esm2015/lib/widget-board/widget-save.component.js +0 -79
  38. package/esm2015/lib/widget-board/widget.class.js +0 -123
  39. package/esm2015/public-api.js +0 -7
  40. package/esm5/acorex-layout.js +0 -7
  41. package/esm5/lib/widget-board/editors/widget-size-editor/widget-size.editor.js +0 -52
  42. package/esm5/lib/widget-board/editors/widget-size-editor/widget-size.module.js +0 -22
  43. package/esm5/lib/widget-board/widget-board.component.js +0 -494
  44. package/esm5/lib/widget-board/widget-board.module.js +0 -68
  45. package/esm5/lib/widget-board/widget-config.component.js +0 -90
  46. package/esm5/lib/widget-board/widget-host.component.js +0 -359
  47. package/esm5/lib/widget-board/widget-save.component.js +0 -83
  48. package/esm5/lib/widget-board/widget.class.js +0 -134
  49. package/esm5/public-api.js +0 -7
  50. package/fesm2015/acorex-layout.js +0 -1177
  51. package/fesm2015/acorex-layout.js.map +0 -1
  52. package/fesm5/acorex-layout.js +0 -1264
  53. package/fesm5/acorex-layout.js.map +0 -1
@@ -1,1264 +0,0 @@
1
- import { __decorate, __metadata, __extends, __awaiter, __generator, __spread } from 'tslib';
2
- import { EventEmitter, ChangeDetectorRef, ViewChild, Component, ViewEncapsulation, ChangeDetectionStrategy, ElementRef, ComponentFactoryResolver, Input, Output, ViewContainerRef, HostBinding, NgZone, ViewChildren, QueryList, NgModule } from '@angular/core';
3
- import { propertyEditor, AXValidationFormComponent, AXBasePopupPageComponent, AXPropertyDecorators, AXPopupService, AXLoadingService, AXProperyEditorComponent, AXSearchBoxModule, AXLoadingModule, AXProppertyEditorModule, AXPageModule, AXToolbarModule, AXLabelModule, AXTextAreaModule, AXFieldsetModule, AXTextBoxModule, AXFormGroupModule, AXTabStripModule, AXCheckBoxModule, AXMenuModule, AXValidationModule, AXNumberBoxModule } from '@acorex/components';
4
- import { AXTranslator, AXHtmlUtil, AXObjectUtil, AXRenderService, AXClientRec, AXTranslatorModule } from '@acorex/core';
5
- import { Observable } from 'rxjs';
6
- import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
7
- import { CommonModule } from '@angular/common';
8
- import { RouterModule } from '@angular/router';
9
- import { FormsModule } from '@angular/forms';
10
-
11
- var ɵ0 = function () {
12
- return [1, 2, 3, 5, 10, 20, 30, 60].map(function (c) { return ({
13
- id: 60000 * c,
14
- text: AXTranslator.get('dateTime.duration.format_minute').replace('{0}', c.toString())
15
- }); });
16
- };
17
- // @dynamic
18
- var AXWidgetComponent = /** @class */ (function () {
19
- function AXWidgetComponent() {
20
- var _this = this;
21
- this.uid = AXHtmlUtil.getUID();
22
- this.onBusyChanged = new EventEmitter();
23
- this._isBusy = true;
24
- this.refreshRate = [{
25
- id: 60000 * 5,
26
- text: AXTranslator.get('dateTime.duration.format_minute').replace('{0}', '5')
27
- }];
28
- this.onConfiguredChanged = new EventEmitter();
29
- this.onConfiguredChanged.subscribe(function () {
30
- if (_this.isConfigured === true && _this.getRefreshRate()) {
31
- _this.restartRefreshTimer();
32
- }
33
- else {
34
- _this.stopRefreshTimer();
35
- }
36
- });
37
- }
38
- Object.defineProperty(AXWidgetComponent.prototype, "isBusy", {
39
- get: function () {
40
- return this._isBusy;
41
- },
42
- set: function (v) {
43
- if (v !== this._isBusy) {
44
- var eventData = {
45
- component: this,
46
- oldValue: this._isBusy,
47
- value: v
48
- };
49
- this._isBusy = v;
50
- this.onBusyChanged.emit(eventData);
51
- }
52
- },
53
- enumerable: true,
54
- configurable: true
55
- });
56
- // ???
57
- AXWidgetComponent.prototype.getRefreshRate = function () {
58
- return Array.isArray(this.refreshRate) && this.refreshRate.length ? this.refreshRate[0].id : this.refreshRate;
59
- };
60
- AXWidgetComponent.prototype.startRefreshTimer = function () {
61
- this.intervalId = window.setInterval(this.refresh.bind(this), this.getRefreshRate());
62
- };
63
- AXWidgetComponent.prototype.stopRefreshTimer = function () {
64
- window.clearInterval(this.intervalId);
65
- };
66
- AXWidgetComponent.prototype.restartRefreshTimer = function () {
67
- this.stopRefreshTimer();
68
- this.startRefreshTimer();
69
- };
70
- AXWidgetComponent.prototype.ngOnDestroy = function () {
71
- this.stopRefreshTimer();
72
- };
73
- AXWidgetComponent.prototype.redraw = function () {
74
- };
75
- AXWidgetComponent.prototype.refresh = function () {
76
- this.restartRefreshTimer();
77
- };
78
- Object.defineProperty(AXWidgetComponent.prototype, "isConfigured", {
79
- get: function () {
80
- return true;
81
- },
82
- enumerable: true,
83
- configurable: true
84
- });
85
- AXWidgetComponent.prototype.setValue = function (name, value) {
86
- this[name] = value;
87
- this.onConfiguredChanged.emit();
88
- };
89
- AXWidgetComponent.prototype.getValue = function (name) {
90
- var _a;
91
- var val = this[name];
92
- var config = this['__meta__'].config;
93
- var runtime = (_a = config.props[name]) === null || _a === void 0 ? void 0 : _a.runtime;
94
- if (runtime && this.provideValue) {
95
- var res = this.provideValue({
96
- name: name,
97
- value: val,
98
- uniqueName: config.uniqueName,
99
- options: config.options,
100
- });
101
- if (this.provideValue instanceof Promise) {
102
- return res;
103
- }
104
- else {
105
- return Promise.resolve(res);
106
- }
107
- }
108
- return Promise.resolve(val);
109
- };
110
- __decorate([
111
- propertyEditor({
112
- editorClass: 'ax/editors/widget-size',
113
- title: 'common.size',
114
- visible: false,
115
- order: -99,
116
- }),
117
- __metadata("design:type", Array)
118
- ], AXWidgetComponent.prototype, "widgetSize", void 0);
119
- __decorate([
120
- propertyEditor({
121
- editorClass: 'ax/editors/select',
122
- title: 'common.refresh-rate',
123
- visible: true,
124
- order: -98,
125
- editorOptions: {
126
- items: ɵ0,
127
- allowNull: false,
128
- allowSearch: false,
129
- selectionDataMode: 'value',
130
- selectionMode: 'single',
131
- valueField: 'id',
132
- }
133
- }),
134
- __metadata("design:type", Object)
135
- ], AXWidgetComponent.prototype, "refreshRate", void 0);
136
- return AXWidgetComponent;
137
- }());
138
-
139
- var AXWidgetConfigComponent = /** @class */ (function (_super) {
140
- __extends(AXWidgetConfigComponent, _super);
141
- function AXWidgetConfigComponent(cdr) {
142
- var _this = _super.call(this) || this;
143
- _this.cdr = cdr;
144
- _this.props = [];
145
- _this.displayProps = [];
146
- _this.changes = [];
147
- _this.context = {};
148
- return _this;
149
- }
150
- AXWidgetConfigComponent.prototype.getFooterButtons = function () {
151
- return [
152
- {
153
- name: 'okay',
154
- submitBehavior: true,
155
- text: AXTranslator.get('common.confirm'),
156
- style: 'success'
157
- },
158
- {
159
- name: 'cancel',
160
- cancelBehavior: true,
161
- text: AXTranslator.get('common.cancel'),
162
- style: 'danger blank'
163
- }
164
- ];
165
- };
166
- AXWidgetConfigComponent.prototype.onFooterButtonClick = function (e) {
167
- var _this = this;
168
- if (e.name === 'cancel') {
169
- this.close();
170
- }
171
- if (e.name === 'okay') {
172
- this.form.validate().then(function (c) {
173
- if (c.result) {
174
- _this.close(_this.changes);
175
- }
176
- });
177
- }
178
- };
179
- AXWidgetConfigComponent.prototype.handleValueChange = function (e) {
180
- var prop = this.changes.find(function (c) { return c.property.name === e.property.name; });
181
- if (prop) {
182
- prop.value = e.value;
183
- }
184
- else {
185
- this.changes.push({ property: e.property, value: e.value });
186
- }
187
- this.updateContext();
188
- };
189
- AXWidgetConfigComponent.prototype.ngOnInit = function () {
190
- this.displayProps = this.props.filter(function (c) { return c.property.visible !== false; }).sort(function (a, b) { return a.property.order - b.property.order; });
191
- this.updateContext();
192
- };
193
- AXWidgetConfigComponent.prototype.updateContext = function () {
194
- var ctx = {};
195
- this.props.forEach(function (p) {
196
- ctx[p.property.name] = p.value;
197
- });
198
- this.changes.forEach(function (p) {
199
- ctx[p.property.name] = p.value;
200
- });
201
- this.context = ctx;
202
- };
203
- AXWidgetConfigComponent.prototype.identify = function (index, item) {
204
- return item.property.name;
205
- };
206
- AXWidgetConfigComponent.ctorParameters = function () { return [
207
- { type: ChangeDetectorRef }
208
- ]; };
209
- __decorate([
210
- ViewChild(AXValidationFormComponent),
211
- __metadata("design:type", AXValidationFormComponent)
212
- ], AXWidgetConfigComponent.prototype, "form", void 0);
213
- AXWidgetConfigComponent = __decorate([
214
- Component({
215
- template: "<ax-page>\r\n <ax-page-content>\r\n <div class=\"container\">\r\n <ax-validation-form #form>\r\n <div class=\"row\" *ngFor=\"let p of displayProps; trackBy: identify\">\r\n <div class=\"col-12\">\r\n <ax-label>{{p.property.title | trans}}</ax-label>\r\n <ng-container ax-property-editor-renderer [property]=\"p\" [context]=\"context\" [host]=\"widget\" [validationForm]=\"form\"\r\n (onValueChange)=\"handleValueChange($event)\">\r\n </ng-container>\r\n </div>\r\n </div>\r\n </ax-validation-form>\r\n </div>\r\n </ax-page-content>\r\n</ax-page>",
216
- encapsulation: ViewEncapsulation.None,
217
- changeDetection: ChangeDetectionStrategy.OnPush
218
- }),
219
- __metadata("design:paramtypes", [ChangeDetectorRef])
220
- ], AXWidgetConfigComponent);
221
- return AXWidgetConfigComponent;
222
- }(AXBasePopupPageComponent));
223
-
224
- var AXWidgetSaveComponent = /** @class */ (function (_super) {
225
- __extends(AXWidgetSaveComponent, _super);
226
- function AXWidgetSaveComponent() {
227
- var _this = _super !== null && _super.apply(this, arguments) || this;
228
- _this.props = [];
229
- return _this;
230
- }
231
- AXWidgetSaveComponent.prototype.getFooterButtons = function () {
232
- return [
233
- {
234
- name: 'okay',
235
- submitBehavior: true,
236
- text: AXTranslator.get('common.confirm'),
237
- style: 'ax success'
238
- },
239
- {
240
- name: 'cancel',
241
- cancelBehavior: true,
242
- text: AXTranslator.get('common.cancel'),
243
- style: 'ax light'
244
- }
245
- ];
246
- };
247
- AXWidgetSaveComponent.prototype.ngOnInit = function () {
248
- var _a, _b;
249
- var titleProp = this.props.find(function (c) { return c.property.name === 'title' || c.property.name === 'name'; });
250
- var title = ((_a = titleProp) === null || _a === void 0 ? void 0 : _a.value) || this.config.title;
251
- var pp = {};
252
- (_b = this.props) === null || _b === void 0 ? void 0 : _b.forEach(function (c) {
253
- pp[c.property.name] = c.property;
254
- });
255
- this.data = {
256
- component: this.config.component,
257
- title: title,
258
- uniqueName: this.config.uniqueName + "-" + AXHtmlUtil.getUID(),
259
- options: AXObjectUtil.deepJSONClone(this.config.options),
260
- props: AXObjectUtil.deepJSONClone(pp)
261
- };
262
- this.displayProps = this.props
263
- .filter(function (c) { return c.property.visible !== false; })
264
- .sort(function (a, b) { return a.property.order - b.property.order; })
265
- .map(function (c) { return ({
266
- name: c.property.name,
267
- title: c.property.title,
268
- allow: true
269
- }); });
270
- };
271
- AXWidgetSaveComponent.prototype.onFooterButtonClick = function (e) {
272
- var _this = this;
273
- if (e.name === 'cancel') {
274
- this.close();
275
- }
276
- if (e.name === 'okay') {
277
- this.props.forEach(function (p) {
278
- var pp = _this.displayProps.find(function (c) { return c.name === p.property.name; });
279
- if (pp == null || !pp.allow) {
280
- var ppp = _this.data.props[p.property.name];
281
- if (ppp) {
282
- ppp.visible = false;
283
- }
284
- else {
285
- ppp = { visible: false };
286
- }
287
- }
288
- });
289
- this.close(this.data);
290
- }
291
- };
292
- AXWidgetSaveComponent = __decorate([
293
- Component({
294
- template: "<ax-page>\r\n <ax-page-content>\r\n <div class=\"container\">\r\n <div class=\"row\">\r\n <div class=\"col-12\">\r\n <ax-form-group>\r\n <ax-label>{{'common.title' | trans}}</ax-label>\r\n <ax-text-box [(value)]=\"data.title\"></ax-text-box>\r\n </ax-form-group>\r\n </div>\r\n </div>\r\n <div class=\"row\">\r\n <div class=\"col-12\">\r\n <ax-form-group>\r\n <ax-label>{{'common.description' | trans}}</ax-label>\r\n <ax-text-area [(value)]=\"data.description\"></ax-text-area>\r\n </ax-form-group>\r\n </div>\r\n </div>\r\n <!-- <div class=\"row\">\r\n <div class=\"col-12\">\r\n <ax-form-group>\r\n <ax-label>{{'common.uniquename' | trans}}</ax-label>\r\n <ax-text-box></ax-text-box>\r\n </ax-form-group>\r\n </div>\r\n </div> -->\r\n <div class=\"row\" style=\"margin-block-end: var(--ax-size-md);margin-block-start: var(--ax-size-md);\">\r\n <div class=\"col-12\">\r\n <ax-fieldset caption=\"{{'widget-board.configurable-props' | trans}}\">\r\n <div class=\"row\" *ngFor=\"let prop of displayProps\">\r\n <div class=\"col-12\" style=\"margin-block-end: var(--ax-size-sm)\">\r\n <ax-check-box [(value)]=\"prop.allow\" label=\"{{ prop.title | trans }}\">\r\n\r\n </ax-check-box>\r\n </div>\r\n </div>\r\n </ax-fieldset>\r\n </div>\r\n </div>\r\n </div>\r\n </ax-page-content>\r\n</ax-page>",
295
- encapsulation: ViewEncapsulation.None,
296
- changeDetection: ChangeDetectionStrategy.OnPush
297
- })
298
- ], AXWidgetSaveComponent);
299
- return AXWidgetSaveComponent;
300
- }(AXBasePopupPageComponent));
301
-
302
- var AXWidgetHostComponent = /** @class */ (function () {
303
- function AXWidgetHostComponent(ref, componentFactoryResolver, rendererService, cdr, popup, loadingService) {
304
- this.ref = ref;
305
- this.componentFactoryResolver = componentFactoryResolver;
306
- this.rendererService = rendererService;
307
- this.cdr = cdr;
308
- this.popup = popup;
309
- this.loadingService = loadingService;
310
- this._hasProps = false;
311
- this._hasMenu = false;
312
- this.configMenuItem = [
313
- {
314
- icon: 'far fa-ellipsis-h',
315
- items: []
316
- }
317
- ];
318
- this.onRemove = new EventEmitter();
319
- this.onConfigChanged = new EventEmitter();
320
- this.onResized = new EventEmitter();
321
- this.onSave = new EventEmitter();
322
- this._isLoading = false;
323
- this.sizeX = 1;
324
- this.sizeY = 1;
325
- this.col = 1;
326
- this.row = 1;
327
- }
328
- Object.defineProperty(AXWidgetHostComponent.prototype, "widget", {
329
- get: function () {
330
- return this._widget;
331
- },
332
- enumerable: true,
333
- configurable: true
334
- });
335
- Object.defineProperty(AXWidgetHostComponent.prototype, "element", {
336
- get: function () {
337
- return this.ref.nativeElement;
338
- },
339
- enumerable: true,
340
- configurable: true
341
- });
342
- Object.defineProperty(AXWidgetHostComponent.prototype, "isLoading", {
343
- get: function () {
344
- return this._isLoading;
345
- },
346
- set: function (v) {
347
- this._isLoading = v;
348
- if (this._loadingId && !v) {
349
- this.loadingService.hide(this._loadingId);
350
- this._loadingId = null;
351
- }
352
- if (v) {
353
- this._loadingId = this.loadingService.show(this.ref.nativeElement);
354
- }
355
- },
356
- enumerable: true,
357
- configurable: true
358
- });
359
- Object.defineProperty(AXWidgetHostComponent.prototype, "isConfigured", {
360
- get: function () {
361
- var _a;
362
- return ((_a = this._widget) === null || _a === void 0 ? void 0 : _a.isConfigured) || false;
363
- },
364
- enumerable: true,
365
- configurable: true
366
- });
367
- AXWidgetHostComponent.prototype.ngOnInit = function () {
368
- this.isLoading = true;
369
- };
370
- AXWidgetHostComponent.prototype.ngAfterViewInit = function () {
371
- var _a;
372
- return __awaiter(this, void 0, void 0, function () {
373
- var component, route, widgetFactory;
374
- var _this = this;
375
- return __generator(this, function (_b) {
376
- switch (_b.label) {
377
- case 0:
378
- if (!(typeof this.config.component === 'string')) return [3 /*break*/, 2];
379
- return [4 /*yield*/, this.rendererService.findLoadedComponentByRoute(this.config.component, 20)];
380
- case 1:
381
- route = _b.sent();
382
- component = (_a = route) === null || _a === void 0 ? void 0 : _a.component;
383
- return [3 /*break*/, 3];
384
- case 2:
385
- if (typeof this.config.component === 'function') {
386
- component = this.config.component;
387
- }
388
- _b.label = 3;
389
- case 3:
390
- if (component == null) {
391
- console.error("Invalid Widget Component!", this.config);
392
- this.onRemove.emit(this);
393
- return [2 /*return*/];
394
- }
395
- widgetFactory = this.componentFactoryResolver.resolveComponentFactory(component);
396
- this.componentRef = this.vc.createComponent(widgetFactory);
397
- this._widget = this.componentRef.instance;
398
- this._widget.provideValue = this.provideValue;
399
- if (this._widget.onBusyChanged) {
400
- this._widget.onBusyChanged.subscribe(function (d) {
401
- if (!_this._widget.widgetSize) {
402
- _this._widget.setValue('widgetSize', [_this.sizeX, _this.sizeY]);
403
- }
404
- else {
405
- _this.setSizeFromOptions();
406
- }
407
- _this.isLoading = d.value;
408
- _this.cdr.detectChanges();
409
- });
410
- }
411
- if (this._widget.onConfiguredChanged) {
412
- this._widget.onConfiguredChanged.subscribe(function () {
413
- _this.setSizeFromOptions();
414
- });
415
- }
416
- //
417
- if (this.config.options) {
418
- Object.assign(this._widget, this.config.options);
419
- }
420
- this._hasProps = AXPropertyDecorators.getProperties(this._widget).length > 0;
421
- this.isLoading = false;
422
- this.config['__meta__'].instance = this;
423
- this._widget['__meta__'] = {};
424
- this._widget['__meta__'].config = this.config;
425
- //
426
- this.configMenuItem[0].items.push({
427
- name: 'refresh',
428
- icon: 'far fa-undo',
429
- text: AXTranslator.get('common.refresh'),
430
- onClick: function () {
431
- var _a, _b;
432
- (_b = (_a = _this) === null || _a === void 0 ? void 0 : _a.widget) === null || _b === void 0 ? void 0 : _b.refresh();
433
- }
434
- });
435
- //
436
- if (this._hasProps) {
437
- this.configMenuItem[0].items.push({
438
- name: 'configs',
439
- icon: 'far fa-cogs',
440
- text: AXTranslator.get('common.configs'),
441
- onClick: function () {
442
- _this.openConfigDialog();
443
- }
444
- });
445
- }
446
- this.configMenuItem[0].items.push({
447
- name: 'save',
448
- icon: 'far fa-save',
449
- text: AXTranslator.get('common.save-as'),
450
- onClick: function () {
451
- _this.openSaveDialog();
452
- }
453
- });
454
- if (true) {
455
- this.configMenuItem[0].items.push({
456
- name: 'remove',
457
- icon: 'far fa-times',
458
- style: 'ax danger blank',
459
- text: AXTranslator.get('common.remove'),
460
- onClick: function () {
461
- _this.onRemove.emit(_this);
462
- }
463
- });
464
- }
465
- this._hasMenu = this.configMenuItem[0].items.length > 0;
466
- this.cdr.detectChanges();
467
- return [2 /*return*/];
468
- }
469
- });
470
- });
471
- };
472
- AXWidgetHostComponent.prototype.setSizeFromOptions = function () {
473
- var _this = this;
474
- this._widget.getValue('widgetSize').then(function (c) {
475
- var oldSizeX = _this.sizeX;
476
- var oldSizeY = _this.sizeY;
477
- if (c && Array.isArray(c) && (oldSizeX !== c[0] || oldSizeY !== c[1])) {
478
- _this.config.sizeX = _this.sizeX = c[0];
479
- _this.config.sizeY = _this.sizeY = c[1];
480
- _this.onResized.emit({
481
- component: _this._widget,
482
- config: _this.config
483
- });
484
- }
485
- _this.cdr.detectChanges();
486
- });
487
- };
488
- AXWidgetHostComponent.prototype.remove = function (e) {
489
- e.preventDefault();
490
- e.stopPropagation();
491
- this.onRemove.emit(this);
492
- return false;
493
- };
494
- AXWidgetHostComponent.prototype.handleConfig = function (e) {
495
- e.preventDefault();
496
- e.stopPropagation();
497
- this.openConfigDialog();
498
- return false;
499
- };
500
- AXWidgetHostComponent.prototype.openConfigDialog = function () {
501
- var _this = this;
502
- var ppp = this.getMergedProps();
503
- this.popup.open(AXWidgetConfigComponent, {
504
- title: AXTranslator.get('common.configs'),
505
- size: 'sm',
506
- data: {
507
- props: ppp.map(function (c) { return ({ property: c.options, value: _this._widget[c.options.name] }); }),
508
- widget: this.widget
509
- }
510
- }).then(function (c) {
511
- if (c.data) {
512
- if (!_this.config.options) {
513
- _this.config.options = {};
514
- }
515
- c.data.forEach(function (p) {
516
- _this._widget.setValue(p.property.name, p.value);
517
- _this.config.options[p.property.name] = p.value;
518
- });
519
- _this.emitConfigChanged();
520
- _this._widget.redraw();
521
- _this.cdr.detectChanges();
522
- }
523
- });
524
- };
525
- AXWidgetHostComponent.prototype.openSaveDialog = function () {
526
- var _this = this;
527
- var ppp = this.getMergedProps();
528
- this.popup.open(AXWidgetSaveComponent, {
529
- title: AXTranslator.get('common.save-as'),
530
- size: 'sm',
531
- data: {
532
- config: this.config,
533
- props: ppp.map(function (c) { return ({ property: c.options, value: _this._widget[c.options.name] }); })
534
- }
535
- }).then(function (c) {
536
- if (c.data) {
537
- _this.onSave.emit({
538
- component: _this._widget,
539
- data: c.data
540
- });
541
- }
542
- });
543
- };
544
- AXWidgetHostComponent.prototype.handleOptionClick = function (e) {
545
- e.preventDefault();
546
- e.stopPropagation();
547
- this.openConfigDialog();
548
- return false;
549
- };
550
- AXWidgetHostComponent.prototype.ngOnDestroy = function () {
551
- this.vc.clear();
552
- if (this.componentRef) {
553
- this.componentRef.destroy();
554
- }
555
- };
556
- AXWidgetHostComponent.prototype.getMergedProps = function () {
557
- var ppp = AXObjectUtil.deepCopy(AXPropertyDecorators.getProperties(this._widget));
558
- var _loop_1 = function (key) {
559
- if (Object.prototype.hasOwnProperty.call(this_1.config.props, key)) {
560
- var newP = this_1.config.props[key];
561
- var existPropDec = ppp.find(function (p) { return p.property === key; });
562
- if (existPropDec) {
563
- Object.assign(existPropDec.options, newP);
564
- }
565
- }
566
- };
567
- var this_1 = this;
568
- for (var key in this.config.props) {
569
- _loop_1(key);
570
- }
571
- return ppp;
572
- };
573
- AXWidgetHostComponent.prototype.emitConfigChanged = function () {
574
- this.onConfigChanged.emit({
575
- component: this._widget,
576
- config: this.config
577
- });
578
- };
579
- AXWidgetHostComponent.ctorParameters = function () { return [
580
- { type: ElementRef },
581
- { type: ComponentFactoryResolver },
582
- { type: AXRenderService },
583
- { type: ChangeDetectorRef },
584
- { type: AXPopupService },
585
- { type: AXLoadingService }
586
- ]; };
587
- __decorate([
588
- Input(),
589
- __metadata("design:type", Function)
590
- ], AXWidgetHostComponent.prototype, "provideValue", void 0);
591
- __decorate([
592
- Output(),
593
- __metadata("design:type", EventEmitter)
594
- ], AXWidgetHostComponent.prototype, "onRemove", void 0);
595
- __decorate([
596
- Output(),
597
- __metadata("design:type", EventEmitter)
598
- ], AXWidgetHostComponent.prototype, "onConfigChanged", void 0);
599
- __decorate([
600
- Output(),
601
- __metadata("design:type", EventEmitter)
602
- ], AXWidgetHostComponent.prototype, "onResized", void 0);
603
- __decorate([
604
- Output(),
605
- __metadata("design:type", EventEmitter)
606
- ], AXWidgetHostComponent.prototype, "onSave", void 0);
607
- __decorate([
608
- Input(),
609
- __metadata("design:type", Object)
610
- ], AXWidgetHostComponent.prototype, "config", void 0);
611
- __decorate([
612
- ViewChild('vc', { read: ViewContainerRef }),
613
- __metadata("design:type", ViewContainerRef)
614
- ], AXWidgetHostComponent.prototype, "vc", void 0);
615
- __decorate([
616
- HostBinding('attr.data-size-x'),
617
- Input(),
618
- __metadata("design:type", Number)
619
- ], AXWidgetHostComponent.prototype, "sizeX", void 0);
620
- __decorate([
621
- HostBinding('attr.data-size-y'),
622
- Input(),
623
- __metadata("design:type", Number)
624
- ], AXWidgetHostComponent.prototype, "sizeY", void 0);
625
- __decorate([
626
- HostBinding('attr.data-col'),
627
- Input(),
628
- __metadata("design:type", Number)
629
- ], AXWidgetHostComponent.prototype, "col", void 0);
630
- __decorate([
631
- HostBinding('attr.data-row'),
632
- Input(),
633
- __metadata("design:type", Number)
634
- ], AXWidgetHostComponent.prototype, "row", void 0);
635
- AXWidgetHostComponent = __decorate([
636
- Component({
637
- selector: 'ax-widget-host',
638
- template: "<div class='widget-container'>\r\n <div class=\"widget-config-overlay\" *ngIf=\"!isConfigured\" (click)=\"handleConfig($event)\">\r\n <div class=\"widget-title\">{{config.title}}</div>\r\n <div class=\"widget-config-box\">\r\n <div class=\"config-title\">{{ 'widget-board.configure' | trans}}</div>\r\n <div class=\"config-icon\"><i class=\"fas fa-cogs fa-5x\" aria-hidden=\"true\"></i></div>\r\n </div>\r\n </div>\r\n <div class='widget-edit-overlay'>\r\n <div class='widget-edit-menu'>\r\n <button class=\"widget-edit-menu-button\" (click)=\"handleConfig($event)\"\r\n (mousedown)=\"$event.stopPropagation()\" *ngIf=\"_hasProps\" (mouseup)=\"$event.stopPropagation()\">\r\n <i class=\"far fa-cogs\" aria-hidden=\"true\"></i>\r\n </button>\r\n <button class=\"widget-edit-menu-button\" (click)=\"remove($event)\" (mousedown)=\"$event.stopPropagation()\"\r\n (mouseup)=\"$event.stopPropagation()\">\r\n <i class=\"far fa-times\" aria-hidden=\"true\"></i>\r\n </button>\r\n </div>\r\n\r\n </div>\r\n <div class=\"widget-options-menu\" *ngIf=\"_hasMenu\">\r\n <ax-menu [items]='configMenuItem' direction=\"horizontal\"></ax-menu>\r\n </div>\r\n <!-- <ax-loading-panel [visible]=\"isBusy\">\r\n </ax-loading-panel> -->\r\n <div class=\"widget-content\">\r\n <ng-container #vc></ng-container>\r\n </div>\r\n</div>",
639
- host: { class: 'ax widget-host', tabindex: '0' },
640
- encapsulation: ViewEncapsulation.None,
641
- changeDetection: ChangeDetectionStrategy.OnPush
642
- }),
643
- __metadata("design:paramtypes", [ElementRef,
644
- ComponentFactoryResolver,
645
- AXRenderService,
646
- ChangeDetectorRef,
647
- AXPopupService,
648
- AXLoadingService])
649
- ], AXWidgetHostComponent);
650
- return AXWidgetHostComponent;
651
- }());
652
-
653
- var AXWidgetBoardComponent = /** @class */ (function () {
654
- function AXWidgetBoardComponent(ref, zone, cdr) {
655
- this.ref = ref;
656
- this.zone = zone;
657
- this.cdr = cdr;
658
- this.widgets = [];
659
- this.galleryItems = [];
660
- this.tileSize = 80;
661
- this.gapSize = 5;
662
- this.newWidget = null;
663
- this._isInEditing = false;
664
- this.isDragging = false;
665
- this.DATA_COL = 'data-col';
666
- this.DATA_ROW = 'data-row';
667
- this.DATA_SIZE_X = 'data-size-x';
668
- this.DATA_SIZE_Y = 'data-size-y';
669
- this.DATA_OLD_COL = 'data-old-col';
670
- this.DATA_OLD_ROW = 'data-old-row';
671
- this.onConfigChanged = new EventEmitter();
672
- this.onWidgetSave = new EventEmitter();
673
- }
674
- AXWidgetBoardComponent.prototype.isInEditing = function () {
675
- return this._isInEditing;
676
- };
677
- AXWidgetBoardComponent.prototype.ngOnInit = function () {
678
- if (this.rtl == null) {
679
- this.rtl = window.getComputedStyle(this.ref.nativeElement, null).getPropertyValue('direction') === 'rtl';
680
- }
681
- };
682
- AXWidgetBoardComponent.prototype.ngAfterViewInit = function () {
683
- var _this = this;
684
- this.zone.runOutsideAngular(function (c) {
685
- var style = document.createElement('style');
686
- style.type = 'text/css';
687
- _this.ref.nativeElement.appendChild(style);
688
- // add css data classes
689
- for (var i = 1; i <= 50; i++) {
690
- style.innerHTML += "[" + _this.DATA_COL + "=\"" + i + "\"] { " + (_this.rtl ? 'right' : 'left') + ": " + (i - 1) * (_this.tileSize + _this.gapSize) + "px; }";
691
- style.innerHTML += "[" + _this.DATA_ROW + "=\"" + i + "\"] { top: " + (i - 1) * (_this.tileSize + _this.gapSize) + "px; }";
692
- style.innerHTML += "[" + _this.DATA_SIZE_X + "=\"" + i + "\"] { width: " + ((i * _this.tileSize) + ((i - 1) * _this.gapSize)) + "px; }";
693
- style.innerHTML += "[" + _this.DATA_SIZE_Y + "=\"" + i + "\"] { height: " + ((i * _this.tileSize) + ((i - 1) * _this.gapSize)) + "px; }";
694
- }
695
- });
696
- };
697
- AXWidgetBoardComponent.prototype.calcGridSize = function () {
698
- var _this = this;
699
- this.zone.runOutsideAngular(function () {
700
- var width = (Math.max.apply(Math, __spread(_this.widgets.map(function (c) { return c.col + c.sizeX - 1; })))) * (_this.tileSize + _this.gapSize);
701
- var height = (Math.max.apply(Math, __spread(_this.widgets.map(function (c) { return c.row + c.sizeY - 1; })))) * (_this.tileSize + _this.gapSize);
702
- _this.container.nativeElement.style.width = width + 'px';
703
- _this.container.nativeElement.style.height = height + 'px';
704
- });
705
- };
706
- AXWidgetBoardComponent.prototype.toggleEdit = function () {
707
- this._isInEditing ? this.finishEdit() : this.startEdit();
708
- };
709
- AXWidgetBoardComponent.prototype.dragStart = function (e) {
710
- var _this = this;
711
- e.preventDefault();
712
- e.stopPropagation();
713
- this.zone.runOutsideAngular(function () {
714
- if (_this._isInEditing && e.which === 1) {
715
- _this.dragItem = e.currentTarget;
716
- _this.dragItem.setAttribute('data-x-offset', (_this.dragItem.offsetLeft - e.clientX).toString());
717
- //
718
- _this.dragItem.setAttribute('data-y-offset', (_this.dragItem.offsetTop - e.clientY).toString());
719
- _this.dragItem.classList.add('widget-dragging');
720
- _this.dragItem.classList.remove('animate__animated', 'animate__pulse');
721
- }
722
- });
723
- return false;
724
- };
725
- AXWidgetBoardComponent.prototype.removePositionData = function () {
726
- var _this = this;
727
- this.zone.runOutsideAngular(function () {
728
- if (_this.dragItem && _this._isInEditing && _this.dragItem.getAttribute(_this.DATA_OLD_COL) == null) {
729
- _this.dragItem.setAttribute(_this.DATA_OLD_COL, _this.dragItem.getAttribute(_this.DATA_COL));
730
- _this.dragItem.setAttribute(_this.DATA_OLD_ROW, _this.dragItem.getAttribute(_this.DATA_ROW));
731
- _this.dragItem.removeAttribute(_this.DATA_COL);
732
- _this.dragItem.removeAttribute(_this.DATA_ROW);
733
- }
734
- });
735
- };
736
- AXWidgetBoardComponent.prototype.resetPositionData = function () {
737
- var _this = this;
738
- this.zone.runOutsideAngular(function () {
739
- if (_this.dragItem && _this._isInEditing) {
740
- _this.setPosition(_this.dragItem, _this.dragItem.getAttribute(_this.DATA_OLD_COL), _this.dragItem.getAttribute(_this.DATA_OLD_ROW));
741
- }
742
- });
743
- };
744
- AXWidgetBoardComponent.prototype.setPosition = function (element, col, row) {
745
- var _this = this;
746
- this.zone.runOutsideAngular(function () {
747
- element.setAttribute(_this.DATA_COL, col);
748
- element.setAttribute(_this.DATA_ROW, row);
749
- element.removeAttribute(_this.DATA_OLD_COL);
750
- element.removeAttribute(_this.DATA_OLD_ROW);
751
- element.style.removeProperty('top');
752
- element.style.removeProperty('left');
753
- var widget = _this.widgets.find(function (c) { return c['__meta__'].instance.element === element; });
754
- widget.col = Number(col);
755
- widget.row = Number(row);
756
- });
757
- };
758
- AXWidgetBoardComponent.prototype.drag = function (e) {
759
- var _this = this;
760
- e.preventDefault();
761
- e.stopPropagation();
762
- this.zone.runOutsideAngular(function () {
763
- if (_this.dragItem && _this._isInEditing) {
764
- _this.isDragging = true;
765
- _this.addPlaceholder();
766
- var xOffset = Number(_this.dragItem.getAttribute('data-x-offset'));
767
- var yOffset = Number(_this.dragItem.getAttribute('data-y-offset'));
768
- _this.dragItem.style.left = e.clientX + xOffset + 'px';
769
- _this.dragItem.style.top = e.clientY + yOffset + 'px';
770
- //
771
- _this.detectBestPlacement();
772
- _this.removePositionData();
773
- }
774
- });
775
- return false;
776
- };
777
- AXWidgetBoardComponent.prototype.dragEnd = function (e) {
778
- var _this = this;
779
- this.zone.runOutsideAngular(function () {
780
- if (_this.dragItem && _this._isInEditing && _this.isDragging) {
781
- _this.dragItem.classList.remove('widget-dragging');
782
- _this.dragItem.classList.add('animate__animated', 'animate__pulse');
783
- //
784
- var p = _this.container.nativeElement.querySelector('.widget-blank-placeholder');
785
- if (_this.newWidget) {
786
- var w_1 = {
787
- uniqueName: _this.newWidget.uniqueName,
788
- component: _this.newWidget.component,
789
- title: _this.newWidget.title,
790
- options: _this.newWidget.options,
791
- sizeX: _this.newWidget.sizeX,
792
- sizeY: _this.newWidget.sizeY,
793
- col: Number(p.getAttribute(_this.DATA_COL)),
794
- row: Number(p.getAttribute(_this.DATA_ROW))
795
- };
796
- _this.widgets.push(w_1);
797
- _this.newWidget = null;
798
- _this.container.nativeElement.removeChild(_this.dragItem);
799
- _this.zone.run(function () {
800
- _this.cdr.detectChanges();
801
- _this.calcGridSize();
802
- setTimeout(function () {
803
- w_1['__meta__'].instance.element.addEventListener('mousedown', _this.dragStart.bind(_this), false);
804
- }, 1000);
805
- });
806
- }
807
- else {
808
- if (p) {
809
- _this.setPosition(_this.dragItem, p.getAttribute(_this.DATA_COL), p.getAttribute(_this.DATA_ROW));
810
- }
811
- else {
812
- _this.setPosition(_this.dragItem, _this.dragItem.getAttribute(_this.DATA_OLD_COL), _this.dragItem.getAttribute(_this.DATA_OLD_ROW));
813
- }
814
- }
815
- //
816
- _this.removePlaceholder();
817
- _this.dragItem = null;
818
- _this.calcGridSize();
819
- _this.emitConfigChanged();
820
- }
821
- _this.isDragging = false;
822
- });
823
- };
824
- AXWidgetBoardComponent.prototype.detectFirstEmptySlot = function (w) {
825
- var xTile = Math.floor(this.ref.nativeElement.parentElement.offsetWidth / this.tileSize);
826
- for (var j = 1; j <= 100; j++) {
827
- var _loop_1 = function (i) {
828
- var rec = new AXClientRec({
829
- left: i,
830
- top: j,
831
- width: w.sizeX,
832
- height: w.sizeY
833
- });
834
- var el = this_1.widgets.filter(function (c) { return c !== w; }).find(function (c) {
835
- return rec.intersect({
836
- left: c.col,
837
- top: c.row,
838
- width: c.sizeX,
839
- height: c.sizeY
840
- });
841
- });
842
- if (el == null) {
843
- w.col = i;
844
- w.row = j;
845
- return { value: void 0 };
846
- }
847
- };
848
- var this_1 = this;
849
- for (var i = 1; i <= xTile - w.sizeX; i++) {
850
- var state_1 = _loop_1(i);
851
- if (typeof state_1 === "object")
852
- return state_1.value;
853
- }
854
- }
855
- };
856
- AXWidgetBoardComponent.prototype.detectBestPlacement = function () {
857
- var _this = this;
858
- this.zone.runOutsideAngular(function () {
859
- var p = _this.container.nativeElement.querySelector('.widget-blank-placeholder');
860
- var col = Math.ceil(_this.dragItem.offsetLeft / _this.tileSize);
861
- if (_this.rtl) {
862
- col = Math.ceil((_this.container.nativeElement.clientWidth - (_this.dragItem.offsetLeft + _this.dragItem.clientWidth)) / _this.tileSize);
863
- }
864
- var row = Math.ceil(_this.dragItem.offsetTop / _this.tileSize);
865
- if (col < 1) {
866
- col = 1;
867
- }
868
- if (row < 1) {
869
- row = 1;
870
- }
871
- var widgets = Array.from(_this.ref.nativeElement.querySelectorAll('.widget-host')).map(function (c) { return c; });
872
- p.setAttribute(_this.DATA_COL, col.toString());
873
- p.setAttribute(_this.DATA_ROW, row.toString());
874
- var collision = widgets.filter(function (c) { return c !== _this.dragItem; }).some(function (c) { return AXHtmlUtil.collision(c, _this.dragItem); });
875
- if (collision) {
876
- _this.removePlaceholder();
877
- }
878
- });
879
- };
880
- AXWidgetBoardComponent.prototype.addPlaceholder = function () {
881
- var _this = this;
882
- this.zone.runOutsideAngular(function () {
883
- _this.removePlaceholder();
884
- if (_this.dragItem) {
885
- var p = document.createElement('div');
886
- p.classList.add('widget-blank-placeholder');
887
- p.setAttribute(_this.DATA_COL, _this.dragItem.getAttribute(_this.DATA_COL));
888
- p.setAttribute(_this.DATA_ROW, _this.dragItem.getAttribute(_this.DATA_ROW));
889
- p.setAttribute(_this.DATA_SIZE_X, _this.dragItem.getAttribute(_this.DATA_SIZE_X));
890
- p.setAttribute(_this.DATA_SIZE_Y, _this.dragItem.getAttribute(_this.DATA_SIZE_Y));
891
- _this.container.nativeElement.appendChild(p);
892
- }
893
- });
894
- };
895
- AXWidgetBoardComponent.prototype.removePlaceholder = function () {
896
- var _a;
897
- var p = this.container.nativeElement.querySelector('.widget-blank-placeholder');
898
- (_a = p) === null || _a === void 0 ? void 0 : _a.remove();
899
- };
900
- AXWidgetBoardComponent.prototype.startEdit = function () {
901
- var _this = this;
902
- this._isInEditing = true;
903
- this.calcGridSize();
904
- this.ref.nativeElement.classList.add('grid-background');
905
- var bg = this.ref.nativeElement;
906
- bg.style.setProperty('background-position', (this.rtl ? 'right' : 'left') + " top");
907
- // tslint:disable-next-line: max-line-length
908
- var pattern = "url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"" + (this.tileSize + this.gapSize) + "\" height=\"" + (this.tileSize + this.gapSize) + "\"> <rect style=\"fill: %23dadada\" x=\"" + (this.rtl ? this.gapSize : 0) + "\" width=\"" + this.tileSize + "\" height=\"" + this.tileSize + "\" y=\"0\"></rect></svg>')";
909
- bg.style.setProperty('background-image', pattern);
910
- //
911
- var widgets = Array.from(this.ref.nativeElement.querySelectorAll('.widget-host'));
912
- widgets.forEach(function (w) {
913
- w.addEventListener('mousedown', _this.dragStart.bind(_this), false);
914
- });
915
- this.ref.nativeElement.addEventListener('mousemove', this.drag.bind(this), false);
916
- this.ref.nativeElement.addEventListener('mouseup', this.dragEnd.bind(this), false);
917
- };
918
- AXWidgetBoardComponent.prototype.finishEdit = function () {
919
- var _this = this;
920
- this.ref.nativeElement.classList.remove('grid-background');
921
- var bg = this.ref.nativeElement;
922
- bg.style.removeProperty('background-image');
923
- //
924
- this._isInEditing = false;
925
- var widgets = Array.from(this.ref.nativeElement.querySelectorAll('.widget-host'));
926
- widgets.forEach(function (w) {
927
- w.removeEventListener('mousedown', _this.dragStart.bind(_this), false);
928
- });
929
- this.ref.nativeElement.removeEventListener('mousemove', this.drag.bind(this), false);
930
- this.ref.nativeElement.removeEventListener('mouseup', this.dragEnd.bind(this), false);
931
- this.emitConfigChanged();
932
- };
933
- AXWidgetBoardComponent.prototype.addWidget = function (widget) {
934
- var _this = this;
935
- this.zone.runOutsideAngular(function () {
936
- _this.newWidget = {
937
- uniqueName: widget.uniqueName,
938
- component: widget.component,
939
- title: widget.title,
940
- col: 1,
941
- row: 1,
942
- sizeX: widget.sizeX,
943
- sizeY: widget.sizeY,
944
- options: widget.options,
945
- props: widget.props
946
- };
947
- _this.detectFirstEmptySlot(_this.newWidget);
948
- var w = {
949
- uniqueName: _this.newWidget.uniqueName,
950
- component: _this.newWidget.component,
951
- title: _this.newWidget.title,
952
- options: _this.newWidget.options,
953
- props: _this.newWidget.props,
954
- sizeX: _this.newWidget.sizeX,
955
- sizeY: _this.newWidget.sizeY,
956
- col: _this.newWidget.col,
957
- row: _this.newWidget.row
958
- };
959
- _this.widgets.push(w);
960
- _this.newWidget = null;
961
- _this.zone.run(function () {
962
- _this.cdr.detectChanges();
963
- _this.calcGridSize();
964
- _this.emitConfigChanged();
965
- setTimeout(function () {
966
- w['__meta__'].instance.element.addEventListener('mousedown', _this.dragStart.bind(_this), false);
967
- }, 1000);
968
- });
969
- });
970
- };
971
- AXWidgetBoardComponent.prototype.handleOnRemove = function (w) {
972
- var _this = this;
973
- w.element.classList.add('animate__animated', 'animate__zoomOut');
974
- w.element.addEventListener('animationend', function () {
975
- _this.widgets = _this.widgets.filter(function (c) { return c.__meta__.id !== w.config.__meta__.id; });
976
- _this.cdr.detectChanges();
977
- _this.calcGridSize();
978
- _this.emitConfigChanged();
979
- });
980
- };
981
- AXWidgetBoardComponent.prototype.handleOnSave = function (e) {
982
- this.onWidgetSave.emit(e);
983
- };
984
- AXWidgetBoardComponent.prototype.trackByFn = function (index, item) {
985
- var _a, _b;
986
- if (!((_a = item['__meta__']) === null || _a === void 0 ? void 0 : _a.id)) {
987
- item['__meta__'] = {};
988
- item['__meta__'].id = AXHtmlUtil.getUID();
989
- }
990
- return (_b = item['__meta__']) === null || _b === void 0 ? void 0 : _b.id;
991
- };
992
- AXWidgetBoardComponent.prototype.load = function (widgets) {
993
- var _this = this;
994
- this.clear();
995
- return new Promise(function (resolve, reject) {
996
- if (widgets) {
997
- var loadedWidgets_1 = [];
998
- if (typeof widgets === 'string') {
999
- try {
1000
- loadedWidgets_1.push.apply(loadedWidgets_1, __spread(JSON.parse(widgets)));
1001
- }
1002
- catch (error) {
1003
- reject('Invalid widget json data!');
1004
- }
1005
- }
1006
- else {
1007
- loadedWidgets_1.push.apply(loadedWidgets_1, __spread(widgets));
1008
- }
1009
- var intervalId_1 = -1;
1010
- var loadFunc = function () {
1011
- var _a;
1012
- if (_this.galleryItems && _this.galleryItems.length > 0) {
1013
- loadedWidgets_1.forEach(function (w) {
1014
- var gitem = _this.galleryItems.find(function (c) { return c.uniqueName === w.uniqueName; });
1015
- if (gitem) {
1016
- w.component = gitem.component;
1017
- if (gitem.props) {
1018
- w.props = JSON.parse(JSON.stringify(gitem.props));
1019
- }
1020
- }
1021
- });
1022
- (_a = _this.widgets).push.apply(_a, __spread(loadedWidgets_1));
1023
- window.clearInterval(intervalId_1);
1024
- _this.cdr.detectChanges();
1025
- resolve();
1026
- }
1027
- };
1028
- intervalId_1 = window.setInterval(loadFunc, 200);
1029
- }
1030
- else {
1031
- resolve();
1032
- }
1033
- });
1034
- };
1035
- AXWidgetBoardComponent.prototype.clear = function () {
1036
- if (this.widgets.length) {
1037
- this.widgets = [];
1038
- this.cdr.detectChanges();
1039
- this.emitConfigChanged();
1040
- }
1041
- };
1042
- AXWidgetBoardComponent.prototype.save = function () {
1043
- var obj = this.widgets.map(function (c) { return ({
1044
- uniqueName: c.uniqueName,
1045
- component: c.component,
1046
- title: c.title,
1047
- sizeX: c.sizeX,
1048
- sizeY: c.sizeY,
1049
- col: c.col,
1050
- row: c.row,
1051
- options: c.options,
1052
- props: c.props
1053
- }); });
1054
- return Promise.resolve(JSON.stringify(obj));
1055
- };
1056
- AXWidgetBoardComponent.prototype.refresh = function () {
1057
- this.widgetHosts.forEach(function (host) {
1058
- host.widget.refresh();
1059
- });
1060
- };
1061
- AXWidgetBoardComponent.prototype.handleOnConfigChanged = function (e) {
1062
- this.cdr.detectChanges();
1063
- this.emitConfigChanged();
1064
- };
1065
- AXWidgetBoardComponent.prototype.handleOnResizedChanged = function (e) {
1066
- this.detectFirstEmptySlot(e.config);
1067
- this.cdr.detectChanges();
1068
- this.emitConfigChanged();
1069
- };
1070
- AXWidgetBoardComponent.prototype.emitConfigChanged = function () {
1071
- var _this = this;
1072
- if (!this.resizeChangeObserver) {
1073
- this.resizeChangeObserver = new Observable();
1074
- Observable.create(function (observer) {
1075
- _this.resizeChangeObserver = observer;
1076
- })
1077
- .pipe(debounceTime(750))
1078
- .pipe(distinctUntilChanged())
1079
- .subscribe(function (c) {
1080
- _this.onConfigChanged.emit({
1081
- component: _this
1082
- });
1083
- });
1084
- }
1085
- this.resizeChangeObserver.next(new Date());
1086
- };
1087
- AXWidgetBoardComponent.ctorParameters = function () { return [
1088
- { type: ElementRef },
1089
- { type: NgZone },
1090
- { type: ChangeDetectorRef }
1091
- ]; };
1092
- __decorate([
1093
- ViewChild('container'),
1094
- __metadata("design:type", ElementRef)
1095
- ], AXWidgetBoardComponent.prototype, "container", void 0);
1096
- __decorate([
1097
- ViewChildren(AXWidgetHostComponent),
1098
- __metadata("design:type", QueryList)
1099
- ], AXWidgetBoardComponent.prototype, "widgetHosts", void 0);
1100
- __decorate([
1101
- Input(),
1102
- __metadata("design:type", Array)
1103
- ], AXWidgetBoardComponent.prototype, "galleryItems", void 0);
1104
- __decorate([
1105
- Input(),
1106
- __metadata("design:type", Number)
1107
- ], AXWidgetBoardComponent.prototype, "tileSize", void 0);
1108
- __decorate([
1109
- Input(),
1110
- __metadata("design:type", Number)
1111
- ], AXWidgetBoardComponent.prototype, "gapSize", void 0);
1112
- __decorate([
1113
- Input(),
1114
- __metadata("design:type", Function)
1115
- ], AXWidgetBoardComponent.prototype, "provideValue", void 0);
1116
- __decorate([
1117
- Output(),
1118
- __metadata("design:type", EventEmitter)
1119
- ], AXWidgetBoardComponent.prototype, "onConfigChanged", void 0);
1120
- __decorate([
1121
- Output(),
1122
- __metadata("design:type", EventEmitter)
1123
- ], AXWidgetBoardComponent.prototype, "onWidgetSave", void 0);
1124
- AXWidgetBoardComponent = __decorate([
1125
- Component({
1126
- selector: 'ax-widget-board',
1127
- template: "<div class=\"widgets-container\" [class.rtl]=\"rtl\" #container>\r\n <ax-widget-host *ngFor=\"let w of widgets;trackBy: trackByFn\" [config]='w' [sizeX]=\"w.sizeX\"\r\n [sizeY]=\"w.sizeY\" [col]=\"w.col\" [row]=\"w.row\" (onRemove)=\"handleOnRemove($event)\" (onSave)=\"handleOnSave($event)\"\r\n (onConfigChanged)=\"handleOnConfigChanged($event)\" (onResized)=\"handleOnResizedChanged($event)\"\r\n [provideValue]=\"provideValue\">\r\n </ax-widget-host>\r\n</div>\r\n",
1128
- host: { class: 'ax widget-board' },
1129
- encapsulation: ViewEncapsulation.None,
1130
- changeDetection: ChangeDetectionStrategy.OnPush,
1131
- styles: [".widget-board{display:inline-block;margin:15px 20px;min-width:calc(100% - 40px);min-height:calc(100% - 34px);--animate-duration:0.5s;background-repeat:no-repeat}.widget-board.grid-background{background-repeat:repeat!important}.widget-board.grid-background .widgets-container .widget-host{touch-action:none;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.widget-board.grid-background .widgets-container .widget-host .widget-edit-overlay{display:block;cursor:move}.widget-board.grid-background .widgets-container .widget-host.widget-dragging{z-index:1000}.widget-board.grid-background .widgets-container .widget-host:focus{outline-width:1px;outline-style:solid;outline-color:var(--ax-primary-color)}.widget-board.grid-background .widget-blank-placeholder{background:var(--ax-primary-trans-light-color);position:absolute}.widget-board .widgets-container{position:relative;touch-action:none}.widget-board .widgets-container.rtl .widget-host .widget-options-menu{right:unset!important;left:0!important}.widget-board .widgets-container .widget-host{position:absolute;background:#fff;box-shadow:2px 2px 3px #dadada}.widget-board .widgets-container .widget-host .widget-content{width:100%;height:100%;display:flex;flex-direction:column}.widget-board .widgets-container .widget-host .widget-content .widget-title{padding:var(--ax-size-md);text-align:start;font-size:1.5em;position:absolute}.widget-board .widgets-container .widget-host .widget-edit-loading{display:none;background:rgba(255,255,255,.85);position:absolute;width:100%;height:100%;top:0;left:0;z-index:2;display:flex}.widget-board .widgets-container .widget-host .widget-config-overlay{position:absolute;background:#fff;width:100%;height:100%;top:0;left:0;z-index:1;padding:var(--ax-size-md);cursor:pointer}.widget-board .widgets-container .widget-host .widget-config-overlay:hover .widget-title{text-decoration:underline}.widget-board .widgets-container .widget-host .widget-config-overlay .widget-title{text-align:start;font-size:1.5em}.widget-board .widgets-container .widget-host .widget-config-overlay .widget-config-box{align-self:center;text-align:center;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);color:var(--ax-gray-dark-color)}.widget-board .widgets-container .widget-host .widget-config-overlay .widget-config-box .config-title{font-size:1.2em;margin-bottom:var(--ax-size-md)}.widget-board .widgets-container .widget-host .widget-edit-overlay{display:none;background:rgba(255,255,255,.5);position:absolute;width:100%;height:100%;top:0;left:0;z-index:10}.widget-board .widgets-container .widget-host .widget-edit-overlay .widget-edit-menu{margin:6px;text-align:end;float:inline-end;opacity:1;transition:opacity 1s}.widget-board .widgets-container .widget-host .widget-edit-overlay .widget-edit-menu .widget-edit-menu-button{display:inline-block;background-color:#f0f0f0;border-radius:1px;border:2px solid #fff;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;padding:0;height:32px;width:32px;cursor:pointer;color:#666}.widget-board .widgets-container .widget-host .widget-edit-overlay .widget-edit-menu .widget-edit-menu-button:hover{border-color:#a6a6a6;background-color:#c8c8c8}.widget-board .widgets-container .widget-host .widget-options-menu{display:none;position:absolute;top:0;right:0;z-index:2;cursor:pointer;padding:2px 5px}.widget-board .widgets-container .widget-host .widget-options-menu:hover{background-color:#f0f0f0}.widget-board .widgets-container .widget-host .widget-container{padding:1px;height:100%}.widget-board .widgets-container .widget-host .widget-container:hover .widget-options-menu{display:block}"]
1132
- }),
1133
- __metadata("design:paramtypes", [ElementRef,
1134
- NgZone,
1135
- ChangeDetectorRef])
1136
- ], AXWidgetBoardComponent);
1137
- return AXWidgetBoardComponent;
1138
- }());
1139
-
1140
- var AXWidgetSizePropertyEditorComponent = /** @class */ (function (_super) {
1141
- __extends(AXWidgetSizePropertyEditorComponent, _super);
1142
- function AXWidgetSizePropertyEditorComponent(cdr) {
1143
- var _this = _super.call(this, cdr) || this;
1144
- _this.cdr = cdr;
1145
- _this.minX = 1;
1146
- _this.maxX = 10;
1147
- _this.minY = 1;
1148
- _this.maxY = 10;
1149
- return _this;
1150
- }
1151
- AXWidgetSizePropertyEditorComponent.prototype.ngOnInit = function () {
1152
- if (Array.isArray(this.value)) {
1153
- this.sizeX = this.value[0];
1154
- this.sizeY = this.value[1];
1155
- }
1156
- else {
1157
- this.sizeX = 2;
1158
- this.sizeY = 2;
1159
- }
1160
- };
1161
- AXWidgetSizePropertyEditorComponent.prototype.handleMinValueChange = function (e) {
1162
- this.sizeX = e.value;
1163
- if (this.sizeY > 0) {
1164
- _super.prototype.handleValueChange.call(this, [this.sizeX, this.sizeY]);
1165
- }
1166
- };
1167
- AXWidgetSizePropertyEditorComponent.prototype.handleMaxValueChange = function (e) {
1168
- this.sizeY = e.value;
1169
- if (this.sizeX > 0) {
1170
- _super.prototype.handleValueChange.call(this, [this.sizeX, this.sizeY]);
1171
- }
1172
- };
1173
- AXWidgetSizePropertyEditorComponent.prototype.ngAfterViewInit = function () {
1174
- this.onRenderCompleted.emit();
1175
- };
1176
- AXWidgetSizePropertyEditorComponent.ctorParameters = function () { return [
1177
- { type: ChangeDetectorRef }
1178
- ]; };
1179
- AXWidgetSizePropertyEditorComponent = __decorate([
1180
- Component({
1181
- template: "<div style=\"display: flex;\">\r\n <div style=\"margin-inline-end: 0.5em;flex: calc(50% - 0.25em);\">\r\n <ax-number-box (onValueChanged)=\"handleMinValueChange($event)\" [value]=\"sizeX\" [min]=\"minX\" [max]=\"maxX\">\r\n </ax-number-box>\r\n </div>\r\n <div style=\"flex: calc(50% - 0.25em);\">\r\n <ax-number-box (onValueChanged)=\"handleMaxValueChange($event)\" [value]=\"sizeY\" [min]=\"minY\" [max]=\"maxY\">\r\n </ax-number-box>\r\n </div>\r\n</div>"
1182
- }),
1183
- __metadata("design:paramtypes", [ChangeDetectorRef])
1184
- ], AXWidgetSizePropertyEditorComponent);
1185
- return AXWidgetSizePropertyEditorComponent;
1186
- }(AXProperyEditorComponent));
1187
-
1188
- var AXWidgetBoardModule = /** @class */ (function () {
1189
- /**
1190
- *
1191
- */
1192
- function AXWidgetBoardModule() {
1193
- AXTranslator.load('en', {
1194
- 'widget-board': {
1195
- 'configurable-props': 'Configurable Properties',
1196
- configure: 'Configure Widget'
1197
- }
1198
- });
1199
- AXTranslator.load('fa', {
1200
- 'widget-board': {
1201
- 'configurable-props': 'ویژگی های قابل تنظیم',
1202
- configure: 'پیکر بندی ابزارک'
1203
- }
1204
- });
1205
- }
1206
- AXWidgetBoardModule = __decorate([
1207
- NgModule({
1208
- imports: [
1209
- CommonModule,
1210
- AXSearchBoxModule,
1211
- AXLoadingModule,
1212
- RouterModule,
1213
- AXProppertyEditorModule,
1214
- AXPageModule,
1215
- AXToolbarModule,
1216
- AXTranslatorModule,
1217
- AXLabelModule,
1218
- AXTextAreaModule,
1219
- AXFieldsetModule,
1220
- AXTextBoxModule,
1221
- AXFormGroupModule,
1222
- AXTabStripModule,
1223
- AXCheckBoxModule,
1224
- AXMenuModule,
1225
- AXTranslatorModule,
1226
- AXValidationModule,
1227
- RouterModule.forChild([
1228
- {
1229
- component: AXWidgetSizePropertyEditorComponent,
1230
- path: 'ax/editors/widget-size'
1231
- },
1232
- ])
1233
- ],
1234
- exports: [AXWidgetBoardComponent, AXProppertyEditorModule],
1235
- declarations: [AXWidgetBoardComponent, AXWidgetHostComponent, AXWidgetConfigComponent, AXWidgetSaveComponent],
1236
- entryComponents: [AXWidgetConfigComponent, AXWidgetSaveComponent],
1237
- providers: []
1238
- }),
1239
- __metadata("design:paramtypes", [])
1240
- ], AXWidgetBoardModule);
1241
- return AXWidgetBoardModule;
1242
- }());
1243
-
1244
- var AXWidgetSizePropertyEditorModule = /** @class */ (function () {
1245
- function AXWidgetSizePropertyEditorModule() {
1246
- }
1247
- AXWidgetSizePropertyEditorModule = __decorate([
1248
- NgModule({
1249
- declarations: [AXWidgetSizePropertyEditorComponent],
1250
- imports: [CommonModule, FormsModule, AXNumberBoxModule],
1251
- exports: [AXWidgetSizePropertyEditorComponent],
1252
- entryComponents: [AXWidgetSizePropertyEditorComponent],
1253
- providers: [],
1254
- })
1255
- ], AXWidgetSizePropertyEditorModule);
1256
- return AXWidgetSizePropertyEditorModule;
1257
- }());
1258
-
1259
- /**
1260
- * Generated bundle index. Do not edit.
1261
- */
1262
-
1263
- export { AXWidgetBoardComponent, AXWidgetBoardModule, AXWidgetComponent, AXWidgetHostComponent, AXWidgetSizePropertyEditorComponent, AXWidgetSizePropertyEditorModule, ɵ0, AXWidgetConfigComponent as ɵa, AXWidgetSaveComponent as ɵb };
1264
- //# sourceMappingURL=acorex-layout.js.map