@sd-angular/core 0.0.935 → 0.0.936

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.
@@ -1117,7 +1117,7 @@ SdGridService.ctorParameters = () => [
1117
1117
  { type: SdUtilityService }
1118
1118
  ];
1119
1119
 
1120
- var _paginator, _sort, _subscription$1, _optionChanges, _initCellDef, _initFilterDef, _initFooterDef, _filterExportInfo, _initConfiguration, _filterLocal, _getFilter, _load$1, _render, _exportedItems, _allColumns, _allExportedColumns, _onExport, _updateSelectedItems, _generateEditorHanlder;
1120
+ var _paginator, _sort, _subscription$1, _optionChanges, _initCellDef, _initFilterDef, _initFooterDef, _filterExportInfo, _initConfiguration, _filterLocal, _getFilter, _load$1, _render, _exportedItems, _allColumns, _allExportedColumns, _onExport, _updateSelectedItems;
1121
1121
  class SdGridMaterial {
1122
1122
  constructor(ref, configuration, gridConfigurationService, exportService, notifyService, translateService, gridService) {
1123
1123
  this.ref = ref;
@@ -1672,10 +1672,6 @@ class SdGridMaterial {
1672
1672
  var _a;
1673
1673
  (_a = this.gridFilter) === null || _a === void 0 ? void 0 : _a.setFilter(args);
1674
1674
  };
1675
- _generateEditorHanlder.set(this, (item) => {
1676
- // item.editorHandler = item.editorHandler || {};
1677
- // this.editorVisiblePipe.transform(null, item, this.gridOption);
1678
- });
1679
1675
  this.onCreate = () => {
1680
1676
  var _a;
1681
1677
  const { type, editor, columns } = this.gridOption;
@@ -1720,6 +1716,9 @@ class SdGridMaterial {
1720
1716
  this.ref.detectChanges();
1721
1717
  };
1722
1718
  this.onSave = (item) => __awaiter(this, void 0, void 0, function* () {
1719
+ if (item.editorHandlerRow.saving) {
1720
+ return;
1721
+ }
1723
1722
  const { editor } = this.gridOption;
1724
1723
  try {
1725
1724
  item.editorHandlerRow.saving = true;
@@ -1862,8 +1861,28 @@ class SdGridMaterial {
1862
1861
  drop(event, columns) {
1863
1862
  moveItemInArray(columns, event.previousIndex, event.currentIndex);
1864
1863
  }
1864
+ get editedItems() {
1865
+ return this.items.filter(item => {
1866
+ if (!item.originItem) {
1867
+ return true;
1868
+ }
1869
+ if (Object.keys(item.originItem).some(key => item.originItem[key] !== item[key])) {
1870
+ return true;
1871
+ }
1872
+ return false;
1873
+ }).map(item => {
1874
+ const { editorStatus, editorHandlerRow, editorHandlerColumn, expandDetail, isExpanded, isExpanding, isSelected, originItem } = item, result = __rest(item, ["editorStatus", "editorHandlerRow", "editorHandlerColumn", "expandDetail", "isExpanded", "isExpanding", "isSelected", "originItem"]);
1875
+ return Object.assign(Object.assign({}, result), { editorErrorMessage: editorHandlerRow === null || editorHandlerRow === void 0 ? void 0 : editorHandlerRow.errorMessage });
1876
+ });
1877
+ }
1878
+ get gridItems() {
1879
+ return this.items.map(item => {
1880
+ const { editorStatus, editorHandlerRow, editorHandlerColumn, expandDetail, isExpanded, isExpanding, isSelected, originItem } = item, result = __rest(item, ["editorStatus", "editorHandlerRow", "editorHandlerColumn", "expandDetail", "isExpanded", "isExpanding", "isSelected", "originItem"]);
1881
+ return result;
1882
+ });
1883
+ }
1865
1884
  }
1866
- _paginator = new WeakMap(), _sort = new WeakMap(), _subscription$1 = new WeakMap(), _optionChanges = new WeakMap(), _initCellDef = new WeakMap(), _initFilterDef = new WeakMap(), _initFooterDef = new WeakMap(), _filterExportInfo = new WeakMap(), _initConfiguration = new WeakMap(), _filterLocal = new WeakMap(), _getFilter = new WeakMap(), _load$1 = new WeakMap(), _render = new WeakMap(), _exportedItems = new WeakMap(), _allColumns = new WeakMap(), _allExportedColumns = new WeakMap(), _onExport = new WeakMap(), _updateSelectedItems = new WeakMap(), _generateEditorHanlder = new WeakMap();
1885
+ _paginator = new WeakMap(), _sort = new WeakMap(), _subscription$1 = new WeakMap(), _optionChanges = new WeakMap(), _initCellDef = new WeakMap(), _initFilterDef = new WeakMap(), _initFooterDef = new WeakMap(), _filterExportInfo = new WeakMap(), _initConfiguration = new WeakMap(), _filterLocal = new WeakMap(), _getFilter = new WeakMap(), _load$1 = new WeakMap(), _render = new WeakMap(), _exportedItems = new WeakMap(), _allColumns = new WeakMap(), _allExportedColumns = new WeakMap(), _onExport = new WeakMap(), _updateSelectedItems = new WeakMap();
1867
1886
  SdGridMaterial.decorators = [
1868
1887
  { type: Component, args: [{
1869
1888
  selector: 'sd-grid-material',
@@ -2701,7 +2720,7 @@ class SdDesktopCell {
2701
2720
  SdDesktopCell.decorators = [
2702
2721
  { type: Component, args: [{
2703
2722
  selector: 'sd-desktop-cell',
2704
- template: "<ng-container *ngIf=\"column && item\">\r\n <ng-container *ngIf=\"item.editorHandlerRow;else useView\">\r\n <ng-container *sdLet=\"item[column.field] | sdEditorHandlerColumn:item:column:gridOption\">\r\n <ng-container *ngIf=\"item.editorHandlerColumn[column.field]?.visible;else useDisabledView\">\r\n <ng-container *ngIf=\"cellDef[column.field]\">\r\n <ng-container *ngTemplateOutlet=\"\r\n cellDef[column.field].templateRef;\r\n context: { item: item, column: column, idx: idx, editorStatus: 'edited' }\r\n \">\r\n </ng-container>\r\n </ng-container>\r\n <sd-desktop-cell-editor *ngIf=\"!cellDef[column.field]\" [column]=\"column\" [item]=\"item\"></sd-desktop-cell-editor>\r\n </ng-container>\r\n </ng-container>\r\n </ng-container>\r\n <ng-template #useView>\r\n <ng-container *ngIf=\"cellDef[column.field]\">\r\n <ng-container *ngTemplateOutlet=\"\r\n cellDef[column.field].templateRef;\r\n context: { item: item, column: column, idx: idx }\r\n \">\r\n </ng-container>\r\n </ng-container>\r\n <sd-desktop-cell-view *ngIf=\"!cellDef[column.field]\" [key]=\"key\" [column]=\"column\" [item]=\"item\"></sd-desktop-cell-view>\r\n </ng-template>\r\n <ng-template #useDisabledView>\r\n <ng-container *ngIf=\"cellDef[column.field]\">\r\n <ng-container *ngTemplateOutlet=\"\r\n cellDef[column.field].templateRef;\r\n context: { item: item, column: column, idx: idx, editorStatus: 'disabled' }\r\n \">\r\n </ng-container>\r\n </ng-container>\r\n <sd-desktop-cell-view *ngIf=\"!cellDef[column.field]\" [key]=\"key\" [column]=\"column\" [item]=\"item\"></sd-desktop-cell-view>\r\n </ng-template>\r\n</ng-container>",
2723
+ template: "<ng-container *ngIf=\"column && item\">\r\n <ng-container *ngIf=\"item.editorHandlerRow;else useView\">\r\n <ng-container *sdLet=\"item[column.field] | sdEditorHandlerColumn:item:column:gridOption\">\r\n <ng-container *ngIf=\"item.editorHandlerColumn[column.field]?.visible;else useView\">\r\n <ng-container *sdLet=\"item[column.field] | sdEditorValidate:item:column:gridOption\">\r\n <ng-container *ngIf=\"cellDef[column.field]\">\r\n <ng-container *ngTemplateOutlet=\"\r\n cellDef[column.field].templateRef;\r\n context: { item: item, column: column, idx: idx, isEdited: true }\r\n \">\r\n </ng-container>\r\n </ng-container>\r\n <sd-desktop-cell-editor *ngIf=\"!cellDef[column.field]\" [column]=\"column\" [item]=\"item\">\r\n </sd-desktop-cell-editor>\r\n </ng-container>\r\n </ng-container>\r\n </ng-container>\r\n </ng-container>\r\n <ng-template #useView>\r\n <ng-container *ngIf=\"cellDef[column.field]\">\r\n <ng-container *ngTemplateOutlet=\"\r\n cellDef[column.field].templateRef;\r\n context: { item: item, column: column, idx: idx }\r\n \">\r\n </ng-container>\r\n </ng-container>\r\n <sd-desktop-cell-view *ngIf=\"!cellDef[column.field]\" [key]=\"key\" [column]=\"column\" [item]=\"item\">\r\n </sd-desktop-cell-view>\r\n </ng-template>\r\n</ng-container>",
2705
2724
  changeDetection: ChangeDetectionStrategy.OnPush,
2706
2725
  styles: [".c-color-success{color:#4caf50}.c-color-danger{color:#f82c13}.c-img{font-size:30px;opacity:.5}.c-img.pointer:hover{opacity:.9}.c-badge{border-radius:20px;display:inline-block;margin-bottom:4px;padding:2px 12px;text-align:center}.c-badge.c-warning{background:#fff3e0;color:#ff9600}.c-badge.c-info{background:#e7e9ff;color:#2962ff}.c-badge.c-success{background:#e8f5e9;color:#4caf50}.c-badge.c-danger{background:#fee8e7;color:#f82c13}.c-badge.c-normal{background:rgba(0,0,0,.12);color:#000}.wes-status .c-material-icon{font-size:12px;height:12px;width:12px}.wes-status.text-secondary .c-material-icon{color:rgba(0,0,0,.5)}.c-badge-circle .c-material-icon{font-size:12px;height:12px;width:12px}.c-badge-circle.c-unknown{color:#212121}.c-badge-circle.c-unknown .c-material-icon{color:rgba(0,0,0,.5)}.c-badge-circle.c-secondary{color:#212121}.c-badge-circle.c-info{color:#2962ff}.c-badge-circle.c-success{color:#4caf50}.c-badge-circle.c-danger{color:#f82c13}.c-badge-circle.c-warning{color:#ff9600}"]
2707
2726
  },] }
@@ -2816,9 +2835,15 @@ class SdEditorValidatePipe {
2816
2835
  constructor() {
2817
2836
  this.delay = 1000; // Sau khoảng thời gian delay nếu không có thay đổi thì thì mới bắt đầu thực hiện validate
2818
2837
  }
2819
- transform(value, item, validate) {
2838
+ transform(value, item, column, gridOption) {
2839
+ var _a;
2820
2840
  return __awaiter(this, void 0, void 0, function* () {
2821
- if (!item.editorHandlerRow) {
2841
+ const { editor } = gridOption;
2842
+ if (!((_a = item.editorHandlerRow) === null || _a === void 0 ? void 0 : _a.visible)) {
2843
+ return true;
2844
+ }
2845
+ if (!editor.validate) {
2846
+ item.editorHandlerRow.errorMessage = null;
2822
2847
  return true;
2823
2848
  }
2824
2849
  this.previous = new Date();
@@ -2828,11 +2853,7 @@ class SdEditorValidatePipe {
2828
2853
  if (dif < this.delay) {
2829
2854
  return true;
2830
2855
  }
2831
- if (!validate) {
2832
- item.editorHandlerRow.errorMessage = null;
2833
- return true;
2834
- }
2835
- const result = validate(item);
2856
+ const result = editor.validate(item);
2836
2857
  if (result instanceof Promise) {
2837
2858
  item.editorHandlerRow.errorMessage = yield result;
2838
2859
  return true;