@sd-angular/core 1.3.200 → 1.3.202

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.
@@ -1,5 +1,5 @@
1
1
  import { SdScrollDirective, SdCommonModule } from '@sd-angular/core/common';
2
- import { InjectionToken, Directive, TemplateRef, Input, Component, ChangeDetectionStrategy, ChangeDetectorRef, ViewChild, Injectable, Inject, Optional, EventEmitter, HostListener, QueryList, ContentChild, ContentChildren, Pipe, Output, NgModule } from '@angular/core';
2
+ import { Directive, TemplateRef, Input, InjectionToken, Component, ChangeDetectionStrategy, ChangeDetectorRef, ViewChild, Injectable, Inject, Optional, EventEmitter, HostListener, QueryList, ContentChild, ContentChildren, Pipe, Output, NgModule } from '@angular/core';
3
3
  import { CommonModule, DatePipe, DecimalPipe } from '@angular/common';
4
4
  import { MatIconModule } from '@angular/material/icon';
5
5
  import { __classPrivateFieldGet, __classPrivateFieldSet, __awaiter } from 'tslib';
@@ -32,14 +32,6 @@ import { MatCheckboxModule } from '@angular/material/checkbox';
32
32
  import { MatListModule } from '@angular/material/list';
33
33
  import { SdGroupModule } from '@sd-angular/core/group';
34
34
 
