@schneideress/dashboardframework 0.0.279 → 13.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/README.md +8 -8
  2. package/esm2020/lib/custom.notifier.options.mjs +41 -0
  3. package/esm2020/lib/ra-dashboard-area/ra.dashboard.area.mjs +445 -0
  4. package/esm2020/lib/ra-widget-container/lock-tooltip/lock.tooltip.component.mjs +43 -0
  5. package/esm2020/lib/ra-widget-container/ra.widget.container.component.mjs +767 -0
  6. package/esm2020/lib/ra.base.dashboard.filter.mjs +44 -0
  7. package/esm2020/lib/ra.base.dashboard.template.mjs +36 -0
  8. package/esm2020/lib/ra.dashbard.event.bus.mjs +46 -0
  9. package/esm2020/lib/ra.dashboard.module.mjs +64 -0
  10. package/esm2020/lib/ra.dashboard.responsive.service.mjs +136 -0
  11. package/esm2020/lib/ra.dashboard.service.mjs +77 -0
  12. package/esm2020/lib/ra.event.enum.mjs +60 -0
  13. package/esm2020/lib/ra.gridster.config.mjs +56 -0
  14. package/esm2020/public-api.mjs +15 -0
  15. package/esm2020/schneideress-dashboardframework.mjs +5 -0
  16. package/fesm2015/schneideress-dashboardframework.mjs +1800 -0
  17. package/fesm2015/schneideress-dashboardframework.mjs.map +1 -0
  18. package/fesm2020/schneideress-dashboardframework.mjs +1790 -0
  19. package/fesm2020/schneideress-dashboardframework.mjs.map +1 -0
  20. package/lib/ra-dashboard-area/ra.dashboard.area.d.ts +5 -3
  21. package/lib/ra-widget-container/lock-tooltip/lock.tooltip.component.d.ts +3 -0
  22. package/lib/ra-widget-container/ra.widget.container.component.d.ts +6 -4
  23. package/lib/ra.base.dashboard.filter.d.ts +3 -2
  24. package/lib/ra.base.dashboard.template.d.ts +4 -2
  25. package/lib/ra.dashbard.event.bus.d.ts +3 -0
  26. package/lib/ra.dashboard.module.d.ts +15 -0
  27. package/lib/ra.dashboard.responsive.service.d.ts +8 -5
  28. package/lib/ra.dashboard.service.d.ts +4 -2
  29. package/lib/ra.gridster.config.d.ts +1 -1
  30. package/package.json +26 -20
  31. package/schneideress-dashboardframework.d.ts +1 -6
  32. package/bundles/schneideress-dashboardframework.umd.js +0 -5103
  33. package/bundles/schneideress-dashboardframework.umd.js.map +0 -1
  34. package/bundles/schneideress-dashboardframework.umd.min.js +0 -16
  35. package/bundles/schneideress-dashboardframework.umd.min.js.map +0 -1
  36. package/esm2015/gridster/index.js +0 -14
  37. package/esm2015/gridster/lib/gridster.component.js +0 -471
  38. package/esm2015/gridster/lib/gridster.interface.js +0 -3
  39. package/esm2015/gridster/lib/gridster.module.js +0 -25
  40. package/esm2015/gridster/lib/gridsterCompact.service.js +0 -162
  41. package/esm2015/gridster/lib/gridsterConfig.constant.js +0 -104
  42. package/esm2015/gridster/lib/gridsterConfig.interface.js +0 -27
  43. package/esm2015/gridster/lib/gridsterConfigS.interface.js +0 -1
  44. package/esm2015/gridster/lib/gridsterDraggable.service.js +0 -351
  45. package/esm2015/gridster/lib/gridsterEmptyCell.service.js +0 -216
  46. package/esm2015/gridster/lib/gridsterItem.component.js +0 -141
  47. package/esm2015/gridster/lib/gridsterItem.interface.js +0 -1
  48. package/esm2015/gridster/lib/gridsterItemComponent.interface.js +0 -3
  49. package/esm2015/gridster/lib/gridsterPreview.component.js +0 -45
  50. package/esm2015/gridster/lib/gridsterPush.service.js +0 -296
  51. package/esm2015/gridster/lib/gridsterPushResize.service.js +0 -225
  52. package/esm2015/gridster/lib/gridsterRenderer.service.js +0 -208
  53. package/esm2015/gridster/lib/gridsterResizable.service.js +0 -368
  54. package/esm2015/gridster/lib/gridsterResizeEventType.interface.js +0 -1
  55. package/esm2015/gridster/lib/gridsterScroll.service.js +0 -119
  56. package/esm2015/gridster/lib/gridsterSwap.service.js +0 -85
  57. package/esm2015/gridster/lib/gridsterUtils.service.js +0 -89
  58. package/esm2015/lib/custom.notifier.options.js +0 -41
  59. package/esm2015/lib/ra-dashboard-area/ra.dashboard.area.js +0 -492
  60. package/esm2015/lib/ra-widget-container/lock-tooltip/lock.tooltip.component.js +0 -48
  61. package/esm2015/lib/ra-widget-container/ra.widget.container.component.js +0 -829
  62. package/esm2015/lib/ra.base.dashboard.filter.js +0 -54
  63. package/esm2015/lib/ra.base.dashboard.template.js +0 -33
  64. package/esm2015/lib/ra.dashbard.event.bus.js +0 -46
  65. package/esm2015/lib/ra.dashboard.module.js +0 -44
  66. package/esm2015/lib/ra.dashboard.responsive.service.js +0 -140
  67. package/esm2015/lib/ra.dashboard.service.js +0 -82
  68. package/esm2015/lib/ra.event.enum.js +0 -60
  69. package/esm2015/lib/ra.gridster.config.js +0 -56
  70. package/esm2015/public-api.js +0 -13
  71. package/esm2015/schneideress-dashboardframework.js +0 -11
  72. package/esm5/gridster/index.js +0 -14
  73. package/esm5/gridster/lib/gridster.component.js +0 -474
  74. package/esm5/gridster/lib/gridster.interface.js +0 -7
  75. package/esm5/gridster/lib/gridster.module.js +0 -28
  76. package/esm5/gridster/lib/gridsterCompact.service.js +0 -163
  77. package/esm5/gridster/lib/gridsterConfig.constant.js +0 -104
  78. package/esm5/gridster/lib/gridsterConfig.interface.js +0 -27
  79. package/esm5/gridster/lib/gridsterConfigS.interface.js +0 -1
  80. package/esm5/gridster/lib/gridsterDraggable.service.js +0 -356
  81. package/esm5/gridster/lib/gridsterEmptyCell.service.js +0 -220
  82. package/esm5/gridster/lib/gridsterItem.component.js +0 -142
  83. package/esm5/gridster/lib/gridsterItem.interface.js +0 -1
  84. package/esm5/gridster/lib/gridsterItemComponent.interface.js +0 -7
  85. package/esm5/gridster/lib/gridsterPreview.component.js +0 -46
  86. package/esm5/gridster/lib/gridsterPush.service.js +0 -297
  87. package/esm5/gridster/lib/gridsterPushResize.service.js +0 -226
  88. package/esm5/gridster/lib/gridsterRenderer.service.js +0 -209
  89. package/esm5/gridster/lib/gridsterResizable.service.js +0 -373
  90. package/esm5/gridster/lib/gridsterResizeEventType.interface.js +0 -1
  91. package/esm5/gridster/lib/gridsterScroll.service.js +0 -119
  92. package/esm5/gridster/lib/gridsterSwap.service.js +0 -86
  93. package/esm5/gridster/lib/gridsterUtils.service.js +0 -93
  94. package/esm5/lib/custom.notifier.options.js +0 -41
  95. package/esm5/lib/ra-dashboard-area/ra.dashboard.area.js +0 -503
  96. package/esm5/lib/ra-widget-container/lock-tooltip/lock.tooltip.component.js +0 -50
  97. package/esm5/lib/ra-widget-container/ra.widget.container.component.js +0 -891
  98. package/esm5/lib/ra.base.dashboard.filter.js +0 -57
  99. package/esm5/lib/ra.base.dashboard.template.js +0 -36
  100. package/esm5/lib/ra.dashbard.event.bus.js +0 -47
  101. package/esm5/lib/ra.dashboard.module.js +0 -47
  102. package/esm5/lib/ra.dashboard.responsive.service.js +0 -151
  103. package/esm5/lib/ra.dashboard.service.js +0 -85
  104. package/esm5/lib/ra.event.enum.js +0 -60
  105. package/esm5/lib/ra.gridster.config.js +0 -56
  106. package/esm5/public-api.js +0 -13
  107. package/esm5/schneideress-dashboardframework.js +0 -11
  108. package/fesm2015/schneideress-dashboardframework.js +0 -4749
  109. package/fesm2015/schneideress-dashboardframework.js.map +0 -1
  110. package/fesm5/schneideress-dashboardframework.js +0 -4883
  111. package/fesm5/schneideress-dashboardframework.js.map +0 -1
  112. package/gridster/index.d.ts +0 -11
  113. package/gridster/lib/gridster.component.d.ts +0 -67
  114. package/gridster/lib/gridster.interface.d.ts +0 -46
  115. package/gridster/lib/gridster.module.d.ts +0 -2
  116. package/gridster/lib/gridsterCompact.service.d.ts +0 -15
  117. package/gridster/lib/gridsterConfig.constant.d.ts +0 -2
  118. package/gridster/lib/gridsterConfig.interface.d.ts +0 -133
  119. package/gridster/lib/gridsterConfigS.interface.d.ts +0 -93
  120. package/gridster/lib/gridsterDraggable.service.d.ts +0 -59
  121. package/gridster/lib/gridsterEmptyCell.service.d.ts +0 -29
  122. package/gridster/lib/gridsterItem.component.d.ts +0 -32
  123. package/gridster/lib/gridsterItem.interface.d.ts +0 -21
  124. package/gridster/lib/gridsterItemComponent.interface.d.ts +0 -25
  125. package/gridster/lib/gridsterPreview.component.d.ts +0 -10
  126. package/gridster/lib/gridsterPush.service.d.ts +0 -33
  127. package/gridster/lib/gridsterPushResize.service.d.ts +0 -26
  128. package/gridster/lib/gridsterRenderer.service.d.ts +0 -38
  129. package/gridster/lib/gridsterResizable.service.d.ts +0 -67
  130. package/gridster/lib/gridsterResizeEventType.interface.d.ts +0 -6
  131. package/gridster/lib/gridsterScroll.service.d.ts +0 -4
  132. package/gridster/lib/gridsterSwap.service.d.ts +0 -13
  133. package/gridster/lib/gridsterUtils.service.d.ts +0 -16
  134. package/schneideress-dashboardframework.metadata.json +0 -1
