@skyux/tiles 5.6.2 → 6.0.0-beta.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 (81) hide show
  1. package/documentation.json +1 -1
  2. package/esm2020/index.mjs +24 -0
  3. package/esm2020/lib/modules/shared/sky-tiles-resources.module.mjs +60 -0
  4. package/esm2020/lib/modules/tiles/tile/tile-summary.component.mjs +16 -0
  5. package/esm2020/lib/modules/tiles/tile/tile-title.component.mjs +15 -0
  6. package/esm2020/lib/modules/tiles/tile/tile.component.mjs +160 -0
  7. package/esm2020/lib/modules/tiles/tile/tile.module.mjs +53 -0
  8. package/esm2020/lib/modules/tiles/tile-content/tile-content-section.component.mjs +15 -0
  9. package/esm2020/lib/modules/tiles/tile-content/tile-content.component.mjs +14 -0
  10. package/esm2020/lib/modules/tiles/tile-content/tile-content.module.mjs +20 -0
  11. package/esm2020/lib/modules/tiles/tile-dashboard/tile-dashboard-message-type.mjs +15 -0
  12. package/esm2020/lib/modules/tiles/tile-dashboard/tile-dashboard-message.mjs +2 -0
  13. package/esm2020/lib/modules/tiles/tile-dashboard/tile-dashboard.component.mjs +128 -0
  14. package/esm2020/lib/modules/tiles/tile-dashboard/tile-dashboard.module.mjs +32 -0
  15. package/esm2020/lib/modules/tiles/tile-dashboard/tile-dashboard.service.mjs +525 -0
  16. package/esm2020/lib/modules/tiles/tile-dashboard-column/tile-dashboard-column.component.mjs +32 -0
  17. package/esm2020/lib/modules/tiles/tile-dashboard-column/tile-dashboard-column.module.mjs +19 -0
  18. package/esm2020/lib/modules/tiles/tile-dashboard-config/tile-dashboard-config-layout-column.mjs +2 -0
  19. package/esm2020/lib/modules/tiles/tile-dashboard-config/tile-dashboard-config-layout-tile.mjs +2 -0
  20. package/esm2020/lib/modules/tiles/tile-dashboard-config/tile-dashboard-config-layout.mjs +2 -0
  21. package/esm2020/lib/modules/tiles/tile-dashboard-config/tile-dashboard-config-reorder-data.mjs +2 -0
  22. package/esm2020/lib/modules/tiles/tile-dashboard-config/tile-dashboard-config-tile.mjs +2 -0
  23. package/esm2020/lib/modules/tiles/tile-dashboard-config/tile-dashboard-config.mjs +2 -0
  24. package/esm2020/lib/modules/tiles/tiles.module.mjs +31 -0
  25. package/esm2020/skyux-tiles.mjs +5 -0
  26. package/fesm2015/skyux-tiles.mjs +1076 -0
  27. package/fesm2015/skyux-tiles.mjs.map +1 -0
  28. package/{fesm2015/skyux-tiles.js → fesm2020/skyux-tiles.mjs} +57 -86
  29. package/fesm2020/skyux-tiles.mjs.map +1 -0
  30. package/lib/modules/shared/sky-tiles-resources.module.d.ts +1 -1
  31. package/package.json +27 -14
  32. package/bundles/skyux-tiles.umd.js +0 -1662
  33. package/esm2015/index.js +0 -24
  34. package/esm2015/index.js.map +0 -1
  35. package/esm2015/lib/modules/shared/sky-tiles-resources.module.js +0 -60
  36. package/esm2015/lib/modules/shared/sky-tiles-resources.module.js.map +0 -1
  37. package/esm2015/lib/modules/tiles/tile/tile-summary.component.js +0 -19
  38. package/esm2015/lib/modules/tiles/tile/tile-summary.component.js.map +0 -1
  39. package/esm2015/lib/modules/tiles/tile/tile-title.component.js +0 -19
  40. package/esm2015/lib/modules/tiles/tile/tile-title.component.js.map +0 -1
  41. package/esm2015/lib/modules/tiles/tile/tile.component.js +0 -165
  42. package/esm2015/lib/modules/tiles/tile/tile.component.js.map +0 -1
  43. package/esm2015/lib/modules/tiles/tile/tile.module.js +0 -53
  44. package/esm2015/lib/modules/tiles/tile/tile.module.js.map +0 -1
  45. package/esm2015/lib/modules/tiles/tile-content/tile-content-section.component.js +0 -19
  46. package/esm2015/lib/modules/tiles/tile-content/tile-content-section.component.js.map +0 -1
  47. package/esm2015/lib/modules/tiles/tile-content/tile-content.component.js +0 -18
  48. package/esm2015/lib/modules/tiles/tile-content/tile-content.component.js.map +0 -1
  49. package/esm2015/lib/modules/tiles/tile-content/tile-content.module.js +0 -20
  50. package/esm2015/lib/modules/tiles/tile-content/tile-content.module.js.map +0 -1
  51. package/esm2015/lib/modules/tiles/tile-dashboard/tile-dashboard-message-type.js +0 -15
  52. package/esm2015/lib/modules/tiles/tile-dashboard/tile-dashboard-message-type.js.map +0 -1
  53. package/esm2015/lib/modules/tiles/tile-dashboard/tile-dashboard-message.js +0 -2
  54. package/esm2015/lib/modules/tiles/tile-dashboard/tile-dashboard-message.js.map +0 -1
  55. package/esm2015/lib/modules/tiles/tile-dashboard/tile-dashboard.component.js +0 -133
  56. package/esm2015/lib/modules/tiles/tile-dashboard/tile-dashboard.component.js.map +0 -1
  57. package/esm2015/lib/modules/tiles/tile-dashboard/tile-dashboard.module.js +0 -32
  58. package/esm2015/lib/modules/tiles/tile-dashboard/tile-dashboard.module.js.map +0 -1
  59. package/esm2015/lib/modules/tiles/tile-dashboard/tile-dashboard.service.js +0 -525
  60. package/esm2015/lib/modules/tiles/tile-dashboard/tile-dashboard.service.js.map +0 -1
  61. package/esm2015/lib/modules/tiles/tile-dashboard-column/tile-dashboard-column.component.js +0 -36
  62. package/esm2015/lib/modules/tiles/tile-dashboard-column/tile-dashboard-column.component.js.map +0 -1
  63. package/esm2015/lib/modules/tiles/tile-dashboard-column/tile-dashboard-column.module.js +0 -19
  64. package/esm2015/lib/modules/tiles/tile-dashboard-column/tile-dashboard-column.module.js.map +0 -1
  65. package/esm2015/lib/modules/tiles/tile-dashboard-config/tile-dashboard-config-layout-column.js +0 -2
  66. package/esm2015/lib/modules/tiles/tile-dashboard-config/tile-dashboard-config-layout-column.js.map +0 -1
  67. package/esm2015/lib/modules/tiles/tile-dashboard-config/tile-dashboard-config-layout-tile.js +0 -2
  68. package/esm2015/lib/modules/tiles/tile-dashboard-config/tile-dashboard-config-layout-tile.js.map +0 -1
  69. package/esm2015/lib/modules/tiles/tile-dashboard-config/tile-dashboard-config-layout.js +0 -2
  70. package/esm2015/lib/modules/tiles/tile-dashboard-config/tile-dashboard-config-layout.js.map +0 -1
  71. package/esm2015/lib/modules/tiles/tile-dashboard-config/tile-dashboard-config-reorder-data.js +0 -2
  72. package/esm2015/lib/modules/tiles/tile-dashboard-config/tile-dashboard-config-reorder-data.js.map +0 -1
  73. package/esm2015/lib/modules/tiles/tile-dashboard-config/tile-dashboard-config-tile.js +0 -2
  74. package/esm2015/lib/modules/tiles/tile-dashboard-config/tile-dashboard-config-tile.js.map +0 -1
  75. package/esm2015/lib/modules/tiles/tile-dashboard-config/tile-dashboard-config.js +0 -2
  76. package/esm2015/lib/modules/tiles/tile-dashboard-config/tile-dashboard-config.js.map +0 -1
  77. package/esm2015/lib/modules/tiles/tiles.module.js +0 -31
  78. package/esm2015/lib/modules/tiles/tiles.module.js.map +0 -1
  79. package/esm2015/skyux-tiles.js +0 -5
  80. package/esm2015/skyux-tiles.js.map +0 -1
  81. package/fesm2015/skyux-tiles.js.map +0 -1