35
- const DEFAULT_TABLE_CONFIG = {
36
- paginate: {
37
- pageSize: 20,
38
- pages: [20, 50, 100, 200]
39
- }
40
- };
41
- const TABLE_CONFIG = new InjectionToken('sd-table.configuration');
42
-
43
35
  class SdTabelCellDefDirective {
44
36
  constructor(templateRef) {
45
37
  this.templateRef = templateRef;
@@ -57,6 +49,35 @@ SdTabelCellDefDirective.propDecorators = {
57
49
  sdTableCellDef: [{ type: Input }]
58
50
  };
59
51
 
52
+ class SdTableFilterDefDirective {
53
+ constructor(templateRef) {
54
+ this.templateRef = templateRef;
55
+ }
56
+ set showing(val) {
57
+ this.defaultShowing = (val === '') || val;
58
+ }
59
+ }
60
+ SdTableFilterDefDirective.decorators = [
61
+ { type: Directive, args: [{
62
+ selector: '[sdTableFilterDef]'
63
+ },] }
64
+ ];
65
+ SdTableFilterDefDirective.ctorParameters = () => [
66
+ { type: TemplateRef }
67
+ ];
68
+ SdTableFilterDefDirective.propDecorators = {
69
+ sdTableFilterDef: [{ type: Input }],
70
+ showing: [{ type: Input, args: ['defaultShowing',] }]
71
+ };
72
+
73
+ const DEFAULT_TABLE_CONFIG = {
74
+ paginate: {
75
+ pageSize: 20,
76
+ pages: [20, 50, 100, 200]
77
+ }
78
+ };
79
+ const TABLE_CONFIG = new InjectionToken('sd-table.configuration');
80
+
60
81
  var _filterRegister;
61
82
  class SdPopupFilter {
62
83
  constructor(cdRef) {
@@ -226,27 +247,6 @@ SdTableFilter.propDecorators = {
226
247
  _filterRegister: [{ type: Input, args: ['filterRegister',] }]
227
248
  };
228
249
 
229
- class SdTableFilterDefDirective {
230
- constructor(templateRef) {
231
- this.templateRef = templateRef;
232
- }
233
- set showing(val) {
234
- this.defaultShowing = (val === '') || val;
235
- }
236
- }
237
- SdTableFilterDefDirective.decorators = [
238
- { type: Directive, args: [{
239
- selector: '[sdTableFilterDef]'
240
- },] }
241
- ];
242
- SdTableFilterDefDirective.ctorParameters = () => [
243
- { type: TemplateRef }
244
- ];
245
- SdTableFilterDefDirective.propDecorators = {
246
- sdTableFilterDef: [{ type: Input }],
247
- showing: [{ type: Input, args: ['defaultShowing',] }]
248
- };
249
-
250
250
  class SdMaterialSubInformationDefDirective {
251
251
  constructor(templateRef) {
252
252
  this.templateRef = templateRef;
@@ -1195,9 +1195,16 @@ class SdTable {
1195
1195
  obj[column.field] = Date.toFormat(date, 'HH:mm');
1196
1196
  }
1197
1197
  else if (column.type === 'values' || column.type === 'lazy-values') {
1198
- // Nếu là values thì lấy giá trị của value được chọn
1199
- obj[column.field] =
1200
- ((_z = (_y = __classPrivateFieldGet(this, _cacheObjValues)[column.field]) === null || _y === void 0 ? void 0 : _y[item[column.field]]) === null || _z === void 0 ? void 0 : _z[column.option.displayField]) || item[column.field];
1198
+ const value = item[column.field];
1199
+ if (column.type === 'lazy-values' && typeof column.option.mapValue === 'function') {
1200
+ const val = column.option.mapValue(value, item);
1201
+ const vals = (Array.isArray(val) ? val : [val]).filter(e => !!(e === null || e === void 0 ? void 0 : e.toString()));
1202
+ obj[column.field] = (_y = vals.map(val => { var _a, _b; return ((_b = (_a = __classPrivateFieldGet(this, _cacheObjValues)[column.field]) === null || _a === void 0 ? void 0 : _a[val]) === null || _b === void 0 ? void 0 : _b[column.option.displayField]) || val; })) === null || _y === void 0 ? void 0 : _y.join(', ');
1203
+ }
1204
+ else {
1205
+ const vals = (Array.isArray(value) ? value : [value]).filter(e => !!(e === null || e === void 0 ? void 0 : e.toString()));
1206
+ obj[column.field] = (_z = vals.map(val => { var _a, _b; return ((_b = (_a = __classPrivateFieldGet(this, _cacheObjValues)[column.field]) === null || _a === void 0 ? void 0 : _a[val]) === null || _b === void 0 ? void 0 : _b[column.option.displayField]) || val; })) === null || _z === void 0 ? void 0 : _z.join(', ');
1207
+ }
1201
1208
  }
1202
1209
  else {
1203
1210
  obj[column.field] = item[column.field];
@@ -1443,7 +1450,7 @@ class SdTable {
1443
1450
  }
1444
1451
  }));
1445
1452
  _format.set(this, (rawItems, columns) => __awaiter(this, void 0, void 0, function* () {
1446
- var _5, _6, _7, _8, _9;
1453
+ var _5, _6, _7;
1447
1454
  const items = rawItems.map(MapToSdTableItem);
1448
1455
  for (const column of columns) {
1449
1456
  // Clickable
@@ -1459,7 +1466,9 @@ class SdTable {
1459
1466
  }
1460
1467
  return (_b = item.data) === null || _b === void 0 ? void 0 : _b[field];
1461
1468
  })
1462
- .filter(val => (!!val || val === 0) && !Object.keys(__classPrivateFieldGet(this, _cacheObjValues)[field]).includes(val))
1469
+ .filter(val => !!(val === null || val === void 0 ? void 0 : val.toString()))
1470
+ .reduce((current, next) => [...current, ...(Array.isArray(next) ? next : [next])], [])
1471
+ .filter(val => !Object.keys(__classPrivateFieldGet(this, _cacheObjValues)[field]).includes(val))
1463
1472
  .union();
1464
1473
  if (values.length) {
1465
1474
  const lazyItems = (yield views(values).catch(err => {
@@ -1522,10 +1531,13 @@ class SdTable {
1522
1531
  }
1523
1532
  if (column.type === 'values' || column.type === 'lazy-values') {
1524
1533
  if (column.type === 'lazy-values' && typeof column.option.mapValue === 'function') {
1525
- display.data = ((_6 = (_5 = __classPrivateFieldGet(this, _cacheObjValues)[field]) === null || _5 === void 0 ? void 0 : _5[column.option.mapValue(value, rowData)]) === null || _6 === void 0 ? void 0 : _6[column.option.displayField]) || value;
1534
+ const val = column.option.mapValue(value, rowData);
1535
+ const vals = (Array.isArray(val) ? val : [val]).filter(e => !!(e === null || e === void 0 ? void 0 : e.toString()));
1536
+ display.data = (_5 = vals.map(val => { var _a, _b; return ((_b = (_a = __classPrivateFieldGet(this, _cacheObjValues)[field]) === null || _a === void 0 ? void 0 : _a[val]) === null || _b === void 0 ? void 0 : _b[column.option.displayField]) || val; })) === null || _5 === void 0 ? void 0 : _5.join(', ');
1526
1537
  }
1527
1538
  else {
1528
- display.data = ((_8 = (_7 = __classPrivateFieldGet(this, _cacheObjValues)[field]) === null || _7 === void 0 ? void 0 : _7[value]) === null || _8 === void 0 ? void 0 : _8[column.option.displayField]) || value;
1539
+ const vals = (Array.isArray(value) ? value : [value]).filter(e => !!(e === null || e === void 0 ? void 0 : e.toString()));
1540
+ display.data = (_6 = vals.map(val => { var _a, _b; return ((_b = (_a = __classPrivateFieldGet(this, _cacheObjValues)[field]) === null || _a === void 0 ? void 0 : _a[val]) === null || _b === void 0 ? void 0 : _b[column.option.displayField]) || val; })) === null || _6 === void 0 ? void 0 : _6.join(', ');
1529
1541
  }
1530
1542
  }
1531
1543
  if (column.type === 'number' && Number.isNumber(value)) {
@@ -1545,7 +1557,7 @@ class SdTable {
1545
1557
  display.badge = {
1546
1558
  type: !(column === null || column === void 0 ? void 0 : column.badgeType) ? 'icon' : column.badgeType,
1547
1559
  color: column.badge(value, rowData),
1548
- icon: (_9 = column.badgeIcon) === null || _9 === void 0 ? void 0 : _9.call(column, value, rowData),
1560
+ icon: (_7 = column.badgeIcon) === null || _7 === void 0 ? void 0 : _7.call(column, value, rowData),
1549
1561
  };
1550
1562
  }
1551
1563
  else if (column.type === 'bool') {
@@ -2527,5 +2539,5 @@ class SdTableQuickFilter {
2527
2539
  * Generated bundle index. Do not edit.
2528
2540
  */
2529
2541
 
2530
- export { DEFAULT_TABLE_CONFIG, MatPaginatorIntlCro, SdFilterOperators, SdTable, SdTableModule, SdTableQuickFilter, TABLE_CONFIG, SdTableQuickAction as ɵa, SdDesktopCell as ɵb, SdSelectionVisibleSelectAllPipe as ɵba, SdGroupPipe as ɵbb, SdDesktopCellView as ɵc, SdDesktopCommand as ɵd, SdColumnInlineFilter as ɵe, SdPopupConfiguration as ɵf, SdTableConfigurationService as ɵg, TABLE_CONFIG as ɵi, SdTableFilter as ɵj, SdPopupFilter as ɵk, SdMaterialSubInformationDefDirective as ɵl, SdTabelCellDefDirective as ɵm, SdMaterialFooterDefDirective as ɵn, SdTableFilterDefDirective as ɵo, SdTableFilterService as ɵp, SdCommandFilterPipe as ɵq, SdCommandDisablePipe as ɵr, SdCommandIconPipe as ɵs, SdCommandTitlePipe as ɵt, SdColumnTooltipPipe as ɵu, SdFilterColumnPipe as ɵv, SdFilterExternalPipe as ɵw, SdSelectionActionFilterPipe as ɵx, SdSelectionVisiblePipe as ɵy, SdSelectionDisablePipe as ɵz };
2542
+ export { DEFAULT_TABLE_CONFIG, MatPaginatorIntlCro, SdFilterOperators, SdTabelCellDefDirective, SdTable, SdTableFilterDefDirective, SdTableModule, SdTableQuickFilter, TABLE_CONFIG, SdTableQuickAction as ɵa, SdDesktopCell as ɵb, SdDesktopCellView as ɵc, SdDesktopCommand as ɵd, SdColumnInlineFilter as ɵe, SdPopupConfiguration as ɵf, SdTableConfigurationService as ɵg, TABLE_CONFIG as ɵi, SdTableFilter as ɵj, SdPopupFilter as ɵk, SdMaterialSubInformationDefDirective as ɵl, SdMaterialFooterDefDirective as ɵm, SdTableFilterService as ɵn, SdCommandFilterPipe as ɵo, SdCommandDisablePipe as ɵp, SdCommandIconPipe as ɵq, SdCommandTitlePipe as ɵr, SdColumnTooltipPipe as ɵs, SdFilterColumnPipe as ɵt, SdFilterExternalPipe as ɵu, SdSelectionActionFilterPipe as ɵv, SdSelectionVisiblePipe as ɵw, SdSelectionDisablePipe as ɵx, SdSelectionVisibleSelectAllPipe as ɵy, SdGroupPipe as ɵz };
2531
2543
  //# sourceMappingURL=sd-angular-core-table.js.map