@@ -1,4749 +0,0 @@
1
- import { __decorate, __metadata, __awaiter, __param } from 'tslib';
2
- import { Injector, ɵɵdefineInjectable, ɵɵinject, INJECTOR, Injectable, EventEmitter, NgZone, Input, Output, ViewChild, ElementRef, Component, Renderer2, ChangeDetectorRef, ViewEncapsulation, Host, NgModule } from '@angular/core';
3
- import { of, Subject } from 'rxjs';
4
- import { BaseService, RATranslateService, RAPermissionService, DomService, RACommonModule } from '@schneideress/ra-common';
5
- import { filter, map } from 'rxjs/operators';
6
- import { NgxUiLoaderService, NgxUiLoaderModule } from 'ngx-ui-loader';
7
- import { NotifierService, NotifierModule } from 'angular-notifier';
8
- import { RaWidgetlockStatus, WidgetViewState, RADownloadType, RADownloadOption } from '@schneideress/widgetframework';
9
- import { BrowserModule } from '@angular/platform-browser';
10
- import { HttpClientModule } from '@angular/common/http';
11
- import { CommonModule } from '@angular/common';
12
- import { RAUserControlModule } from '@schneideress/user-controls';
13
- import { RACommonControlsModule } from '@schneideress/common-controls';
14
-
15
- let RaDashboardService = class RaDashboardService extends BaseService {
16
- constructor(injector) {
17
- super(injector, '');
18
- this.loadedScripts = [];
19
- this.clientId = undefined;
20
- }
21
- /*
22
- * To load external scripts in the dom
23
- */
24
- loadExternalScript(scriptPath, callback) {
25
- if (this.loadedScripts.indexOf(scriptPath) == -1) {
26
- const script = document.createElement('script');
27
- script.src = scriptPath;
28
- // script.addEventListener("load", callback(), true);
29
- script.onload = function () {
30
- callback();
31
- };
32
- document.body.appendChild(script);
33
- this.loadedScripts.push(scriptPath);
34
- }
35
- else {
36
- callback();
37
- }
38
- }
39
- /*
40
- * To retrieve the list of widgets based on dashboard id & areaId
41
- */
42
- getWidgetsByDashboardArea(widgetInfo, appConfig) {
43
- this.baseUrl = appConfig.apiBaseUrl;
44
- return this.post('widget/GetWidgetByArea', widgetInfo);
45
- }
46
- updateWidgets(widgetList, appConfig) {
47
- this.baseUrl = appConfig.apiBaseUrl;
48
- return this.post('widget/UpdateAreaWidgets', widgetList);
49
- }
50
- getWidgetConfigInfo(widgetInfo) {
51
- return of();
52
- }
53
- /*
54
- * To update the configuration of a widget.
55
- */
56
- updateConfig(config, widgetInstanceId) {
57
- }
58
- /**To add widget to the database */
59
- addWidget(widgetInfo, appConfig) {
60
- this.baseUrl = appConfig.apiBaseUrl;
61
- return this.post('widget/AddWidgetUser', widgetInfo);
62
- }
63
- /** To Delete current widget from DOM*/
64
- deleteWidget(widgetInfo, appConfig) {
65
- this.baseUrl = appConfig.apiBaseUrl;
66
- return this.delete('widget/DeleteWidgetUser?widgetInstanceId=' + widgetInfo.widgetInstanceId);
67
- }
68
- /**To Update widgetInfo in database */
69
- updateWidget(widgetInfo, appConfig) {
70
- this.baseUrl = appConfig.apiBaseUrl;
71
- return this.post('widget/UpdateUserWidget', widgetInfo);
72
- }
73
- /** To Move or change position if current widget container*/
74
- moveWidget(widgetInfo) {
75
- }
76
- /** To Copy Current widget with same configuration*/
77
- copyWidget(widgetInfo) {
78
- }
79
- };
80
- RaDashboardService.ctorParameters = () => [
81
- { type: Injector }
82
- ];
83
- RaDashboardService.ngInjectableDef = ɵɵdefineInjectable({ factory: function RaDashboardService_Factory() { return new RaDashboardService(ɵɵinject(INJECTOR)); }, token: RaDashboardService, providedIn: "root" });
84
- RaDashboardService = __decorate([
85
- Injectable({
86
- providedIn: 'root'
87
- }),
88
- __metadata("design:paramtypes", [Injector])
89
- ], RaDashboardService);
90
-
91
- let RADashboardEventBus = class RADashboardEventBus {
92
- constructor() {
93
- this.eventQueue = new Subject();
94
- }
95
- /**
96
- * To emit an event with the name & data
97
- */
98
- publish(eventName, data) {
99
- this.eventQueue.next({ eventName, data });
100
- }
101
- /**
102
- * To emit an event with the name, data, key & value
103
- */
104
- publishWithKey(eventName, data, key, value) {
105
- this.eventQueue.next({ eventName, data, key, value });
106
- }
107
- /**
108
- * To subscribe to an event with the name
109
- */
110
- subscribe(eventName) {
111
- return this.eventQueue.asObservable().pipe(filter((event) => {
112
- return event.eventName == eventName;
113
- }), map(event => event.data));
114
- }
115
- /**
116
- * To subscribe to an event with the name key & value
117
- */
118
- subscribeWithKey(eventName, key, value) {
119
- return this.eventQueue.asObservable().pipe(filter((event) => {
120
- return event.eventName == eventName && event.key == key && event.value == value;
121
- }), map(event => event.data));
122
- }
123
- };
124
- RADashboardEventBus.ngInjectableDef = ɵɵdefineInjectable({ factory: function RADashboardEventBus_Factory() { return new RADashboardEventBus(); }, token: RADashboardEventBus, providedIn: "root" });
125
- RADashboardEventBus = __decorate([
126
- Injectable({
127
- providedIn: 'root'
128
- })
129
- ], RADashboardEventBus);
130
-
131
- var RAEvent;
132
- (function (RAEvent) {
133
- /** widget selection click on widget library */
134
- RAEvent["WidgetSelected"] = "widgetSelected";
135
- /** triggers when user click on the edit link in widget container */
136
- RAEvent["WidgetEditClicked"] = "widgetEditClicked";
137
- /** triggers when user clicks the cancel button on widget configuration window */
138
- RAEvent["ConfigCancelClick"] = "configCancelClick";
139
- /** triggers when user click on the close button on widget configuration window */
140
- RAEvent["ConfigCloseClick"] = "configCloseClick";
141
- /** add button click on widget configuration window */
142
- RAEvent["ConfigAddClick"] = "configAddClick";
143
- /** triggers when a user click on the save button in widget configuration window */
144
- RAEvent["ConfigChanged"] = "configChanged";
145
- /**To rearrange widgets in a dashboard */
146
- RAEvent["RearrangeClicked"] = "rearrangeClicked";
147
- /**dashboard customize button click */
148
- RAEvent["DashboardCustomizeClick"] = "dashboardCustomizeClick";
149
- /**triggers when user clicks on the dashboard change icon in header section */
150
- RAEvent["DashboardChanged"] = "dashboardChanged";
151
- /** triggers when user clicks the close button on library */
152
- RAEvent["WidgetLibraryCloseBtnClicked"] = "WidgetLibraryCloseBtnClicked";
153
- /** triggers when user clicks on view dashboard*/
154
- RAEvent["LoadDashboard"] = "LoadDashboard";
155
- /** triggers when user clicks on copywidget */
156
- RAEvent["CopyWidget"] = "CopyWidget";
157
- /**triggers when user clicks on Move widget */
158
- RAEvent["MoveWidget"] = "MoveWidget";
159
- /**triggers when user raise delete widget event */
160
- RAEvent["WidgetDelete"] = "WidgetDelete";
161
- /** used to add widget to widgetlist when user copies a widget to current dashboard */
162
- RAEvent["AddWidget"] = "AddWidget";
163
- /** done button click on widget library flyout */
164
- RAEvent["widgetLibraryDoneClick"] = "widgetLibraryDoneClick";
165
- /**refresh favorite icon after srtting and resetting favorites */
166
- RAEvent["favoriteIconRefresh"] = "favoriteIconRefresh";
167
- /**to refresh menu content */
168
- RAEvent["QuickLinkRefresh"] = "QuickLinkRefresh";
169
- /**To raise widget added event */
170
- RAEvent["WidgetAdded"] = "WidgetAdded";
171
- /**To update global filter site from map widget selected site */
172
- RAEvent["UpdateGlobalFilterFromMapWidget"] = "UpdateGlobalFilterFromMapWidget";
173
- /**To add widget on empty dashboard */
174
- RAEvent["AddWidgetEmptyDashboard"] = "AddWidgetEmptyDashboard";
175
- /**To raise new widget add click event */
176
- RAEvent["AddNewWidgetToDashboard"] = "AddNewWidgetToDashboard";
177
- RAEvent["HideDashboardBanner"] = "HideDashboardBanner";
178
- /**To launch flyout from custom widget library */
179
- RAEvent["LaunchCustomWidgetFlyout"] = "LaunchCustomWidgetFlyout";
180
- /**update applied filter badge for inaplicable filters */
181
- RAEvent["UpdateAppledFiterForInapplicableFilter"] = "UpdateAppledFiterForInapplicableFilter";
182
- /**show inapplicable filter message in global filter flyout */
183
- RAEvent["ShowInapplicableFilterMessage"] = "ShowInapplicableFilterMessage";
184
- })(RAEvent || (RAEvent = {}));
185
- var RAEventKey;
186
- (function (RAEventKey) {
187
- /** on edit widget click */
188
- RAEventKey["WidgetInstanceId"] = "widgetInstanceId";
189
- })(RAEventKey || (RAEventKey = {}));
190
-
191
- const GridsterConfigDefaultSettings = {
192
- gridType: 'scrollVertical',
193
- compactType: 'none',
194
- margin: 10,
195
- outerMargin: true,
196
- outerMarginTop: 10,
197
- outerMarginRight: 10,
198
- outerMarginBottom: 30,
199
- outerMarginLeft: 10,
200
- useTransformPositioning: true,
201
- mobileBreakpoint: 640,
202
- minCols: 10,
203
- maxCols: 10,
204
- minRows: 1,
205
- maxRows: 100,
206
- maxItemCols: 10,
207
- minItemCols: 1,
208
- maxItemRows: 1000,
209
- minItemRows: 1,
210
- maxItemArea: 1000,
211
- minItemArea: 1,
212
- defaultItemCols: 1,
213
- defaultItemRows: 1,
214
- keepFixedHeightInMobile: false,
215
- keepFixedWidthInMobile: false,
216
- scrollSensitivity: 10,
217
- scrollSpeed: 20,
218
- enableEmptyCellClick: false,
219
- enableEmptyCellContextMenu: false,
220
- enableEmptyCellDrop: false,
221
- enableEmptyCellDrag: false,
222
- emptyCellDragMaxCols: 50,
223
- emptyCellDragMaxRows: 50,
224
- ignoreMarginInRow: true,
225
- draggable: {
226
- enabled: true,
227
- dragHandleClass: 'widget-move',
228
- ignoreContent: true
229
- },
230
- resizable: {
231
- enabled: true,
232
- },
233
- swap: true,
234
- pushItems: true,
235
- disablePushOnDrag: false,
236
- disablePushOnResize: false,
237
- pushDirections: { north: true, east: true, south: true, west: true },
238
- pushResizeItems: false,
239
- displayGrid: 'none',
240
- disableWindowResize: false,
241
- disableWarnings: false,
242
- scrollToNewItems: true,
243
- autoResizeonDrag: false,
244
- setGridSize: false
245
- };
246
-
247
- let RADashboardResponsiveService = class RADashboardResponsiveService {
248
- constructor() {
249
- this.resized = new Subject();
250
- this.maxColsDesktop = 8;
251
- this.resInfo = [
252
- { id: 1, start: 0, end: 767, minCols: 1, maxCols: 1 },
253
- { id: 2, start: 768, end: 1024, minCols: 1, maxCols: 2 },
254
- { id: 3, start: 1025, end: 1366, minCols: 1, maxCols: 6 },
255
- {
256
- id: 4,
257
- start: 1367,
258
- end: 9999999999,
259
- minCols: 1,
260
- maxCols: this.maxColsDesktop,
261
- },
262
- ];
263
- this.setScreenWidth();
264
- window.addEventListener("resize", () => {
265
- var context = this;
266
- if (this.screenWidthAdjusted)
267
- clearTimeout(this.screenWidthAdjusted);
268
- this.screenWidthAdjusted = setTimeout(() => {
269
- context.setScreenWidth();
270
- }, 500);
271
- });
272
- }
273
- setScreenWidth() {
274
- this.screenWidth = window.outerWidth;
275
- if (this.IsDesktopView) {
276
- this.currentResInfo = this.resInfo[3];
277
- this.resized.next(true);
278
- }
279
- else {
280
- let resInfo = this.resInfo.filter((item) => {
281
- return item.end >= this.screenWidth && item.start <= this.screenWidth;
282
- })[0];
283
- if (!this.currentResInfo || this.currentResInfo.id != resInfo.id) {
284
- this.currentResInfo = resInfo;
285
- this.resized.next();
286
- }
287
- }
288
- }
289
- get IsDesktopView() {
290
- let agent = navigator.userAgent || navigator.vendor || window.opera;
291
- if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(agent) ||
292
- /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(agent.substring(0, 4)))
293
- return false;
294
- return true;
295
- }
296
- get IsMobile() {
297
- let check = false;
298
- let agent = navigator.userAgent || navigator.vendor || window.opera;
299
- if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(agent) ||
300
- /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(agent.substring(0, 4)))
301
- check = true;
302
- return check;
303
- }
304
- getGridsterConfig(isWidgetMgmnt) {
305
- let config = GridsterConfigDefaultSettings;
306
- config.minCols = this.currentResInfo.maxCols;
307
- config.maxCols = this.currentResInfo.maxCols;
308
- config.minRows = this.currentResInfo.minCols;
309
- config.maxItemCols = this.currentResInfo.maxCols;
310
- config.minItemCols = this.currentResInfo.minCols;
311
- config.minItemRows = this.currentResInfo.minCols;
312
- config.minItemArea =
313
- this.currentResInfo.minCols * this.currentResInfo.minCols;
314
- config.defaultItemCols = this.currentResInfo.minCols;
315
- config.defaultItemRows = this.currentResInfo.minCols;
316
- if (!this.IsDesktopView || !isWidgetMgmnt) {
317
- config.resizable.enabled = false;
318
- config.swap = false;
319
- config.draggable.enabled = false;
320
- }
321
- else {
322
- config.resizable.enabled = true;
323
- config.swap = true;
324
- config.draggable.enabled = true;
325
- }
326
- return config;
327
- }
328
- /**To map IwidgetInfo object to gridsterItem */
329
- getGridsterItem(widget) {
330
- if (widget.widgetSettings) {
331
- widget.settings = JSON.parse(widget.widgetSettings);
332
- }
333
- let gridsterItem = {
334
- cols: this.getWidth(widget.width),
335
- rows: this.getHeight(widget.height),
336
- x: this.IsDesktopView ? widget.position_x : 0,
337
- y: this.IsDesktopView ? widget.position_y : 0,
338
- widgetInfo: widget,
339
- minItemRows: this.getMinItemRows(widget),
340
- minItemCols: this.getMinItemCols(widget),
341
- };
342
- return gridsterItem;
343
- }
344
- getWidth(width) {
345
- if (!this.IsDesktopView) {
346
- width = Math.floor((width / this.maxColsDesktop) * this.currentResInfo.maxCols);
347
- if (width < this.currentResInfo.minCols)
348
- width = this.currentResInfo.minCols;
349
- }
350
- return width;
351
- }
352
- getMinItemRows(widget) {
353
- if (this.IsDesktopView) {
354
- if (widget.settings && widget.settings.minRows) {
355
- return widget.settings.minRows;
356
- }
357
- }
358
- }
359
- getMinItemCols(widget) {
360
- if (this.IsDesktopView) {
361
- if (widget.settings && widget.settings.minCols) {
362
- return widget.settings.minCols;
363
- }
364
- }
365
- }
366
- getHeight(height) {
367
- if (!this.IsDesktopView) {
368
- height = Math.floor((height / this.maxColsDesktop) * this.currentResInfo.maxCols);
369
- if (height < this.currentResInfo.minCols)
370
- height = this.currentResInfo.minCols;
371
- }
372
- return height;
373
- }
374
- };
375
- RADashboardResponsiveService.ngInjectableDef = ɵɵdefineInjectable({ factory: function RADashboardResponsiveService_Factory() { return new RADashboardResponsiveService(); }, token: RADashboardResponsiveService, providedIn: "root" });
376
- RADashboardResponsiveService = __decorate([
377
- Injectable({ providedIn: "root" }),
378
- __metadata("design:paramtypes", [])
379
- ], RADashboardResponsiveService);
380
-
381
- let RADashboardArea = class RADashboardArea {
382
- constructor(dashboardService, ngZone, ngxService, translateService, notifier, responsiveService, permissionService) {
383
- this.dashboardService = dashboardService;
384
- this.ngZone = ngZone;
385
- this.ngxService = ngxService;
386
- this.translateService = translateService;
387
- this.notifier = notifier;
388
- this.responsiveService = responsiveService;
389
- this.permissionService = permissionService;
390
- this.widgetList = Array();
391
- this.gridheight = 300;
392
- this.gridcellHeight = 0;
393
- this.userWidgets = [];
394
- this.PAMWidgets = [];
395
- this.isWidgetLoaded = false;
396
- this.domResized = false;
397
- this.showEmptyDashboard = false;
398
- this.isWidgetMgmnt = false;
399
- this.widgetHeight = 2;
400
- this.widgetWidth = 4;
401
- this.isIndicatorDashboard = false;
402
- this.hideDashboardBanner = new EventEmitter();
403
- }
404
- ngOnInit() {
405
- this.isWidgetMgmnt = this.permissionService.hasPermission('ra.widgetmanagement');
406
- this.initiateGridsterConfig();
407
- this.lastViewType = this.responsiveService.IsDesktopView ? 'desktop' : 'mobile';
408
- this.responsiveService.resized.subscribe((isDesktop) => {
409
- if (this.lastViewType != (isDesktop ? 'desktop' : 'mobile') || !isDesktop) {
410
- this.lastViewType = (isDesktop ? 'desktop' : 'mobile');
411
- this.widgetList = [];
412
- setTimeout(() => {
413
- this.initiateGridsterConfig();
414
- this.options.api.optionsChanged();
415
- if (this.userWidgets) {
416
- this.widgetList = this.mapObjectListToGridsterItemList(this.userWidgets);
417
- setTimeout(() => {
418
- this.setAreaHeight();
419
- });
420
- }
421
- else {
422
- this.loadWidgets(this.userDashboardId, this.areaKey);
423
- }
424
- this.domResized = !this.domResized;
425
- });
426
- }
427
- else {
428
- setTimeout(() => {
429
- this.gridcellHeight = this.options.api.getCurrentRowHeight();
430
- this.domResized = !this.domResized;
431
- this.setAreaHeight();
432
- }, 100);
433
- }
434
- });
435
- }
436
- ngOnChanges(changes) {
437
- this.isWidgetMgmnt = this.permissionService.hasPermission('ra.widgetmanagement');
438
- if (this.raDashboardEventBus && this.appConfig && !this.isWidgetLoaded) {
439
- this.isWidgetLoaded = true;
440
- this.loadWidgets(this.userDashboardId, this.areaKey);
441
- }
442
- if (changes.raDashboardEventBus && changes.raDashboardEventBus.currentValue != changes.raDashboardEventBus.previousValue) {
443
- this.inititateEventBusSubscritions();
444
- }
445
- }
446
- /**To set GridsterConfig */
447
- initiateGridsterConfig() {
448
- /**To override default configuration values to the gridster control */
449
- this.options = this.responsiveService.getGridsterConfig(this.isWidgetMgmnt);
450
- this.options.initCallback = (gridster) => {
451
- if (this.options.api) {
452
- this.gridcellHeight = this.options.api.getCurrentRowHeight();
453
- }
454
- };
455
- this.options.itemChangeCallback = (item) => {
456
- if (this.responsiveService.IsDesktopView) {
457
- if (item.widgetInfo && item.widgetInfo.widgetInstanceId) {
458
- this.updateWidgetPosition(item.widgetInfo.widgetInstanceId);
459
- }
460
- }
461
- this.setAreaHeight();
462
- };
463
- }
464
- /** To initiate eventbus subsctiptions */
465
- inititateEventBusSubscritions() {
466
- this.widgetDeleteEvent = this.raDashboardEventBus.subscribe(RAEvent.WidgetDelete).subscribe((instanceId) => {
467
- this.ngZone.run(() => {
468
- this.deleteWidget(instanceId, true);
469
- });
470
- });
471
- this.widgetAddEvent = this.raDashboardEventBus.subscribe(RAEvent.AddWidget).subscribe((widgetInfo) => {
472
- this.ngZone.run(() => {
473
- this.copyWidget(widgetInfo);
474
- });
475
- });
476
- this.conifgAddClick = this.raDashboardEventBus.subscribe(RAEvent.ConfigAddClick).subscribe((e) => {
477
- this.ngZone.run(() => {
478
- this.addWidget(e);
479
- });
480
- });
481
- this.rearrangeWidgetClick = this.raDashboardEventBus.subscribe(RAEvent.RearrangeClicked).subscribe((e) => {
482
- this.ngZone.run(() => {
483
- this.rearrangeWidgets();
484
- });
485
- });
486
- this.widgetLibraryDoneClick = this.raDashboardEventBus.subscribe(RAEvent.widgetLibraryDoneClick).subscribe((widgetList) => {
487
- this.ngZone.run(() => {
488
- if (widgetList) {
489
- this.addWidgetListToGridster(widgetList, 0);
490
- }
491
- });
492
- });
493
- }
494
- /**
495
- * temp fix- recursive method to iterate over the list of items
496
- * and add them to gridster in the given order
497
- * @param widgetList -list of widgets
498
- * @param index -index of the current value to be added
499
- */
500
- addWidgetListToGridster(widgetList, index) {
501
- let areaContext = this;
502
- let indexVal = index + 1;
503
- if (index > widgetList.length - 1)
504
- return;
505
- else {
506
- if (index == 0) {
507
- areaContext.addWidget(widgetList[index]);
508
- areaContext.addWidgetListToGridster(widgetList, indexVal);
509
- }
510
- else {
511
- setTimeout(() => {
512
- areaContext.addWidget(widgetList[index]);
513
- areaContext.addWidgetListToGridster(widgetList, indexVal);
514
- }, 1000);
515
- }
516
- }
517
- }
518
- ngOnDestroy() {
519
- if (this.conifgAddClick)
520
- this.conifgAddClick.unsubscribe();
521
- if (this.widgetAddEvent)
522
- this.widgetAddEvent.unsubscribe();
523
- if (this.widgetDeleteEvent)
524
- this.widgetDeleteEvent.unsubscribe();
525
- if (this.widgetLibraryDoneClick)
526
- this.widgetLibraryDoneClick.unsubscribe();
527
- if (this.rearrangeWidgetClick)
528
- this.rearrangeWidgetClick.unsubscribe();
529
- }
530
- /**To update position/dimention of all widgets in the area */
531
- updateWidgets() {
532
- this.dashboardService.updateWidgets(this.formatWidgetDataForPositionDetails(this.mapGridsterListToObject(this.widgetList)), this.appConfig).subscribe(widgets => {
533
- });
534
- return true;
535
- }
536
- /**To update widget dimensions */
537
- updateWidgetPosition(widgetInstanceId) {
538
- let widgetFilteredList = [];
539
- let widget = this.widgetList.filter(filtered => filtered.widgetInfo && filtered.widgetInfo.widgetInstanceId == widgetInstanceId);
540
- if (widget && widget.length > 0) {
541
- widgetFilteredList.push(widget[0]);
542
- let widgetList = this.mapGridsterListToObject(widgetFilteredList);
543
- this.dashboardService.updateWidgets(this.formatWidgetDataForPositionDetails(widgetList), this.appConfig).subscribe(widgets => {
544
- });
545
- }
546
- return true;
547
- }
548
- /**To restrict request payload to be of min size (position & size details) */
549
- formatWidgetDataForPositionDetails(widgetItemList) {
550
- let itemList = [];
551
- widgetItemList.forEach(function (widgetItem) {
552
- let item = {};
553
- item.widgetInstanceId = widgetItem.widgetInstanceId;
554
- item.position_x = widgetItem.position_x;
555
- item.position_y = widgetItem.position_y;
556
- item.width = widgetItem.width;
557
- item.height = widgetItem.height;
558
- itemList.push(item);
559
- });
560
- return itemList;
561
- }
562
- /** To retrieve widgets based on userDashboardid and area name */
563
- loadWidgets(userDashboarId, areaKey) {
564
- let widgetInfo = {
565
- dashboardId: userDashboarId.toString(),
566
- dashboardAreaKey: areaKey,
567
- isIndicatorDashboard: this.isIndicatorDashboard
568
- };
569
- this.widgetList = [];
570
- this.dashboardService.getWidgetsByDashboardArea(widgetInfo, this.appConfig).subscribe(widgets => {
571
- this.userWidgets = widgets;
572
- this.PAMWidgets = [];
573
- widgets.forEach(element => {
574
- var settings = undefined;
575
- if (element.widgetSettings) {
576
- settings = JSON.parse(element.widgetSettings);
577
- if (settings && settings.isPAMWidget)
578
- this.PAMWidgets.push(element.widgetInstanceId);
579
- }
580
- });
581
- this.checkPAMWidgets();
582
- if (widgets && widgets.length > 0) {
583
- this.dashboardService.clientId = widgets[0].clientId;
584
- this.widgetList = this.mapObjectListToGridsterItemList(widgets);
585
- this.setAreaHeight();
586
- this.raDashboardEventBus.publish(RAEvent.HideDashboardBanner, false);
587
- }
588
- else {
589
- this.showEmptyDashboard = true;
590
- this.raDashboardEventBus.publish(RAEvent.HideDashboardBanner, this.showEmptyDashboard);
591
- }
592
- });
593
- }
594
- /** To set Area(Gridster) height dynamically as widgets are added/removed */
595
- setAreaHeight() {
596
- setTimeout(() => {
597
- let isMobile = false;
598
- if (this.options.mobileBreakpoint > this.gridWrapper.nativeElement.clientWidth) {
599
- isMobile = true;
600
- }
601
- let areaScrollHeight = 0;
602
- let areaHeight = 0;
603
- let curRowHeight = 0;
604
- if (this.options.api) {
605
- curRowHeight = this.options.api.getCurrentRowHeight();
606
- }
607
- this.showEmptyDashboard = this.userWidgets.length > 0 ? false : true;
608
- this.widgetList.forEach((t) => {
609
- let currentHeight = t.y + t.rows;
610
- if (currentHeight > areaScrollHeight) {
611
- areaScrollHeight = currentHeight;
612
- }
613
- if (curRowHeight == 0) {
614
- currentHeight = this.widgetList[0].curRowHeight;
615
- }
616
- t.widgetInfo.rowHeight = curRowHeight;
617
- });
618
- this.gridcellHeight = curRowHeight;
619
- if (this.options.api) {
620
- areaHeight = areaScrollHeight * this.options.api.getCurrentRowHeight() + 100;
621
- }
622
- let areaScrollHeightMob = 0;
623
- if (isMobile) {
624
- areaScrollHeightMob = this.widgetList.length * 300 + 200;
625
- areaHeight = areaScrollHeightMob;
626
- }
627
- if (areaHeight < 600) {
628
- areaHeight = 600;
629
- }
630
- this.gridheight = areaHeight;
631
- });
632
- }
633
- /** To remove a widget instance from dashboard and to save info in database */
634
- deleteWidget(widgetInstanceId, isalertDisabled = false) {
635
- let gridsterItem = this.widgetList.filter((item) => {
636
- return item.widgetInfo.widgetInstanceId === widgetInstanceId;
637
- });
638
- if (gridsterItem.length > 0) {
639
- let widget = this.userWidgets.filter((item) => {
640
- return item.widgetInstanceId === widgetInstanceId;
641
- });
642
- if (widget.length > 0) {
643
- this.userWidgets.splice(this.userWidgets.indexOf(widget[0]), 1);
644
- }
645
- if (this.PAMWidgets.length > 0) {
646
- var indx = this.PAMWidgets.indexOf(widgetInstanceId);
647
- if (indx > -1)
648
- this.PAMWidgets.splice(indx, 1);
649
- this.checkPAMWidgets();
650
- }
651
- this.widgetList.splice(this.widgetList.indexOf(gridsterItem[0]), 1);
652
- this.setAreaHeight();
653
- if (!isalertDisabled) {
654
- this.notifier.notify('success', " " + this.translateService.translate('Common.Widgettext') + " " + gridsterItem[0].widgetInfo.widgetTitle + " " + this.translateService.translate('Common.deletedSuccesfully') + " ");
655
- }
656
- }
657
- this.showEmptyDashboard = this.userWidgets.length > 0 ? false : true;
658
- if (this.showEmptyDashboard == true) {
659
- this.raDashboardEventBus.publish(RAEvent.HideDashboardBanner, this.showEmptyDashboard);
660
- }
661
- }
662
- /**To rearrange widgets position in the dashboard, compactLeft&Up,compactLeft,compactUp,etc*/
663
- rearrangeWidgets() {
664
- for (let i = 0; i < this.userWidgets.length; i++) {
665
- this.userWidgets[i].position_x = 0;
666
- this.userWidgets[i].position_y = 0;
667
- }
668
- this.widgetList = this.mapObjectListToGridsterItemList(this.userWidgets);
669
- if (this.widgetList.length > 0)
670
- this.updateWidgetPosition(this.widgetList[0].widgetInfo.widgetInstanceId);
671
- setTimeout(() => {
672
- this.setAreaHeight();
673
- });
674
- }
675
- /**To add widget instance to the database with the next available position and to make changes in
676
- * dashboard area.
677
- */
678
- addWidget(data) {
679
- data.height = this.widgetHeight;
680
- data.width = this.widgetWidth;
681
- this.raDashboardEventBus.publish(RAEvent.HideDashboardBanner, false);
682
- if (data.widgetSettings) {
683
- if (typeof data.widgetSettings === 'string')
684
- data.widgetSettings = JSON.parse(data.widgetSettings);
685
- if (data.widgetSettings.defaultCols) {
686
- data.width = data.widgetSettings.defaultCols;
687
- }
688
- if (data.widgetSettings.defaultRows) {
689
- data.height = data.widgetSettings.defaultRows;
690
- }
691
- data.widgetSettings = null;
692
- }
693
- data = this.setPositions(data);
694
- /** to find the available position in gridster, temp commenting the code-returning higher y value than normal */
695
- data.dashboardAreaKey = this.areaKey;
696
- data.dashboardId = this.userDashboardId;
697
- this.ngxService.start();
698
- this.dashboardService.addWidget(data, this.appConfig).subscribe(widget => {
699
- this.userWidgets.push(widget);
700
- let gridsterItem = this.responsiveService.getGridsterItem(widget);
701
- this.widgetList.push(gridsterItem);
702
- this.setAreaHeight();
703
- if (this.options.api) {
704
- let curRowHeight = Number(this.options.api.getCurrentRowHeight());
705
- if (curRowHeight > 0) {
706
- widget.rowHeight = curRowHeight;
707
- this.gridcellHeight = curRowHeight;
708
- }
709
- }
710
- var widgetInstanceId = 0;
711
- if (widget && widget.widgetInstanceId) {
712
- widgetInstanceId = widget.widgetInstanceId;
713
- /**To save added widget position in db */
714
- if (this.responsiveService.IsDesktopView) {
715
- setTimeout(() => {
716
- this.updateWidgetPosition(widgetInstanceId);
717
- });
718
- }
719
- }
720
- if (widget.settings && widget.settings.isPAMWidget) {
721
- this.PAMWidgets.push(widget.widgetInstanceId);
722
- this.checkPAMWidgets();
723
- }
724
- this.raDashboardEventBus.publish(RAEvent.WidgetAdded, widget);
725
- });
726
- }
727
- setPositions(data) {
728
- data.position_x = 0;
729
- data.position_y = 0;
730
- if (!this.responsiveService.IsDesktopView) {
731
- if (this.userWidgets.length > 0) {
732
- let widget = this.userWidgets[this.userWidgets.length - 1];
733
- if (widget.position_x + widget.width > (this.responsiveService.maxColsDesktop / 2)) {
734
- data.position_y = widget.position_y + 1;
735
- }
736
- else {
737
- data.position_y = widget.position_y;
738
- data.position_x = this.responsiveService.maxColsDesktop - (widget.position_x + widget.width);
739
- }
740
- }
741
- }
742
- return data;
743
- }
744
- /** To add widget to current widget list ,invoked from copy widget window*/
745
- copyWidget(data) {
746
- data = this.setPositions(data);
747
- if (!this.responsiveService.IsDesktopView) {
748
- this.dashboardService.updateWidgets(this.formatWidgetDataForPositionDetails([data]), this.appConfig).subscribe(widgets => {
749
- });
750
- }
751
- this.userWidgets.push(data);
752
- let gridsterItem = this.responsiveService.getGridsterItem(data);
753
- this.widgetList.push(gridsterItem);
754
- this.setAreaHeight();
755
- if (data.settings && data.settings.isPAMWidget) {
756
- this.PAMWidgets.push(data.widgetInstanceId);
757
- this.checkPAMWidgets();
758
- }
759
- }
760
- mapObjectListToGridsterItemList(widgetList) {
761
- let widgetArray = Array();
762
- widgetList.forEach(widget => {
763
- widgetArray.push(this.responsiveService.getGridsterItem(widget));
764
- });
765
- return widgetArray;
766
- }
767
- mapGridsterItemToObject(widgetItem) {
768
- let widget;
769
- widget = widgetItem.widgetInfo;
770
- widget.height = widgetItem.rows;
771
- widget.width = widgetItem.cols;
772
- widget.position_x = widgetItem.x;
773
- widget.position_y = widgetItem.y;
774
- widget.rowHeight = widgetItem.curRowHeight;
775
- return widget;
776
- }
777
- mapGridsterListToObject(widgetItemList) {
778
- let widgetListArray = Array();
779
- widgetItemList.forEach(widget => {
780
- widgetListArray.push(this.mapGridsterItemToObject(widget));
781
- });
782
- return widgetListArray;
783
- }
784
- addNewWidget() {
785
- this.raDashboardEventBus.publish(RAEvent.AddNewWidgetToDashboard, null);
786
- }
787
- updateAppliedFilters(data) {
788
- this.raDashboardEventBus.publish(RAEvent.UpdateAppledFiterForInapplicableFilter, data);
789
- }
790
- checkPAMWidgets() {
791
- if (this.PAMWidgets.length > 0) {
792
- this.raDashboardEventBus.publish(RAEvent.ShowInapplicableFilterMessage, true);
793
- }
794
- else {
795
- this.raDashboardEventBus.publish(RAEvent.ShowInapplicableFilterMessage, false);
796
- }
797
- }
798
- };
799
- RADashboardArea.ctorParameters = () => [
800
- { type: RaDashboardService },
801
- { type: NgZone },
802
- { type: NgxUiLoaderService },
803
- { type: RATranslateService },
804
- { type: NotifierService },
805
- { type: RADashboardResponsiveService },
806
- { type: RAPermissionService }
807
- ];
808
- __decorate([
809
- Input('user-dashboard-id'),
810
- __metadata("design:type", Number)
811
- ], RADashboardArea.prototype, "userDashboardId", void 0);
812
- __decorate([
813
- Input('area-key'),
814
- __metadata("design:type", String)
815
- ], RADashboardArea.prototype, "areaKey", void 0);
816
- __decorate([
817
- Input('global-filter'),
818
- __metadata("design:type", Object)
819
- ], RADashboardArea.prototype, "globalFilter", void 0);
820
- __decorate([
821
- Input('event-bus'),
822
- __metadata("design:type", RADashboardEventBus)
823
- ], RADashboardArea.prototype, "raDashboardEventBus", void 0);
824
- __decorate([
825
- Input('widget-height'),
826
- __metadata("design:type", Number)
827
- ], RADashboardArea.prototype, "widgetHeight", void 0);
828
- __decorate([
829
- Input('widget-width'),
830
- __metadata("design:type", Number)
831
- ], RADashboardArea.prototype, "widgetWidth", void 0);
832
- __decorate([
833
- Input('app-config'),
834
- __metadata("design:type", Object)
835
- ], RADashboardArea.prototype, "appConfig", void 0);
836
- __decorate([
837
- Input('isIndicatorDashboard'),
838
- __metadata("design:type", Boolean)
839
- ], RADashboardArea.prototype, "isIndicatorDashboard", void 0);
840
- __decorate([
841
- Output(),
842
- __metadata("design:type", Object)
843
- ], RADashboardArea.prototype, "hideDashboardBanner", void 0);
844
- __decorate([
845
- ViewChild('gridWrapper', { static: false }),
846
- __metadata("design:type", ElementRef)
847
- ], RADashboardArea.prototype, "gridWrapper", void 0);
848
- RADashboardArea = __decorate([
849
- Component({
850
- selector: 'ra-dashboard-area',
851
- template: "<div #gridWrapper class=\"wrap gridster gridster-mobile\" [ngStyle]=\"{'height': userWidgets.length > 0 ? (gridheight + 'px') : 'unset'}\">\r\n <!-- <div #gridWrapper class=\"wrap gridster\"> -->\r\n <gridster [options]=\"options\" style=\"height:100%;\" *ngIf=\"userWidgets.length > 0\">\r\n <gridster-item [item]=\"item\" *ngFor=\"let item of widgetList\">\r\n <ra-widget-container [app-config]=\"appConfig\" [event-bus]=\"raDashboardEventBus\"\r\n (widgetDeleted)=\"deleteWidget($event)\" [data]=\"item\" [global-filter]=\"globalFilter\"\r\n [grid-cell-height]=\"gridcellHeight\" *ngIf=\"gridcellHeight && gridcellHeight > 0\" [widget-width]=\"item.cols\"\r\n [widget-height]=\"item.rows\" [widget-instance-id]=\"item.widgetInstanceId\" [dom-resized]=\"domResized\"\r\n (updateAppliedFilters)=\"updateAppliedFilters($event)\">\r\n </ra-widget-container>\r\n </gridster-item>\r\n </gridster>\r\n\r\n <div class=\"empty-padding kiosk-hide\" *ngIf=\"showEmptyDashboard\">\r\n <div class=\"empty-wrapper\">\r\n <div></div>\r\n <div class=\"m-1 empty-prefix\">\r\n <i class=\"fal fa-edit edit-icon\"></i>\r\n <span class=\"empty-title\">{{'dashboard.emptydashboard'|translate}}</span>\r\n </div>\r\n <div class=\"empty-content light\">\r\n <div>\r\n <div class=\"col-sm-12 empty-msg\">\r\n {{'dashboard.emptydashboardmessage'|translate}} <br />\r\n {{'dashboard.emptydashboardmessage2'|translate}}\r\n </div>\r\n <button *ngIf=\"isWidgetMgmnt\" class=\"btn btnLib btn-sm m-1 dashboard-button light\" (click)=\"addNewWidget()\">\r\n <i class=\"fal fa-plus m-1\"></i>{{'dashboard.addawidgets'|translate}}</button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <notifier-container></notifier-container>\r\n</div>",
852
- styles: ["gridster{width:inherit;resize:height;display:flex;background-color:#ededed;overflow-y:hidden!important}.dvheader{width:100%;height:35px;background:#000;color:#fff;padding:7px 3px 5px 6px;text-transform:uppercase}gridster-item{box-sizing:border-box;z-index:1;position:absolute;overflow:hidden;transition:.3s;display:none;background:#fff;-webkit-user-select:text;-moz-user-select:text;user-select:text;box-shadow:0 1px 10px rgba(0,0,0,.05)}gridster-item:hover{box-shadow:0 1px 10px rgba(0,0,0,.15)}@media screen and (max-width:685px){.gridster-mobile{height:auto!important;margin-bottom:50px!important}}@media screen and (max-width:350px){.gridster-mobile{min-height:330px!important;margin-bottom:0!important}}.empty-padding{padding:40px 20px 20px;background-color:#ededed;display:flex;justify-content:center;align-content:center}.empty-wrapper{display:flex;background-color:#fff;border-radius:8px;min-height:125px;width:72%}.empty-prefix{color:#32ad3c;font-size:18px;display:flex;align-items:center;padding:10px 30px;min-width:max-content;min-width:-moz-max-content}.empty-content{color:#333;border-left:1px solid #a9afb1;width:100%;display:flex;align-items:center;padding:15px 30px 10px 40px}.empty-msg{padding:0 0 5px;font-size:16px}.dashboard-button{padding:5px 10px 5px 5px!important}.btnLib{background-color:#ededed;color:#333!important}.btn-group-sm>.btn,.btn-sm{padding:5px 20px 5px 5px}.edit-icon{color:#32ad3c;font-size:24px;margin-right:15px}.empty-title{margin-top:10px}@media screen and (max-width:600px){.empty-padding{padding:10px;background-color:#ededed;width:100%;display:block}.empty-wrapper{display:flex;background-color:#fff;border-radius:8px;min-height:125px;width:100%}.empty-prefix{color:#32ad3c;font-size:16px;display:flex;height:40px;padding:6px 10px 8px}.empty-content{color:#333;display:flex;padding:5px 10px 10px;margin-top:44px;margin-left:-185px;border-left:none}.empty-msg{padding:12px 10px 10px 5px;font-size:14px;border-top:1px solid #a9afb1}.edit-icon{color:#32ad3c;font-size:20px;margin-right:6px}.empty-title{margin-top:6px}}"]
853
- }),
854
- __metadata("design:paramtypes", [RaDashboardService,
855
- NgZone,
856
- NgxUiLoaderService,
857
- RATranslateService,
858
- NotifierService,
859
- RADashboardResponsiveService,
860
- RAPermissionService])
861
- ], RADashboardArea);
862
-
863
- let LockTooltip = class LockTooltip {
864
- constructor(domService) {
865
- this.domService = domService;
866
- }
867
- ngOnInit() {
868
- if (this.element) {
869
- this.setPopupPosition();
870
- }
871
- }
872
- setPopupPosition() {
873
- let rect = this.element.getBoundingClientRect();
874
- if ((rect.left + 250) > window.innerWidth) {
875
- this.containerLeft = (rect.left - ((rect.left + 270) - window.innerWidth)) + 'px';
876
- }
877
- else {
878
- this.containerLeft = rect.left + 'px';
879
- }
880
- if (rect.bottom + 100 < window.innerHeight) {
881
- this.containerTop = (rect.bottom) + 'px';
882
- this.containerBottom = null;
883
- }
884
- else {
885
- this.containerTop = null;
886
- this.containerBottom = (window.innerHeight - rect.top) + 'px';
887
- }
888
- }
889
- removeMe(comp) {
890
- setTimeout(() => {
891
- this.domService.removeComponent(comp);
892
- });
893
- }
894
- };
895
- LockTooltip.ctorParameters = () => [
896
- { type: DomService }
897
- ];
898
- LockTooltip = __decorate([
899
- Component({
900
- selector: 'ra-lock-tooltip',
901
- template: "<div class=\"lock-popup-content light widget-config-item\"\r\n [ngStyle]=\"{'top': containerTop,'bottom':containerBottom,'position':'fixed','left':containerLeft,'z-index': '9999','width':'250px','min-height':'fit-content'}\">\r\n <div *ngIf=\"data && !template\">\r\n <label style=\"color: #D9F0FA;\">\r\n {{title}}:\r\n </label>\r\n <div style=\"color: white;\">\r\n <label class=\"bold\" style=\"margin-bottom: 0px;width: 100%;\" *ngFor=\"let item of data\">\r\n {{item}}\r\n </label>\r\n </div>\r\n <hr style=\"background-color: white;\">\r\n <div style=\"color: #D9F0FA;\">\r\n <label>{{footer}}</label>\r\n </div>\r\n </div>\r\n <div *ngIf=\"!data && template\">\r\n <ng-container *ngTemplateOutlet=\"template\">\r\n </ng-container>\r\n </div>\r\n</div>",
902
- styles: [".lock-popup-content{margin-top:8px;position:absolute;right:0;top:79%;box-shadow:0 8px 16px 8px rgba(0,0,0,.2);z-index:899;font-size:12px;min-width:220px!important;min-height:112px;background-color:#219bfd;opacity:.9;padding:15px;color:#fff}.widget-config-item i{font-size:17px;color:#42b4e6}.widget-config-item span{font-size:12px;font:inherit;padding-left:12px;color:#42b4e6}"]
903
- }),
904
- __metadata("design:paramtypes", [DomService])
905
- ], LockTooltip);
906
-
907
- let RAWidgetContainer = class RAWidgetContainer {
908
- constructor(dashboardService, ngxService, translateService, ngZone, notifier, renderer, raPermissionService, domService) {
909
- this.dashboardService = dashboardService;
910
- this.ngxService = ngxService;
911
- this.translateService = translateService;
912
- this.ngZone = ngZone;
913
- this.notifier = notifier;
914
- this.renderer = renderer;
915
- this.raPermissionService = raPermissionService;
916
- this.domService = domService;
917
- this.showPanel = true;
918
- this.isWidgetLoaded = false;
919
- this.lockClass = "unlocked";
920
- this.lockStatus = RaWidgetlockStatus.Unlocked;
921
- this.isDownloadIconVisible = false;
922
- this.isChartDownloadVisible = false;
923
- this.isGridDownloadVisible = false;
924
- this.enableTitleLine = false;
925
- this.isGlobalFilterApplied = false;
926
- this.toolTipValue = ' ';
927
- this.toolTipWidth = '0px';
928
- this.editToolTipValue = ' ';
929
- this.copyToolTipValue = ' ';
930
- this.moveToolTipValue = ' ';
931
- this.excelToolTipValue = ' ';
932
- this.deleteToolTipValue = ' ';
933
- this.editText = '';
934
- this.copyText = '';
935
- this.moveText = '';
936
- this.excelText = '';
937
- this.deleteText = '';
938
- this.editToolTipWidth = '0px';
939
- this.copyToolTipWidth = '0px';
940
- this.moveToolTipWidth = '0px';
941
- this.excelToolTipWidth = '0px';
942
- this.deleteToolTipWidth = '0px';
943
- this.noPadding = false;
944
- this.isMouseHover = false;
945
- this.showSettingsLink = true;
946
- this.isKpiView = false;
947
- this.showExcell = true;
948
- this.hideTitle = false;
949
- this.inapplicableFilters = [];
950
- this.widgetDeleted = new EventEmitter();
951
- this.updateAppliedFilters = new EventEmitter();
952
- this.isWidgetStateApplicable = false;
953
- this.widgetEmptyState = '';
954
- this.lockVisible = false;
955
- this.isWidgetMgmnt = false;
956
- this.enableTitleLineActual = false;
957
- this.renderer.listen('window', 'click', (e) => {
958
- if (e.target.className) {
959
- if (e.target.className != 'fal fa-ellipsis-v widget-menu-ellipse') {
960
- this.removeMenu();
961
- }
962
- }
963
- else {
964
- this.removeMenu();
965
- }
966
- });
967
- }
968
- set setResized(resized) {
969
- this.invokeWidgetResizedEvent();
970
- }
971
- ngOnInit() {
972
- this.WidgetDisplayName = this.getwidgetTitleTranslation(this.data.widgetInfo.widgetTitle);
973
- this.lockIconTitle = this.translateService.translate('Common.lockedfields');
974
- this.lockIconFooter = this.translateService.translate('Common.lockedfieldseditinfo');
975
- this.inapplicableIconTitle = this.translateService.translate('Common.InapplicableFilters');
976
- this.inapplicableIconFooter = this.translateService.translate('Common.InapplicableFiltersDesc');
977
- }
978
- get widgetViewState() { return WidgetViewState; }
979
- ngOnChanges(changes) {
980
- this.isWidgetMgmnt = this.raPermissionService.hasPermission('ra.widgetmanagement');
981
- if (changes.raDashboardEventBus && changes.raDashboardEventBus.currentValue != changes.raDashboardEventBus.previousValue) {
982
- this.configChanged = this.raDashboardEventBus.subscribeWithKey(RAEvent.ConfigChanged, RAEventKey.WidgetInstanceId, this.data.widgetInfo.widgetInstanceId.toString()).subscribe((e) => {
983
- this.ngZone.run(() => {
984
- this.configChangeEventHandler(e);
985
- });
986
- });
987
- }
988
- if (this.widgetElement && changes.globalFilter && changes.globalFilter.currentValue != changes.globalFilter.previousValue) {
989
- let filterObj = this.getParsedConfig(this.globalFilter);
990
- if (filterObj.WidgetInstanceId) {
991
- if (this.data.widgetInfo.widgetInstanceId != filterObj.WidgetInstanceId)
992
- this.refreshWidget(this.data.widgetInfo);
993
- }
994
- else {
995
- this.refreshWidget(this.data.widgetInfo);
996
- }
997
- }
998
- if (changes.width && changes.width.currentValue != changes.width.previousValue ||
999
- (changes.height && changes.height.currentValue != changes.height.previousValue)) {
1000
- this.invokeWidgetResizedEvent();
1001
- }
1002
- }
1003
- invokeWidgetResizedEvent() {
1004
- if (this.widgetElement) {
1005
- if (typeof this.widgetElement.widgetResized === "function") {
1006
- let size = {};
1007
- size.height = this.height;
1008
- size.width = this.width;
1009
- size.cellHeight = this.gridCellHeight;
1010
- this.widgetElement.widgetResized(size);
1011
- if (this.height == 1 || this.width == 1)
1012
- this.isKpiView = true;
1013
- else
1014
- this.isKpiView = false;
1015
- }
1016
- }
1017
- }
1018
- mouseHover(isHover = true) {
1019
- this.isMouseHover = isHover;
1020
- if (this.widgetElement) {
1021
- if (typeof this.widgetElement.hoverStatus === "function") {
1022
- this.widgetElement.hoverStatus(isHover);
1023
- }
1024
- else {
1025
- console.warn('widget framework outdated, please update to version 0.0.96');
1026
- }
1027
- }
1028
- }
1029
- ngAfterViewInit() {
1030
- setTimeout(() => {
1031
- this.loadWidget(this.data.widgetInfo);
1032
- });
1033
- document.addEventListener("scroll", () => {
1034
- this.removeMenu();
1035
- this.closePopup();
1036
- });
1037
- setTimeout(() => {
1038
- let item = jQuery(this.wcWrapper.nativeElement).closest('gridster-item');
1039
- item.bind('mouseenter', () => {
1040
- window.gridsterItemEnter = true;
1041
- });
1042
- item.bind('mouseleave', () => {
1043
- window.gridsterItemEnter = false;
1044
- setTimeout(() => {
1045
- if (!window.mouseOverWidgetMenu) {
1046
- this.removeMenu();
1047
- }
1048
- });
1049
- });
1050
- });
1051
- }
1052
- ngOnDestroy() {
1053
- if (this.configChanged)
1054
- this.configChanged.unsubscribe();
1055
- if (this.widgetElementHandler && this.data && this.data.widgetInfo && this.data.widgetInfo.widgetInstanceId) {
1056
- document.body.removeEventListener('widgetinitiated' + this.data.widgetInfo.widgetInstanceId, this.widgetElementHandler);
1057
- }
1058
- }
1059
- /** To Edit current widget configuration*/
1060
- editWidget() {
1061
- let widgetConfigFilter;
1062
- if (this.widgetElement && typeof (this.widgetElement.getConfigFilter) == 'function') {
1063
- let configData = this.widgetElement.getConfigFilter();
1064
- if (configData) {
1065
- widgetConfigFilter = configData;
1066
- }
1067
- }
1068
- if (widgetConfigFilter) {
1069
- this.raDashboardEventBus.publish(RAEvent.WidgetEditClicked, widgetConfigFilter);
1070
- }
1071
- else {
1072
- let widgetConfigFilterData = this.generateConfigFilter(false);
1073
- this.raDashboardEventBus.publish(RAEvent.WidgetEditClicked, widgetConfigFilterData);
1074
- }
1075
- }
1076
- /** To Delete current widget from DOM*/
1077
- deleteWidget() {
1078
- let widgetContainerContext = this;
1079
- widgetContainerContext.ngxService.start();
1080
- widgetContainerContext.dashboardService.deleteWidget(this.data.widgetInfo, this.appConfig).subscribe(status => {
1081
- widgetContainerContext.ngxService.stop();
1082
- if (status) {
1083
- widgetContainerContext.widgetDeleted.emit(this.data.widgetInfo.widgetInstanceId);
1084
- this.setInapplicableFilters(undefined, this.data.widgetInfo.widgetInstanceId);
1085
- }
1086
- else {
1087
- widgetContainerContext.notifier.notify('error', " " + this.translateService.translate('FailedToRemoveWidget') + " (" + this.translateService.translate('Common.' + this.data.widgetInfo.widgetTitle, true) + ")!");
1088
- }
1089
- });
1090
- }
1091
- /** To Move or change position if current widget container*/
1092
- moveWidget() {
1093
- this.raDashboardEventBus.publish(RAEvent.MoveWidget, this.data.widgetInfo);
1094
- this.setInapplicableFilters(undefined, this.data.widgetInfo.widgetInstanceId);
1095
- // this.dashboardService.moveWidget(widgetInfo);
1096
- }
1097
- /** To Copy Current widget with same configuration*/
1098
- copyWidget() {
1099
- this.raDashboardEventBus.publish(RAEvent.CopyWidget, this.data.widgetInfo);
1100
- //this.dashboardService.copyWidget(widgetInfo);
1101
- }
1102
- visitPage() {
1103
- this.baseUrl = this.getHostUrl();
1104
- let url = this.baseUrl + this.detailPageUrl;
1105
- if (this.data.widgetInfo && this.data.widgetInfo.widgetSettings) {
1106
- this.widgetSettings = this.getParsedConfig(this.data.widgetInfo.widgetSettings);
1107
- if (this.widgetSettings.customPageParams || this.widgetSettings.customPageURL) {
1108
- let params = this.widgetElement.getPageParamsClicked();
1109
- if (params) {
1110
- if (this.data.widgetInfo.widgetType == 'AV Widget' || this.widgetSettings.customPageURL)
1111
- url = url + params;
1112
- else
1113
- url = url + '?' + params;
1114
- }
1115
- }
1116
- }
1117
- window.open(url, '_blank');
1118
- }
1119
- getHostUrl() {
1120
- return window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
1121
- }
1122
- configChangeEventHandler(widgetInfo) {
1123
- this.data.widgetInfo = widgetInfo;
1124
- if (this.gridCellHeight > 0) {
1125
- this.data.widgetInfo.rowHeight = this.gridCellHeight;
1126
- }
1127
- if (this.widgetElement && typeof (this.widgetElement.setConfigFilter) == 'function') {
1128
- this.widgetElement.setConfigFilter(this.generateConfigFilter(true));
1129
- }
1130
- else {
1131
- console.warn('widget framework outdated, please update to version 0.0.98');
1132
- }
1133
- this.refreshWidget(this.data.widgetInfo, true);
1134
- }
1135
- generateConfigFilter(configChanged = false) {
1136
- let widgetConfigFilterData = {
1137
- appConfig: this.appConfig,
1138
- globalFilter: this.globalFilter,
1139
- widgetInfo: this.data.widgetInfo,
1140
- config: this.data.widgetInfo.widgetConfigInfo.config,
1141
- configChanges: this.getConfigChanges(configChanged)
1142
- };
1143
- return widgetConfigFilterData;
1144
- }
1145
- /** To load external custom element to the widget container*/
1146
- loadWidget(widgetInfo) {
1147
- return __awaiter(this, void 0, void 0, function* () {
1148
- widgetInfo.rowHeight = this.gridCellHeight;
1149
- let widgetConfigFilter = {
1150
- config: widgetInfo.widgetConfigInfo.config,
1151
- globalFilter: this.globalFilter,
1152
- configChanges: this.getConfigChanges(false)
1153
- };
1154
- if (widgetInfo.widgetSettings) {
1155
- this.widgetSettings = this.getParsedConfig(widgetInfo.widgetSettings);
1156
- this.applayWidgetSettings(this.widgetSettings);
1157
- }
1158
- this.detailPageUrl = widgetInfo.detailPageUrl;
1159
- let me = this;
1160
- this.dashboardService.loadExternalScript(widgetInfo.scriptUrl, () => {
1161
- this.setNotConfiguredState(widgetInfo);
1162
- let appModule = this.data.widgetInfo.widgetName;
1163
- if (this.data.widgetInfo.applicationModule && this.data.widgetInfo.applicationModule.length > 0) {
1164
- appModule = this.data.widgetInfo.applicationModule;
1165
- }
1166
- this.translateService.loadTranslations(this.appConfig.appManagementBaseUrl, appModule, false).then(() => {
1167
- me.widgetElement = document.createElement(widgetInfo.customTag);
1168
- me.widgetElement.setAttribute("widget-instance-id", widgetInfo.widgetInstanceId);
1169
- let handler = function (event) {
1170
- setTimeout(() => __awaiter(this, void 0, void 0, function* () {
1171
- this.widgetElement.addEventListener('on-widget-respond', (e) => {
1172
- var type = e.detail.type;
1173
- switch (type) {
1174
- case 'onDataLoad':
1175
- if (e.detail.data)
1176
- this.showPanel = true;
1177
- else
1178
- this.showPanel = false;
1179
- break;
1180
- case 'onConfigEditClicked':
1181
- this.editWidget();
1182
- break;
1183
- case 'onEnableDefaultState':
1184
- this.setEmptyState(e.detail.data);
1185
- break;
1186
- case 'onSetTitleUnderline':
1187
- if (e.detail.data == true)
1188
- this.enableTitleLine = true;
1189
- else
1190
- this.enableTitleLine = this.enableTitleLineActual;
1191
- break;
1192
- case 'onWidgetTitleHidden':
1193
- if (e.detail.data == true)
1194
- this.hideTitle = true;
1195
- else
1196
- this.hideTitle = false;
1197
- break;
1198
- case 'onUpdateLockData':
1199
- this.setLock(e.detail.data);
1200
- break;
1201
- case 'onGlobalFilterApplicableCheck':
1202
- this.setInapplicableFilters(e.detail.data, widgetInfo.widgetInstanceId);
1203
- break;
1204
- default:
1205
- break;
1206
- }
1207
- });
1208
- if (typeof (this.widgetElement.titleLineEnabled) != 'undefined') {
1209
- let titleLineEnabled = this.widgetElement.titleLineEnabled();
1210
- if (titleLineEnabled) {
1211
- this.enableTitleLine = titleLineEnabled;
1212
- this.enableTitleLineActual = titleLineEnabled;
1213
- }
1214
- }
1215
- this.editText = this.translateService.translate('Common.edit');
1216
- if (this.translateService.translate('Common.edit').length > 6) {
1217
- this.editText = (this.translateService.translate('Common.edit').substring(0, 6) + '...');
1218
- this.editToolTipValue = this.translateService.translate('Common.edit');
1219
- this.editToolTipWidth = "300px";
1220
- }
1221
- this.copyText = this.translateService.translate('Common.copy');
1222
- if (this.translateService.translate('Common.copy').length > 6) {
1223
- this.copyText = (this.translateService.translate('Common.copy').substring(0, 6) + '...');
1224
- this.copyToolTipValue = this.translateService.translate('Common.copy');
1225
- this.copyToolTipWidth = "300px";
1226
- }
1227
- this.moveText = this.translateService.translate('Common.move');
1228
- if (this.translateService.translate('Common.move').length > 6) {
1229
- this.moveText = (this.translateService.translate('Common.move').substring(0, 6) + '...');
1230
- this.moveToolTipValue = this.translateService.translate('Common.move');
1231
- this.moveToolTipWidth = "300px";
1232
- }
1233
- this.excelText = this.translateService.translate('Common.excel');
1234
- if (this.translateService.translate('Common.excel').length > 6) {
1235
- this.excelText = (this.translateService.translate('Common.excel').substring(0, 6) + '...');
1236
- this.excelToolTipValue = this.translateService.translate('Common.excel');
1237
- this.excelToolTipWidth = "300px";
1238
- }
1239
- this.deleteText = this.translateService.translate('Common.delete');
1240
- if (this.translateService.translate('Common.delete').length > 6) {
1241
- this.deleteText = (this.translateService.translate('Common.delete').substring(0, 6) + '...');
1242
- this.deleteToolTipValue = this.translateService.translate('Common.delete');
1243
- this.deleteToolTipWidth = "300px";
1244
- }
1245
- this.isWidgetLoaded = true;
1246
- widgetConfigFilter.appConfig = this.appConfig;
1247
- widgetConfigFilter.widgetInfo = widgetInfo;
1248
- widgetConfigFilter.configChanges = this.getConfigChanges(false);
1249
- widgetConfigFilter.widgetInfo.widgetName = widgetInfo.widgetName;
1250
- widgetConfigFilter.globalFilter = this.globalFilter;
1251
- this.widgetElement.loadContent(widgetConfigFilter);
1252
- yield this.setLock(widgetConfigFilter.config);
1253
- yield this.setDownloadIcon();
1254
- }));
1255
- }.bind(this);
1256
- this.widgetElementHandler = handler;
1257
- document.body.addEventListener('widgetinitiated' + widgetInfo.widgetInstanceId, handler);
1258
- this.ctlWidget.nativeElement.appendChild(this.widgetElement);
1259
- });
1260
- });
1261
- });
1262
- }
1263
- /**To set Default State for the widget when it is not configured */
1264
- setNotConfiguredState(widgetInfo, forceEnable = false) {
1265
- if ((widgetInfo.showDefaultState && (widgetInfo.widgetConfigInfo.config == "" || Object.keys(JSON.parse(widgetInfo.widgetConfigInfo.config)).length == 0)) || (forceEnable)) {
1266
- this.isWidgetStateApplicable = true;
1267
- this.widgetEmptyState = WidgetViewState.emptyConfig.toString();
1268
- }
1269
- else {
1270
- this.widgetEmptyState = '';
1271
- this.isWidgetStateApplicable = false;
1272
- }
1273
- }
1274
- /**To configure empty state for the widget */
1275
- setEmptyState(widgetState) {
1276
- if (this.height == 1 || this.width == 1)
1277
- this.isKpiView = true;
1278
- else
1279
- this.isKpiView = false;
1280
- this.widgetEmptyState = widgetState.widgetViewState;
1281
- this.isGlobalFilterApplied = widgetState.isGlobalFilterApplied;
1282
- if (widgetState != WidgetViewState.normal) {
1283
- this.isWidgetStateApplicable = true;
1284
- this.isDownloadIconVisible = false;
1285
- }
1286
- else {
1287
- this.isWidgetStateApplicable = false;
1288
- }
1289
- switch (widgetState) {
1290
- case WidgetViewState.emptyConfig:
1291
- this.setNotConfiguredState(this.data.widgetInfo, true);
1292
- break;
1293
- case WidgetViewState.emptyData:
1294
- break;
1295
- case WidgetViewState.error:
1296
- break;
1297
- }
1298
- }
1299
- getConfigChanges(configChanged = false) {
1300
- let configChanges = {
1301
- isConfigUpdated: configChanged,
1302
- updatedConfigProperty: []
1303
- };
1304
- return configChanges;
1305
- }
1306
- /** To refresh widget on input config changes */
1307
- refreshWidget(widgetInfo, configChanged = false) {
1308
- return __awaiter(this, void 0, void 0, function* () {
1309
- this.WidgetDisplayName = this.translateService.translate('Common.' + this.data.widgetInfo.widgetTitle, true);
1310
- widgetInfo.rowHeight = this.gridCellHeight;
1311
- this.setNotConfiguredState(widgetInfo);
1312
- let widgetContainerContext = this;
1313
- let widgetConfigFilter = {
1314
- config: widgetInfo.widgetConfigInfo.config,
1315
- globalFilter: this.globalFilter,
1316
- appConfig: this.appConfig,
1317
- widgetInfo: widgetInfo,
1318
- configChanges: this.getConfigChanges(configChanged)
1319
- };
1320
- if (widgetContainerContext.isWidgetLoaded) {
1321
- if (this.widgetElement && typeof (this.widgetElement.setConfigFilter) == 'function') {
1322
- widgetContainerContext.widgetElement.setConfigFilter(widgetConfigFilter);
1323
- }
1324
- widgetContainerContext.widgetElement.loadContent(widgetConfigFilter);
1325
- yield this.setLock(widgetConfigFilter.config);
1326
- yield this.setDownloadIcon();
1327
- }
1328
- });
1329
- }
1330
- mouseOver(event) {
1331
- this.toolTipValue = ' ';
1332
- this.toolTipWidth = '0px';
1333
- let element = this.searchInput.nativeElement;
1334
- if (element.offsetWidth < element.scrollWidth) {
1335
- this.toolTipValue = element.innerHTML;
1336
- this.toolTipWidth = '300px';
1337
- }
1338
- else {
1339
- this.toolTipWidth = '0px';
1340
- }
1341
- }
1342
- setLock(config) {
1343
- return __awaiter(this, void 0, void 0, function* () {
1344
- this.lockTemplateInfo = this.widgetElement.loadLockInfo();
1345
- var configObj;
1346
- if (config) {
1347
- configObj = JSON.parse(config);
1348
- if (configObj && configObj.Locks != undefined) {
1349
- if (configObj.Locks.IsDateLocked || configObj.Locks.IsDatesLocked || configObj.Locks.IsParticipantLocked || configObj.Locks.IsSourceLocked) {
1350
- this.lockDetails = [];
1351
- if (configObj.Locks.IsDateLocked || configObj.Locks.IsDatesLocked)
1352
- this.lockDetails.push(this.translateService.translate('Common.DateRange'));
1353
- if (configObj.Locks.IsParticipantLocked) {
1354
- this.lockDetails.push(this.translateService.translate('Common.DivisionOrGrouporSite'));
1355
- }
1356
- if (configObj.Locks.IsSourceLocked)
1357
- this.lockDetails.push(this.translateService.translate('Common.DataStream'));
1358
- }
1359
- else {
1360
- this.lockDetails = undefined;
1361
- }
1362
- }
1363
- else {
1364
- this.lockDetails = undefined;
1365
- }
1366
- }
1367
- });
1368
- }
1369
- setDownloadIcon() {
1370
- return __awaiter(this, void 0, void 0, function* () {
1371
- let downloadType = yield this.widgetElement.getDownloadType();
1372
- this.downloadIconType = downloadType;
1373
- this.isDownloadIconVisible = false;
1374
- this.isChartDownloadVisible = false;
1375
- this.isGridDownloadVisible = false;
1376
- this.showExcell = true;
1377
- if (downloadType != RADownloadType.None) {
1378
- this.isDownloadIconVisible = true;
1379
- }
1380
- else {
1381
- if (!this.isWidgetMgmnt && !this.detailPageUrl) {
1382
- this.showSettingsLink = false;
1383
- }
1384
- }
1385
- if (downloadType == RADownloadType.Chart) {
1386
- this.isChartDownloadVisible = true;
1387
- }
1388
- if (downloadType == RADownloadType.Grid) {
1389
- this.isGridDownloadVisible = true;
1390
- }
1391
- if (downloadType == RADownloadType.Statistics) {
1392
- this.isGridDownloadVisible = true;
1393
- this.showExcell = false;
1394
- }
1395
- });
1396
- }
1397
- downloadIconClicked(type) {
1398
- switch (type) {
1399
- case "CSV":
1400
- this.widgetElement.downloadClicked(this.downloadIconType, RADownloadOption.CSV);
1401
- break;
1402
- case "PNG":
1403
- this.widgetElement.downloadClicked(this.downloadIconType, RADownloadOption.PNG);
1404
- break;
1405
- case "PDF":
1406
- this.widgetElement.downloadClicked(this.downloadIconType, RADownloadOption.PDF);
1407
- break;
1408
- case "SVG":
1409
- this.widgetElement.downloadClicked(this.downloadIconType, RADownloadOption.SVG);
1410
- break;
1411
- case "JPEG":
1412
- this.widgetElement.downloadClicked(this.downloadIconType, RADownloadOption.JPEG);
1413
- break;
1414
- }
1415
- }
1416
- removeMenu() {
1417
- jQuery('#ra-db-widget-menu').remove();
1418
- }
1419
- checkVisitLinkVisiblity() {
1420
- let isVisitApplicable = true;
1421
- if (this.widgetElement && typeof this.widgetElement.getVisitLinkVisibilityStatus === "function") {
1422
- isVisitApplicable = this.widgetElement.getVisitLinkVisibilityStatus();
1423
- }
1424
- return isVisitApplicable;
1425
- }
1426
- /**Show dropdown on gear icon click */
1427
- showDropDown(e) {
1428
- this.setDownloadIcon();
1429
- this.removeMenu();
1430
- setTimeout(() => {
1431
- let targetPos = e.target.getBoundingClientRect();
1432
- let style = "position:fixed;top:" + (targetPos.y + 15) + 'px' + ';left:' + (e.pageX - 122) + 'px;z-index:1000;';
1433
- let html = this.getContenxtHtml(style);
1434
- jQuery(html).appendTo('body');
1435
- if (this.isWidgetMgmnt) {
1436
- this.addEventListener('wcEditWidget', this.editWidget);
1437
- this.addEventListener('wcCopyWidget', this.copyWidget);
1438
- this.addEventListener('wcMoveWidget', this.moveWidget);
1439
- this.addEventListener('wcWidgetDelete', this.deleteWidget);
1440
- }
1441
- let customPageParams = false;
1442
- if (this.data.widgetInfo && this.data.widgetInfo.widgetSettings) {
1443
- this.widgetSettings = this.getParsedConfig(this.data.widgetInfo.widgetSettings);
1444
- if (this.widgetSettings.customPageParams || this.widgetSettings.customPageURL) {
1445
- customPageParams = true;
1446
- }
1447
- }
1448
- if ((this.detailPageUrl || customPageParams) && this.checkVisitLinkVisiblity()) {
1449
- this.addEventListener('wcVisitWidget', this.visitPage);
1450
- }
1451
- if (this.isChartDownloadVisible) {
1452
- this.addEventListener('wcDownloadPng', this.downloadIconClicked, 'PNG');
1453
- this.addEventListener('wcDownloadJpg', this.downloadIconClicked, 'JPEG');
1454
- this.addEventListener('wcDownloadPdf', this.downloadIconClicked, 'PDF');
1455
- this.addEventListener('wcDownloadSvg', this.downloadIconClicked, 'SVG');
1456
- }
1457
- if (this.isGridDownloadVisible && this.showExcell) {
1458
- this.addEventListener('wcDownloadExcel', this.downloadIconClicked, 'CSV');
1459
- }
1460
- document.getElementById('ra-db-widget-menu').addEventListener('mouseenter', () => {
1461
- window.mouseOverWidgetMenu = true;
1462
- });
1463
- document.getElementById('ra-db-widget-menu').addEventListener('mouseleave', () => {
1464
- window.mouseOverWidgetMenu = false;
1465
- setTimeout(() => {
1466
- if (!window.gridsterItemEnter) {
1467
- this.removeMenu();
1468
- }
1469
- });
1470
- });
1471
- });
1472
- }
1473
- addEventListener(id, event, params) {
1474
- let element = document.getElementById(id);
1475
- if (element) {
1476
- element.addEventListener('click', () => {
1477
- event.call(this, params);
1478
- });
1479
- }
1480
- }
1481
- getContenxtHtml(style) {
1482
- let html = '<div id="ra-db-widget-menu"' + 'style="' + style + '" class="download-content dropdown-content widget-config-item dropdown-click" style="z-index: 1002;">';
1483
- let settings = '';
1484
- if (this.isWidgetMgmnt) {
1485
- settings += this.getHtmlForButton('wcEditWidget', 'fal fa-edit', this.editText);
1486
- settings += this.getHtmlForButton('wcCopyWidget', 'fal fa-copy', this.copyText);
1487
- settings += this.getHtmlForButton('wcMoveWidget', 'fal fa-arrows-alt', this.moveText);
1488
- }
1489
- let customPageParams = false;
1490
- if (this.data.widgetInfo && this.data.widgetInfo.widgetSettings) {
1491
- this.widgetSettings = this.getParsedConfig(this.data.widgetInfo.widgetSettings);
1492
- if (this.widgetSettings.customPageParams || this.widgetSettings.customPageURL) {
1493
- customPageParams = true;
1494
- }
1495
- }
1496
- if ((this.detailPageUrl || customPageParams) && this.checkVisitLinkVisiblity()) {
1497
- settings += '<a style="max-height: 30px;align-items: center;align-content: center; display: flex;" id="wcVisitWidget">';
1498
- settings += '<i style="padding-left: 4px;font-size: 27px !important;" class="fal fa-angle-right"></i> ';
1499
- settings += '<span style="padding-left: 11px;margin-top: 2px;" style="padding-left: 6px;">';
1500
- settings += this.translateService.translate('Common.visitpage');
1501
- settings += '</span></a>';
1502
- }
1503
- if ((this.detailPageUrl && this.checkVisitLinkVisiblity()) || this.isWidgetMgmnt) {
1504
- html += '<div style="color: #9FA0A4;font-size: 12px;padding-top: 8px;padding-left: 12px;">';
1505
- html += this.translateService.translate('Common.settings') + '</div>';
1506
- html += settings;
1507
- html += this.getHr();
1508
- }
1509
- if (this.isDownloadIconVisible) {
1510
- if (this.showExcell) {
1511
- if (this.detailPageUrl || this.isWidgetMgmnt)
1512
- html += '<span style="color: #9FA0A4;font-size: 12px;">';
1513
- else
1514
- html += '<span style="color: #9FA0A4;font-size: 12px;padding-top:5px;display:block;">';
1515
- html += this.translateService.translate('Common.downloads');
1516
- html += '</span>';
1517
- }
1518
- if (this.isChartDownloadVisible) {
1519
- html += '<div style="padding-top: 10px;" class="chartDownload">';
1520
- html += this.getHtmlForButton('wcDownloadPng', 'fal fa-file-image', this.translateService.translate('Common.png'));
1521
- html += this.getHtmlForButton('wcDownloadJpg', 'fal fa-file-image', this.translateService.translate('Common.jpeg'));
1522
- html += this.getHtmlForButton('wcDownloadPdf', 'fal fa-file-pdf', this.translateService.translate('Common.pdf'));
1523
- html += this.getHtmlForButton('wcDownloadSvg', 'fal fa-file-alt', this.translateService.translate('Common.svg'));
1524
- html += '</div>';
1525
- }
1526
- if (this.isGridDownloadVisible && this.showExcell) {
1527
- html += '<div class="gridDownload">';
1528
- html += this.getHtmlForButton('wcDownloadExcel', 'fal fa-download', this.excelText);
1529
- html += '</div>';
1530
- }
1531
- }
1532
- if (this.isDownloadIconVisible && this.isWidgetMgmnt && this.showExcell) {
1533
- html += this.getHr();
1534
- }
1535
- if (this.isWidgetMgmnt) {
1536
- html += '<a id="wcWidgetDelete"><i class="fal fa-times" style="padding-left: 3px;color: red;"></i><span>';
1537
- html += this.deleteText;
1538
- html += '</span></a>';
1539
- }
1540
- html += '</div>';
1541
- return html;
1542
- }
1543
- getHr() {
1544
- return '<hr class="hr" style="margin-top: 5px;margin-bottom: 5px;">';
1545
- }
1546
- getHtmlForButton(id, fontClass, text) {
1547
- let html = '<a id="' + id + '"><i style="width:16px" class="' + fontClass + '"></i> <span style="padding-left: 6px;">';
1548
- html += text;
1549
- html += '</span></a>';
1550
- return html;
1551
- }
1552
- getParsedConfig(config) {
1553
- let parsedConfig;
1554
- if (config) {
1555
- if (typeof config === 'string') {
1556
- try {
1557
- parsedConfig = JSON.parse(config);
1558
- }
1559
- catch (_a) {
1560
- parsedConfig = {};
1561
- }
1562
- return parsedConfig;
1563
- }
1564
- }
1565
- return config;
1566
- }
1567
- applayWidgetSettings(settings) {
1568
- if (settings.NoPadding)
1569
- this.noPadding = true;
1570
- else
1571
- this.noPadding = false;
1572
- }
1573
- setInapplicableFilters(data, instanceId) {
1574
- var widgetData = {};
1575
- this.inapplicableFilters = [];
1576
- widgetData.instanceId = instanceId;
1577
- if (data && data.length > 0) {
1578
- data.forEach(element => {
1579
- if (element == 'dateRange')
1580
- this.inapplicableFilters.push(this.translateService.translate('Common.DateRange'));
1581
- else if (element == 'participant') {
1582
- this.inapplicableFilters.push(this.translateService.translate('Common.DivisionGroup'));
1583
- }
1584
- else if (element == 'source')
1585
- this.inapplicableFilters.push(this.translateService.translate('Common.DataStream'));
1586
- else
1587
- this.inapplicableFilters.push(element);
1588
- });
1589
- widgetData.data = data;
1590
- }
1591
- else {
1592
- widgetData.data = undefined;
1593
- }
1594
- this.updateAppliedFilters.emit(widgetData);
1595
- }
1596
- openPopup(title, data, footer, type, template = undefined) {
1597
- let props = {};
1598
- if (type == 'innaplicable' && this.banPopupDiv)
1599
- props.element = this.banPopupDiv.nativeElement;
1600
- if (type == 'lock' && this.lockPopupDiv)
1601
- props.element = this.lockPopupDiv.nativeElement;
1602
- props.title = title;
1603
- props.data = data;
1604
- props.footer = footer;
1605
- if (template)
1606
- props.template = template;
1607
- this.currentComponent = this.domService.appendComponent(LockTooltip, document.body, props);
1608
- this.popupInstance = this.currentComponent.instance;
1609
- }
1610
- closePopup() {
1611
- if (this.currentComponent)
1612
- this.popupInstance.removeMe(this.currentComponent);
1613
- }
1614
- getwidgetTitleTranslation(item) {
1615
- let rKey = 'DBW_' + this.translateService.makeCode(item);
1616
- let translatedString = '';
1617
- if (this.dashboardService.clientId) {
1618
- const translationModule = this.dashboardService.clientId + '_DBW';
1619
- translatedString = this.translateService.translate(translationModule + '.' + rKey);
1620
- if (translatedString.toLowerCase() === rKey.toLowerCase()) {
1621
- return item;
1622
- }
1623
- else {
1624
- return translatedString;
1625
- }
1626
- }
1627
- else
1628
- return item;
1629
- }
1630
- };
1631
- RAWidgetContainer.ctorParameters = () => [
1632
- { type: RaDashboardService },
1633
- { type: NgxUiLoaderService },
1634
- { type: RATranslateService },
1635
- { type: NgZone },
1636
- { type: NotifierService },
1637
- { type: Renderer2 },
1638
- { type: RAPermissionService },
1639
- { type: DomService }
1640
- ];
1641
- __decorate([
1642
- ViewChild('ctlWidget', { static: false }),
1643
- __metadata("design:type", ElementRef)
1644
- ], RAWidgetContainer.prototype, "ctlWidget", void 0);
1645
- __decorate([
1646
- ViewChild('widgetDropdown', { static: false }),
1647
- __metadata("design:type", ElementRef)
1648
- ], RAWidgetContainer.prototype, "widgetDropdown", void 0);
1649
- __decorate([
1650
- ViewChild('searchInput', { static: false }),
1651
- __metadata("design:type", ElementRef)
1652
- ], RAWidgetContainer.prototype, "searchInput", void 0);
1653
- __decorate([
1654
- ViewChild('wcWrapper', { static: false }),
1655
- __metadata("design:type", ElementRef)
1656
- ], RAWidgetContainer.prototype, "wcWrapper", void 0);
1657
- __decorate([
1658
- ViewChild('banPopupDiv', { static: false }),
1659
- __metadata("design:type", ElementRef)
1660
- ], RAWidgetContainer.prototype, "banPopupDiv", void 0);
1661
- __decorate([
1662
- ViewChild('lockPopupDiv', { static: false }),
1663
- __metadata("design:type", ElementRef)
1664
- ], RAWidgetContainer.prototype, "lockPopupDiv", void 0);
1665
- __decorate([
1666
- Input('widget-instance-id'),
1667
- __metadata("design:type", Number)
1668
- ], RAWidgetContainer.prototype, "widgetInstanceId", void 0);
1669
- __decorate([
1670
- Input('global-filter'),
1671
- __metadata("design:type", Object)
1672
- ], RAWidgetContainer.prototype, "globalFilter", void 0);
1673
- __decorate([
1674
- Input('data'),
1675
- __metadata("design:type", Object)
1676
- ], RAWidgetContainer.prototype, "data", void 0);
1677
- __decorate([
1678
- Input('event-bus'),
1679
- __metadata("design:type", RADashboardEventBus)
1680
- ], RAWidgetContainer.prototype, "raDashboardEventBus", void 0);
1681
- __decorate([
1682
- Input('app-config'),
1683
- __metadata("design:type", Object)
1684
- ], RAWidgetContainer.prototype, "appConfig", void 0);
1685
- __decorate([
1686
- Input('widget-width'),
1687
- __metadata("design:type", Number)
1688
- ], RAWidgetContainer.prototype, "width", void 0);
1689
- __decorate([
1690
- Input('widget-height'),
1691
- __metadata("design:type", Number)
1692
- ], RAWidgetContainer.prototype, "height", void 0);
1693
- __decorate([
1694
- Input('grid-cell-height'),
1695
- __metadata("design:type", Number)
1696
- ], RAWidgetContainer.prototype, "gridCellHeight", void 0);
1697
- __decorate([
1698
- Output(),
1699
- __metadata("design:type", Object)
1700
- ], RAWidgetContainer.prototype, "widgetDeleted", void 0);
1701
- __decorate([
1702
- Output(),
1703
- __metadata("design:type", Object)
1704
- ], RAWidgetContainer.prototype, "updateAppliedFilters", void 0);
1705
- __decorate([
1706
- Input('dom-resized'),
1707
- __metadata("design:type", Boolean),
1708
- __metadata("design:paramtypes", [Boolean])
1709
- ], RAWidgetContainer.prototype, "setResized", null);
1710
- RAWidgetContainer = __decorate([
1711
- Component({
1712
- selector: 'ra-widget-container',
1713
- template: "<div #wcWrapper class=\"wc-wrapper\" (mouseenter)=\"mouseHover(true)\" (mouseleave)=\"mouseHover(false)\"\r\n [ngStyle]=\"{'margin-left': noPadding?'0px':'15px','margin-right': noPadding?'0px':'15px'}\">\r\n <div class=\"wcheader widget-move\" *ngIf=\"!hideTitle\"\r\n [ngClass]=\"{'underLine': enableTitleLine || isWidgetStateApplicable}\">\r\n <div class=\"col-md-12 wc-mover\" style=\"padding-left: 0px;height:inherit;padding-right: 0px;\">\r\n <div style=\"display:flex;margin-top:10px;\"\r\n [ngStyle]=\"{'margin-left': noPadding?'15px':'0px','margin-right': noPadding?'15px':'0px'}\">\r\n <div class=\"col-9 float-left title-label\">\r\n <ra-tooltip [value]=\"toolTipValue\" [width]=\"toolTipWidth\">\r\n <div [hidden]=\"hideTitle\" style=\"text-overflow: ellipsis;white-space: nowrap;overflow: hidden;\"\r\n (mouseover)=\"mouseOver($event)\" #searchInput>{{WidgetDisplayName}}</div>\r\n </ra-tooltip>\r\n </div>\r\n <div class=\"col-3\" style=\"cursor:default;padding-right: 0px;\"> \r\n <div class=\"float-right\" style=\"display: flex;\">\r\n <div #banPopupDiv (mouseover)=\"openPopup(inapplicableIconTitle,inapplicableFilters,inapplicableIconFooter,'innaplicable')\" (mouseout)=\"closePopup()\" class=\"title-bar-lock-icon lock-dropdown\" [hidden]=\"!inapplicableFilters || inapplicableFilters.length == 0 || !globalFilter || globalFilter == '{}'\">\r\n <i class=\"fal fa-ban lock\"></i> \r\n </div>\r\n <div #lockPopupDiv (mouseover)=\"openPopup(lockIconTitle,lockDetails,lockIconFooter,'lock',lockTemplateInfo)\" (mouseout)=\"closePopup()\" class=\"title-bar-lock-icon lock-dropdown\" [hidden]=\"!lockDetails && !lockTemplateInfo\">\r\n <i class=\"fal fa-lock lock\"></i> \r\n </div>\r\n <div class=\"widget-menu\" style=\"width:10px;\"\r\n [ngClass]=\"{'widget-menu-show': isMouseHover && showSettingsLink}\">\r\n <div class=\"dropbtn title-bar-icon\">\r\n <i (click)=\"showDropDown($event)\" #widgetDropdown class=\"fal fa-ellipsis-v widget-menu-ellipse\"></i>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n <div *ngIf=\"hideTitle\" class=\"wcheader widget-move\"\r\n style=\"height: 45px;width: 95%;cursor: move;z-index: 99;opacity: 0;\">\r\n </div>\r\n <div *ngIf=\"hideTitle\" class=\"widget-menu widget-menu-title-hidden\" [ngClass]=\"{'widget-menu-show': isMouseHover && showSettingsLink}\">\r\n <div class=\"dropbtn title-bar-icon\">\r\n <i (click)=\"showDropDown($event)\" class=\"fal fa-ellipsis-v\" style=\"text-align: center;\"></i>\r\n </div>\r\n </div>\r\n <div class=\"wcBody\" [ngStyle]=\"{'bottom': noPadding?'0px':'10px','top':hideTitle?'10px':'46px'}\">\r\n <div [hidden]=\"isWidgetStateApplicable\" class=\"m-fadeOut widget-overlay\" [ngClass]=\"{'m-fadeIn': showPanel}\">\r\n <div class=\"lds-roller\">\r\n <div></div>\r\n <div></div>\r\n <div></div>\r\n <div></div>\r\n <div></div>\r\n <div></div>\r\n <div></div>\r\n <div></div>\r\n </div>\r\n </div>\r\n <div class=\"wc\" [hidden]=\"isWidgetStateApplicable\">\r\n <div #ctlWidget></div>\r\n </div>\r\n <div *ngIf=\"isWidgetStateApplicable\" class=\"defaultConfig\">\r\n <ra-widget-state style=\"width: 100%;height: 100%;\" [isWidgetStateApplicable]=\"isWidgetStateApplicable\"\r\n [isGlobalFilterApplied]=\"isGlobalFilterApplied\" [widgetEmptyState]=\"widgetEmptyState\"\r\n (editWidgetClicked)=editWidget() [widthCol]=\"width\" [heightCol]=\"height\">\r\n </ra-widget-state>\r\n </div>\r\n <div>\r\n </div>\r\n </div>\r\n</div>"
1714
- }),
1715
- __metadata("design:paramtypes", [RaDashboardService,
1716
- NgxUiLoaderService,
1717
- RATranslateService,
1718
- NgZone,
1719
- NotifierService,
1720
- Renderer2,
1721
- RAPermissionService,
1722
- DomService])
1723
- ], RAWidgetContainer);
1724
-
1725
- const customNotifierOptions = {
1726
- position: {
1727
- horizontal: {
1728
- position: 'right',
1729
- distance: 12
1730
- },
1731
- vertical: {
1732
- position: 'top',
1733
- distance: 12,
1734
- gap: 10
1735
- }
1736
- },
1737
- theme: 'material',
1738
- behaviour: {
1739
- autoHide: 5000,
1740
- onClick: 'hide',
1741
- onMouseover: 'pauseAutoHide',
1742
- showDismissButton: true,
1743
- stacking: 4
1744
- },
1745
- animations: {
1746
- enabled: true,
1747
- show: {
1748
- preset: 'slide',
1749
- speed: 300,
1750
- easing: 'ease'
1751
- },
1752
- hide: {
1753
- preset: 'fade',
1754
- speed: 300,
1755
- easing: 'ease',
1756
- offset: 50
1757
- },
1758
- shift: {
1759
- speed: 300,
1760
- easing: 'ease'
1761
- },
1762
- overlap: 150
1763
- }
1764
- };
1765
-
1766
- var GridType;
1767
- (function (GridType) {
1768
- GridType["Fit"] = "fit";
1769
- GridType["ScrollVertical"] = "scrollVertical";
1770
- GridType["ScrollHorizontal"] = "scrollHorizontal";
1771
- GridType["Fixed"] = "fixed";
1772
- GridType["VerticalFixed"] = "verticalFixed";
1773
- GridType["HorizontalFixed"] = "horizontalFixed";
1774
- })(GridType || (GridType = {}));
1775
- var DisplayGrid;
1776
- (function (DisplayGrid) {
1777
- DisplayGrid["Always"] = "always";
1778
- DisplayGrid["OnDragAndResize"] = "onDrag&Resize";
1779
- DisplayGrid["None"] = "none";
1780
- })(DisplayGrid || (DisplayGrid = {}));
1781
- var CompactType;
1782
- (function (CompactType) {
1783
- CompactType["None"] = "none";
1784
- CompactType["CompactUp"] = "compactUp";
1785
- CompactType["CompactLeft"] = "compactLeft";
1786
- CompactType["CompactUpAndLeft"] = "compactUp&Left";
1787
- CompactType["CompactLeftAndUp"] = "compactLeft&Up";
1788
- CompactType["CompactRight"] = "compactRight";
1789
- CompactType["CompactUpAndRight"] = "compactUp&Right";
1790
- CompactType["CompactRightAndUp"] = "compactRight&Up";
1791
- })(CompactType || (CompactType = {}));
1792
-
1793
- const GridsterConfigService = {
1794
- gridType: GridType.Fit,
1795
- // 'scrollVertical' will fit on width and height of the items will be the same as the width
1796
- // 'scrollHorizontal' will fit on height and width of the items will be the same as the height
1797
- // 'fixed' will set the rows and columns dimensions based on fixedColWidth and fixedRowHeight options
1798
- // 'verticalFixed' will set the rows to fixedRowHeight and columns width will fit the space available
1799
- // 'horizontalFixed' will set the columns to fixedColWidth and rows height will fit the space available
1800
- fixedColWidth: 250,
1801
- fixedRowHeight: 250,
1802
- keepFixedHeightInMobile: false,
1803
- keepFixedWidthInMobile: false,
1804
- setGridSize: false,
1805
- compactType: CompactType.None,
1806
- mobileBreakpoint: 640,
1807
- minCols: 1,
1808
- maxCols: 100,
1809
- minRows: 1,
1810
- maxRows: 100,
1811
- defaultItemCols: 1,
1812
- defaultItemRows: 1,
1813
- maxItemCols: 50,
1814
- maxItemRows: 50,
1815
- minItemCols: 1,
1816
- minItemRows: 1,
1817
- minItemArea: 1,
1818
- maxItemArea: 2500,
1819
- margin: 10,
1820
- outerMargin: true,
1821
- outerMarginTop: null,
1822
- outerMarginRight: null,
1823
- outerMarginBottom: null,
1824
- outerMarginLeft: null,
1825
- useTransformPositioning: true,
1826
- scrollSensitivity: 10,
1827
- scrollSpeed: 20,
1828
- initCallback: undefined,
1829
- destroyCallback: undefined,
1830
- gridSizeChangedCallback: undefined,
1831
- itemChangeCallback: undefined,
1832
- // Arguments: gridsterItem, gridsterItemComponent
1833
- itemResizeCallback: undefined,
1834
- // Arguments: gridsterItem, gridsterItemComponent
1835
- itemInitCallback: undefined,
1836
- // Arguments: gridsterItem, gridsterItemComponent
1837
- itemRemovedCallback: undefined,
1838
- // Arguments: gridsterItem, gridsterItemComponent
1839
- itemValidateCallback: undefined,
1840
- // Arguments: gridsterItem
1841
- enableEmptyCellClick: false,
1842
- enableEmptyCellContextMenu: false,
1843
- enableEmptyCellDrop: false,
1844
- enableEmptyCellDrag: false,
1845
- emptyCellClickCallback: undefined,
1846
- emptyCellContextMenuCallback: undefined,
1847
- emptyCellDropCallback: undefined,
1848
- emptyCellDragCallback: undefined,
1849
- emptyCellDragMaxCols: 50,
1850
- emptyCellDragMaxRows: 50,
1851
- // Arguments: event, gridsterItem{x, y, rows: defaultItemRows, cols: defaultItemCols}
1852
- ignoreMarginInRow: false,
1853
- draggable: {
1854
- delayStart: 0,
1855
- enabled: false,
1856
- ignoreContentClass: 'gridster-item-content',
1857
- ignoreContent: false,
1858
- dragHandleClass: 'drag-handler',
1859
- stop: undefined,
1860
- start: undefined,
1861
- // Arguments: item, gridsterItem, event
1862
- dropOverItems: false,
1863
- dropOverItemsCallback: undefined // callback on drop over another item
1864
- // Arguments: source, target, gridComponent
1865
- },
1866
- resizable: {
1867
- delayStart: 0,
1868
- enabled: false,
1869
- handles: {
1870
- s: true,
1871
- e: true,
1872
- n: true,
1873
- w: true,
1874
- se: true,
1875
- ne: true,
1876
- sw: true,
1877
- nw: true
1878
- },
1879
- stop: undefined,
1880
- start: undefined // callback when resizing an item starts.
1881
- // Arguments: item, gridsterItem, event
1882
- },
1883
- swap: true,
1884
- pushItems: false,
1885
- disablePushOnDrag: false,
1886
- disablePushOnResize: false,
1887
- pushDirections: { north: true, east: true, south: true, west: true },
1888
- pushResizeItems: false,
1889
- displayGrid: DisplayGrid.OnDragAndResize,
1890
- disableWindowResize: false,
1891
- disableWarnings: false,
1892
- scrollToNewItems: false,
1893
- disableAutoPositionOnConflict: false,
1894
- };
1895
-
1896
- var GridsterUtils_1;
1897
- let GridsterUtils = GridsterUtils_1 = class GridsterUtils {
1898
- static merge(obj1, obj2, properties) {
1899
- for (const p in obj2) {
1900
- if (obj2[p] !== void 0 && properties.hasOwnProperty(p)) {
1901
- if (typeof obj2[p] === 'object') {
1902
- obj1[p] = GridsterUtils_1.merge(obj1[p], obj2[p], properties[p]);
1903
- }
1904
- else {
1905
- obj1[p] = obj2[p];
1906
- }
1907
- }
1908
- }
1909
- return obj1;
1910
- }
1911
- static debounce(func, wait) {
1912
- let timeout;
1913
- return function () {
1914
- const context = this, args = arguments;
1915
- const later = function () {
1916
- timeout = null;
1917
- func.apply(context, args);
1918
- };
1919
- clearTimeout(timeout);
1920
- timeout = setTimeout(later, wait);
1921
- };
1922
- }
1923
- static checkTouchEvent(e) {
1924
- if (e.clientX === undefined && e.touches) {
1925
- if (e.touches && e.touches.length) {
1926
- e.clientX = e.touches[0].clientX;
1927
- e.clientY = e.touches[0].clientY;
1928
- }
1929
- else if (e.changedTouches && e.changedTouches.length) {
1930
- e.clientX = e.changedTouches[0].clientX;
1931
- e.clientY = e.changedTouches[0].clientY;
1932
- }
1933
- }
1934
- }
1935
- static checkContentClassForEvent(gridster, e) {
1936
- if (gridster.$options.draggable.ignoreContent) {
1937
- if (!GridsterUtils_1.checkContentClass(e.target, e.currentTarget, gridster.$options.draggable.dragHandleClass)) {
1938
- return true;
1939
- }
1940
- }
1941
- else {
1942
- if (GridsterUtils_1.checkContentClass(e.target, e.currentTarget, gridster.$options.draggable.ignoreContentClass)) {
1943
- return true;
1944
- }
1945
- }
1946
- return false;
1947
- }
1948
- static checkContentClassForEmptyCellClickEvent(gridster, e) {
1949
- return GridsterUtils_1.checkContentClass(e.target, e.currentTarget, gridster.$options.draggable.ignoreContentClass)
1950
- || GridsterUtils_1.checkContentClass(e.target, e.currentTarget, gridster.$options.draggable.dragHandleClass);
1951
- }
1952
- static checkContentClass(target, current, contentClass) {
1953
- if (!target || target === current) {
1954
- return false;
1955
- }
1956
- if (target.hasAttribute('class') && target.getAttribute('class').split(' ').indexOf(contentClass) > -1) {
1957
- return true;
1958
- }
1959
- else {
1960
- return GridsterUtils_1.checkContentClass(target.parentNode, current, contentClass);
1961
- }
1962
- }
1963
- static compareItems(a, b) {
1964
- if (a.y > b.y) {
1965
- return -1;
1966
- }
1967
- else if (a.y < b.y) {
1968
- return 1;
1969
- }
1970
- else if (a.x > b.x) {
1971
- return -1;
1972
- }
1973
- else {
1974
- return 1;
1975
- }
1976
- }
1977
- };
1978
- GridsterUtils = GridsterUtils_1 = __decorate([
1979
- Injectable()
1980
- ], GridsterUtils);
1981
-
1982
- class GridsterComponentInterface {
1983
- }
1984
-
1985
- let GridsterEmptyCell = class GridsterEmptyCell {
1986
- constructor(gridster) {
1987
- this.gridster = gridster;
1988
- }
1989
- destroy() {
1990
- delete this.initialItem;
1991
- delete this.gridster.movingItem;
1992
- if (this.gridster.previewStyle) {
1993
- this.gridster.previewStyle();
1994
- }
1995
- delete this.gridster;
1996
- if (this.emptyCellExit) {
1997
- this.emptyCellExit();
1998
- this.emptyCellExit = null;
1999
- }
2000
- }
2001
- updateOptions() {
2002
- if (this.gridster.$options.enableEmptyCellClick && !this.emptyCellClick && this.gridster.options.emptyCellClickCallback) {
2003
- this.emptyCellClick = this.gridster.renderer.listen(this.gridster.el, 'click', this.emptyCellClickCb.bind(this));
2004
- this.emptyCellClickTouch = this.gridster.renderer.listen(this.gridster.el, 'touchend', this.emptyCellClickCb.bind(this));
2005
- }
2006
- else if (!this.gridster.$options.enableEmptyCellClick && this.emptyCellClick && this.emptyCellClickTouch) {
2007
- this.emptyCellClick();
2008
- this.emptyCellClickTouch();
2009
- this.emptyCellClick = null;
2010
- this.emptyCellClickTouch = null;
2011
- }
2012
- if (this.gridster.$options.enableEmptyCellContextMenu && !this.emptyCellContextMenu &&
2013
- this.gridster.options.emptyCellContextMenuCallback) {
2014
- this.emptyCellContextMenu = this.gridster.renderer.listen(this.gridster.el, 'contextmenu', this.emptyCellContextMenuCb.bind(this));
2015
- }
2016
- else if (!this.gridster.$options.enableEmptyCellContextMenu && this.emptyCellContextMenu) {
2017
- this.emptyCellContextMenu();
2018
- this.emptyCellContextMenu = null;
2019
- }
2020
- if (this.gridster.$options.enableEmptyCellDrop && !this.emptyCellDrop && this.gridster.options.emptyCellDropCallback) {
2021
- this.emptyCellDrop = this.gridster.renderer.listen(this.gridster.el, 'drop', this.emptyCellDragDrop.bind(this));
2022
- this.gridster.zone.runOutsideAngular(() => {
2023
- this.emptyCellMove = this.gridster.renderer.listen(this.gridster.el, 'dragover', this.emptyCellDragOver.bind(this));
2024
- });
2025
- this.emptyCellExit = this.gridster.renderer.listen('document', 'dragend', () => {
2026
- this.gridster.movingItem = null;
2027
- this.gridster.previewStyle();
2028
- });
2029
- }
2030
- else if (!this.gridster.$options.enableEmptyCellDrop && this.emptyCellDrop && this.emptyCellMove && this.emptyCellExit) {
2031
- this.emptyCellDrop();
2032
- this.emptyCellMove();
2033
- this.emptyCellExit();
2034
- this.emptyCellMove = null;
2035
- this.emptyCellDrop = null;
2036
- this.emptyCellExit = null;
2037
- }
2038
- if (this.gridster.$options.enableEmptyCellDrag && !this.emptyCellDrag && this.gridster.options.emptyCellDragCallback) {
2039
- this.emptyCellDrag = this.gridster.renderer.listen(this.gridster.el, 'mousedown', this.emptyCellMouseDown.bind(this));
2040
- this.emptyCellDragTouch = this.gridster.renderer.listen(this.gridster.el, 'touchstart', this.emptyCellMouseDown.bind(this));
2041
- }
2042
- else if (!this.gridster.$options.enableEmptyCellDrag && this.emptyCellDrag && this.emptyCellDragTouch) {
2043
- this.emptyCellDrag();
2044
- this.emptyCellDragTouch();
2045
- this.emptyCellDrag = null;
2046
- this.emptyCellDragTouch = null;
2047
- }
2048
- }
2049
- emptyCellClickCb(e) {
2050
- if (this.gridster.movingItem || GridsterUtils.checkContentClassForEmptyCellClickEvent(this.gridster, e)) {
2051
- return;
2052
- }
2053
- const item = this.getValidItemFromEvent(e);
2054
- if (!item) {
2055
- return;
2056
- }
2057
- if (this.gridster.options.emptyCellClickCallback) {
2058
- this.gridster.options.emptyCellClickCallback(e, item);
2059
- }
2060
- this.gridster.cdRef.markForCheck();
2061
- }
2062
- emptyCellContextMenuCb(e) {
2063
- if (this.gridster.movingItem || GridsterUtils.checkContentClassForEmptyCellClickEvent(this.gridster, e)) {
2064
- return;
2065
- }
2066
- e.preventDefault();
2067
- e.stopPropagation();
2068
- const item = this.getValidItemFromEvent(e);
2069
- if (!item) {
2070
- return;
2071
- }
2072
- if (this.gridster.options.emptyCellContextMenuCallback) {
2073
- this.gridster.options.emptyCellContextMenuCallback(e, item);
2074
- }
2075
- this.gridster.cdRef.markForCheck();
2076
- }
2077
- emptyCellDragDrop(e) {
2078
- const item = this.getValidItemFromEvent(e);
2079
- if (!item) {
2080
- return;
2081
- }
2082
- if (this.gridster.options.emptyCellDropCallback) {
2083
- this.gridster.options.emptyCellDropCallback(e, item);
2084
- }
2085
- this.gridster.cdRef.markForCheck();
2086
- }
2087
- emptyCellDragOver(e) {
2088
- e.preventDefault();
2089
- e.stopPropagation();
2090
- const item = this.getValidItemFromEvent(e);
2091
- if (item) {
2092
- e.dataTransfer.dropEffect = 'move';
2093
- this.gridster.movingItem = item;
2094
- }
2095
- else {
2096
- e.dataTransfer.dropEffect = 'none';
2097
- this.gridster.movingItem = null;
2098
- }
2099
- this.gridster.previewStyle();
2100
- }
2101
- emptyCellMouseDown(e) {
2102
- if (GridsterUtils.checkContentClassForEmptyCellClickEvent(this.gridster, e)) {
2103
- return;
2104
- }
2105
- e.preventDefault();
2106
- e.stopPropagation();
2107
- const item = this.getValidItemFromEvent(e);
2108
- const leftMouseButtonCode = 1;
2109
- if (!item || e.buttons !== leftMouseButtonCode) {
2110
- return;
2111
- }
2112
- this.initialItem = item;
2113
- this.gridster.movingItem = item;
2114
- this.gridster.previewStyle();
2115
- this.gridster.zone.runOutsideAngular(() => {
2116
- this.emptyCellMMove = this.gridster.renderer.listen('window', 'mousemove', this.emptyCellMouseMove.bind(this));
2117
- this.emptyCellMMoveTouch = this.gridster.renderer.listen('window', 'touchmove', this.emptyCellMouseMove.bind(this));
2118
- });
2119
- this.emptyCellUp = this.gridster.renderer.listen('window', 'mouseup', this.emptyCellMouseUp.bind(this));
2120
- this.emptyCellUpTouch = this.gridster.renderer.listen('window', 'touchend', this.emptyCellMouseUp.bind(this));
2121
- }
2122
- emptyCellMouseMove(e) {
2123
- e.preventDefault();
2124
- e.stopPropagation();
2125
- const item = this.getValidItemFromEvent(e, this.initialItem);
2126
- if (!item) {
2127
- return;
2128
- }
2129
- this.gridster.movingItem = item;
2130
- this.gridster.previewStyle();
2131
- }
2132
- emptyCellMouseUp(e) {
2133
- this.emptyCellMMove();
2134
- this.emptyCellMMoveTouch();
2135
- this.emptyCellUp();
2136
- this.emptyCellUpTouch();
2137
- const item = this.getValidItemFromEvent(e, this.initialItem);
2138
- if (item) {
2139
- this.gridster.movingItem = item;
2140
- }
2141
- if (this.gridster.options.emptyCellDragCallback && this.gridster.movingItem) {
2142
- this.gridster.options.emptyCellDragCallback(e, this.gridster.movingItem);
2143
- }
2144
- setTimeout(() => {
2145
- this.initialItem = null;
2146
- if (this.gridster) {
2147
- this.gridster.movingItem = null;
2148
- this.gridster.previewStyle();
2149
- }
2150
- });
2151
- this.gridster.cdRef.markForCheck();
2152
- }
2153
- getValidItemFromEvent(e, oldItem) {
2154
- e.preventDefault();
2155
- e.stopPropagation();
2156
- GridsterUtils.checkTouchEvent(e);
2157
- const rect = this.gridster.el.getBoundingClientRect();
2158
- const x = e.clientX + this.gridster.el.scrollLeft - rect.left - this.gridster.$options.margin;
2159
- const y = e.clientY + this.gridster.el.scrollTop - rect.top - this.gridster.$options.margin;
2160
- const item = {
2161
- x: this.gridster.pixelsToPositionX(x, Math.floor, true),
2162
- y: this.gridster.pixelsToPositionY(y, Math.floor, true),
2163
- cols: this.gridster.$options.defaultItemCols,
2164
- rows: this.gridster.$options.defaultItemRows
2165
- };
2166
- if (oldItem) {
2167
- item.cols = Math.min(Math.abs(oldItem.x - item.x) + 1, this.gridster.$options.emptyCellDragMaxCols);
2168
- item.rows = Math.min(Math.abs(oldItem.y - item.y) + 1, this.gridster.$options.emptyCellDragMaxRows);
2169
- if (oldItem.x < item.x) {
2170
- item.x = oldItem.x;
2171
- }
2172
- else if (oldItem.x - item.x > this.gridster.$options.emptyCellDragMaxCols - 1) {
2173
- item.x = this.gridster.movingItem ? this.gridster.movingItem.x : 0;
2174
- }
2175
- if (oldItem.y < item.y) {
2176
- item.y = oldItem.y;
2177
- }
2178
- else if (oldItem.y - item.y > this.gridster.$options.emptyCellDragMaxRows - 1) {
2179
- item.y = this.gridster.movingItem ? this.gridster.movingItem.y : 0;
2180
- }
2181
- }
2182
- if (this.gridster.checkCollision(item)) {
2183
- return;
2184
- }
2185
- return item;
2186
- }
2187
- };
2188
- GridsterEmptyCell.ctorParameters = () => [
2189
- { type: GridsterComponentInterface }
2190
- ];
2191
- GridsterEmptyCell = __decorate([
2192
- Injectable(),
2193
- __metadata("design:paramtypes", [GridsterComponentInterface])
2194
- ], GridsterEmptyCell);
2195
-
2196
- let GridsterCompact = class GridsterCompact {
2197
- constructor(gridster) {
2198
- this.gridster = gridster;
2199
- }
2200
- destroy() {
2201
- delete this.gridster;
2202
- }
2203
- checkCompact() {
2204
- if (this.gridster.$options.compactType !== CompactType.None) {
2205
- if (this.gridster.$options.compactType === CompactType.CompactUp) {
2206
- this.checkCompactUp();
2207
- }
2208
- else if (this.gridster.$options.compactType === CompactType.CompactLeft) {
2209
- this.checkCompactLeft();
2210
- }
2211
- else if (this.gridster.$options.compactType === CompactType.CompactUpAndLeft) {
2212
- this.checkCompactUp();
2213
- this.checkCompactLeft();
2214
- }
2215
- else if (this.gridster.$options.compactType === CompactType.CompactLeftAndUp) {
2216
- this.checkCompactLeft();
2217
- this.checkCompactUp();
2218
- }
2219
- else if (this.gridster.$options.compactType === CompactType.CompactRight) {
2220
- this.checkCompactRight();
2221
- }
2222
- else if (this.gridster.$options.compactType === CompactType.CompactUpAndRight) {
2223
- this.checkCompactUp();
2224
- this.checkCompactRight();
2225
- }
2226
- else if (this.gridster.$options.compactType === CompactType.CompactRightAndUp) {
2227
- this.checkCompactRight();
2228
- this.checkCompactUp();
2229
- }
2230
- }
2231
- }
2232
- checkCompactItem(item) {
2233
- if (this.gridster.$options.compactType !== CompactType.None) {
2234
- if (this.gridster.$options.compactType === CompactType.CompactUp) {
2235
- this.moveUpTillCollision(item);
2236
- }
2237
- else if (this.gridster.$options.compactType === CompactType.CompactLeft) {
2238
- this.moveLeftTillCollision(item);
2239
- }
2240
- else if (this.gridster.$options.compactType === CompactType.CompactUpAndLeft) {
2241
- this.moveUpTillCollision(item);
2242
- this.moveLeftTillCollision(item);
2243
- }
2244
- else if (this.gridster.$options.compactType === CompactType.CompactLeftAndUp) {
2245
- this.moveLeftTillCollision(item);
2246
- this.moveUpTillCollision(item);
2247
- }
2248
- else if (this.gridster.$options.compactType === CompactType.CompactUpAndRight) {
2249
- this.moveUpTillCollision(item);
2250
- this.moveRightTillCollision(item);
2251
- }
2252
- }
2253
- }
2254
- checkCompactUp() {
2255
- let widgetMovedUp = false, widget, moved;
2256
- const l = this.gridster.grid.length;
2257
- for (let i = 0; i < l; i++) {
2258
- widget = this.gridster.grid[i];
2259
- if (widget.$item.compactEnabled === false) {
2260
- continue;
2261
- }
2262
- moved = this.moveUpTillCollision(widget.$item);
2263
- if (moved) {
2264
- widgetMovedUp = true;
2265
- widget.item.y = widget.$item.y;
2266
- widget.itemChanged();
2267
- }
2268
- }
2269
- if (widgetMovedUp) {
2270
- this.checkCompact();
2271
- }
2272
- }
2273
- moveUpTillCollision(item) {
2274
- item.y -= 1;
2275
- if (this.gridster.checkCollision(item)) {
2276
- item.y += 1;
2277
- return false;
2278
- }
2279
- else {
2280
- this.moveUpTillCollision(item);
2281
- return true;
2282
- }
2283
- }
2284
- checkCompactLeft() {
2285
- let widgetMovedUp = false, widget, moved;
2286
- const l = this.gridster.grid.length;
2287
- for (let i = 0; i < l; i++) {
2288
- widget = this.gridster.grid[i];
2289
- if (widget.$item.compactEnabled === false) {
2290
- continue;
2291
- }
2292
- moved = this.moveLeftTillCollision(widget.$item);
2293
- if (moved) {
2294
- widgetMovedUp = true;
2295
- widget.item.x = widget.$item.x;
2296
- widget.itemChanged();
2297
- }
2298
- }
2299
- if (widgetMovedUp) {
2300
- this.checkCompact();
2301
- }
2302
- }
2303
- checkCompactRight() {
2304
- let widgetMovedUp = false, widget, moved;
2305
- const l = this.gridster.grid.length;
2306
- for (let i = 0; i < l; i++) {
2307
- widget = this.gridster.grid[i];
2308
- if (widget.$item.compactEnabled === false) {
2309
- continue;
2310
- }
2311
- moved = this.moveRightTillCollision(widget.$item);
2312
- if (moved) {
2313
- widgetMovedUp = true;
2314
- widget.item.x = widget.$item.x;
2315
- widget.itemChanged();
2316
- }
2317
- }
2318
- if (widgetMovedUp) {
2319
- this.checkCompact();
2320
- }
2321
- }
2322
- moveLeftTillCollision(item) {
2323
- item.x -= 1;
2324
- if (this.gridster.checkCollision(item)) {
2325
- item.x += 1;
2326
- return false;
2327
- }
2328
- else {
2329
- this.moveLeftTillCollision(item);
2330
- return true;
2331
- }
2332
- }
2333
- moveRightTillCollision(item) {
2334
- item.x += 1;
2335
- if (this.gridster.checkCollision(item)) {
2336
- item.x -= 1;
2337
- return false;
2338
- }
2339
- else {
2340
- this.moveRightTillCollision(item);
2341
- return true;
2342
- }
2343
- }
2344
- };
2345
- GridsterCompact.ctorParameters = () => [
2346
- { type: GridsterComponentInterface }
2347
- ];
2348
- GridsterCompact = __decorate([
2349
- Injectable(),
2350
- __metadata("design:paramtypes", [GridsterComponentInterface])
2351
- ], GridsterCompact);
2352
-
2353
- let GridsterRenderer = class GridsterRenderer {
2354
- constructor(gridster) {
2355
- this.gridster = gridster;
2356
- }
2357
- destroy() {
2358
- delete this.gridster;
2359
- }
2360
- updateItem(el, item, renderer) {
2361
- if (this.gridster.mobile) {
2362
- this.clearCellPosition(renderer, el);
2363
- if (this.gridster.$options.keepFixedHeightInMobile) {
2364
- renderer.setStyle(el, 'height', (item.rows * this.gridster.$options.fixedRowHeight) + 'px');
2365
- }
2366
- else {
2367
- renderer.setStyle(el, 'height', (this.gridster.curWidth / 2 * item.rows) + 'px');
2368
- }
2369
- if (this.gridster.$options.keepFixedWidthInMobile) {
2370
- renderer.setStyle(el, 'width', this.gridster.$options.fixedColWidth + 'px');
2371
- }
2372
- else {
2373
- renderer.setStyle(el, 'width', '');
2374
- }
2375
- renderer.setStyle(el, 'margin-bottom', this.gridster.$options.margin + 'px');
2376
- renderer.setStyle(el, 'margin-right', '');
2377
- }
2378
- else {
2379
- const x = Math.round(this.gridster.curColWidth * item.x);
2380
- const y = Math.round(this.gridster.curRowHeight * item.y);
2381
- const width = this.gridster.curColWidth * item.cols - this.gridster.$options.margin;
2382
- const height = (this.gridster.curRowHeight * item.rows - this.gridster.$options.margin);
2383
- // set the cell style
2384
- this.setCellPosition(renderer, el, x, y);
2385
- renderer.setStyle(el, 'width', width + 'px');
2386
- renderer.setStyle(el, 'height', height + 'px');
2387
- let marginBottom = null;
2388
- let marginRight = null;
2389
- if (this.gridster.$options.outerMargin) {
2390
- if (this.gridster.rows === item.rows + item.y) {
2391
- if (this.gridster.$options.outerMarginBottom !== null) {
2392
- marginBottom = this.gridster.$options.outerMarginBottom + 'px';
2393
- }
2394
- else {
2395
- marginBottom = this.gridster.$options.margin + 'px';
2396
- }
2397
- }
2398
- if (this.gridster.columns === item.cols + item.x) {
2399
- if (this.gridster.$options.outerMarginBottom !== null) {
2400
- marginRight = this.gridster.$options.outerMarginRight + 'px';
2401
- }
2402
- else {
2403
- marginRight = this.gridster.$options.margin + 'px';
2404
- }
2405
- }
2406
- }
2407
- renderer.setStyle(el, 'margin-bottom', marginBottom);
2408
- renderer.setStyle(el, 'margin-right', marginRight);
2409
- }
2410
- }
2411
- updateGridster() {
2412
- let addClass = '';
2413
- let removeClass1 = '';
2414
- let removeClass2 = '';
2415
- let removeClass3 = '';
2416
- if (this.gridster.$options.gridType === GridType.Fit) {
2417
- addClass = GridType.Fit;
2418
- removeClass1 = GridType.ScrollVertical;
2419
- removeClass2 = GridType.ScrollHorizontal;
2420
- removeClass3 = GridType.Fixed;
2421
- }
2422
- else if (this.gridster.$options.gridType === GridType.ScrollVertical) {
2423
- this.gridster.curRowHeight = this.gridster.curColWidth;
2424
- addClass = GridType.ScrollVertical;
2425
- removeClass1 = GridType.Fit;
2426
- removeClass2 = GridType.ScrollHorizontal;
2427
- removeClass3 = GridType.Fixed;
2428
- }
2429
- else if (this.gridster.$options.gridType === GridType.ScrollHorizontal) {
2430
- this.gridster.curColWidth = this.gridster.curRowHeight;
2431
- addClass = GridType.ScrollHorizontal;
2432
- removeClass1 = GridType.Fit;
2433
- removeClass2 = GridType.ScrollVertical;
2434
- removeClass3 = GridType.Fixed;
2435
- }
2436
- else if (this.gridster.$options.gridType === GridType.Fixed) {
2437
- this.gridster.curColWidth = this.gridster.$options.fixedColWidth +
2438
- (this.gridster.$options.ignoreMarginInRow ? 0 : this.gridster.$options.margin);
2439
- this.gridster.curRowHeight = this.gridster.$options.fixedRowHeight +
2440
- (this.gridster.$options.ignoreMarginInRow ? 0 : this.gridster.$options.margin);
2441
- addClass = GridType.Fixed;
2442
- removeClass1 = GridType.Fit;
2443
- removeClass2 = GridType.ScrollVertical;
2444
- removeClass3 = GridType.ScrollHorizontal;
2445
- }
2446
- else if (this.gridster.$options.gridType === GridType.VerticalFixed) {
2447
- this.gridster.curRowHeight = this.gridster.$options.fixedRowHeight +
2448
- (this.gridster.$options.ignoreMarginInRow ? 0 : this.gridster.$options.margin);
2449
- addClass = GridType.ScrollVertical;
2450
- removeClass1 = GridType.Fit;
2451
- removeClass2 = GridType.ScrollHorizontal;
2452
- removeClass3 = GridType.Fixed;
2453
- }
2454
- else if (this.gridster.$options.gridType === GridType.HorizontalFixed) {
2455
- this.gridster.curColWidth = this.gridster.$options.fixedColWidth +
2456
- (this.gridster.$options.ignoreMarginInRow ? 0 : this.gridster.$options.margin);
2457
- addClass = GridType.ScrollHorizontal;
2458
- removeClass1 = GridType.Fit;
2459
- removeClass2 = GridType.ScrollVertical;
2460
- removeClass3 = GridType.Fixed;
2461
- }
2462
- if (this.gridster.mobile) {
2463
- this.gridster.renderer.removeClass(this.gridster.el, addClass);
2464
- }
2465
- else {
2466
- this.gridster.renderer.addClass(this.gridster.el, addClass);
2467
- }
2468
- this.gridster.renderer.removeClass(this.gridster.el, removeClass1);
2469
- this.gridster.renderer.removeClass(this.gridster.el, removeClass2);
2470
- this.gridster.renderer.removeClass(this.gridster.el, removeClass3);
2471
- }
2472
- getGridColumnStyle(i) {
2473
- return Object.assign({}, this.getLeftPosition(this.gridster.curColWidth * i), { width: this.gridster.curColWidth - this.gridster.$options.margin + 'px', height: this.gridster.gridRows.length * this.gridster.curRowHeight - this.gridster.$options.margin + 'px' });
2474
- }
2475
- getGridRowStyle(i) {
2476
- return Object.assign({}, this.getTopPosition(this.gridster.curRowHeight * i), { width: this.gridster.gridColumns.length * this.gridster.curColWidth - this.gridster.$options.margin + 'px', height: this.gridster.curRowHeight - this.gridster.$options.margin + 'px' });
2477
- }
2478
- getLeftPosition(d) {
2479
- if (this.gridster.$options.useTransformPositioning) {
2480
- return {
2481
- transform: 'translateX(' + d + 'px)',
2482
- };
2483
- }
2484
- else {
2485
- return {
2486
- left: (this.getLeftMargin() + d) + 'px'
2487
- };
2488
- }
2489
- }
2490
- getTopPosition(d) {
2491
- if (this.gridster.$options.useTransformPositioning) {
2492
- return {
2493
- transform: 'translateY(' + d + 'px)',
2494
- };
2495
- }
2496
- else {
2497
- return {
2498
- top: this.getTopMargin() + d + 'px'
2499
- };
2500
- }
2501
- }
2502
- clearCellPosition(renderer, el) {
2503
- if (this.gridster.$options.useTransformPositioning) {
2504
- renderer.setStyle(el, 'transform', '');
2505
- }
2506
- else {
2507
- renderer.setStyle(el, 'top', '');
2508
- renderer.setStyle(el, 'left', '');
2509
- }
2510
- }
2511
- setCellPosition(renderer, el, x, y) {
2512
- if (this.gridster.$options.useTransformPositioning) {
2513
- const transform = 'translate3d(' + x + 'px, ' + y + 'px, 0)';
2514
- renderer.setStyle(el, 'transform', transform);
2515
- }
2516
- else {
2517
- renderer.setStyle(el, 'left', this.getLeftMargin() + x + 'px');
2518
- renderer.setStyle(el, 'top', this.getTopMargin() + y + 'px');
2519
- }
2520
- }
2521
- getLeftMargin() {
2522
- if (this.gridster.$options.outerMargin) {
2523
- if (this.gridster.$options.outerMarginLeft !== null) {
2524
- return this.gridster.$options.outerMarginLeft;
2525
- }
2526
- else {
2527
- return this.gridster.$options.margin;
2528
- }
2529
- }
2530
- else {
2531
- return 0;
2532
- }
2533
- }
2534
- getTopMargin() {
2535
- if (this.gridster.$options.outerMargin) {
2536
- if (this.gridster.$options.outerMarginTop !== null) {
2537
- return this.gridster.$options.outerMarginTop;
2538
- }
2539
- else {
2540
- return this.gridster.$options.margin;
2541
- }
2542
- }
2543
- else {
2544
- return 0;
2545
- }
2546
- }
2547
- };
2548
- GridsterRenderer.ctorParameters = () => [
2549
- { type: GridsterComponentInterface }
2550
- ];
2551
- GridsterRenderer = __decorate([
2552
- Injectable(),
2553
- __metadata("design:paramtypes", [GridsterComponentInterface])
2554
- ], GridsterRenderer);
2555
-
2556
- var GridsterComponent_1;
2557
- let GridsterComponent = GridsterComponent_1 = class GridsterComponent {
2558
- constructor(el, renderer, cdRef, zone) {
2559
- this.renderer = renderer;
2560
- this.cdRef = cdRef;
2561
- this.zone = zone;
2562
- this.gridColumns = [];
2563
- this.gridRows = [];
2564
- this.el = el.nativeElement;
2565
- this.$options = JSON.parse(JSON.stringify(GridsterConfigService));
2566
- this.calculateLayoutDebounce = GridsterUtils.debounce(this.calculateLayout.bind(this), 0);
2567
- this.mobile = false;
2568
- this.curWidth = 0;
2569
- this.curHeight = 0;
2570
- this.grid = [];
2571
- this.curColWidth = 0;
2572
- this.curRowHeight = 0;
2573
- this.dragInProgress = false;
2574
- this.emptyCell = new GridsterEmptyCell(this);
2575
- this.compact = new GridsterCompact(this);
2576
- this.gridRenderer = new GridsterRenderer(this);
2577
- }
2578
- static checkCollisionTwoItems(item, item2) {
2579
- return item.x < item2.x + item2.cols
2580
- && item.x + item.cols > item2.x
2581
- && item.y < item2.y + item2.rows
2582
- && item.y + item.rows > item2.y;
2583
- }
2584
- ngOnInit() {
2585
- if (this.options.initCallback) {
2586
- this.options.initCallback(this);
2587
- }
2588
- }
2589
- ngOnChanges(changes) {
2590
- if (changes.options) {
2591
- this.setOptions();
2592
- this.options.api = {
2593
- optionsChanged: this.optionsChanged.bind(this),
2594
- resize: this.onResize.bind(this),
2595
- getNextPossiblePosition: this.getNextPossiblePosition.bind(this),
2596
- getFirstPossiblePosition: this.getFirstPossiblePosition.bind(this),
2597
- getLastPossiblePosition: this.getLastPossiblePosition.bind(this),
2598
- getCurrentRowHeight: this.getCurrentRowHeight.bind(this)
2599
- };
2600
- this.columns = this.$options.minCols;
2601
- this.rows = this.$options.minRows;
2602
- this.setGridSize();
2603
- this.calculateLayout();
2604
- }
2605
- }
2606
- getCurrentRowHeight() {
2607
- return this.curRowHeight;
2608
- }
2609
- resize() {
2610
- let height;
2611
- let width;
2612
- if (this.$options.gridType === 'fit' && !this.mobile) {
2613
- width = this.el.offsetWidth;
2614
- height = this.el.offsetHeight;
2615
- }
2616
- else {
2617
- width = this.el.clientWidth;
2618
- height = this.el.clientHeight;
2619
- }
2620
- if ((width !== this.curWidth || height !== this.curHeight) && this.checkIfToResize()) {
2621
- this.onResize();
2622
- }
2623
- }
2624
- setOptions() {
2625
- this.$options = GridsterUtils.merge(this.$options, this.options, this.$options);
2626
- if (!this.$options.disableWindowResize && !this.windowResize) {
2627
- this.windowResize = this.renderer.listen('window', 'resize', this.onResize.bind(this));
2628
- }
2629
- else if (this.$options.disableWindowResize && this.windowResize) {
2630
- this.windowResize();
2631
- this.windowResize = null;
2632
- }
2633
- this.emptyCell.updateOptions();
2634
- }
2635
- optionsChanged() {
2636
- this.setOptions();
2637
- let widgetsIndex = this.grid.length - 1, widget;
2638
- for (; widgetsIndex >= 0; widgetsIndex--) {
2639
- widget = this.grid[widgetsIndex];
2640
- widget.updateOptions();
2641
- }
2642
- this.calculateLayout();
2643
- }
2644
- ngOnDestroy() {
2645
- if (this.windowResize) {
2646
- this.windowResize();
2647
- }
2648
- if (this.options.destroyCallback) {
2649
- this.options.destroyCallback(this);
2650
- }
2651
- //if (this.options.api) {
2652
- /* this.options.api getting undefined for new dashboard load- temp fix
2653
- * on new dashboard area load, old dashboard area gets destroyed, but that leads to
2654
- * ondestroy of current this.options.api instance - needs to investigate further
2655
- */
2656
- if (false) {
2657
- this.options.api.resize = undefined;
2658
- this.options.api.optionsChanged = undefined;
2659
- this.options.api.getNextPossiblePosition = undefined;
2660
- this.options.api = undefined;
2661
- }
2662
- this.emptyCell.destroy();
2663
- delete this.emptyCell;
2664
- this.compact.destroy();
2665
- delete this.compact;
2666
- }
2667
- onResize() {
2668
- this.setGridSize();
2669
- this.calculateLayout();
2670
- }
2671
- checkIfToResize() {
2672
- const clientWidth = this.el.clientWidth;
2673
- const offsetWidth = this.el.offsetWidth;
2674
- const scrollWidth = this.el.scrollWidth;
2675
- const clientHeight = this.el.clientHeight;
2676
- const offsetHeight = this.el.offsetHeight;
2677
- const scrollHeight = this.el.scrollHeight;
2678
- const verticalScrollPresent = clientWidth < offsetWidth && scrollHeight > offsetHeight
2679
- && scrollHeight - offsetHeight < offsetWidth - clientWidth;
2680
- const horizontalScrollPresent = clientHeight < offsetHeight
2681
- && scrollWidth > offsetWidth && scrollWidth - offsetWidth < offsetHeight - clientHeight;
2682
- if (verticalScrollPresent) {
2683
- return false;
2684
- }
2685
- return !horizontalScrollPresent;
2686
- }
2687
- setGridSize() {
2688
- const el = this.el;
2689
- let width = el.clientWidth;
2690
- let height = el.clientHeight;
2691
- if (this.$options.setGridSize || this.$options.gridType === 'fit' && !this.mobile) {
2692
- width = el.offsetWidth;
2693
- height = el.offsetHeight;
2694
- }
2695
- else {
2696
- width = el.clientWidth;
2697
- height = el.clientHeight;
2698
- }
2699
- this.curWidth = width;
2700
- this.curHeight = height;
2701
- }
2702
- setGridDimensions() {
2703
- this.setGridSize();
2704
- if (!this.mobile && this.$options.mobileBreakpoint > this.curWidth) {
2705
- this.mobile = !this.mobile;
2706
- this.renderer.addClass(this.el, 'mobile');
2707
- }
2708
- else if (this.mobile && this.$options.mobileBreakpoint < this.curWidth) {
2709
- this.mobile = !this.mobile;
2710
- this.renderer.removeClass(this.el, 'mobile');
2711
- }
2712
- let rows = this.$options.minRows, columns = this.$options.minCols;
2713
- let widgetsIndex = this.grid.length - 1, widget;
2714
- for (; widgetsIndex >= 0; widgetsIndex--) {
2715
- widget = this.grid[widgetsIndex];
2716
- if (!widget.notPlaced) {
2717
- rows = Math.max(rows, widget.$item.y + widget.$item.rows);
2718
- columns = Math.max(columns, widget.$item.x + widget.$item.cols);
2719
- }
2720
- }
2721
- if (this.columns !== columns || this.rows !== rows) {
2722
- this.columns = columns;
2723
- this.rows = rows;
2724
- if (this.options.gridSizeChangedCallback) {
2725
- this.options.gridSizeChangedCallback(this);
2726
- }
2727
- }
2728
- }
2729
- calculateLayout() {
2730
- if (this.compact) {
2731
- this.compact.checkCompact();
2732
- }
2733
- this.setGridDimensions();
2734
- if (this.$options.outerMargin) {
2735
- let marginWidth = -this.$options.margin;
2736
- if (this.$options.outerMarginLeft !== null) {
2737
- marginWidth += this.$options.outerMarginLeft;
2738
- this.renderer.setStyle(this.el, 'padding-left', this.$options.outerMarginLeft + 'px');
2739
- }
2740
- else {
2741
- marginWidth += this.$options.margin;
2742
- this.renderer.setStyle(this.el, 'padding-left', this.$options.margin + 'px');
2743
- }
2744
- if (this.$options.outerMarginRight !== null) {
2745
- marginWidth += this.$options.outerMarginRight;
2746
- this.renderer.setStyle(this.el, 'padding-right', this.$options.outerMarginRight + 'px');
2747
- }
2748
- else {
2749
- marginWidth += this.$options.margin;
2750
- this.renderer.setStyle(this.el, 'padding-right', this.$options.margin + 'px');
2751
- }
2752
- this.curColWidth = (this.curWidth - marginWidth) / this.columns;
2753
- let marginHeight = -this.$options.margin;
2754
- if (this.$options.outerMarginTop !== null) {
2755
- marginHeight += this.$options.outerMarginTop;
2756
- this.renderer.setStyle(this.el, 'padding-top', this.$options.outerMarginTop + 'px');
2757
- }
2758
- else {
2759
- marginHeight += this.$options.margin;
2760
- this.renderer.setStyle(this.el, 'padding-top', this.$options.margin + 'px');
2761
- }
2762
- if (this.$options.outerMarginBottom !== null) {
2763
- marginHeight += this.$options.outerMarginBottom;
2764
- this.renderer.setStyle(this.el, 'padding-bottom', this.$options.outerMarginBottom + 'px');
2765
- }
2766
- else {
2767
- marginHeight += this.$options.margin;
2768
- this.renderer.setStyle(this.el, 'padding-bottom', this.$options.margin + 'px');
2769
- }
2770
- this.curRowHeight = (this.curHeight - marginHeight) / this.rows;
2771
- }
2772
- else {
2773
- this.curColWidth = (this.curWidth + this.$options.margin) / this.columns;
2774
- this.curRowHeight = (this.curHeight + this.$options.margin) / this.rows;
2775
- this.renderer.setStyle(this.el, 'padding-left', 0 + 'px');
2776
- this.renderer.setStyle(this.el, 'padding-right', 0 + 'px');
2777
- this.renderer.setStyle(this.el, 'padding-top', 0 + 'px');
2778
- this.renderer.setStyle(this.el, 'padding-bottom', 0 + 'px');
2779
- }
2780
- this.gridRenderer.updateGridster();
2781
- this.updateGrid();
2782
- if (this.$options.setGridSize) {
2783
- this.renderer.setStyle(this.el, 'width', (this.columns * this.curColWidth + this.$options.margin) + 'px');
2784
- this.renderer.setStyle(this.el, 'height', (this.rows * this.curRowHeight + this.$options.margin) + 'px');
2785
- }
2786
- else {
2787
- this.renderer.setStyle(this.el, 'width', '');
2788
- this.renderer.setStyle(this.el, 'height', '');
2789
- }
2790
- let widgetsIndex = this.grid.length - 1, widget;
2791
- for (; widgetsIndex >= 0; widgetsIndex--) {
2792
- widget = this.grid[widgetsIndex];
2793
- widget.setSize();
2794
- widget.drag.toggle();
2795
- widget.resize.toggle();
2796
- }
2797
- setTimeout(this.resize.bind(this), 100);
2798
- }
2799
- updateGrid() {
2800
- if (this.$options.displayGrid === 'always' && !this.mobile) {
2801
- this.renderer.addClass(this.el, 'display-grid');
2802
- }
2803
- else if (this.$options.displayGrid === 'onDrag&Resize' && this.dragInProgress) {
2804
- this.renderer.addClass(this.el, 'display-grid');
2805
- }
2806
- else if (this.$options.displayGrid === 'none' || !this.dragInProgress || this.mobile) {
2807
- this.renderer.removeClass(this.el, 'display-grid');
2808
- }
2809
- this.setGridDimensions();
2810
- this.gridColumns.length = Math.max(this.columns, Math.floor(this.curWidth / this.curColWidth)) || 0;
2811
- this.gridRows.length = Math.max(this.rows, Math.floor(this.curHeight / this.curRowHeight)) || 0;
2812
- this.cdRef.markForCheck();
2813
- }
2814
- addItem(itemComponent) {
2815
- if (itemComponent.$item.cols === undefined) {
2816
- itemComponent.$item.cols = this.$options.defaultItemCols;
2817
- itemComponent.item.cols = itemComponent.$item.cols;
2818
- itemComponent.itemChanged();
2819
- }
2820
- if (itemComponent.$item.rows === undefined) {
2821
- itemComponent.$item.rows = this.$options.defaultItemRows;
2822
- itemComponent.item.rows = itemComponent.$item.rows;
2823
- itemComponent.itemChanged();
2824
- }
2825
- if (itemComponent.$item.x === -1 || itemComponent.$item.y === -1) {
2826
- this.autoPositionItem(itemComponent);
2827
- }
2828
- else if (this.checkCollision(itemComponent.$item)) {
2829
- if (!this.$options.disableWarnings) {
2830
- itemComponent.notPlaced = true;
2831
- console.warn('Can\'t be placed in the bounds of the dashboard, trying to auto position!/n' +
2832
- JSON.stringify(itemComponent.item, ['cols', 'rows', 'x', 'y']));
2833
- }
2834
- if (!this.$options.disableAutoPositionOnConflict) {
2835
- this.autoPositionItem(itemComponent);
2836
- }
2837
- else {
2838
- itemComponent.notPlaced = true;
2839
- }
2840
- }
2841
- this.grid.push(itemComponent);
2842
- this.calculateLayoutDebounce();
2843
- }
2844
- removeItem(itemComponent) {
2845
- this.grid.splice(this.grid.indexOf(itemComponent), 1);
2846
- this.calculateLayoutDebounce();
2847
- if (this.options.itemRemovedCallback) {
2848
- this.options.itemRemovedCallback(itemComponent.item, itemComponent);
2849
- }
2850
- }
2851
- checkCollision(item) {
2852
- let collision = false;
2853
- if (this.options.itemValidateCallback) {
2854
- collision = !this.options.itemValidateCallback(item);
2855
- }
2856
- if (!collision && this.checkGridCollision(item)) {
2857
- collision = true;
2858
- }
2859
- if (!collision) {
2860
- const c = this.findItemWithItem(item);
2861
- if (c) {
2862
- collision = c;
2863
- }
2864
- }
2865
- return collision;
2866
- }
2867
- checkGridCollision(item) {
2868
- const noNegativePosition = item.y > -1 && item.x > -1;
2869
- const maxGridCols = item.cols + item.x <= this.$options.maxCols;
2870
- const maxGridRows = item.rows + item.y <= this.$options.maxRows;
2871
- const maxItemCols = item.maxItemCols === undefined ? this.$options.maxItemCols : item.maxItemCols;
2872
- const minItemCols = item.minItemCols === undefined ? this.$options.minItemCols : item.minItemCols;
2873
- const maxItemRows = item.maxItemRows === undefined ? this.$options.maxItemRows : item.maxItemRows;
2874
- const minItemRows = item.minItemRows === undefined ? this.$options.minItemRows : item.minItemRows;
2875
- const inColsLimits = item.cols <= maxItemCols && item.cols >= minItemCols;
2876
- const inRowsLimits = item.rows <= maxItemRows && item.rows >= minItemRows;
2877
- const minAreaLimit = item.minItemArea === undefined ? this.$options.minItemArea : item.minItemArea;
2878
- const maxAreaLimit = item.maxItemArea === undefined ? this.$options.maxItemArea : item.maxItemArea;
2879
- const area = item.cols * item.rows;
2880
- const inMinArea = minAreaLimit <= area;
2881
- const inMaxArea = maxAreaLimit >= area;
2882
- return !(noNegativePosition && maxGridCols && maxGridRows && inColsLimits && inRowsLimits && inMinArea && inMaxArea);
2883
- }
2884
- findItemWithItem(item) {
2885
- let widgetsIndex = this.grid.length - 1, widget;
2886
- for (; widgetsIndex > -1; widgetsIndex--) {
2887
- widget = this.grid[widgetsIndex];
2888
- if (widget.$item !== item && GridsterComponent_1.checkCollisionTwoItems(widget.$item, item)) {
2889
- return widget;
2890
- }
2891
- }
2892
- return false;
2893
- }
2894
- findItemsWithItem(item) {
2895
- const a = [];
2896
- let widgetsIndex = this.grid.length - 1, widget;
2897
- for (; widgetsIndex > -1; widgetsIndex--) {
2898
- widget = this.grid[widgetsIndex];
2899
- if (widget.$item !== item && GridsterComponent_1.checkCollisionTwoItems(widget.$item, item)) {
2900
- a.push(widget);
2901
- }
2902
- }
2903
- return a;
2904
- }
2905
- autoPositionItem(itemComponent) {
2906
- if (this.getNextPossiblePosition(itemComponent.$item)) {
2907
- itemComponent.notPlaced = false;
2908
- itemComponent.item.x = itemComponent.$item.x;
2909
- itemComponent.item.y = itemComponent.$item.y;
2910
- itemComponent.itemChanged();
2911
- }
2912
- else {
2913
- itemComponent.notPlaced = true;
2914
- if (!this.$options.disableWarnings) {
2915
- console.warn('Can\'t be placed in the bounds of the dashboard!/n' +
2916
- JSON.stringify(itemComponent.item, ['cols', 'rows', 'x', 'y']));
2917
- }
2918
- }
2919
- }
2920
- getNextPossiblePosition(newItem, startingFrom = {}) {
2921
- if (newItem.cols === -1) {
2922
- newItem.cols = this.$options.defaultItemCols;
2923
- }
2924
- if (newItem.rows === -1) {
2925
- newItem.rows = this.$options.defaultItemRows;
2926
- }
2927
- this.setGridDimensions();
2928
- let rowsIndex = startingFrom.y || 0, colsIndex;
2929
- for (; rowsIndex < this.rows; rowsIndex++) {
2930
- newItem.y = rowsIndex;
2931
- colsIndex = startingFrom.x || 0;
2932
- for (; colsIndex < this.columns; colsIndex++) {
2933
- newItem.x = colsIndex;
2934
- if (!this.checkCollision(newItem)) {
2935
- return true;
2936
- }
2937
- }
2938
- }
2939
- const canAddToRows = this.$options.maxRows >= this.rows + newItem.rows;
2940
- const canAddToColumns = this.$options.maxCols >= this.columns + newItem.cols;
2941
- const addToRows = this.rows <= this.columns && canAddToRows;
2942
- if (!addToRows && canAddToColumns) {
2943
- newItem.x = this.columns;
2944
- newItem.y = 0;
2945
- return true;
2946
- }
2947
- else if (canAddToRows) {
2948
- newItem.y = this.rows;
2949
- newItem.x = 0;
2950
- return true;
2951
- }
2952
- return false;
2953
- }
2954
- getFirstPossiblePosition(item) {
2955
- const tmpItem = Object.assign({}, item);
2956
- this.getNextPossiblePosition(tmpItem);
2957
- return tmpItem;
2958
- }
2959
- getLastPossiblePosition(item) {
2960
- let farthestItem = { y: 0, x: 0 };
2961
- farthestItem = this.grid.reduce((prev, curr) => {
2962
- const currCoords = { y: curr.$item.y + curr.$item.rows - 1, x: curr.$item.x + curr.$item.cols - 1 };
2963
- if (GridsterUtils.compareItems(prev, currCoords) === 1) {
2964
- return currCoords;
2965
- }
2966
- else {
2967
- return prev;
2968
- }
2969
- }, farthestItem);
2970
- const tmpItem = Object.assign({}, item);
2971
- this.getNextPossiblePosition(tmpItem, farthestItem);
2972
- return tmpItem;
2973
- }
2974
- pixelsToPositionX(x, roundingMethod, noLimit) {
2975
- const position = roundingMethod(x / this.curColWidth);
2976
- if (noLimit) {
2977
- return position;
2978
- }
2979
- else {
2980
- return Math.max(position, 0);
2981
- }
2982
- }
2983
- pixelsToPositionY(y, roundingMethod, noLimit) {
2984
- const position = roundingMethod(y / this.curRowHeight);
2985
- if (noLimit) {
2986
- return position;
2987
- }
2988
- else {
2989
- return Math.max(position, 0);
2990
- }
2991
- }
2992
- positionXToPixels(x) {
2993
- return x * this.curColWidth;
2994
- }
2995
- positionYToPixels(y) {
2996
- return y * this.curRowHeight;
2997
- }
2998
- };
2999
- GridsterComponent.ctorParameters = () => [
3000
- { type: ElementRef },
3001
- { type: Renderer2 },
3002
- { type: ChangeDetectorRef },
3003
- { type: NgZone }
3004
- ];
3005
- __decorate([
3006
- Input(),
3007
- __metadata("design:type", Object)
3008
- ], GridsterComponent.prototype, "options", void 0);
3009
- GridsterComponent = GridsterComponent_1 = __decorate([
3010
- Component({
3011
- selector: 'gridster',
3012
- template: "<div class=\"gridster-column\" *ngFor=\"let column of gridColumns; let i = index;\"\r\n [ngStyle]=\"gridRenderer.getGridColumnStyle(i)\"></div>\r\n<div class=\"gridster-row\" *ngFor=\"let row of gridRows; let i = index;\"\r\n [ngStyle]=\"gridRenderer.getGridRowStyle(i)\"></div>\r\n<ng-content></ng-content>\r\n<gridster-preview class=\"gridster-preview\"></gridster-preview>\r\n",
3013
- encapsulation: ViewEncapsulation.None,
3014
- styles: ["gridster{clear:both;position:relative;box-sizing:border-box;background:#fff;width:100%;height:100%;-webkit-user-select:none;-moz-user-select:none;user-select:none;display:block;overflow:auto}gridster.fit{overflow-x:hidden;overflow-y:hidden}gridster.scrollVertical{overflow-x:hidden;overflow-y:auto}gridster.scrollHorizontal{overflow-x:auto;overflow-y:hidden}gridster.fixed{overflow:auto}gridster.mobile{overflow-x:hidden;overflow-y:auto;flex-flow:column}gridster.mobile gridster-item{position:relative;width:100%!important;min-height:300px!important}gridster .gridster-column,gridster .gridster-row{position:absolute;display:none;transition:.3s;box-sizing:border-box}gridster.display-grid .gridster-column,gridster.display-grid .gridster-row{display:block}gridster .gridster-column{border-left:1px solid #ccc;border-right:1px solid #ccc}gridster .gridster-row{border-top:1px solid #ccc;border-bottom:1px solid #ccc}"]
3015
- }),
3016
- __metadata("design:paramtypes", [ElementRef, Renderer2, ChangeDetectorRef, NgZone])
3017
- ], GridsterComponent);
3018
-
3019
- class GridsterItemComponentInterface {
3020
- }
3021
-
3022
- let GridsterSwap = class GridsterSwap {
3023
- constructor(gridsterItem) {
3024
- this.gridsterItem = gridsterItem;
3025
- this.gridster = gridsterItem.gridster;
3026
- }
3027
- destroy() {
3028
- delete this.gridster;
3029
- delete this.gridsterItem;
3030
- delete this.swapedItem;
3031
- }
3032
- swapItems() {
3033
- if (this.gridster.$options.swap) {
3034
- this.checkSwapBack();
3035
- this.checkSwap(this.gridsterItem);
3036
- }
3037
- }
3038
- checkSwapBack() {
3039
- if (this.swapedItem) {
3040
- const x = this.swapedItem.$item.x;
3041
- const y = this.swapedItem.$item.y;
3042
- this.swapedItem.$item.x = this.swapedItem.item.x || 0;
3043
- this.swapedItem.$item.y = this.swapedItem.item.y || 0;
3044
- if (this.gridster.checkCollision(this.swapedItem.$item)) {
3045
- this.swapedItem.$item.x = x;
3046
- this.swapedItem.$item.y = y;
3047
- }
3048
- else {
3049
- this.swapedItem.setSize();
3050
- this.gridsterItem.$item.x = this.gridsterItem.item.x || 0;
3051
- this.gridsterItem.$item.y = this.gridsterItem.item.y || 0;
3052
- this.swapedItem = undefined;
3053
- }
3054
- }
3055
- }
3056
- restoreSwapItem() {
3057
- if (this.swapedItem) {
3058
- this.swapedItem.$item.x = this.swapedItem.item.x || 0;
3059
- this.swapedItem.$item.y = this.swapedItem.item.y || 0;
3060
- this.swapedItem.setSize();
3061
- this.swapedItem = undefined;
3062
- }
3063
- }
3064
- setSwapItem() {
3065
- if (this.swapedItem) {
3066
- this.swapedItem.checkItemChanges(this.swapedItem.$item, this.swapedItem.item);
3067
- this.swapedItem = undefined;
3068
- }
3069
- }
3070
- checkSwap(pushedBy) {
3071
- const gridsterItemCollision = this.gridster.checkCollision(pushedBy.$item);
3072
- if (gridsterItemCollision && gridsterItemCollision !== true && gridsterItemCollision.canBeDragged()) {
3073
- const gridsterItemCollide = gridsterItemCollision;
3074
- const copyCollisionX = gridsterItemCollide.$item.x;
3075
- const copyCollisionY = gridsterItemCollide.$item.y;
3076
- const copyX = pushedBy.$item.x;
3077
- const copyY = pushedBy.$item.y;
3078
- gridsterItemCollide.$item.x = pushedBy.item.x || 0;
3079
- gridsterItemCollide.$item.y = pushedBy.item.y || 0;
3080
- pushedBy.$item.x = gridsterItemCollide.item.x || 0;
3081
- pushedBy.$item.y = gridsterItemCollide.item.y || 0;
3082
- if (this.gridster.checkCollision(gridsterItemCollide.$item) || this.gridster.checkCollision(pushedBy.$item)) {
3083
- pushedBy.$item.x = copyX;
3084
- pushedBy.$item.y = copyY;
3085
- gridsterItemCollide.$item.x = copyCollisionX;
3086
- gridsterItemCollide.$item.y = copyCollisionY;
3087
- }
3088
- else {
3089
- gridsterItemCollide.setSize();
3090
- this.swapedItem = gridsterItemCollide;
3091
- }
3092
- }
3093
- }
3094
- };
3095
- GridsterSwap.ctorParameters = () => [
3096
- { type: GridsterItemComponentInterface }
3097
- ];
3098
- GridsterSwap = __decorate([
3099
- Injectable(),
3100
- __metadata("design:paramtypes", [GridsterItemComponentInterface])
3101
- ], GridsterSwap);
3102
-
3103
- let scrollSensitivity;
3104
- let scrollSpeed;
3105
- const intervalDuration = 50;
3106
- let gridsterElement;
3107
- let resizeEvent;
3108
- let resizeEventType;
3109
- let intervalE;
3110
- let intervalW;
3111
- let intervalN;
3112
- let intervalS;
3113
- function scroll(gridster, left, top, width, height, e, lastMouse, calculateItemPosition, resize, resizeEventScrollType) {
3114
- scrollSensitivity = gridster.$options.scrollSensitivity;
3115
- scrollSpeed = gridster.$options.scrollSpeed;
3116
- gridsterElement = gridster.el;
3117
- resizeEvent = resize;
3118
- resizeEventType = resizeEventScrollType;
3119
- const offsetWidth = gridsterElement.offsetWidth;
3120
- const offsetHeight = gridsterElement.offsetHeight;
3121
- const offsetLeft = gridsterElement.scrollLeft;
3122
- const offsetTop = gridsterElement.scrollTop;
3123
- const elemTopOffset = top - offsetTop;
3124
- const elemBottomOffset = offsetHeight + offsetTop - top - height;
3125
- if (lastMouse.clientY < e.clientY && elemBottomOffset < scrollSensitivity) {
3126
- cancelN();
3127
- if ((resizeEvent && resizeEventType && !resizeEventType.s) || intervalS) {
3128
- return;
3129
- }
3130
- intervalS = startVertical(1, calculateItemPosition, lastMouse);
3131
- }
3132
- else if (lastMouse.clientY > e.clientY && offsetTop > 0 && elemTopOffset < scrollSensitivity) {
3133
- cancelS();
3134
- if ((resizeEvent && resizeEventType && !resizeEventType.n) || intervalN) {
3135
- return;
3136
- }
3137
- intervalN = startVertical(-1, calculateItemPosition, lastMouse);
3138
- }
3139
- else if (lastMouse.clientY !== e.clientY) {
3140
- cancelVertical();
3141
- }
3142
- const elemRightOffset = offsetLeft + offsetWidth - left - width;
3143
- const elemLeftOffset = left - offsetLeft;
3144
- if (lastMouse.clientX < e.clientX && elemRightOffset <= scrollSensitivity) {
3145
- cancelW();
3146
- if ((resizeEvent && resizeEventType && !resizeEventType.e) || intervalE) {
3147
- return;
3148
- }
3149
- intervalE = startHorizontal(1, calculateItemPosition, lastMouse);
3150
- }
3151
- else if (lastMouse.clientX > e.clientX && offsetLeft > 0 && elemLeftOffset < scrollSensitivity) {
3152
- cancelE();
3153
- if ((resizeEvent && resizeEventType && !resizeEventType.w) || intervalW) {
3154
- return;
3155
- }
3156
- intervalW = startHorizontal(-1, calculateItemPosition, lastMouse);
3157
- }
3158
- else if (lastMouse.clientX !== e.clientX) {
3159
- cancelHorizontal();
3160
- }
3161
- }
3162
- function startVertical(sign, calculateItemPosition, lastMouse) {
3163
- let clientY = lastMouse.clientY;
3164
- return setInterval(() => {
3165
- if (!gridsterElement || sign === -1 && gridsterElement.scrollTop - scrollSpeed < 0) {
3166
- cancelVertical();
3167
- }
3168
- gridsterElement.scrollTop += sign * scrollSpeed;
3169
- clientY += sign * scrollSpeed;
3170
- calculateItemPosition({ clientX: lastMouse.clientX, clientY: clientY });
3171
- }, intervalDuration);
3172
- }
3173
- function startHorizontal(sign, calculateItemPosition, lastMouse) {
3174
- let clientX = lastMouse.clientX;
3175
- return setInterval(() => {
3176
- if (!gridsterElement || sign === -1 && gridsterElement.scrollLeft - scrollSpeed < 0) {
3177
- cancelHorizontal();
3178
- }
3179
- gridsterElement.scrollLeft += sign * scrollSpeed;
3180
- clientX += sign * scrollSpeed;
3181
- calculateItemPosition({ clientX: clientX, clientY: lastMouse.clientY });
3182
- }, intervalDuration);
3183
- }
3184
- function cancelScroll() {
3185
- cancelHorizontal();
3186
- cancelVertical();
3187
- gridsterElement = undefined;
3188
- }
3189
- function cancelHorizontal() {
3190
- cancelE();
3191
- cancelW();
3192
- }
3193
- function cancelVertical() {
3194
- cancelN();
3195
- cancelS();
3196
- }
3197
- function cancelE() {
3198
- if (intervalE) {
3199
- clearInterval(intervalE);
3200
- intervalE = 0;
3201
- }
3202
- }
3203
- function cancelW() {
3204
- if (intervalW) {
3205
- clearInterval(intervalW);
3206
- intervalW = 0;
3207
- }
3208
- }
3209
- function cancelS() {
3210
- if (intervalS) {
3211
- clearInterval(intervalS);
3212
- intervalS = 0;
3213
- }
3214
- }
3215
- function cancelN() {
3216
- if (intervalN) {
3217
- clearInterval(intervalN);
3218
- intervalN = 0;
3219
- }
3220
- }
3221
-
3222
- let GridsterPush = class GridsterPush {
3223
- constructor(gridsterItem) {
3224
- this.pushedItems = [];
3225
- this.pushedItemsTemp = [];
3226
- this.pushedItemsTempPath = [];
3227
- this.pushedItemsPath = [];
3228
- this.gridsterItem = gridsterItem;
3229
- this.gridster = gridsterItem.gridster;
3230
- this.tryPattern = {
3231
- fromEast: [this.tryWest, this.trySouth, this.tryNorth, this.tryEast],
3232
- fromWest: [this.tryEast, this.trySouth, this.tryNorth, this.tryWest],
3233
- fromNorth: [this.trySouth, this.tryEast, this.tryWest, this.tryNorth],
3234
- fromSouth: [this.tryNorth, this.tryEast, this.tryWest, this.trySouth]
3235
- };
3236
- this.fromSouth = 'fromSouth';
3237
- this.fromNorth = 'fromNorth';
3238
- this.fromEast = 'fromEast';
3239
- this.fromWest = 'fromWest';
3240
- }
3241
- destroy() {
3242
- delete this.gridster;
3243
- delete this.gridsterItem;
3244
- }
3245
- pushItems(direction, disable) {
3246
- if (this.gridster.$options.pushItems && !disable) {
3247
- this.pushedItemsOrder = [];
3248
- const pushed = this.push(this.gridsterItem, direction);
3249
- if (!pushed) {
3250
- this.restoreTempItems();
3251
- }
3252
- this.pushedItemsOrder = [];
3253
- this.pushedItemsTemp = [];
3254
- this.pushedItemsTempPath = [];
3255
- return pushed;
3256
- }
3257
- else {
3258
- return false;
3259
- }
3260
- }
3261
- restoreTempItems() {
3262
- let i = this.pushedItemsTemp.length - 1;
3263
- for (; i > -1; i--) {
3264
- this.removeFromTempPushed(this.pushedItemsTemp[i]);
3265
- }
3266
- }
3267
- restoreItems() {
3268
- let i = 0;
3269
- const l = this.pushedItems.length;
3270
- let pushedItem;
3271
- for (; i < l; i++) {
3272
- pushedItem = this.pushedItems[i];
3273
- pushedItem.$item.x = pushedItem.item.x || 0;
3274
- pushedItem.$item.y = pushedItem.item.y || 0;
3275
- pushedItem.setSize();
3276
- }
3277
- this.pushedItems = [];
3278
- this.pushedItemsPath = [];
3279
- }
3280
- setPushedItems() {
3281
- let i = 0;
3282
- const l = this.pushedItems.length;
3283
- let pushedItem;
3284
- for (; i < l; i++) {
3285
- pushedItem = this.pushedItems[i];
3286
- pushedItem.checkItemChanges(pushedItem.$item, pushedItem.item);
3287
- }
3288
- this.pushedItems = [];
3289
- this.pushedItemsPath = [];
3290
- }
3291
- checkPushBack() {
3292
- let i = this.pushedItems.length - 1;
3293
- let change = false;
3294
- for (; i > -1; i--) {
3295
- if (this.checkPushedItem(this.pushedItems[i], i)) {
3296
- change = true;
3297
- }
3298
- }
3299
- if (change) {
3300
- this.checkPushBack();
3301
- }
3302
- }
3303
- push(gridsterItem, direction) {
3304
- if (this.gridster.checkGridCollision(gridsterItem.$item)) {
3305
- return false;
3306
- }
3307
- if (direction === '') {
3308
- return false;
3309
- }
3310
- const a = this.gridster.findItemsWithItem(gridsterItem.$item);
3311
- let i = a.length - 1, itemCollision;
3312
- let makePush = true;
3313
- const b = [];
3314
- for (; i > -1; i--) {
3315
- itemCollision = a[i];
3316
- if (itemCollision === this.gridsterItem) {
3317
- makePush = false;
3318
- break;
3319
- }
3320
- if (!itemCollision.canBeDragged()) {
3321
- makePush = false;
3322
- break;
3323
- }
3324
- const compare = this.pushedItemsTemp.find((el) => {
3325
- return el.$item.x === itemCollision.$item.x && el.$item.y === itemCollision.$item.y;
3326
- });
3327
- if (compare) {
3328
- makePush = false;
3329
- break;
3330
- }
3331
- if (this.tryPattern[direction][0].call(this, itemCollision, gridsterItem)) {
3332
- this.pushedItemsOrder.push(itemCollision);
3333
- b.push(itemCollision);
3334
- }
3335
- else if (this.tryPattern[direction][1].call(this, itemCollision, gridsterItem)) {
3336
- this.pushedItemsOrder.push(itemCollision);
3337
- b.push(itemCollision);
3338
- }
3339
- else if (this.tryPattern[direction][2].call(this, itemCollision, gridsterItem)) {
3340
- this.pushedItemsOrder.push(itemCollision);
3341
- b.push(itemCollision);
3342
- }
3343
- else if (this.tryPattern[direction][3].call(this, itemCollision, gridsterItem)) {
3344
- this.pushedItemsOrder.push(itemCollision);
3345
- b.push(itemCollision);
3346
- }
3347
- else {
3348
- makePush = false;
3349
- break;
3350
- }
3351
- }
3352
- if (!makePush) {
3353
- i = this.pushedItemsOrder.lastIndexOf(b[0]);
3354
- if (i > -1) {
3355
- let j = this.pushedItemsOrder.length - 1;
3356
- for (; j >= i; j--) {
3357
- itemCollision = this.pushedItemsOrder[j];
3358
- this.pushedItemsOrder.pop();
3359
- this.removeFromTempPushed(itemCollision);
3360
- this.removeFromPushedItem(itemCollision);
3361
- }
3362
- }
3363
- }
3364
- return makePush;
3365
- }
3366
- trySouth(gridsterItemCollide, gridsterItem) {
3367
- if (!this.gridster.$options.pushDirections.south) {
3368
- return false;
3369
- }
3370
- this.addToTempPushed(gridsterItemCollide);
3371
- gridsterItemCollide.$item.y = gridsterItem.$item.y + gridsterItem.$item.rows;
3372
- if (this.push(gridsterItemCollide, this.fromNorth)) {
3373
- gridsterItemCollide.setSize();
3374
- this.addToPushed(gridsterItemCollide);
3375
- return true;
3376
- }
3377
- else {
3378
- this.removeFromTempPushed(gridsterItemCollide);
3379
- }
3380
- return false;
3381
- }
3382
- tryNorth(gridsterItemCollide, gridsterItem) {
3383
- if (!this.gridster.$options.pushDirections.north) {
3384
- return false;
3385
- }
3386
- this.addToTempPushed(gridsterItemCollide);
3387
- gridsterItemCollide.$item.y = gridsterItem.$item.y - gridsterItemCollide.$item.rows;
3388
- if (this.push(gridsterItemCollide, this.fromSouth)) {
3389
- gridsterItemCollide.setSize();
3390
- this.addToPushed(gridsterItemCollide);
3391
- return true;
3392
- }
3393
- else {
3394
- this.removeFromTempPushed(gridsterItemCollide);
3395
- }
3396
- return false;
3397
- }
3398
- tryEast(gridsterItemCollide, gridsterItem) {
3399
- if (!this.gridster.$options.pushDirections.east) {
3400
- return false;
3401
- }
3402
- this.addToTempPushed(gridsterItemCollide);
3403
- gridsterItemCollide.$item.x = gridsterItem.$item.x + gridsterItem.$item.cols;
3404
- if (this.push(gridsterItemCollide, this.fromWest)) {
3405
- gridsterItemCollide.setSize();
3406
- this.addToPushed(gridsterItemCollide);
3407
- return true;
3408
- }
3409
- else {
3410
- this.removeFromTempPushed(gridsterItemCollide);
3411
- }
3412
- return false;
3413
- }
3414
- tryWest(gridsterItemCollide, gridsterItem) {
3415
- if (!this.gridster.$options.pushDirections.west) {
3416
- return false;
3417
- }
3418
- this.addToTempPushed(gridsterItemCollide);
3419
- gridsterItemCollide.$item.x = gridsterItem.$item.x - gridsterItemCollide.$item.cols;
3420
- if (this.push(gridsterItemCollide, this.fromEast)) {
3421
- gridsterItemCollide.setSize();
3422
- this.addToPushed(gridsterItemCollide);
3423
- return true;
3424
- }
3425
- else {
3426
- this.removeFromTempPushed(gridsterItemCollide);
3427
- }
3428
- return false;
3429
- }
3430
- addToTempPushed(gridsterItem) {
3431
- let i = this.pushedItemsTemp.indexOf(gridsterItem);
3432
- if (i === -1) {
3433
- i = this.pushedItemsTemp.push(gridsterItem) - 1;
3434
- this.pushedItemsTempPath[i] = [];
3435
- }
3436
- this.pushedItemsTempPath[i].push({ x: gridsterItem.$item.x, y: gridsterItem.$item.y });
3437
- }
3438
- removeFromTempPushed(gridsterItem) {
3439
- const i = this.pushedItemsTemp.indexOf(gridsterItem);
3440
- const tempPosition = this.pushedItemsTempPath[i].pop();
3441
- if (!tempPosition) {
3442
- return;
3443
- }
3444
- gridsterItem.$item.x = tempPosition.x;
3445
- gridsterItem.$item.y = tempPosition.y;
3446
- gridsterItem.setSize();
3447
- if (!this.pushedItemsTempPath[i].length) {
3448
- this.pushedItemsTemp.splice(i, 1);
3449
- this.pushedItemsTempPath.splice(i, 1);
3450
- }
3451
- }
3452
- addToPushed(gridsterItem) {
3453
- if (this.pushedItems.indexOf(gridsterItem) < 0) {
3454
- this.pushedItems.push(gridsterItem);
3455
- this.pushedItemsPath.push([{ x: gridsterItem.item.x || 0, y: gridsterItem.item.y || 0 },
3456
- { x: gridsterItem.$item.x, y: gridsterItem.$item.y }]);
3457
- }
3458
- else {
3459
- const i = this.pushedItems.indexOf(gridsterItem);
3460
- this.pushedItemsPath[i].push({ x: gridsterItem.$item.x, y: gridsterItem.$item.y });
3461
- }
3462
- }
3463
- removeFromPushed(i) {
3464
- if (i > -1) {
3465
- this.pushedItems.splice(i, 1);
3466
- this.pushedItemsPath.splice(i, 1);
3467
- }
3468
- }
3469
- removeFromPushedItem(gridsterItem) {
3470
- const i = this.pushedItems.indexOf(gridsterItem);
3471
- if (i > -1) {
3472
- this.pushedItemsPath[i].pop();
3473
- if (!this.pushedItemsPath.length) {
3474
- this.pushedItems.splice(i, 1);
3475
- this.pushedItemsPath.splice(i, 1);
3476
- }
3477
- }
3478
- }
3479
- checkPushedItem(pushedItem, i) {
3480
- const path = this.pushedItemsPath[i];
3481
- let j = path.length - 2;
3482
- let lastPosition, x, y;
3483
- let change = false;
3484
- for (; j > -1; j--) {
3485
- lastPosition = path[j];
3486
- x = pushedItem.$item.x;
3487
- y = pushedItem.$item.y;
3488
- pushedItem.$item.x = lastPosition.x;
3489
- pushedItem.$item.y = lastPosition.y;
3490
- if (!this.gridster.findItemWithItem(pushedItem.$item)) {
3491
- pushedItem.setSize();
3492
- path.splice(j + 1, path.length - j - 1);
3493
- change = true;
3494
- }
3495
- else {
3496
- pushedItem.$item.x = x;
3497
- pushedItem.$item.y = y;
3498
- }
3499
- }
3500
- if (path.length < 2) {
3501
- this.removeFromPushed(i);
3502
- }
3503
- return change;
3504
- }
3505
- };
3506
- GridsterPush.ctorParameters = () => [
3507
- { type: GridsterItemComponentInterface }
3508
- ];
3509
- GridsterPush = __decorate([
3510
- Injectable(),
3511
- __metadata("design:paramtypes", [GridsterItemComponentInterface])
3512
- ], GridsterPush);
3513
-
3514
- let GridsterDraggable = class GridsterDraggable {
3515
- constructor(gridsterItem, gridster, zone) {
3516
- this.zone = zone;
3517
- this.collision = false;
3518
- this.gridsterItem = gridsterItem;
3519
- this.gridster = gridster;
3520
- this.lastMouse = {
3521
- clientX: 0,
3522
- clientY: 0
3523
- };
3524
- this.path = [];
3525
- }
3526
- destroy() {
3527
- if (this.gridster.previewStyle) {
3528
- this.gridster.previewStyle(true);
3529
- }
3530
- delete this.gridsterItem;
3531
- delete this.gridster;
3532
- delete this.collision;
3533
- if (this.mousedown) {
3534
- this.mousedown();
3535
- this.touchstart();
3536
- }
3537
- }
3538
- dragStart(e) {
3539
- switch (e.which) {
3540
- case 1:
3541
- // left mouse button
3542
- break;
3543
- case 2:
3544
- case 3:
3545
- // right or middle mouse button
3546
- return;
3547
- }
3548
- if (this.gridster.options.draggable && this.gridster.options.draggable.start) {
3549
- this.gridster.options.draggable.start(this.gridsterItem.item, this.gridsterItem, e);
3550
- }
3551
- e.stopPropagation();
3552
- e.preventDefault();
3553
- this.dragFunction = this.dragMove.bind(this);
3554
- this.dragStopFunction = this.dragStop.bind(this);
3555
- this.zone.runOutsideAngular(() => {
3556
- this.mousemove = this.gridsterItem.renderer.listen('document', 'mousemove', this.dragFunction);
3557
- this.touchmove = this.gridster.renderer.listen(this.gridster.el, 'touchmove', this.dragFunction);
3558
- });
3559
- this.mouseup = this.gridsterItem.renderer.listen('document', 'mouseup', this.dragStopFunction);
3560
- this.mouseleave = this.gridsterItem.renderer.listen('document', 'mouseleave', this.dragStopFunction);
3561
- this.cancelOnBlur = this.gridsterItem.renderer.listen('window', 'blur', this.dragStopFunction);
3562
- this.touchend = this.gridsterItem.renderer.listen('document', 'touchend', this.dragStopFunction);
3563
- this.touchcancel = this.gridsterItem.renderer.listen('document', 'touchcancel', this.dragStopFunction);
3564
- this.gridsterItem.renderer.addClass(this.gridsterItem.el, 'gridster-item-moving');
3565
- this.margin = this.gridster.$options.margin;
3566
- this.offsetLeft = this.gridster.el.scrollLeft - this.gridster.el.offsetLeft;
3567
- this.offsetTop = this.gridster.el.scrollTop - this.gridster.el.offsetTop;
3568
- this.left = this.gridsterItem.left - this.margin;
3569
- this.top = this.gridsterItem.top - this.margin;
3570
- this.width = this.gridsterItem.width;
3571
- this.height = this.gridsterItem.height;
3572
- this.diffLeft = e.clientX + this.offsetLeft - this.margin - this.left;
3573
- this.diffTop = e.clientY + this.offsetTop - this.margin - this.top;
3574
- this.gridster.movingItem = this.gridsterItem.$item;
3575
- this.gridster.previewStyle(true);
3576
- this.push = new GridsterPush(this.gridsterItem);
3577
- this.swap = new GridsterSwap(this.gridsterItem);
3578
- this.gridster.dragInProgress = true;
3579
- this.gridster.updateGrid();
3580
- this.path.push({ x: this.gridsterItem.item.x || 0, y: this.gridsterItem.item.y || 0 });
3581
- }
3582
- dragMove(e) {
3583
- e.stopPropagation();
3584
- e.preventDefault();
3585
- GridsterUtils.checkTouchEvent(e);
3586
- this.offsetLeft = this.gridster.el.scrollLeft - this.gridster.el.offsetLeft;
3587
- this.offsetTop = this.gridster.el.scrollTop - this.gridster.el.offsetTop;
3588
- scroll(this.gridster, this.left, this.top, this.width, this.height, e, this.lastMouse, this.calculateItemPositionFromMousePosition.bind(this));
3589
- this.calculateItemPositionFromMousePosition(e);
3590
- }
3591
- calculateItemPositionFromMousePosition(e) {
3592
- this.left = e.clientX + this.offsetLeft - this.diffLeft;
3593
- this.top = e.clientY + this.offsetTop - this.diffTop;
3594
- this.calculateItemPosition();
3595
- this.lastMouse.clientX = e.clientX;
3596
- this.lastMouse.clientY = e.clientY;
3597
- this.zone.run(() => {
3598
- this.gridster.updateGrid();
3599
- });
3600
- }
3601
- dragStop(e) {
3602
- e.stopPropagation();
3603
- e.preventDefault();
3604
- cancelScroll();
3605
- this.cancelOnBlur();
3606
- this.mousemove();
3607
- this.mouseup();
3608
- this.mouseleave();
3609
- this.touchmove();
3610
- this.touchend();
3611
- this.touchcancel();
3612
- this.gridsterItem.renderer.removeClass(this.gridsterItem.el, 'gridster-item-moving');
3613
- this.gridster.dragInProgress = false;
3614
- this.gridster.updateGrid();
3615
- this.path = [];
3616
- if (this.gridster.options.draggable && this.gridster.options.draggable.stop) {
3617
- Promise.resolve(this.gridster.options.draggable.stop(this.gridsterItem.item, this.gridsterItem, e))
3618
- .then(this.makeDrag.bind(this), this.cancelDrag.bind(this));
3619
- }
3620
- else {
3621
- this.makeDrag();
3622
- }
3623
- setTimeout(() => {
3624
- if (this.gridster) {
3625
- this.gridster.movingItem = null;
3626
- this.gridster.previewStyle(true);
3627
- }
3628
- });
3629
- }
3630
- cancelDrag() {
3631
- this.gridsterItem.$item.x = this.gridsterItem.item.x || 0;
3632
- this.gridsterItem.$item.y = this.gridsterItem.item.y || 0;
3633
- this.gridsterItem.setSize();
3634
- if (this.push) {
3635
- this.push.restoreItems();
3636
- }
3637
- if (this.swap) {
3638
- this.swap.restoreSwapItem();
3639
- }
3640
- if (this.push) {
3641
- this.push.destroy();
3642
- delete this.push;
3643
- }
3644
- if (this.swap) {
3645
- this.swap.destroy();
3646
- delete this.swap;
3647
- }
3648
- }
3649
- makeDrag() {
3650
- if (this.gridster.$options.draggable.dropOverItems && this.gridster.options.draggable
3651
- && this.gridster.options.draggable.dropOverItemsCallback
3652
- && this.collision && this.collision !== true && this.collision.$item) {
3653
- this.gridster.options.draggable.dropOverItemsCallback(this.gridsterItem.item, this.collision.item, this.gridster);
3654
- }
3655
- this.collision = false;
3656
- this.gridsterItem.setSize();
3657
- this.gridsterItem.checkItemChanges(this.gridsterItem.$item, this.gridsterItem.item);
3658
- if (this.push) {
3659
- this.push.setPushedItems();
3660
- }
3661
- if (this.swap) {
3662
- this.swap.setSwapItem();
3663
- }
3664
- if (this.push) {
3665
- this.push.destroy();
3666
- delete this.push;
3667
- }
3668
- if (this.swap) {
3669
- this.swap.destroy();
3670
- delete this.swap;
3671
- }
3672
- }
3673
- checkforavailableSpaceintheArea() {
3674
- let itemRowsbackup = this.gridsterItem.$item.rows;
3675
- let itemColsbackup = this.gridsterItem.$item.cols;
3676
- this.gridsterItem.$item.x = this.positionX;
3677
- this.gridsterItem.$item.y = this.positionY;
3678
- /** isCollide = 2 - no collision */
3679
- var isCollide = 1;
3680
- /** To iterate over the width of the gridster iTem and to check for collision */
3681
- do {
3682
- this.gridsterItem.$item.rows = itemRowsbackup;
3683
- /** To iterate over the height of the gridster Item and check for collision */
3684
- for (let rowcount = this.gridsterItem.$item.rows; rowcount >= 15; rowcount--) {
3685
- if (!this.gridster.checkCollision(this.gridsterItem.$item)) {
3686
- isCollide = 2;
3687
- break;
3688
- }
3689
- else { /** has collision - check with x-1 position and*/
3690
- let rowbkup = this.gridsterItem.$item.x;
3691
- let lastPossiblePositionX = this.gridsterItem.$item.x;
3692
- do {
3693
- this.gridsterItem.$item.x = this.gridsterItem.$item.x - 1;
3694
- if (!this.gridster.checkCollision(this.gridsterItem.$item)) {
3695
- lastPossiblePositionX = this.gridsterItem.$item.x;
3696
- }
3697
- else {
3698
- this.gridsterItem.$item.x = lastPossiblePositionX;
3699
- let originalCols = this.gridsterItem.$item.cols;
3700
- let lastPossibleCols = this.gridsterItem.$item.cols;
3701
- do {
3702
- this.gridsterItem.$item.cols = this.gridsterItem.$item.cols + 1;
3703
- if (this.gridster.checkCollision(this.gridsterItem.$item)) {
3704
- this.gridsterItem.$item.cols = lastPossibleCols;
3705
- break;
3706
- }
3707
- else {
3708
- lastPossibleCols = this.gridsterItem.$item.cols;
3709
- }
3710
- } while (this.gridsterItem.$item.cols - originalCols < 15);
3711
- break;
3712
- }
3713
- } while (this.gridsterItem.$item.x > 0);
3714
- if (this.gridster.checkCollision(this.gridsterItem.$item)) {
3715
- this.gridsterItem.$item.rows = this.gridsterItem.$item.rows - 1;
3716
- this.gridsterItem.$item.x = rowbkup;
3717
- }
3718
- else {
3719
- isCollide = 2;
3720
- break;
3721
- }
3722
- }
3723
- }
3724
- if (isCollide == 2) {
3725
- break;
3726
- }
3727
- this.gridsterItem.$item.cols = this.gridsterItem.$item.cols - 1;
3728
- } while (this.gridsterItem.$item.cols >= 15);
3729
- // while (this.gridsterItem.$item.rows>=15 || this.gridsterItem.$item.cols>=15);
3730
- if (isCollide == 1) {
3731
- this.gridsterItem.$item.x = this.positionXBackup;
3732
- this.gridsterItem.$item.y = this.positionYBackup;
3733
- this.gridsterItem.$item.cols = itemColsbackup;
3734
- this.gridsterItem.$item.rows = itemRowsbackup;
3735
- }
3736
- else {
3737
- // this.gridsterItem.item.rows=this.gridsterItem.$item.rows;
3738
- // this.gridsterItem.item.cols=this.gridsterItem.$item.cols;
3739
- }
3740
- return this.gridsterItem.$item;
3741
- }
3742
- calculateItemPosition() {
3743
- this.gridster.movingItem = this.gridsterItem.$item;
3744
- this.positionX = this.gridster.pixelsToPositionX(this.left, Math.round);
3745
- this.positionY = this.gridster.pixelsToPositionY(this.top, Math.round);
3746
- this.positionXBackup = this.gridsterItem.$item.x;
3747
- this.positionYBackup = this.gridsterItem.$item.y;
3748
- this.gridsterItem.$item.x = this.positionX;
3749
- if (this.gridster.checkGridCollision(this.gridsterItem.$item)) {
3750
- this.gridsterItem.$item.x = this.positionXBackup;
3751
- }
3752
- this.gridsterItem.$item.y = this.positionY;
3753
- if (this.gridster.checkGridCollision(this.gridsterItem.$item)) {
3754
- this.gridsterItem.$item.y = this.positionYBackup;
3755
- }
3756
- if (this.gridster.options.autoResizeonDrag) {
3757
- this.gridsterItem.$item = this.checkforavailableSpaceintheArea();
3758
- this.gridsterItem.setSize();
3759
- }
3760
- this.gridster.gridRenderer.setCellPosition(this.gridsterItem.renderer, this.gridsterItem.el, this.left, this.top);
3761
- if (this.positionXBackup !== this.gridsterItem.$item.x || this.positionYBackup !== this.gridsterItem.$item.y) {
3762
- const lastPosition = this.path[this.path.length - 1];
3763
- let direction = '';
3764
- if (lastPosition.x < this.gridsterItem.$item.x) {
3765
- direction = this.push.fromWest;
3766
- }
3767
- else if (lastPosition.x > this.gridsterItem.$item.x) {
3768
- direction = this.push.fromEast;
3769
- }
3770
- else if (lastPosition.y < this.gridsterItem.$item.y) {
3771
- direction = this.push.fromNorth;
3772
- }
3773
- else if (lastPosition.y > this.gridsterItem.$item.y) {
3774
- direction = this.push.fromSouth;
3775
- }
3776
- this.push.pushItems(direction, this.gridster.$options.disablePushOnDrag);
3777
- this.swap.swapItems();
3778
- this.collision = this.gridster.checkCollision(this.gridsterItem.$item);
3779
- if (this.collision) {
3780
- this.gridsterItem.$item.x = this.positionXBackup;
3781
- this.gridsterItem.$item.y = this.positionYBackup;
3782
- if (this.gridster.$options.draggable.dropOverItems && this.collision !== true && this.collision.$item) {
3783
- this.gridster.movingItem = null;
3784
- }
3785
- }
3786
- else {
3787
- this.path.push({ x: this.gridsterItem.$item.x, y: this.gridsterItem.$item.y });
3788
- }
3789
- this.push.checkPushBack();
3790
- }
3791
- this.gridster.previewStyle(true);
3792
- }
3793
- toggle() {
3794
- const enableDrag = this.gridsterItem.canBeDragged();
3795
- if (!this.enabled && enableDrag) {
3796
- this.enabled = !this.enabled;
3797
- this.dragStartFunction = this.dragStartDelay.bind(this);
3798
- this.mousedown = this.gridsterItem.renderer.listen(this.gridsterItem.el, 'mousedown', this.dragStartFunction);
3799
- this.touchstart = this.gridsterItem.renderer.listen(this.gridsterItem.el, 'touchstart', this.dragStartFunction);
3800
- }
3801
- else if (this.enabled && !enableDrag) {
3802
- this.enabled = !this.enabled;
3803
- this.mousedown();
3804
- this.touchstart();
3805
- }
3806
- }
3807
- dragStartDelay(e) {
3808
- if (e.target.hasAttribute('class') && e.target.getAttribute('class').split(' ').indexOf('gridster-item-resizable-handler') > -1) {
3809
- return;
3810
- }
3811
- if (GridsterUtils.checkContentClassForEvent(this.gridster, e)) {
3812
- return;
3813
- }
3814
- GridsterUtils.checkTouchEvent(e);
3815
- if (!this.gridster.$options.draggable.delayStart) {
3816
- this.dragStart(e);
3817
- return;
3818
- }
3819
- const timeout = setTimeout(() => {
3820
- this.dragStart(e);
3821
- cancelDrag();
3822
- }, this.gridster.$options.draggable.delayStart);
3823
- const cancelMouse = this.gridsterItem.renderer.listen('document', 'mouseup', cancelDrag);
3824
- const cancelMouseLeave = this.gridsterItem.renderer.listen('document', 'mouseleave', cancelDrag);
3825
- const cancelOnBlur = this.gridsterItem.renderer.listen('window', 'blur', cancelDrag);
3826
- const cancelTouchMove = this.gridsterItem.renderer.listen('document', 'touchmove', cancelMove);
3827
- const cancelTouchEnd = this.gridsterItem.renderer.listen('document', 'touchend', cancelDrag);
3828
- const cancelTouchCancel = this.gridsterItem.renderer.listen('document', 'touchcancel', cancelDrag);
3829
- function cancelMove(eventMove) {
3830
- GridsterUtils.checkTouchEvent(eventMove);
3831
- if (Math.abs(eventMove.clientX - e.clientX) > 9 || Math.abs(eventMove.clientY - e.clientY) > 9) {
3832
- cancelDrag();
3833
- }
3834
- }
3835
- function cancelDrag() {
3836
- clearTimeout(timeout);
3837
- cancelOnBlur();
3838
- cancelMouse();
3839
- cancelMouseLeave();
3840
- cancelTouchMove();
3841
- cancelTouchEnd();
3842
- cancelTouchCancel();
3843
- }
3844
- }
3845
- };
3846
- GridsterDraggable.ctorParameters = () => [
3847
- { type: GridsterItemComponentInterface },
3848
- { type: GridsterComponentInterface },
3849
- { type: NgZone }
3850
- ];
3851
- GridsterDraggable = __decorate([
3852
- Injectable(),
3853
- __metadata("design:paramtypes", [GridsterItemComponentInterface, GridsterComponentInterface, NgZone])
3854
- ], GridsterDraggable);
3855
-
3856
- let GridsterPushResize = class GridsterPushResize {
3857
- constructor(gridsterItem) {
3858
- this.pushedItems = [];
3859
- this.pushedItemsPath = [];
3860
- this.gridsterItem = gridsterItem;
3861
- this.gridster = gridsterItem.gridster;
3862
- this.tryPattern = {
3863
- fromEast: this.tryWest,
3864
- fromWest: this.tryEast,
3865
- fromNorth: this.trySouth,
3866
- fromSouth: this.tryNorth
3867
- };
3868
- this.fromSouth = 'fromSouth';
3869
- this.fromNorth = 'fromNorth';
3870
- this.fromEast = 'fromEast';
3871
- this.fromWest = 'fromWest';
3872
- }
3873
- destroy() {
3874
- delete this.gridster;
3875
- delete this.gridsterItem;
3876
- }
3877
- pushItems(direction) {
3878
- if (this.gridster.$options.pushResizeItems) {
3879
- return this.push(this.gridsterItem, direction);
3880
- }
3881
- else {
3882
- return false;
3883
- }
3884
- }
3885
- restoreItems() {
3886
- let i = 0;
3887
- const l = this.pushedItems.length;
3888
- let pushedItem;
3889
- for (; i < l; i++) {
3890
- pushedItem = this.pushedItems[i];
3891
- pushedItem.$item.x = pushedItem.item.x || 0;
3892
- pushedItem.$item.y = pushedItem.item.y || 0;
3893
- pushedItem.$item.cols = pushedItem.item.cols || 1;
3894
- pushedItem.$item.row = pushedItem.item.row || 1;
3895
- pushedItem.setSize();
3896
- }
3897
- this.pushedItems = [];
3898
- this.pushedItemsPath = [];
3899
- }
3900
- setPushedItems() {
3901
- let i = 0;
3902
- const l = this.pushedItems.length;
3903
- let pushedItem;
3904
- for (; i < l; i++) {
3905
- pushedItem = this.pushedItems[i];
3906
- pushedItem.checkItemChanges(pushedItem.$item, pushedItem.item);
3907
- }
3908
- this.pushedItems = [];
3909
- this.pushedItemsPath = [];
3910
- }
3911
- checkPushBack() {
3912
- let i = this.pushedItems.length - 1;
3913
- let change = false;
3914
- for (; i > -1; i--) {
3915
- if (this.checkPushedItem(this.pushedItems[i], i)) {
3916
- change = true;
3917
- }
3918
- }
3919
- if (change) {
3920
- this.checkPushBack();
3921
- }
3922
- }
3923
- push(gridsterItem, direction) {
3924
- const gridsterItemCollision = this.gridster.checkCollision(gridsterItem.$item);
3925
- if (gridsterItemCollision && gridsterItemCollision !== true &&
3926
- gridsterItemCollision !== this.gridsterItem && gridsterItemCollision.canBeResized()) {
3927
- if (this.tryPattern[direction].call(this, gridsterItemCollision, gridsterItem, direction)) {
3928
- return true;
3929
- }
3930
- }
3931
- else if (gridsterItemCollision === false) {
3932
- return true;
3933
- }
3934
- return false;
3935
- }
3936
- trySouth(gridsterItemCollide, gridsterItem, direction) {
3937
- const backUpY = gridsterItemCollide.$item.y;
3938
- const backUpRows = gridsterItemCollide.$item.rows;
3939
- gridsterItemCollide.$item.y = gridsterItem.$item.y + gridsterItem.$item.rows;
3940
- gridsterItemCollide.$item.rows = backUpRows + backUpY - gridsterItemCollide.$item.y;
3941
- if (!GridsterComponent.checkCollisionTwoItems(gridsterItemCollide.$item, gridsterItem.$item)
3942
- && !this.gridster.checkGridCollision(gridsterItemCollide.$item)) {
3943
- gridsterItemCollide.setSize();
3944
- this.addToPushed(gridsterItemCollide);
3945
- this.push(gridsterItem, direction);
3946
- return true;
3947
- }
3948
- else {
3949
- gridsterItemCollide.$item.y = backUpY;
3950
- gridsterItemCollide.$item.rows = backUpRows;
3951
- }
3952
- return false;
3953
- }
3954
- tryNorth(gridsterItemCollide, gridsterItem, direction) {
3955
- const backUpRows = gridsterItemCollide.$item.rows;
3956
- gridsterItemCollide.$item.rows = gridsterItem.$item.y - gridsterItemCollide.$item.y;
3957
- if (!GridsterComponent.checkCollisionTwoItems(gridsterItemCollide.$item, gridsterItem.$item)
3958
- && !this.gridster.checkGridCollision(gridsterItemCollide.$item)) {
3959
- gridsterItemCollide.setSize();
3960
- this.addToPushed(gridsterItemCollide);
3961
- this.push(gridsterItem, direction);
3962
- return true;
3963
- }
3964
- else {
3965
- gridsterItemCollide.$item.rows = backUpRows;
3966
- }
3967
- return false;
3968
- }
3969
- tryEast(gridsterItemCollide, gridsterItem, direction) {
3970
- const backUpX = gridsterItemCollide.$item.x;
3971
- const backUpCols = gridsterItemCollide.$item.cols;
3972
- gridsterItemCollide.$item.x = gridsterItem.$item.x + gridsterItem.$item.cols;
3973
- gridsterItemCollide.$item.cols = backUpCols + backUpX - gridsterItemCollide.$item.x;
3974
- if (!GridsterComponent.checkCollisionTwoItems(gridsterItemCollide.$item, gridsterItem.$item)
3975
- && !this.gridster.checkGridCollision(gridsterItemCollide.$item)) {
3976
- gridsterItemCollide.setSize();
3977
- this.addToPushed(gridsterItemCollide);
3978
- this.push(gridsterItem, direction);
3979
- return true;
3980
- }
3981
- else {
3982
- gridsterItemCollide.$item.x = backUpX;
3983
- gridsterItemCollide.$item.cols = backUpCols;
3984
- }
3985
- return false;
3986
- }
3987
- tryWest(gridsterItemCollide, gridsterItem, direction) {
3988
- const backUpCols = gridsterItemCollide.$item.cols;
3989
- gridsterItemCollide.$item.cols = gridsterItem.$item.x - gridsterItemCollide.$item.x;
3990
- if (!GridsterComponent.checkCollisionTwoItems(gridsterItemCollide.$item, gridsterItem.$item)
3991
- && !this.gridster.checkGridCollision(gridsterItemCollide.$item)) {
3992
- gridsterItemCollide.setSize();
3993
- this.addToPushed(gridsterItemCollide);
3994
- this.push(gridsterItem, direction);
3995
- return true;
3996
- }
3997
- else {
3998
- gridsterItemCollide.$item.cols = backUpCols;
3999
- }
4000
- return false;
4001
- }
4002
- addToPushed(gridsterItem) {
4003
- if (this.pushedItems.indexOf(gridsterItem) < 0) {
4004
- this.pushedItems.push(gridsterItem);
4005
- this.pushedItemsPath.push([
4006
- {
4007
- x: gridsterItem.item.x || 0,
4008
- y: gridsterItem.item.y || 0,
4009
- cols: gridsterItem.item.cols || 0,
4010
- rows: gridsterItem.item.rows || 0
4011
- },
4012
- {
4013
- x: gridsterItem.$item.x,
4014
- y: gridsterItem.$item.y,
4015
- cols: gridsterItem.$item.cols,
4016
- rows: gridsterItem.$item.rows
4017
- }
4018
- ]);
4019
- }
4020
- else {
4021
- const i = this.pushedItems.indexOf(gridsterItem);
4022
- this.pushedItemsPath[i].push({
4023
- x: gridsterItem.$item.x,
4024
- y: gridsterItem.$item.y,
4025
- cols: gridsterItem.$item.cols,
4026
- rows: gridsterItem.$item.rows
4027
- });
4028
- }
4029
- }
4030
- removeFromPushed(i) {
4031
- if (i > -1) {
4032
- this.pushedItems.splice(i, 1);
4033
- this.pushedItemsPath.splice(i, 1);
4034
- }
4035
- }
4036
- checkPushedItem(pushedItem, i) {
4037
- const path = this.pushedItemsPath[i];
4038
- let j = path.length - 2;
4039
- let lastPosition, x, y, cols, rows;
4040
- for (; j > -1; j--) {
4041
- lastPosition = path[j];
4042
- x = pushedItem.$item.x;
4043
- y = pushedItem.$item.y;
4044
- cols = pushedItem.$item.cols;
4045
- rows = pushedItem.$item.rows;
4046
- pushedItem.$item.x = lastPosition.x;
4047
- pushedItem.$item.y = lastPosition.y;
4048
- pushedItem.$item.cols = lastPosition.cols;
4049
- pushedItem.$item.rows = lastPosition.rows;
4050
- if (!this.gridster.findItemWithItem(pushedItem.$item)) {
4051
- pushedItem.setSize();
4052
- path.splice(j + 1, path.length - 1 - j);
4053
- }
4054
- else {
4055
- pushedItem.$item.x = x;
4056
- pushedItem.$item.y = y;
4057
- pushedItem.$item.cols = cols;
4058
- pushedItem.$item.rows = rows;
4059
- }
4060
- }
4061
- if (path.length < 2) {
4062
- this.removeFromPushed(i);
4063
- return true;
4064
- }
4065
- return false;
4066
- }
4067
- };
4068
- GridsterPushResize.ctorParameters = () => [
4069
- { type: GridsterItemComponentInterface }
4070
- ];
4071
- GridsterPushResize = __decorate([
4072
- Injectable(),
4073
- __metadata("design:paramtypes", [GridsterItemComponentInterface])
4074
- ], GridsterPushResize);
4075
-
4076
- let GridsterResizable = class GridsterResizable {
4077
- constructor(gridsterItem, gridster, zone) {
4078
- this.zone = zone;
4079
- this.gridsterItem = gridsterItem;
4080
- this.gridster = gridster;
4081
- this.lastMouse = {
4082
- clientX: 0,
4083
- clientY: 0
4084
- };
4085
- this.itemBackup = [0, 0, 0, 0];
4086
- this.resizeEventScrollType = { w: false, e: false, n: false, s: false };
4087
- }
4088
- destroy() {
4089
- if (this.gridster.previewStyle) {
4090
- this.gridster.previewStyle();
4091
- }
4092
- delete this.gridsterItem;
4093
- delete this.gridster;
4094
- }
4095
- dragStart(e) {
4096
- switch (e.which) {
4097
- case 1:
4098
- // left mouse button
4099
- break;
4100
- case 2:
4101
- case 3:
4102
- // right or middle mouse button
4103
- return;
4104
- }
4105
- if (this.gridster.options.resizable && this.gridster.options.resizable.start) {
4106
- this.gridster.options.resizable.start(this.gridsterItem.item, this.gridsterItem, e);
4107
- }
4108
- e.stopPropagation();
4109
- e.preventDefault();
4110
- this.dragFunction = this.dragMove.bind(this);
4111
- this.dragStopFunction = this.dragStop.bind(this);
4112
- this.zone.runOutsideAngular(() => {
4113
- this.mousemove = this.gridsterItem.renderer.listen('document', 'mousemove', this.dragFunction);
4114
- this.touchmove = this.gridster.renderer.listen(this.gridster.el, 'touchmove', this.dragFunction);
4115
- });
4116
- this.mouseup = this.gridsterItem.renderer.listen('document', 'mouseup', this.dragStopFunction);
4117
- this.mouseleave = this.gridsterItem.renderer.listen('document', 'mouseleave', this.dragStopFunction);
4118
- this.cancelOnBlur = this.gridsterItem.renderer.listen('window', 'blur', this.dragStopFunction);
4119
- this.touchend = this.gridsterItem.renderer.listen('document', 'touchend', this.dragStopFunction);
4120
- this.touchcancel = this.gridsterItem.renderer.listen('document', 'touchcancel', this.dragStopFunction);
4121
- this.gridsterItem.renderer.addClass(this.gridsterItem.el, 'gridster-item-resizing');
4122
- this.lastMouse.clientX = e.clientX;
4123
- this.lastMouse.clientY = e.clientY;
4124
- this.left = this.gridsterItem.left;
4125
- this.top = this.gridsterItem.top;
4126
- this.width = this.gridsterItem.width;
4127
- this.height = this.gridsterItem.height;
4128
- this.bottom = this.gridsterItem.top + this.gridsterItem.height;
4129
- this.right = this.gridsterItem.left + this.gridsterItem.width;
4130
- this.margin = this.gridster.$options.margin;
4131
- this.offsetLeft = this.gridster.el.scrollLeft - this.gridster.el.offsetLeft;
4132
- this.offsetTop = this.gridster.el.scrollTop - this.gridster.el.offsetTop;
4133
- this.diffLeft = e.clientX + this.offsetLeft - this.left;
4134
- this.diffRight = e.clientX + this.offsetLeft - this.right;
4135
- this.diffTop = e.clientY + this.offsetTop - this.top;
4136
- this.diffBottom = e.clientY + this.offsetTop - this.bottom;
4137
- this.minHeight = this.gridster.positionYToPixels(this.gridsterItem.$item.minItemRows || this.gridster.$options.minItemRows)
4138
- - this.margin;
4139
- this.minWidth = this.gridster.positionXToPixels(this.gridsterItem.$item.minItemCols || this.gridster.$options.minItemCols)
4140
- - this.margin;
4141
- this.gridster.movingItem = this.gridsterItem.$item;
4142
- this.gridster.previewStyle();
4143
- this.push = new GridsterPush(this.gridsterItem);
4144
- this.pushResize = new GridsterPushResize(this.gridsterItem);
4145
- this.gridster.dragInProgress = true;
4146
- this.gridster.updateGrid();
4147
- if (e.target.hasAttribute('class') && e.target.getAttribute('class').split(' ').indexOf('handle-n') > -1) {
4148
- this.resizeEventScrollType.n = true;
4149
- this.directionFunction = this.handleN;
4150
- }
4151
- else if (e.target.hasAttribute('class') && e.target.getAttribute('class').split(' ').indexOf('handle-w') > -1) {
4152
- this.resizeEventScrollType.w = true;
4153
- this.directionFunction = this.handleW;
4154
- }
4155
- else if (e.target.hasAttribute('class') && e.target.getAttribute('class').split(' ').indexOf('handle-s') > -1) {
4156
- this.resizeEventScrollType.s = true;
4157
- this.directionFunction = this.handleS;
4158
- }
4159
- else if (e.target.hasAttribute('class') && e.target.getAttribute('class').split(' ').indexOf('handle-e') > -1) {
4160
- this.resizeEventScrollType.e = true;
4161
- this.directionFunction = this.handleE;
4162
- }
4163
- else if (e.target.hasAttribute('class') && e.target.getAttribute('class').split(' ').indexOf('handle-nw') > -1) {
4164
- this.resizeEventScrollType.n = true;
4165
- this.resizeEventScrollType.w = true;
4166
- this.directionFunction = this.handleNW;
4167
- }
4168
- else if (e.target.hasAttribute('class') && e.target.getAttribute('class').split(' ').indexOf('handle-ne') > -1) {
4169
- this.resizeEventScrollType.n = true;
4170
- this.resizeEventScrollType.e = true;
4171
- this.directionFunction = this.handleNE;
4172
- }
4173
- else if (e.target.hasAttribute('class') && e.target.getAttribute('class').split(' ').indexOf('handle-sw') > -1) {
4174
- this.resizeEventScrollType.s = true;
4175
- this.resizeEventScrollType.w = true;
4176
- this.directionFunction = this.handleSW;
4177
- }
4178
- else if (e.target.hasAttribute('class') && e.target.getAttribute('class').split(' ').indexOf('handle-se') > -1) {
4179
- this.resizeEventScrollType.s = true;
4180
- this.resizeEventScrollType.e = true;
4181
- this.directionFunction = this.handleSE;
4182
- }
4183
- }
4184
- dragMove(e) {
4185
- e.stopPropagation();
4186
- e.preventDefault();
4187
- GridsterUtils.checkTouchEvent(e);
4188
- this.offsetTop = this.gridster.el.scrollTop - this.gridster.el.offsetTop;
4189
- this.offsetLeft = this.gridster.el.scrollLeft - this.gridster.el.offsetLeft;
4190
- scroll(this.gridster, this.left, this.top, this.width, this.height, e, this.lastMouse, this.directionFunction.bind(this), true, this.resizeEventScrollType);
4191
- this.directionFunction(e);
4192
- this.lastMouse.clientX = e.clientX;
4193
- this.lastMouse.clientY = e.clientY;
4194
- this.zone.run(() => {
4195
- this.gridster.updateGrid();
4196
- });
4197
- }
4198
- dragStop(e) {
4199
- e.stopPropagation();
4200
- e.preventDefault();
4201
- cancelScroll();
4202
- this.mousemove();
4203
- this.mouseup();
4204
- this.mouseleave();
4205
- this.cancelOnBlur();
4206
- this.touchmove();
4207
- this.touchend();
4208
- this.touchcancel();
4209
- this.gridster.dragInProgress = false;
4210
- this.gridster.updateGrid();
4211
- if (this.gridster.options.resizable && this.gridster.options.resizable.stop) {
4212
- Promise.resolve(this.gridster.options.resizable.stop(this.gridsterItem.item, this.gridsterItem, e))
4213
- .then(this.makeResize.bind(this), this.cancelResize.bind(this));
4214
- }
4215
- else {
4216
- this.makeResize();
4217
- }
4218
- setTimeout(() => {
4219
- this.gridsterItem.renderer.removeClass(this.gridsterItem.el, 'gridster-item-resizing');
4220
- if (this.gridster) {
4221
- this.gridster.movingItem = null;
4222
- this.gridster.previewStyle();
4223
- }
4224
- });
4225
- }
4226
- cancelResize() {
4227
- this.gridsterItem.$item.cols = this.gridsterItem.item.cols || 1;
4228
- this.gridsterItem.$item.rows = this.gridsterItem.item.rows || 1;
4229
- this.gridsterItem.$item.x = this.gridsterItem.item.x || 0;
4230
- this.gridsterItem.$item.y = this.gridsterItem.item.y || 0;
4231
- this.gridsterItem.setSize();
4232
- this.push.restoreItems();
4233
- this.pushResize.restoreItems();
4234
- this.push.destroy();
4235
- delete this.push;
4236
- this.pushResize.destroy();
4237
- delete this.pushResize;
4238
- }
4239
- makeResize() {
4240
- this.gridsterItem.setSize();
4241
- this.gridsterItem.checkItemChanges(this.gridsterItem.$item, this.gridsterItem.item);
4242
- this.push.setPushedItems();
4243
- this.pushResize.setPushedItems();
4244
- this.push.destroy();
4245
- delete this.push;
4246
- this.pushResize.destroy();
4247
- delete this.pushResize;
4248
- }
4249
- handleN(e) {
4250
- this.top = e.clientY + this.offsetTop - this.diffTop;
4251
- this.height = this.bottom - this.top;
4252
- if (this.minHeight > this.height) {
4253
- this.height = this.minHeight;
4254
- this.top = this.bottom - this.minHeight;
4255
- }
4256
- this.newPosition = this.gridster.pixelsToPositionY(this.top + this.margin, Math.floor);
4257
- if (this.gridsterItem.$item.y !== this.newPosition) {
4258
- this.itemBackup[1] = this.gridsterItem.$item.y;
4259
- this.itemBackup[3] = this.gridsterItem.$item.rows;
4260
- this.gridsterItem.$item.rows += this.gridsterItem.$item.y - this.newPosition;
4261
- this.gridsterItem.$item.y = this.newPosition;
4262
- this.pushResize.pushItems(this.pushResize.fromSouth);
4263
- this.push.pushItems(this.push.fromSouth, this.gridster.$options.disablePushOnResize);
4264
- if (this.gridster.checkCollision(this.gridsterItem.$item)) {
4265
- this.gridsterItem.$item.y = this.itemBackup[1];
4266
- this.gridsterItem.$item.rows = this.itemBackup[3];
4267
- this.setItemTop(this.gridster.positionYToPixels(this.gridsterItem.$item.y));
4268
- this.setItemHeight(this.gridster.positionYToPixels(this.gridsterItem.$item.rows) - this.margin);
4269
- return;
4270
- }
4271
- else {
4272
- this.gridster.previewStyle();
4273
- }
4274
- this.pushResize.checkPushBack();
4275
- this.push.checkPushBack();
4276
- }
4277
- this.setItemTop(this.top);
4278
- this.setItemHeight(this.height);
4279
- }
4280
- handleW(e) {
4281
- this.left = e.clientX + this.offsetLeft - this.diffLeft;
4282
- this.width = this.right - this.left;
4283
- if (this.minWidth > this.width) {
4284
- this.width = this.minWidth;
4285
- this.left = this.right - this.minWidth;
4286
- }
4287
- this.newPosition = this.gridster.pixelsToPositionX(this.left + this.margin, Math.floor);
4288
- if (this.gridsterItem.$item.x !== this.newPosition) {
4289
- this.itemBackup[0] = this.gridsterItem.$item.x;
4290
- this.itemBackup[2] = this.gridsterItem.$item.cols;
4291
- this.gridsterItem.$item.cols += this.gridsterItem.$item.x - this.newPosition;
4292
- this.gridsterItem.$item.x = this.newPosition;
4293
- this.pushResize.pushItems(this.pushResize.fromEast);
4294
- this.push.pushItems(this.push.fromEast, this.gridster.$options.disablePushOnResize);
4295
- if (this.gridster.checkCollision(this.gridsterItem.$item)) {
4296
- this.gridsterItem.$item.x = this.itemBackup[0];
4297
- this.gridsterItem.$item.cols = this.itemBackup[2];
4298
- this.setItemLeft(this.gridster.positionXToPixels(this.gridsterItem.$item.x));
4299
- this.setItemWidth(this.gridster.positionXToPixels(this.gridsterItem.$item.cols) - this.margin);
4300
- return;
4301
- }
4302
- else {
4303
- this.gridster.previewStyle();
4304
- }
4305
- this.pushResize.checkPushBack();
4306
- this.push.checkPushBack();
4307
- }
4308
- this.setItemLeft(this.left);
4309
- this.setItemWidth(this.width);
4310
- }
4311
- handleS(e) {
4312
- this.height = e.clientY + this.offsetTop - this.diffBottom - this.top;
4313
- if (this.minHeight > this.height) {
4314
- this.height = this.minHeight;
4315
- }
4316
- this.bottom = this.top + this.height;
4317
- this.newPosition = this.gridster.pixelsToPositionY(this.bottom, Math.ceil);
4318
- if ((this.gridsterItem.$item.y + this.gridsterItem.$item.rows) !== this.newPosition) {
4319
- this.itemBackup[3] = this.gridsterItem.$item.rows;
4320
- this.gridsterItem.$item.rows = this.newPosition - this.gridsterItem.$item.y;
4321
- this.pushResize.pushItems(this.pushResize.fromNorth);
4322
- this.push.pushItems(this.push.fromNorth, this.gridster.$options.disablePushOnResize);
4323
- if (this.gridster.checkCollision(this.gridsterItem.$item)) {
4324
- this.gridsterItem.$item.rows = this.itemBackup[3];
4325
- this.setItemHeight(this.gridster.positionYToPixels(this.gridsterItem.$item.rows) - this.margin);
4326
- return;
4327
- }
4328
- else {
4329
- this.gridster.previewStyle();
4330
- }
4331
- this.pushResize.checkPushBack();
4332
- this.push.checkPushBack();
4333
- }
4334
- this.setItemHeight(this.height);
4335
- }
4336
- handleE(e) {
4337
- this.width = e.clientX + this.offsetLeft - this.diffRight - this.left;
4338
- if (this.minWidth > this.width) {
4339
- this.width = this.minWidth;
4340
- }
4341
- this.right = this.left + this.width;
4342
- this.newPosition = this.gridster.pixelsToPositionX(this.right, Math.ceil);
4343
- if ((this.gridsterItem.$item.x + this.gridsterItem.$item.cols) !== this.newPosition) {
4344
- this.itemBackup[2] = this.gridsterItem.$item.cols;
4345
- this.gridsterItem.$item.cols = this.newPosition - this.gridsterItem.$item.x;
4346
- this.pushResize.pushItems(this.pushResize.fromWest);
4347
- this.push.pushItems(this.push.fromWest, this.gridster.$options.disablePushOnResize);
4348
- if (this.gridster.checkCollision(this.gridsterItem.$item)) {
4349
- this.gridsterItem.$item.cols = this.itemBackup[2];
4350
- this.setItemWidth(this.gridster.positionXToPixels(this.gridsterItem.$item.cols) - this.margin);
4351
- return;
4352
- }
4353
- else {
4354
- this.gridster.previewStyle();
4355
- }
4356
- this.pushResize.checkPushBack();
4357
- this.push.checkPushBack();
4358
- }
4359
- this.setItemWidth(this.width);
4360
- }
4361
- handleNW(e) {
4362
- this.handleN(e);
4363
- this.handleW(e);
4364
- }
4365
- handleNE(e) {
4366
- this.handleN(e);
4367
- this.handleE(e);
4368
- }
4369
- handleSW(e) {
4370
- this.handleS(e);
4371
- this.handleW(e);
4372
- }
4373
- handleSE(e) {
4374
- this.handleS(e);
4375
- this.handleE(e);
4376
- }
4377
- toggle() {
4378
- this.resizeEnabled = this.gridsterItem.canBeResized();
4379
- }
4380
- dragStartDelay(e) {
4381
- GridsterUtils.checkTouchEvent(e);
4382
- if (!this.gridster.$options.resizable.delayStart) {
4383
- this.dragStart(e);
4384
- return;
4385
- }
4386
- const timeout = setTimeout(() => {
4387
- this.dragStart(e);
4388
- cancelDrag();
4389
- }, this.gridster.$options.resizable.delayStart);
4390
- const cancelMouse = this.gridsterItem.renderer.listen('document', 'mouseup', cancelDrag);
4391
- const cancelMouseLeave = this.gridsterItem.renderer.listen('document', 'mouseleave', cancelDrag);
4392
- const cancelOnBlur = this.gridsterItem.renderer.listen('window', 'blur', cancelDrag);
4393
- const cancelTouchMove = this.gridsterItem.renderer.listen('document', 'touchmove', cancelMove);
4394
- const cancelTouchEnd = this.gridsterItem.renderer.listen('document', 'touchend', cancelDrag);
4395
- const cancelTouchCancel = this.gridsterItem.renderer.listen('document', 'touchcancel', cancelDrag);
4396
- function cancelMove(eventMove) {
4397
- GridsterUtils.checkTouchEvent(eventMove);
4398
- if (Math.abs(eventMove.clientX - e.clientX) > 9 || Math.abs(eventMove.clientY - e.clientY) > 9) {
4399
- cancelDrag();
4400
- }
4401
- }
4402
- function cancelDrag() {
4403
- clearTimeout(timeout);
4404
- cancelOnBlur();
4405
- cancelMouse();
4406
- cancelMouseLeave();
4407
- cancelTouchMove();
4408
- cancelTouchEnd();
4409
- cancelTouchCancel();
4410
- }
4411
- }
4412
- setItemTop(top) {
4413
- this.gridster.gridRenderer.setCellPosition(this.gridsterItem.renderer, this.gridsterItem.el, this.left, top);
4414
- }
4415
- setItemLeft(left) {
4416
- this.gridster.gridRenderer.setCellPosition(this.gridsterItem.renderer, this.gridsterItem.el, left, this.top);
4417
- }
4418
- setItemHeight(height) {
4419
- this.gridsterItem.renderer.setStyle(this.gridsterItem.el, 'height', height + 'px');
4420
- }
4421
- setItemWidth(width) {
4422
- this.gridsterItem.renderer.setStyle(this.gridsterItem.el, 'width', width + 'px');
4423
- }
4424
- };
4425
- GridsterResizable.ctorParameters = () => [
4426
- { type: GridsterItemComponentInterface },
4427
- { type: GridsterComponentInterface },
4428
- { type: NgZone }
4429
- ];
4430
- GridsterResizable = __decorate([
4431
- Injectable(),
4432
- __metadata("design:paramtypes", [GridsterItemComponentInterface, GridsterComponentInterface, NgZone])
4433
- ], GridsterResizable);
4434
-
4435
- let GridsterItemComponent = class GridsterItemComponent {
4436
- constructor(el, gridster, renderer, zone) {
4437
- this.renderer = renderer;
4438
- this.zone = zone;
4439
- this.el = el.nativeElement;
4440
- this.$item = {
4441
- cols: -1,
4442
- rows: -1,
4443
- x: -1,
4444
- y: -1,
4445
- };
4446
- this.gridster = gridster;
4447
- this.drag = new GridsterDraggable(this, gridster, this.zone);
4448
- this.resize = new GridsterResizable(this, gridster, this.zone);
4449
- }
4450
- ngOnInit() {
4451
- this.updateOptions();
4452
- this.gridster.addItem(this);
4453
- }
4454
- updateOptions() {
4455
- this.$item = GridsterUtils.merge(this.$item, this.item, {
4456
- cols: undefined,
4457
- rows: undefined,
4458
- x: undefined,
4459
- y: undefined,
4460
- dragEnabled: undefined,
4461
- resizeEnabled: undefined,
4462
- compactEnabled: undefined,
4463
- maxItemRows: undefined,
4464
- minItemRows: undefined,
4465
- maxItemCols: undefined,
4466
- minItemCols: undefined,
4467
- maxItemArea: undefined,
4468
- minItemArea: undefined,
4469
- });
4470
- }
4471
- ngOnDestroy() {
4472
- this.gridster.removeItem(this);
4473
- this.gridster.movingItem = null;
4474
- delete this.gridster;
4475
- this.drag.destroy();
4476
- delete this.drag;
4477
- this.resize.destroy();
4478
- delete this.resize;
4479
- }
4480
- setSize() {
4481
- this.renderer.setStyle(this.el, 'display', this.notPlaced ? '' : 'block');
4482
- this.gridster.gridRenderer.updateItem(this.el, this.$item, this.renderer);
4483
- this.updateItemSize();
4484
- }
4485
- updateItemSize() {
4486
- const top = this.$item.y * this.gridster.curRowHeight;
4487
- const left = this.$item.x * this.gridster.curColWidth;
4488
- const width = this.$item.cols * this.gridster.curColWidth - this.gridster.$options.margin;
4489
- const height = this.$item.rows * this.gridster.curRowHeight - this.gridster.$options.margin;
4490
- if (!this.init && width > 0 && height > 0) {
4491
- this.init = true;
4492
- if (this.item.initCallback) {
4493
- this.item.initCallback(this.item, this);
4494
- }
4495
- if (this.gridster.options.itemInitCallback) {
4496
- this.item.curRowHeight = this.gridster.curRowHeight;
4497
- this.gridster.options.itemInitCallback(this.item, this);
4498
- }
4499
- if (this.gridster.$options.scrollToNewItems) {
4500
- this.el.scrollIntoView(false);
4501
- }
4502
- }
4503
- if (width !== this.width || height !== this.height) {
4504
- this.width = width;
4505
- this.height = height;
4506
- if (this.gridster.options.itemResizeCallback) {
4507
- this.gridster.options.itemResizeCallback(this.item, this);
4508
- }
4509
- }
4510
- this.top = top;
4511
- this.left = left;
4512
- }
4513
- itemChanged() {
4514
- if (this.gridster.options.itemChangeCallback) {
4515
- this.item.curRowHeight = this.gridster.curRowHeight;
4516
- this.gridster.options.itemChangeCallback(this.item, this);
4517
- }
4518
- }
4519
- checkItemChanges(newValue, oldValue) {
4520
- if (newValue.rows === oldValue.rows && newValue.cols === oldValue.cols && newValue.x === oldValue.x && newValue.y === oldValue.y) {
4521
- return;
4522
- }
4523
- if (this.gridster.checkCollision(this.$item)) {
4524
- this.$item.x = oldValue.x || 0;
4525
- this.$item.y = oldValue.y || 0;
4526
- this.$item.cols = oldValue.cols || 1;
4527
- this.$item.rows = oldValue.rows || 1;
4528
- this.setSize();
4529
- }
4530
- else {
4531
- this.item.cols = this.$item.cols;
4532
- this.item.rows = this.$item.rows;
4533
- this.item.x = this.$item.x;
4534
- this.item.y = this.$item.y;
4535
- this.gridster.calculateLayoutDebounce();
4536
- this.itemChanged();
4537
- }
4538
- }
4539
- canBeDragged() {
4540
- return !this.gridster.mobile &&
4541
- (this.$item.dragEnabled === undefined ? this.gridster.$options.draggable.enabled : this.$item.dragEnabled);
4542
- }
4543
- canBeResized() {
4544
- return !this.gridster.mobile &&
4545
- (this.$item.resizeEnabled === undefined ? this.gridster.$options.resizable.enabled : this.$item.resizeEnabled);
4546
- }
4547
- };
4548
- GridsterItemComponent.ctorParameters = () => [
4549
- { type: ElementRef },
4550
- { type: GridsterComponent, decorators: [{ type: Host }] },
4551
- { type: Renderer2 },
4552
- { type: NgZone }
4553
- ];
4554
- __decorate([
4555
- Input(),
4556
- __metadata("design:type", Object)
4557
- ], GridsterItemComponent.prototype, "item", void 0);
4558
- GridsterItemComponent = __decorate([
4559
- Component({
4560
- selector: 'gridster-item',
4561
- template: "<ng-content></ng-content>\r\n<div (mousedown)=\"resize.dragStartDelay($event)\" (touchstart)=\"resize.dragStartDelay($event)\"\r\n [hidden]=\"!gridster.$options.resizable.handles.s || !resize.resizeEnabled\"\r\n class=\"gridster-item-resizable-handler handle-s\"></div>\r\n<div (mousedown)=\"resize.dragStartDelay($event)\" (touchstart)=\"resize.dragStartDelay($event)\"\r\n [hidden]=\"!gridster.$options.resizable.handles.e || !resize.resizeEnabled\"\r\n class=\"gridster-item-resizable-handler handle-e\"></div>\r\n<div (mousedown)=\"resize.dragStartDelay($event)\" (touchstart)=\"resize.dragStartDelay($event)\"\r\n [hidden]=\"!gridster.$options.resizable.handles.n || !resize.resizeEnabled\"\r\n class=\"gridster-item-resizable-handler handle-n\"></div>\r\n<div (mousedown)=\"resize.dragStartDelay($event)\" (touchstart)=\"resize.dragStartDelay($event)\"\r\n [hidden]=\"!gridster.$options.resizable.handles.w || !resize.resizeEnabled\"\r\n class=\"gridster-item-resizable-handler handle-w\"></div>\r\n<div (mousedown)=\"resize.dragStartDelay($event)\" (touchstart)=\"resize.dragStartDelay($event)\"\r\n [hidden]=\"!gridster.$options.resizable.handles.se || !resize.resizeEnabled\"\r\n class=\"gridster-item-resizable-handler handle-se\"></div>\r\n<div (mousedown)=\"resize.dragStartDelay($event)\" (touchstart)=\"resize.dragStartDelay($event)\"\r\n [hidden]=\"!gridster.$options.resizable.handles.ne || !resize.resizeEnabled\"\r\n class=\"gridster-item-resizable-handler handle-ne\"></div>\r\n<div (mousedown)=\"resize.dragStartDelay($event)\" (touchstart)=\"resize.dragStartDelay($event)\"\r\n [hidden]=\"!gridster.$options.resizable.handles.sw || !resize.resizeEnabled\"\r\n class=\"gridster-item-resizable-handler handle-sw\"></div>\r\n<div (mousedown)=\"resize.dragStartDelay($event)\" (touchstart)=\"resize.dragStartDelay($event)\"\r\n [hidden]=\"!gridster.$options.resizable.handles.nw || !resize.resizeEnabled\"\r\n class=\"gridster-item-resizable-handler handle-nw\"></div>\r\n",
4562
- encapsulation: ViewEncapsulation.None,
4563
- styles: ["gridster-item{box-sizing:border-box;z-index:1;position:absolute;overflow:hidden;transition:.3s;display:none;background:#fff;-webkit-user-select:text;-moz-user-select:text;user-select:text}gridster-item.gridster-item-moving{cursor:move}gridster-item.gridster-item-moving,gridster-item.gridster-item-resizing{transition:none;z-index:2;box-shadow:0 0 5px 5px rgba(0,0,0,.2),0 6px 10px 0 rgba(0,0,0,.14),0 1px 18px 0 rgba(0,0,0,.12)}.gridster-item-resizable-handler{position:absolute;z-index:2}.gridster-item-resizable-handler.handle-n{cursor:n-resize;height:10px;right:0;top:0;left:0}.gridster-item-resizable-handler.handle-e{cursor:e-resize;width:10px;bottom:0;right:0;top:0}.gridster-item-resizable-handler.handle-s{cursor:s-resize;height:10px;right:0;bottom:0;left:0}.gridster-item-resizable-handler.handle-w{cursor:w-resize;width:10px;left:0;top:0;bottom:0}.gridster-item-resizable-handler.handle-ne{cursor:ne-resize;width:10px;height:10px;right:0;top:0}.gridster-item-resizable-handler.handle-nw{cursor:nw-resize;width:10px;height:10px;left:0;top:0}.gridster-item-resizable-handler.handle-se{cursor:se-resize;width:0;height:0;right:0;bottom:0;border-style:solid;border-width:0 0 10px 10px;border-color:transparent}.gridster-item-resizable-handler.handle-sw{cursor:sw-resize;width:10px;height:10px;left:0;bottom:0}gridster-item:hover .gridster-item-resizable-handler.handle-se{border-color:transparent transparent #ccc}"]
4564
- }),
4565
- __param(1, Host()),
4566
- __metadata("design:paramtypes", [ElementRef, GridsterComponent, Renderer2, NgZone])
4567
- ], GridsterItemComponent);
4568
-
4569
- let GridsterPreviewComponent = class GridsterPreviewComponent {
4570
- constructor(el, gridster, renderer) {
4571
- this.renderer = renderer;
4572
- this.el = el.nativeElement;
4573
- this.gridster = gridster;
4574
- this.gridster.previewStyle = this.previewStyle.bind(this);
4575
- }
4576
- ngOnDestroy() {
4577
- delete this.el;
4578
- delete this.gridster.previewStyle;
4579
- delete this.gridster;
4580
- }
4581
- previewStyle(drag) {
4582
- if (!this.gridster.movingItem) {
4583
- this.renderer.setStyle(this.el, 'display', '');
4584
- }
4585
- else {
4586
- if (this.gridster.compact && drag) {
4587
- this.gridster.compact.checkCompactItem(this.gridster.movingItem);
4588
- }
4589
- this.renderer.setStyle(this.el, 'display', 'block');
4590
- this.gridster.gridRenderer.updateItem(this.el, this.gridster.movingItem, this.renderer);
4591
- }
4592
- }
4593
- };
4594
- GridsterPreviewComponent.ctorParameters = () => [
4595
- { type: ElementRef },
4596
- { type: GridsterComponent, decorators: [{ type: Host }] },
4597
- { type: Renderer2 }
4598
- ];
4599
- GridsterPreviewComponent = __decorate([
4600
- Component({
4601
- selector: 'gridster-preview',
4602
- template: '',
4603
- encapsulation: ViewEncapsulation.None,
4604
- styles: ["gridster-preview{position:absolute;display:none;background:#42b4e6}"]
4605
- }),
4606
- __param(1, Host()),
4607
- __metadata("design:paramtypes", [ElementRef, GridsterComponent, Renderer2])
4608
- ], GridsterPreviewComponent);
4609
-
4610
- let GridsterModule = class GridsterModule {
4611
- };
4612
- GridsterModule = __decorate([
4613
- NgModule({
4614
- declarations: [
4615
- GridsterComponent,
4616
- GridsterItemComponent,
4617
- GridsterPreviewComponent
4618
- ],
4619
- imports: [
4620
- CommonModule
4621
- ],
4622
- exports: [GridsterComponent, GridsterItemComponent],
4623
- providers: [],
4624
- bootstrap: []
4625
- })
4626
- ], GridsterModule);
4627
-
4628
- let DashboardFrameworkModule = class DashboardFrameworkModule {
4629
- };
4630
- DashboardFrameworkModule = __decorate([
4631
- NgModule({
4632
- declarations: [
4633
- RADashboardArea,
4634
- RAWidgetContainer,
4635
- LockTooltip
4636
- ],
4637
- imports: [
4638
- BrowserModule,
4639
- GridsterModule,
4640
- HttpClientModule,
4641
- NgxUiLoaderModule,
4642
- NotifierModule.withConfig(customNotifierOptions),
4643
- RACommonModule,
4644
- RAUserControlModule,
4645
- RACommonControlsModule
4646
- ],
4647
- exports: [
4648
- RADashboardArea
4649
- ],
4650
- bootstrap: [RADashboardArea],
4651
- entryComponents: [
4652
- LockTooltip
4653
- ]
4654
- })
4655
- ], DashboardFrameworkModule);
4656
-
4657
- class RaBaseDashboardTemplate {
4658
- constructor(ngZone) {
4659
- this.ngZone = ngZone;
4660
- this.initialize = (eventBus, userDashboardId, appConfig, isIndicatorDashboard) => {
4661
- this.ngZone.run(() => {
4662
- this.userDashboardId = userDashboardId;
4663
- this.appConfig = appConfig;
4664
- this.raDashboardEventBus = eventBus;
4665
- this.isIndicatorDashboard = isIndicatorDashboard;
4666
- });
4667
- this.init();
4668
- };
4669
- }
4670
- ngOnInit() {
4671
- var myEvent = new CustomEvent("event-template-initiated");
4672
- document.body.dispatchEvent(myEvent);
4673
- }
4674
- }
4675
- __decorate([
4676
- Input('dashboard-id'),
4677
- __metadata("design:type", Number)
4678
- ], RaBaseDashboardTemplate.prototype, "dashboardId", void 0);
4679
- __decorate([
4680
- Input('global-filter'),
4681
- __metadata("design:type", Object)
4682
- ], RaBaseDashboardTemplate.prototype, "globalFilter", void 0);
4683
- __decorate([
4684
- Input(),
4685
- __metadata("design:type", Object)
4686
- ], RaBaseDashboardTemplate.prototype, "initialize", void 0);
4687
-
4688
- class RaBaseDashboardFilter {
4689
- constructor() {
4690
- this.getAllFilterConfig = (async) => {
4691
- return this.getFilterConfig();
4692
- };
4693
- this.setInapplicableFilterMsg = (status) => {
4694
- this.showHideInapplicableMsg(status);
4695
- };
4696
- this.isValidEntry = () => {
4697
- return this.isValid();
4698
- };
4699
- this.clearAllData = () => {
4700
- this.clearData();
4701
- };
4702
- this.setAllFilterConfig = (globalFilter, appConfig) => {
4703
- this.setFilterConfig(globalFilter, appConfig);
4704
- };
4705
- this.showOnlyDateRangeControl = (isIndicatorDashboard) => {
4706
- debugger;
4707
- this.showDateRangeControl(isIndicatorDashboard);
4708
- };
4709
- }
4710
- ngOnInit() {
4711
- var myEvent = new CustomEvent("global-filter-initiated");
4712
- document.body.dispatchEvent(myEvent);
4713
- }
4714
- }
4715
- __decorate([
4716
- Input(),
4717
- __metadata("design:type", Object)
4718
- ], RaBaseDashboardFilter.prototype, "getAllFilterConfig", void 0);
4719
- __decorate([
4720
- Input(),
4721
- __metadata("design:type", Object)
4722
- ], RaBaseDashboardFilter.prototype, "setInapplicableFilterMsg", void 0);
4723
- __decorate([
4724
- Input(),
4725
- __metadata("design:type", Object)
4726
- ], RaBaseDashboardFilter.prototype, "isValidEntry", void 0);
4727
- __decorate([
4728
- Input(),
4729
- __metadata("design:type", Object)
4730
- ], RaBaseDashboardFilter.prototype, "clearAllData", void 0);
4731
- __decorate([
4732
- Input(),
4733
- __metadata("design:type", Object)
4734
- ], RaBaseDashboardFilter.prototype, "setAllFilterConfig", void 0);
4735
- __decorate([
4736
- Input(),
4737
- __metadata("design:type", Object)
4738
- ], RaBaseDashboardFilter.prototype, "showOnlyDateRangeControl", void 0);
4739
-
4740
- /*
4741
- * Public API Surface of ra-dashboard-framework
4742
- */
4743
-
4744
- /**
4745
- * Generated bundle index. Do not edit.
4746
- */
4747
-
4748
- export { DashboardFrameworkModule, RADashboardArea, RADashboardEventBus, RADashboardResponsiveService, RAEvent, RAEventKey, RAWidgetContainer, RaBaseDashboardFilter, RaBaseDashboardTemplate, RaDashboardService, LockTooltip as ɵa, GridsterModule as ɵb, GridsterComponent as ɵc, GridsterItemComponent as ɵd, GridsterPreviewComponent as ɵe, customNotifierOptions as ɵf };
4749
- //# sourceMappingURL=schneideress-dashboardframework.js.map