@@ -1,525 +0,0 @@
1
- import { EventEmitter, Injectable, Injector, Output, } from '@angular/core';
2
- import { SkyMediaBreakpoints, SkyMediaQueryService, SkyUIConfigService, } from '@skyux/core';
3
- import { DragulaService } from 'ng2-dragula';
4
- import { take } from 'rxjs/operators';
5
- import * as i0 from "@angular/core";
6
- import * as i1 from "ng2-dragula";
7
- import * as i2 from "@skyux/core";
8
- const ATTR_TILE_ID = '_sky-tile-dashboard-tile-id';
9
- let bagIdIndex = 0;
10
- export class SkyTileDashboardService {
11
- constructor(dragulaService, mediaQuery, uiConfigService) {
12
- this.dragulaService = dragulaService;
13
- this.mediaQuery = mediaQuery;
14
- this.uiConfigService = uiConfigService;
15
- /**
16
- * @internal
17
- */
18
- this.configChange = new EventEmitter();
19
- /**
20
- * Fires when the tile dashboard's initialization is complete.
21
- */
22
- this.dashboardInitialized = new EventEmitter();
23
- this.bagId = 'sky-tile-dashboard-bag-' + ++bagIdIndex;
24
- this.initDragula();
25
- }
26
- /**
27
- * @internal
28
- */
29
- init(config, columns, singleColumn, settingsKey) {
30
- if (settingsKey) {
31
- // Clone this so changes to the config object outside of this class don't modify
32
- // the config used inside and vice versa.
33
- this.defaultConfig = this.config = Object.assign({}, config);
34
- this.settingsKey = settingsKey;
35
- this.uiConfigService
36
- .getConfig(settingsKey, config)
37
- .pipe(take(1))
38
- .subscribe((value) => {
39
- if (value.persisted) {
40
- this.config.layout = value.layout;
41
- this.checkForNewTiles(value.tileIds);
42
- this.configChange.emit(this.config);
43
- this.columns = columns;
44
- this.singleColumn = singleColumn;
45
- this.checkReadyAndLoadTiles();
46
- }
47
- else {
48
- // Bad data, or config is the default config.
49
- this.initToDefaults(config, columns, singleColumn);
50
- }
51
- }, (error) => {
52
- // Config setting key doesn't exist or other config service error
53
- this.initToDefaults(config, columns, singleColumn);
54
- });
55
- }
56
- else {
57
- this.initToDefaults(config, columns, singleColumn);
58
- }
59
- }
60
- /**
61
- * Adds a new tile to the tile dashboard.
62
- * @param tile Specifies the tile configuration.
63
- * @param component Specifies the tile component to add.
64
- */
65
- addTileComponent(tile, component) {
66
- this.tileComponents = this.tileComponents || [];
67
- this.tileComponents.push(component);
68
- component.location.nativeElement.setAttribute(ATTR_TILE_ID, tile.id);
69
- }
70
- /**
71
- * Checks whether a specified tile is collapsed.
72
- * @param tile Specifies the tile component to check.
73
- */
74
- tileIsCollapsed(tile) {
75
- const tileConfig = this.findTile(this.getTileId(tile));
76
- if (tileConfig) {
77
- return tileConfig.isCollapsed;
78
- }
79
- return undefined;
80
- }
81
- /**
82
- * Sets the collapsed state of all tiles.
83
- * @param isCollapsed Indicates whether tiles are collapsed.
84
- */
85
- setAllTilesCollapsed(isCollapsed) {
86
- /*istanbul ignore else */
87
- if (this.config && this.config.layout.multiColumn) {
88
- for (const column of this.config.layout.multiColumn) {
89
- for (const tile of column.tiles) {
90
- tile.isCollapsed = isCollapsed;
91
- }
92
- }
93
- for (const tile of this.config.layout.singleColumn.tiles) {
94
- tile.isCollapsed = isCollapsed;
95
- }
96
- }
97
- if (this.settingsKey) {
98
- this.setUserConfig(this.config);
99
- }
100
- this.configChange.emit(this.config);
101
- }
102
- /**
103
- * Sets the collapsed state of a specified tile.
104
- * @param tile Specifies the tile component.
105
- * @param isCollapsed Indicates whether the tile is collapsed.
106
- */
107
- setTileCollapsed(tile, isCollapsed) {
108
- const tileConfig = this.findTile(this.getTileId(tile));
109
- if (tileConfig) {
110
- tileConfig.isCollapsed = isCollapsed;
111
- if (this.settingsKey) {
112
- this.setUserConfig(this.config);
113
- }
114
- this.configChange.emit(this.config);
115
- }
116
- }
117
- /**
118
- * @internal
119
- */
120
- getTileComponentType(layoutTile) {
121
- if (layoutTile) {
122
- for (const tile of this.config.tiles) {
123
- if (tile.id === layoutTile.id) {
124
- return tile.componentType;
125
- }
126
- }
127
- }
128
- return undefined;
129
- }
130
- /**
131
- * @internal
132
- */
133
- changeColumnMode(isSingleColumn) {
134
- /*istanbul ignore else */
135
- if (this.config) {
136
- if (isSingleColumn) {
137
- this.moveTilesToSingleColumn();
138
- }
139
- else {
140
- this.moveTilesToMultiColumn();
141
- }
142
- }
143
- }
144
- /**
145
- * @internal
146
- */
147
- getTileComponent(tileId) {
148
- for (const tileComponent of this.tileComponents) {
149
- if (tileComponent.location.nativeElement.getAttribute(ATTR_TILE_ID) ===
150
- tileId) {
151
- return tileComponent;
152
- }
153
- }
154
- /*istanbul ignore next */
155
- return undefined;
156
- }
157
- /**
158
- * @internal
159
- */
160
- destroy() {
161
- /*istanbul ignore else */
162
- if (this.mediaSubscription) {
163
- this.mediaSubscription.unsubscribe();
164
- }
165
- }
166
- /**
167
- * @internal
168
- */
169
- moveTileOnKeyDown(tileCmp, direction, tileDescription) {
170
- const isSingleColumnMode = this.mediaQuery.current === SkyMediaBreakpoints.xs ||
171
- this.mediaQuery.current === SkyMediaBreakpoints.sm;
172
- const tileId = this.getTileId(tileCmp);
173
- const tile = this.findTile(tileId);
174
- let column;
175
- let colIndex;
176
- if (isSingleColumnMode) {
177
- column = this.config.layout.singleColumn;
178
- }
179
- else {
180
- column = this.findTileColumn(tileId);
181
- colIndex = this.config.layout.multiColumn.findIndex((value) => value === column);
182
- }
183
- if ((direction === 'left' || direction === 'right') &&
184
- !isSingleColumnMode) {
185
- const operator = direction === 'left' ? -1 : 1;
186
- const newColumn = this.config.layout.multiColumn[colIndex + operator];
187
- if (newColumn) {
188
- // Move the tile to the end of the new column
189
- newColumn.tiles.push(tile);
190
- column.tiles = column.tiles.filter((item) => item !== tile);
191
- this.moveTilesToColumn(this.columns.toArray()[colIndex + operator], [
192
- tile,
193
- ]);
194
- // Report the change in configuration
195
- const reportConfig = this.config;
196
- reportConfig.movedTile = {
197
- tileDescription: tileDescription || /* istanbul ignore next */ tile.id,
198
- column: colIndex + operator + 1,
199
- position: newColumn.tiles.length,
200
- };
201
- this.configChange.emit(reportConfig);
202
- }
203
- }
204
- else {
205
- const operator = direction === 'up' ? -1 : 1;
206
- const curIndex = column.tiles.findIndex((value) => value.id === tile.id);
207
- const tileComponentInstance = this.getTileComponent(tileId);
208
- if (tileComponentInstance && column.tiles[curIndex + operator]) {
209
- const temp = column.tiles[curIndex + operator];
210
- column.tiles[curIndex + operator] = tile;
211
- column.tiles[curIndex] = temp;
212
- // Get the column element
213
- let columnEl;
214
- if (isSingleColumnMode) {
215
- columnEl = this.getColumnEl(this.singleColumn);
216
- }
217
- else {
218
- columnEl = this.getColumnEl(this.columns.toArray()[colIndex]);
219
- }
220
- // Move the tile element in the document
221
- if (curIndex + operator === column.tiles.length - 1) {
222
- columnEl.appendChild(tileComponentInstance.location.nativeElement);
223
- }
224
- else {
225
- columnEl.insertBefore(tileComponentInstance.location.nativeElement, this.getTileComponent(column.tiles[curIndex + operator + 1].id)
226
- .location.nativeElement);
227
- }
228
- // Report the change in configuration
229
- const reportConfig = this.config;
230
- reportConfig.movedTile = {
231
- tileDescription: tileDescription || /* istanbul ignore next */ tile.id,
232
- column: isSingleColumnMode ? undefined : colIndex + 1,
233
- position: curIndex + operator + 1,
234
- };
235
- this.configChange.emit(reportConfig);
236
- }
237
- }
238
- }
239
- getTileId(tile) {
240
- if (tile) {
241
- let el = tile.elementRef.nativeElement;
242
- let tileId;
243
- while (el) {
244
- tileId = el.getAttribute(ATTR_TILE_ID);
245
- if (tileId) {
246
- return tileId;
247
- }
248
- el = el.parentElement;
249
- }
250
- }
251
- return undefined;
252
- }
253
- getTileOrRemoveFromLayout(layoutTile) {
254
- /*istanbul ignore else */
255
- if (layoutTile) {
256
- for (const tile of this.config.tiles) {
257
- if (tile.id === layoutTile.id) {
258
- return tile;
259
- }
260
- }
261
- // If the layout tile was not found in the list of tiles, it was removed since last the user updated settings
262
- /*istanbul ignore else */
263
- if (this.config.layout.singleColumn) {
264
- this.config.layout.singleColumn.tiles =
265
- this.config.layout.singleColumn.tiles.filter((elem) => elem.id !== layoutTile.id);
266
- }
267
- /*istanbul ignore else */
268
- if (this.config.layout.multiColumn) {
269
- this.config.layout.multiColumn.forEach((elem) => {
270
- elem.tiles = elem.tiles.filter((res) => res.id !== layoutTile.id);
271
- });
272
- }
273
- }
274
- /*istanbul ignore next */
275
- return undefined;
276
- }
277
- checkReadyAndLoadTiles() {
278
- if (this.config && this.columns) {
279
- this.loadTiles();
280
- this.initMediaQueries();
281
- this.dashboardInitialized.emit();
282
- }
283
- }
284
- loadTiles() {
285
- const layout = this.config.layout;
286
- if (this.mediaQuery.current === SkyMediaBreakpoints.xs ||
287
- this.mediaQuery.current === SkyMediaBreakpoints.sm) {
288
- for (const tile of layout.singleColumn.tiles) {
289
- this.loadTileIntoColumn(this.singleColumn, tile);
290
- }
291
- }
292
- else {
293
- const columns = this.columns.toArray();
294
- for (let i = 0, n = layout.multiColumn.length; i < n; i++) {
295
- const column = columns[i];
296
- for (const tile of layout.multiColumn[i].tiles) {
297
- this.loadTileIntoColumn(column, tile);
298
- }
299
- }
300
- }
301
- }
302
- loadTileIntoColumn(column, layoutTile) {
303
- const tile = this.getTileOrRemoveFromLayout(layoutTile);
304
- /*istanbul ignore else */
305
- if (tile) {
306
- const componentType = tile.componentType;
307
- const providers = tile.providers /* istanbul ignore next */ || [];
308
- const injector = Injector.create({
309
- providers,
310
- parent: column.injector,
311
- });
312
- const factory = column.resolver.resolveComponentFactory(componentType);
313
- const componentRef = column.content.createComponent(factory, undefined, injector);
314
- this.addTileComponent(layoutTile, componentRef);
315
- // Make sure the component is marked for changes in case the parent component uses
316
- // the OnPush change detection strategy.
317
- componentRef.changeDetectorRef.markForCheck();
318
- }
319
- }
320
- moveTilesToSingleColumn() {
321
- this.moveTilesToColumn(this.singleColumn, this.config.layout.singleColumn.tiles);
322
- }
323
- moveTilesToMultiColumn() {
324
- const layoutColumns = this.config.layout.multiColumn;
325
- const columns = this.columns.toArray();
326
- for (let i = 0, n = layoutColumns.length; i < n; i++) {
327
- this.moveTilesToColumn(columns[i], layoutColumns[i].tiles);
328
- }
329
- }
330
- moveTilesToColumn(column, layoutTiles) {
331
- const columnEl = this.getColumnEl(column);
332
- for (const layoutTile of layoutTiles) {
333
- const tileComponentInstance = this.getTileComponent(layoutTile.id);
334
- /*istanbul ignore else */
335
- if (tileComponentInstance) {
336
- columnEl.appendChild(tileComponentInstance.location.nativeElement);
337
- }
338
- }
339
- }
340
- getConfigForUIState() {
341
- /*istanbul ignore else */
342
- if (this.config) {
343
- this.config = {
344
- tiles: this.config.tiles,
345
- layout: {
346
- singleColumn: this.getSingleColumnLayoutForUIState(),
347
- multiColumn: this.getMultiColumnLayoutForUIState(),
348
- },
349
- };
350
- }
351
- return this.config;
352
- }
353
- getSingleColumnLayoutForUIState() {
354
- if (this.mediaQuery.current === SkyMediaBreakpoints.xs ||
355
- this.mediaQuery.current === SkyMediaBreakpoints.sm) {
356
- return {
357
- tiles: this.getTilesInEl(this.getColumnEl(this.singleColumn)),
358
- };
359
- }
360
- return this.config.layout.singleColumn;
361
- }
362
- getMultiColumnLayoutForUIState() {
363
- if (!(this.mediaQuery.current === SkyMediaBreakpoints.xs ||
364
- this.mediaQuery.current === SkyMediaBreakpoints.sm)) {
365
- const layoutColumns = [];
366
- const columns = this.columns.toArray();
367
- for (const column of columns) {
368
- if (column !== this.singleColumn) {
369
- const layoutColumn = {
370
- tiles: this.getTilesInEl(this.getColumnEl(column)),
371
- };
372
- layoutColumns.push(layoutColumn);
373
- }
374
- }
375
- return layoutColumns;
376
- }
377
- return this.config.layout.multiColumn;
378
- }
379
- getTilesInEl(el) {
380
- const tileEls = el.querySelectorAll('[' + ATTR_TILE_ID + ']');
381
- const layoutTiles = [];
382
- /*istanbul ignore else */
383
- if (tileEls) {
384
- for (let i = 0, n = tileEls.length; i < n; i++) {
385
- const tileEl = tileEls[i];
386
- const tileId = tileEl.getAttribute(ATTR_TILE_ID);
387
- const tile = this.findTile(tileId);
388
- /*istanbul ignore else */
389
- if (tile) {
390
- layoutTiles.push(tile);
391
- }
392
- }
393
- }
394
- return layoutTiles;
395
- }
396
- initMediaQueries() {
397
- /*istanbul ignore else */
398
- if (!this.mediaSubscription) {
399
- this.mediaSubscription = this.mediaQuery.subscribe((args) => {
400
- this.changeColumnMode(args === SkyMediaBreakpoints.xs || args === SkyMediaBreakpoints.sm);
401
- });
402
- }
403
- }
404
- initDragula() {
405
- this.dragulaService.setOptions(this.bagId, {
406
- moves: (el, container, handle) => {
407
- const target = el.querySelector('.sky-tile-grab-handle');
408
- return target.contains(handle);
409
- },
410
- });
411
- this.dragulaService.drop.subscribe((value) => {
412
- const config = this.getConfigForUIState();
413
- /*istanbul ignore else */
414
- if (config) {
415
- if (this.settingsKey) {
416
- this.setUserConfig(config);
417
- }
418
- this.configChange.emit(config);
419
- }
420
- });
421
- }
422
- getColumnEl(column) {
423
- return column.content.element.nativeElement.parentNode;
424
- }
425
- findTile(tileId) {
426
- /*istanbul ignore else */
427
- if (this.config && this.config.layout.multiColumn) {
428
- for (const column of this.config.layout.multiColumn) {
429
- /*istanbul ignore else */
430
- if (column.tiles) {
431
- for (const tile of column.tiles) {
432
- if (tile.id === tileId) {
433
- return tile;
434
- }
435
- }
436
- }
437
- }
438
- }
439
- return undefined;
440
- }
441
- findTileColumn(tileId) {
442
- /*istanbul ignore else */
443
- if (this.config && this.config.layout.multiColumn) {
444
- return this.config.layout.multiColumn.find((col) => col.tiles && !!col.tiles.find((tile) => tile.id === tileId));
445
- }
446
- /*istanbul ignore next */
447
- return undefined;
448
- }
449
- initToDefaults(config, columns, singleColumn) {
450
- this.config = config;
451
- this.columns = columns;
452
- this.singleColumn = singleColumn;
453
- this.checkReadyAndLoadTiles();
454
- }
455
- setUserConfig(config) {
456
- this.uiConfigService
457
- .setConfig(this.settingsKey, {
458
- layout: this.config.layout,
459
- persisted: true,
460
- tileIds: this.defaultConfig.tiles.map((elem) => elem.id),
461
- })
462
- .subscribe(
463
- // eslint-disable-next-line @typescript-eslint/no-empty-function
464
- () => { }, (err) => {
465
- console.warn('Could not save tile dashboard settings.');
466
- console.warn(err);
467
- });
468
- }
469
- checkForNewTiles(oldUserTiles) {
470
- // Get a list of tiles that are in the config's default list but not in the user's settings
471
- const newTiles = this.config.tiles.filter((elem) => {
472
- return oldUserTiles.indexOf(elem.id) === -1;
473
- });
474
- const { multiColumn, singleColumn } = this.config.layout;
475
- // Append new tiles to the end of the layouts
476
- /*istanbul ignore else */
477
- if (newTiles.length > 0) {
478
- /*istanbul ignore else */
479
- if (multiColumn) {
480
- newTiles.forEach((elem) => {
481
- let locationToAdd = 0;
482
- let smallest = multiColumn[0].tiles.length;
483
- multiColumn.forEach((item, index) => {
484
- if (item.tiles.length < smallest) {
485
- locationToAdd = index;
486
- smallest = item.tiles.length;
487
- }
488
- });
489
- multiColumn[locationToAdd].tiles.push({
490
- id: elem.id,
491
- isCollapsed: false,
492
- });
493
- });
494
- }
495
- /*istanbul ignore else */
496
- if (singleColumn) {
497
- newTiles.forEach((elem) => {
498
- singleColumn.tiles.push({ id: elem.id, isCollapsed: false });
499
- });
500
- }
501
- }
502
- /*istanbul ignore else */
503
- if (singleColumn) {
504
- for (const tile of singleColumn.tiles) {
505
- this.getTileOrRemoveFromLayout(tile);
506
- }
507
- }
508
- /*istanbul ignore else */
509
- if (multiColumn) {
510
- for (let i = 0, n = multiColumn.length; i < n; i++) {
511
- for (const tile of multiColumn[i].tiles) {
512
- this.getTileOrRemoveFromLayout(tile);
513
- }
514
- }
515
- }
516
- }
517
- }
518
- SkyTileDashboardService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTileDashboardService, deps: [{ token: i1.DragulaService }, { token: i2.SkyMediaQueryService }, { token: i2.SkyUIConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
519
- SkyTileDashboardService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTileDashboardService });
520
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTileDashboardService, decorators: [{
521
- type: Injectable
522
- }], ctorParameters: function () { return [{ type: i1.DragulaService }, { type: i2.SkyMediaQueryService }, { type: i2.SkyUIConfigService }]; }, propDecorators: { dashboardInitialized: [{
523
- type: Output
524
- }] } });
525
- //# sourceMappingURL=tile-dashboard.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tile-dashboard.service.js","sourceRoot":"","sources":["../../../../../../../../../libs/components/tiles/src/lib/modules/tiles/tile-dashboard/tile-dashboard.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,MAAM,GAEP,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;;;;AAStC,MAAM,YAAY,GAAG,6BAA6B,CAAC;AAEnD,IAAI,UAAU,GAAG,CAAC,CAAC;AAGnB,MAAM,OAAO,uBAAuB;IA+BlC,YACU,cAA8B,EAC9B,UAAgC,EAChC,eAAmC;QAFnC,mBAAc,GAAd,cAAc,CAAgB;QAC9B,e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AO,CAAC,CAAC,IAAI,EAAE,EAAE;oBACxB,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;gBAC/D,CAAC,CAAC,CAAC;aACJ;SACF;QAED,yBAAyB;QACzB,IAAI,YAAY,EAAE;YAChB,KAAK,MAAM,IAAI,IAAI,YAAY,CAAC,KAAK,EAAE;gBACrC,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC;aACtC;SACF;QAED,yBAAyB;QACzB,IAAI,WAAW,EAAE;YACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;gBAClD,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE;oBACvC,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC;iBACtC;aACF;SACF;IACH,CAAC;;qHAtqBU,uBAAuB;yHAAvB,uBAAuB;4FAAvB,uBAAuB;kBADnC,UAAU;yKAgBF,oBAAoB;sBAD1B,MAAM","sourcesContent":["import {\n ComponentRef,\n EventEmitter,\n Injectable,\n Injector,\n Output,\n QueryList,\n} from '@angular/core';\nimport {\n SkyMediaBreakpoints,\n SkyMediaQueryService,\n SkyUIConfigService,\n} from '@skyux/core';\n\nimport { DragulaService } from 'ng2-dragula';\nimport { Subscription } from 'rxjs';\nimport { take } from 'rxjs/operators';\n\nimport { SkyTileDashboardColumnComponent } from '../tile-dashboard-column/tile-dashboard-column.component';\nimport { SkyTileDashboardConfig } from '../tile-dashboard-config/tile-dashboard-config';\nimport { SkyTileDashboardConfigLayoutColumn } from '../tile-dashboard-config/tile-dashboard-config-layout-column';\nimport { SkyTileDashboardConfigLayoutTile } from '../tile-dashboard-config/tile-dashboard-config-layout-tile';\nimport { SkyTileDashboardConfigTile } from '../tile-dashboard-config/tile-dashboard-config-tile';\nimport { SkyTileComponent } from '../tile/tile.component';\n\nconst ATTR_TILE_ID = '_sky-tile-dashboard-tile-id';\n\nlet bagIdIndex = 0;\n\n@Injectable()\nexport class SkyTileDashboardService {\n /**\n * @internal\n */\n public bagId: string;\n\n /**\n * @internal\n */\n public configChange = new EventEmitter<SkyTileDashboardConfig>();\n\n /**\n * Fires when the tile dashboard's initialization is complete.\n */\n @Output()\n public dashboardInitialized = new EventEmitter<void>();\n\n private tileComponents: ComponentRef<any>[];\n\n private config: SkyTileDashboardConfig;\n\n private defaultConfig: SkyTileDashboardConfig;\n\n private columns: QueryList<SkyTileDashboardColumnComponent>;\n\n private singleColumn: SkyTileDashboardColumnComponent;\n\n private mediaSubscription: Subscription;\n\n private settingsKey: string;\n\n constructor(\n private dragulaService: DragulaService,\n private mediaQuery: SkyMediaQueryService,\n private uiConfigService: SkyUIConfigService\n ) {\n this.bagId = 'sky-tile-dashboard-bag-' + ++bagIdIndex;\n\n this.initDragula();\n }\n\n /**\n * @internal\n */\n public init(\n config: SkyTileDashboardConfig,\n columns?: QueryList<SkyTileDashboardColumnComponent>,\n singleColumn?: SkyTileDashboardColumnComponent,\n settingsKey?: string\n ) {\n if (settingsKey) {\n // Clone this so changes to the config object outside of this class don't modify\n // the config used inside and vice versa.\n this.defaultConfig = this.config = Object.assign({}, config);\n\n this.settingsKey = settingsKey;\n\n this.uiConfigService\n .getConfig(settingsKey, config)\n .pipe(take(1))\n .subscribe(\n (value: any) => {\n if (value.persisted) {\n this.config.layout = value.layout;\n this.checkForNewTiles(value.tileIds);\n this.configChange.emit(this.config);\n\n this.columns = columns;\n this.singleColumn = singleColumn;\n this.checkReadyAndLoadTiles();\n } else {\n // Bad data, or config is the default config.\n this.initToDefaults(config, columns, singleColumn);\n }\n },\n (error: any) => {\n // Config setting key doesn't exist or other config service error\n this.initToDefaults(config, columns, singleColumn);\n }\n );\n } else {\n this.initToDefaults(config, columns, singleColumn);\n }\n }\n\n /**\n * Adds a new tile to the tile dashboard.\n * @param tile Specifies the tile configuration.\n * @param component Specifies the tile component to add.\n */\n public addTileComponent(\n tile: SkyTileDashboardConfigLayoutTile,\n component: ComponentRef<any>\n ) {\n this.tileComponents = this.tileComponents || [];\n\n this.tileComponents.push(component);\n\n component.location.nativeElement.setAttribute(ATTR_TILE_ID, tile.id);\n }\n\n /**\n * Checks whether a specified tile is collapsed.\n * @param tile Specifies the tile component to check.\n */\n public tileIsCollapsed(tile: SkyTileComponent): boolean {\n const tileConfig = this.findTile(this.getTileId(tile));\n\n if (tileConfig) {\n return tileConfig.isCollapsed;\n }\n\n return undefined;\n }\n\n /**\n * Sets the collapsed state of all tiles.\n * @param isCollapsed Indicates whether tiles are collapsed.\n */\n public setAllTilesCollapsed(isCollapsed: boolean): void {\n /*istanbul ignore else */\n if (this.config && this.config.layout.multiColumn) {\n for (const column of this.config.layout.multiColumn) {\n for (const tile of column.tiles) {\n tile.isCollapsed = isCollapsed;\n }\n }\n for (const tile of this.config.layout.singleColumn.tiles) {\n tile.isCollapsed = isCollapsed;\n }\n }\n\n if (this.settingsKey) {\n this.setUserConfig(this.config);\n }\n\n this.configChange.emit(this.config);\n }\n\n /**\n * Sets the collapsed state of a specified tile.\n * @param tile Specifies the tile component.\n * @param isCollapsed Indicates whether the tile is collapsed.\n */\n public setTileCollapsed(tile: SkyTileComponent, isCollapsed: boolean) {\n const tileConfig = this.findTile(this.getTileId(tile));\n\n if (tileConfig) {\n tileConfig.isCollapsed = isCollapsed;\n\n if (this.settingsKey) {\n this.setUserConfig(this.config);\n }\n\n this.configChange.emit(this.config);\n }\n }\n\n /**\n * @internal\n */\n public getTileComponentType(\n layoutTile: SkyTileDashboardConfigLayoutTile\n ): any {\n if (layoutTile) {\n for (const tile of this.config.tiles) {\n if (tile.id === layoutTile.id) {\n return tile.componentType;\n }\n }\n }\n\n return undefined;\n }\n\n /**\n * @internal\n */\n public changeColumnMode(isSingleColumn: boolean) {\n /*istanbul ignore else */\n if (this.config) {\n if (isSingleColumn) {\n this.moveTilesToSingleColumn();\n } else {\n this.moveTilesToMultiColumn();\n }\n }\n }\n\n /**\n * @internal\n */\n public getTileComponent(tileId: string): ComponentRef<any> {\n for (const tileComponent of this.tileComponents) {\n if (\n tileComponent.location.nativeElement.getAttribute(ATTR_TILE_ID) ===\n tileId\n ) {\n return tileComponent;\n }\n }\n\n /*istanbul ignore next */\n return undefined;\n }\n\n /**\n * @internal\n */\n public destroy() {\n /*istanbul ignore else */\n if (this.mediaSubscription) {\n this.mediaSubscription.unsubscribe();\n }\n }\n\n /**\n * @internal\n */\n public moveTileOnKeyDown(\n tileCmp: SkyTileComponent,\n direction: string,\n tileDescription: string\n ) {\n const isSingleColumnMode =\n this.mediaQuery.current === SkyMediaBreakpoints.xs ||\n this.mediaQuery.current === SkyMediaBreakpoints.sm;\n\n const tileId = this.getTileId(tileCmp);\n const tile = this.findTile(tileId);\n\n let column: SkyTileDashboardConfigLayoutColumn;\n let colIndex: number;\n if (isSingleColumnMode) {\n column = this.config.layout.singleColumn;\n } else {\n column = this.findTileColumn(tileId);\n colIndex = this.config.layout.multiColumn.findIndex(\n (value) => value === column\n );\n }\n\n if (\n (direction === 'left' || direction === 'right') &&\n !isSingleColumnMode\n ) {\n const operator = direction === 'left' ? -1 : 1;\n const newColumn = this.config.layout.multiColumn[colIndex + operator];\n\n if (newColumn) {\n // Move the tile to the end of the new column\n newColumn.tiles.push(tile);\n column.tiles = column.tiles.filter((item) => item !== tile);\n this.moveTilesToColumn(this.columns.toArray()[colIndex + operator], [\n tile,\n ]);\n\n // Report the change in configuration\n const reportConfig = this.config;\n reportConfig.movedTile = {\n tileDescription:\n tileDescription || /* istanbul ignore next */ tile.id,\n column: colIndex + operator + 1,\n position: newColumn.tiles.length,\n };\n this.configChange.emit(reportConfig);\n }\n } else {\n const operator = direction === 'up' ? -1 : 1;\n const curIndex = column.tiles.findIndex((value) => value.id === tile.id);\n const tileComponentInstance = this.getTileComponent(tileId);\n\n if (tileComponentInstance && column.tiles[curIndex + operator]) {\n const temp = column.tiles[curIndex + operator];\n column.tiles[curIndex + operator] = tile;\n column.tiles[curIndex] = temp;\n\n // Get the column element\n let columnEl: Element;\n if (isSingleColumnMode) {\n columnEl = this.getColumnEl(this.singleColumn);\n } else {\n columnEl = this.getColumnEl(this.columns.toArray()[colIndex]);\n }\n\n // Move the tile element in the document\n if (curIndex + operator === column.tiles.length - 1) {\n columnEl.appendChild(tileComponentInstance.location.nativeElement);\n } else {\n columnEl.insertBefore(\n tileComponentInstance.location.nativeElement,\n this.getTileComponent(column.tiles[curIndex + operator + 1].id)\n .location.nativeElement\n );\n }\n\n // Report the change in configuration\n const reportConfig = this.config;\n reportConfig.movedTile = {\n tileDescription:\n tileDescription || /* istanbul ignore next */ tile.id,\n column: isSingleColumnMode ? undefined : colIndex + 1,\n position: curIndex + operator + 1,\n };\n this.configChange.emit(reportConfig);\n }\n }\n }\n\n private getTileId(tile: SkyTileComponent): string {\n if (tile) {\n let el = tile.elementRef.nativeElement;\n let tileId: string;\n\n while (el) {\n tileId = el.getAttribute(ATTR_TILE_ID);\n\n if (tileId) {\n return tileId;\n }\n\n el = el.parentElement;\n }\n }\n\n return undefined;\n }\n\n private getTileOrRemoveFromLayout(\n layoutTile: SkyTileDashboardConfigLayoutTile\n ): SkyTileDashboardConfigTile {\n /*istanbul ignore else */\n if (layoutTile) {\n for (const tile of this.config.tiles) {\n if (tile.id === layoutTile.id) {\n return tile;\n }\n }\n\n // If the layout tile was not found in the list of tiles, it was removed since last the user updated settings\n /*istanbul ignore else */\n if (this.config.layout.singleColumn) {\n this.config.layout.singleColumn.tiles =\n this.config.layout.singleColumn.tiles.filter(\n (elem) => elem.id !== layoutTile.id\n );\n }\n\n /*istanbul ignore else */\n if (this.config.layout.multiColumn) {\n this.config.layout.multiColumn.forEach((elem) => {\n elem.tiles = elem.tiles.filter((res) => res.id !== layoutTile.id);\n });\n }\n }\n\n /*istanbul ignore next */\n return undefined;\n }\n\n private checkReadyAndLoadTiles() {\n if (this.config && this.columns) {\n this.loadTiles();\n this.initMediaQueries();\n this.dashboardInitialized.emit();\n }\n }\n\n private loadTiles() {\n const layout = this.config.layout;\n\n if (\n this.mediaQuery.current === SkyMediaBreakpoints.xs ||\n this.mediaQuery.current === SkyMediaBreakpoints.sm\n ) {\n for (const tile of layout.singleColumn.tiles) {\n this.loadTileIntoColumn(this.singleColumn, tile);\n }\n } else {\n const columns = this.columns.toArray();\n\n for (let i = 0, n = layout.multiColumn.length; i < n; i++) {\n const column = columns[i];\n\n for (const tile of layout.multiColumn[i].tiles) {\n this.loadTileIntoColumn(column, tile);\n }\n }\n }\n }\n\n private loadTileIntoColumn(\n column: SkyTileDashboardColumnComponent,\n layoutTile: SkyTileDashboardConfigLayoutTile\n ) {\n const tile = this.getTileOrRemoveFromLayout(layoutTile);\n\n /*istanbul ignore else */\n if (tile) {\n const componentType = tile.componentType;\n const providers = tile.providers /* istanbul ignore next */ || [];\n\n const injector = Injector.create({\n providers,\n parent: column.injector,\n });\n\n const factory = column.resolver.resolveComponentFactory(componentType);\n const componentRef = column.content.createComponent(\n factory,\n undefined,\n injector\n );\n\n this.addTileComponent(layoutTile, componentRef);\n\n // Make sure the component is marked for changes in case the parent component uses\n // the OnPush change detection strategy.\n componentRef.changeDetectorRef.markForCheck();\n }\n }\n\n private moveTilesToSingleColumn() {\n this.moveTilesToColumn(\n this.singleColumn,\n this.config.layout.singleColumn.tiles\n );\n }\n\n private moveTilesToMultiColumn() {\n const layoutColumns = this.config.layout.multiColumn;\n const columns = this.columns.toArray();\n\n for (let i = 0, n = layoutColumns.length; i < n; i++) {\n this.moveTilesToColumn(columns[i], layoutColumns[i].tiles);\n }\n }\n\n private moveTilesToColumn(\n column: SkyTileDashboardColumnComponent,\n layoutTiles: SkyTileDashboardConfigLayoutTile[]\n ) {\n const columnEl = this.getColumnEl(column);\n\n for (const layoutTile of layoutTiles) {\n const tileComponentInstance = this.getTileComponent(layoutTile.id);\n\n /*istanbul ignore else */\n if (tileComponentInstance) {\n columnEl.appendChild(tileComponentInstance.location.nativeElement);\n }\n }\n }\n\n private getConfigForUIState(): SkyTileDashboardConfig {\n /*istanbul ignore else */\n if (this.config) {\n this.config = {\n tiles: this.config.tiles,\n layout: {\n singleColumn: this.getSingleColumnLayoutForUIState(),\n multiColumn: this.getMultiColumnLayoutForUIState(),\n },\n };\n }\n\n return this.config;\n }\n\n private getSingleColumnLayoutForUIState(): SkyTileDashboardConfigLayoutColumn {\n if (\n this.mediaQuery.current === SkyMediaBreakpoints.xs ||\n this.mediaQuery.current === SkyMediaBreakpoints.sm\n ) {\n return {\n tiles: this.getTilesInEl(this.getColumnEl(this.singleColumn)),\n };\n }\n\n return this.config.layout.singleColumn;\n }\n\n private getMultiColumnLayoutForUIState(): SkyTileDashboardConfigLayoutColumn[] {\n if (\n !(\n this.mediaQuery.current === SkyMediaBreakpoints.xs ||\n this.mediaQuery.current === SkyMediaBreakpoints.sm\n )\n ) {\n const layoutColumns: SkyTileDashboardConfigLayoutColumn[] = [];\n const columns = this.columns.toArray();\n\n for (const column of columns) {\n if (column !== this.singleColumn) {\n const layoutColumn: SkyTileDashboardConfigLayoutColumn = {\n tiles: this.getTilesInEl(this.getColumnEl(column)),\n };\n\n layoutColumns.push(layoutColumn);\n }\n }\n\n return layoutColumns;\n }\n\n return this.config.layout.multiColumn;\n }\n\n private getTilesInEl(el: Element): SkyTileDashboardConfigLayoutTile[] {\n const tileEls: any = el.querySelectorAll('[' + ATTR_TILE_ID + ']');\n const layoutTiles: SkyTileDashboardConfigLayoutTile[] = [];\n\n /*istanbul ignore else */\n if (tileEls) {\n for (let i = 0, n = tileEls.length; i < n; i++) {\n const tileEl = tileEls[i];\n const tileId = tileEl.getAttribute(ATTR_TILE_ID);\n const tile = this.findTile(tileId);\n\n /*istanbul ignore else */\n if (tile) {\n layoutTiles.push(tile);\n }\n }\n }\n\n return layoutTiles;\n }\n\n private initMediaQueries() {\n /*istanbul ignore else */\n if (!this.mediaSubscription) {\n this.mediaSubscription = this.mediaQuery.subscribe(\n (args: SkyMediaBreakpoints) => {\n this.changeColumnMode(\n args === SkyMediaBreakpoints.xs || args === SkyMediaBreakpoints.sm\n );\n }\n );\n }\n }\n\n private initDragula() {\n this.dragulaService.setOptions(this.bagId, {\n moves: (el: HTMLElement, container: HTMLElement, handle: HTMLElement) => {\n const target = el.querySelector('.sky-tile-grab-handle');\n return target.contains(handle);\n },\n });\n\n this.dragulaService.drop.subscribe((value: any[]) => {\n const config = this.getConfigForUIState();\n\n /*istanbul ignore else */\n if (config) {\n if (this.settingsKey) {\n this.setUserConfig(config);\n }\n\n this.configChange.emit(config);\n }\n });\n }\n\n private getColumnEl(column: SkyTileDashboardColumnComponent): Element {\n return column.content.element.nativeElement.parentNode;\n }\n\n private findTile(tileId: string): SkyTileDashboardConfigLayoutTile {\n /*istanbul ignore else */\n if (this.config && this.config.layout.multiColumn) {\n for (const column of this.config.layout.multiColumn) {\n /*istanbul ignore else */\n if (column.tiles) {\n for (const tile of column.tiles) {\n if (tile.id === tileId) {\n return tile;\n }\n }\n }\n }\n }\n\n return undefined;\n }\n\n private findTileColumn(tileId: string): SkyTileDashboardConfigLayoutColumn {\n /*istanbul ignore else */\n if (this.config && this.config.layout.multiColumn) {\n return this.config.layout.multiColumn.find(\n (col) => col.tiles && !!col.tiles.find((tile) => tile.id === tileId)\n );\n }\n\n /*istanbul ignore next */\n return undefined;\n }\n\n private initToDefaults(\n config: SkyTileDashboardConfig,\n columns: QueryList<SkyTileDashboardColumnComponent>,\n singleColumn: SkyTileDashboardColumnComponent\n ) {\n this.config = config;\n this.columns = columns;\n this.singleColumn = singleColumn;\n this.checkReadyAndLoadTiles();\n }\n\n private setUserConfig(config: SkyTileDashboardConfig) {\n this.uiConfigService\n .setConfig(this.settingsKey, {\n layout: this.config.layout,\n persisted: true,\n tileIds: this.defaultConfig.tiles.map((elem) => elem.id),\n })\n .subscribe(\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n () => {},\n (err) => {\n console.warn('Could not save tile dashboard settings.');\n console.warn(err);\n }\n );\n }\n\n private checkForNewTiles(oldUserTiles: string[]) {\n // Get a list of tiles that are in the config's default list but not in the user's settings\n const newTiles = this.config.tiles.filter((elem) => {\n return oldUserTiles.indexOf(elem.id) === -1;\n });\n\n const { multiColumn, singleColumn } = this.config.layout;\n\n // Append new tiles to the end of the layouts\n /*istanbul ignore else */\n if (newTiles.length > 0) {\n /*istanbul ignore else */\n if (multiColumn) {\n newTiles.forEach((elem) => {\n let locationToAdd = 0;\n let smallest = multiColumn[0].tiles.length;\n multiColumn.forEach((item, index) => {\n if (item.tiles.length < smallest) {\n locationToAdd = index;\n smallest = item.tiles.length;\n }\n });\n multiColumn[locationToAdd].tiles.push({\n id: elem.id,\n isCollapsed: false,\n });\n });\n }\n\n /*istanbul ignore else */\n if (singleColumn) {\n newTiles.forEach((elem) => {\n singleColumn.tiles.push({ id: elem.id, isCollapsed: false });\n });\n }\n }\n\n /*istanbul ignore else */\n if (singleColumn) {\n for (const tile of singleColumn.tiles) {\n this.getTileOrRemoveFromLayout(tile);\n }\n }\n\n /*istanbul ignore else */\n if (multiColumn) {\n for (let i = 0, n = multiColumn.length; i < n; i++) {\n for (const tile of multiColumn[i].tiles) {\n this.getTileOrRemoveFromLayout(tile);\n }\n }\n }\n }\n}\n"]}
@@ -1,36 +0,0 @@
1
- import { Component, ComponentFactoryResolver, Injector, ViewChild, ViewContainerRef, } from '@angular/core';
2
- import { SkyTileDashboardService } from '../tile-dashboard/tile-dashboard.service';
3
- import * as i0 from "@angular/core";
4
- import * as i1 from "../tile-dashboard/tile-dashboard.service";
5
- import * as i2 from "ng2-dragula";
6
- let columnIdIndex = 0;
7
- /**
8
- * @internal
9
- */
10
- export class SkyTileDashboardColumnComponent {
11
- constructor(resolver, injector, dashboardService) {
12
- this.resolver = resolver;
13
- this.injector = injector;
14
- this.dashboardService = dashboardService;
15
- columnIdIndex++;
16
- this.columnId = 'tile-dashboard-column-' + columnIdIndex;
17
- this.bagId = this.dashboardService.bagId;
18
- }
19
- }
20
- SkyTileDashboardColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTileDashboardColumnComponent, deps: [{ token: i0.ComponentFactoryResolver }, { token: i0.Injector }, { token: i1.SkyTileDashboardService }], target: i0.ɵɵFactoryTarget.Component });
21
- SkyTileDashboardColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SkyTileDashboardColumnComponent, selector: "sky-tile-dashboard-column", viewQueries: [{ propertyName: "content", first: true, predicate: ["content"], descendants: true, read: ViewContainerRef }], ngImport: i0, template: "<div class=\"sky-tile-dashboard-column\" [dragula]=\"bagId\">\n <div #content></div>\n</div>\n", styles: [":host{display:flex;flex-grow:1;overflow:hidden}:host{padding:0}:host-context(.sky-responsive-container-xs),:host-context(.sky-responsive-container-sm),:host-context(.sky-responsive-container-md),:host-context(.sky-responsive-container-lg){padding:0}@media (min-width: 768px){:host{padding:0 10px}}:host-context(.sky-responsive-container-sm),:host-context(.sky-responsive-container-md),:host-context(.sky-responsive-container-lg){padding:0 10px}.sky-tile-dashboard-column{min-height:100px;width:100%}@media (min-width: 768px){:host-context(.sky-theme-modern) :host{padding:0 15px}}:host-context(.sky-theme-modern) :host-context(.sky-responsive-container-sm),:host-context(.sky-theme-modern) :host-context(.sky-responsive-container-md),:host-context(.sky-theme-modern) :host-context(.sky-responsive-container-lg){padding:0 15px}@media (min-width: 768px){.sky-theme-modern :host{padding:0 15px}}.sky-theme-modern :host-context(.sky-responsive-container-sm),.sky-theme-modern :host-context(.sky-responsive-container-md),.sky-theme-modern :host-context(.sky-responsive-container-lg){padding:0 15px}\n"], directives: [{ type: i2.DragulaDirective, selector: "[dragula]", inputs: ["dragula", "dragulaModel", "dragulaOptions"] }] });
22
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTileDashboardColumnComponent, decorators: [{
23
- type: Component,
24
- args: [{
25
- selector: 'sky-tile-dashboard-column',
26
- styleUrls: ['./tile-dashboard-column.component.scss'],
27
- templateUrl: './tile-dashboard-column.component.html',
28
- }]
29
- }], ctorParameters: function () { return [{ type: i0.ComponentFactoryResolver }, { type: i0.Injector }, { type: i1.SkyTileDashboardService }]; }, propDecorators: { content: [{
30
- type: ViewChild,
31
- args: ['content', {
32
- read: ViewContainerRef,
33
- static: false,
34
- }]
35
- }] } });
36
- //# sourceMappingURL=tile-dashboard-column.component.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tile-dashboard-column.component.js","sourceRoot":"","sources":["../../../../../../../../../libs/components/tiles/src/lib/modules/tiles/tile-dashboard-column/tile-dashboard-column.component.ts","../../../../../../../../../libs/components/tiles/src/lib/modules/tiles/tile-dashboard-column/tile-dashboard-column.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,wBAAwB,EACxB,QAAQ,EACR,SAAS,EACT,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;;;;AAEnF,IAAI,aAAa,GAAG,CAAC,CAAC;AAEtB;;GAEG;AAMH,MAAM,OAAO,+BAA+B;IAW1C,YACS,QAAkC,EAClC,QAAkB,EACjB,gBAAyC;QAF1C,aAAQ,GAAR,QAAQ,CAA0B;QAClC,aAAQ,GAAR,QAAQ,CAAU;QACjB,qBAAgB,GAAhB,gBAAgB,CAAyB;QAEjD,aAAa,EAAE,CAAC;QAEhB,IAAI,CAAC,QAAQ,GAAG,wBAAwB,GAAG,aAAa,CAAC;QAEzD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC;IAC3C,CAAC;;6HArBU,+BAA+B;iHAA/B,+BAA+B,gJAMlC,gBAAgB,6BC1B1B,iGAGA;4FDiBa,+BAA+B;kBAL3C,SAAS;mBAAC;oBACT,QAAQ,EAAE,2BAA2B;oBACrC,SAAS,EAAE,CAAC,wCAAwC,CAAC;oBACrD,WAAW,EAAE,wCAAwC;iBACtD;4KAUQ,OAAO;sBAJb,SAAS;uBAAC,SAAS,EAAE;wBACpB,IAAI,EAAE,gBAAgB;wBACtB,MAAM,EAAE,KAAK;qBACd","sourcesContent":["import {\n Component,\n ComponentFactoryResolver,\n Injector,\n ViewChild,\n ViewContainerRef,\n} from '@angular/core';\n\nimport { SkyTileDashboardService } from '../tile-dashboard/tile-dashboard.service';\n\nlet columnIdIndex = 0;\n\n/**\n * @internal\n */\n@Component({\n selector: 'sky-tile-dashboard-column',\n styleUrls: ['./tile-dashboard-column.component.scss'],\n templateUrl: './tile-dashboard-column.component.html',\n})\nexport class SkyTileDashboardColumnComponent {\n public bagId: string;\n\n public columnId: string;\n\n @ViewChild('content', {\n read: ViewContainerRef,\n static: false,\n })\n public content: ViewContainerRef;\n\n constructor(\n public resolver: ComponentFactoryResolver,\n public injector: Injector,\n private dashboardService: SkyTileDashboardService\n ) {\n columnIdIndex++;\n\n this.columnId = 'tile-dashboard-column-' + columnIdIndex;\n\n this.bagId = this.dashboardService.bagId;\n }\n}\n","<div class=\"sky-tile-dashboard-column\" [dragula]=\"bagId\">\n <div #content></div>\n</div>\n"]}