@colijnit/corecomponents_v12 257.1.37 → 257.1.38

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.
@@ -9935,7 +9935,8 @@
9935
9935
  };
9936
9936
 
9937
9937
  var BaseSimpleGridComponent = /** @class */ (function () {
9938
- function BaseSimpleGridComponent() {
9938
+ function BaseSimpleGridComponent(changeDetection) {
9939
+ this.changeDetection = changeDetection;
9939
9940
  this.MIN_COLUMN_WIDTH = 50;
9940
9941
  this.dataChanged = new rxjs.Subject();
9941
9942
  this.dragDropEnabled = false;
@@ -9951,6 +9952,7 @@
9951
9952
  this.emitDragDrop = false;
9952
9953
  this.onDrop = new i0.EventEmitter();
9953
9954
  this.selectRow = new i0.EventEmitter();
9955
+ this.deselectRow = new i0.EventEmitter();
9954
9956
  this.dblClickRow = new i0.EventEmitter();
9955
9957
  this.saveRow = new i0.EventEmitter();
9956
9958
  this.deleteRow = new i0.EventEmitter();
@@ -10044,6 +10046,11 @@
10044
10046
  return row.singleColumnIndex;
10045
10047
  };
10046
10048
  BaseSimpleGridComponent.prototype.prepareDataRow = function (row, index) {
10049
+ return __awaiter(this, void 0, void 0, function () {
10050
+ return __generator(this, function (_a) {
10051
+ return [2 /*return*/];
10052
+ });
10053
+ });
10047
10054
  };
10048
10055
  BaseSimpleGridComponent.prototype._setColumns = function (columns) {
10049
10056
  var _a;
@@ -10051,34 +10058,66 @@
10051
10058
  this.columns.sort(function (a, b) { return a.order < b.order ? -1 : 1; });
10052
10059
  };
10053
10060
  BaseSimpleGridComponent.prototype._prepareData = function () {
10054
- if (this._prepared) {
10055
- return;
10056
- }
10057
- this.disabledRows.length = 0;
10058
- if (this.columns && this.columns.length > 0) {
10059
- this.headerColumns = this.columns.filter(function (c) { return !c.singleColumn; });
10060
- this.headerColumnsCopy = this.headerColumns;
10061
- var singleColumnIndex = -1;
10062
- for (var i = 0; i < this.columns.length; i++) {
10063
- if (this.columns[i].singleColumn) {
10064
- singleColumnIndex = i;
10065
- break;
10066
- }
10067
- }
10068
- // first check if there's single column data
10069
- if (singleColumnIndex > -1 && this.data && this.data.length > 0) {
10070
- var field = this.columns[singleColumnIndex].field;
10071
- for (var i = 0; i < this.data.length; i++) { // then mark row as single column row
10072
- if (this.data[i][field] !== undefined && this.data[i][field] !== null && this.data[i][field] !== "") {
10073
- // bit nasty to add prop, but cool for now
10074
- this.data[i].singleColumnIndex = singleColumnIndex;
10075
- }
10076
- this.prepareDataRow(this.data[i], i);
10061
+ return __awaiter(this, void 0, void 0, function () {
10062
+ var singleColumnIndex, i, field, i, j;
10063
+ return __generator(this, function (_a) {
10064
+ switch (_a.label) {
10065
+ case 0:
10066
+ if (this._prepared) {
10067
+ return [2 /*return*/];
10068
+ }
10069
+ this.disabledRows.length = 0;
10070
+ if (!(this.columns && this.columns.length > 0)) return [3 /*break*/, 10];
10071
+ this.headerColumns = this.columns.filter(function (c) { return !c.singleColumn; });
10072
+ this.headerColumnsCopy = this.headerColumns;
10073
+ singleColumnIndex = -1;
10074
+ for (i = 0; i < this.columns.length; i++) {
10075
+ if (this.columns[i].singleColumn) {
10076
+ singleColumnIndex = i;
10077
+ break;
10078
+ }
10079
+ }
10080
+ if (!(this.data && this.data.length > 0)) return [3 /*break*/, 9];
10081
+ if (!(singleColumnIndex > -1)) return [3 /*break*/, 5];
10082
+ field = this.columns[singleColumnIndex].field;
10083
+ i = 0;
10084
+ _a.label = 1;
10085
+ case 1:
10086
+ if (!(i < this.data.length)) return [3 /*break*/, 4];
10087
+ if (this.data[i][field] !== undefined && this.data[i][field] !== null && this.data[i][field] !== "") {
10088
+ // bit nasty to add prop, but cool for now
10089
+ this.data[i].singleColumnIndex = singleColumnIndex;
10090
+ }
10091
+ return [4 /*yield*/, this.prepareDataRow(this.data[i], i)];
10092
+ case 2:
10093
+ _a.sent();
10094
+ _a.label = 3;
10095
+ case 3:
10096
+ i++;
10097
+ return [3 /*break*/, 1];
10098
+ case 4: return [3 /*break*/, 9];
10099
+ case 5:
10100
+ j = 0;
10101
+ _a.label = 6;
10102
+ case 6:
10103
+ if (!(j < this.data.length)) return [3 /*break*/, 9];
10104
+ return [4 /*yield*/, this.prepareDataRow(this.data[j], j)];
10105
+ case 7:
10106
+ _a.sent();
10107
+ _a.label = 8;
10108
+ case 8:
10109
+ j++;
10110
+ return [3 /*break*/, 6];
10111
+ case 9:
10112
+ this._prepared = true;
10113
+ _a.label = 10;
10114
+ case 10:
10115
+ this._resizeColumnsToFit();
10116
+ this.changeDetection.detectChanges();
10117
+ return [2 /*return*/];
10077
10118
  }
10078
- }
10079
- this._prepared = true;
10080
- }
10081
- this._resizeColumnsToFit();
10119
+ });
10120
+ });
10082
10121
  };
10083
10122
  BaseSimpleGridComponent.prototype._resizeColumnsToFit = function () {
10084
10123
  var calculateColumns = this.columns.filter(function (c) { return !c.autoFit && !c.width; });
@@ -10099,6 +10138,9 @@
10099
10138
  BaseSimpleGridComponent.decorators = [
10100
10139
  { type: i0.Directive }
10101
10140
  ];
10141
+ BaseSimpleGridComponent.ctorParameters = function () { return [
10142
+ { type: i0.ChangeDetectorRef }
10143
+ ]; };
10102
10144
  BaseSimpleGridComponent.propDecorators = {
10103
10145
  content: [{ type: i0.ContentChildren, args: [SimpleGridColumnDirective,] }],
10104
10146
  data: [{ type: i0.Input }],
@@ -10113,6 +10155,7 @@
10113
10155
  extraColumns: [{ type: i0.Input }],
10114
10156
  onDrop: [{ type: i0.Output }],
10115
10157
  selectRow: [{ type: i0.Output }],
10158
+ deselectRow: [{ type: i0.Output }],
10116
10159
  dblClickRow: [{ type: i0.Output }],
10117
10160
  saveRow: [{ type: i0.Output }],
10118
10161
  deleteRow: [{ type: i0.Output }],
@@ -10257,15 +10300,16 @@
10257
10300
 
10258
10301
  var SimpleGridComponent = /** @class */ (function (_super) {
10259
10302
  __extends(SimpleGridComponent, _super);
10260
- function SimpleGridComponent(icons, _changeDetection, _formMaster, excelExportService) {
10261
- var _this = _super.call(this) || this;
10303
+ function SimpleGridComponent(icons, changeDetection, _formMaster, excelExportService) {
10304
+ var _this = _super.call(this, changeDetection) || this;
10262
10305
  _this.icons = icons;
10263
- _this._changeDetection = _changeDetection;
10306
+ _this.changeDetection = changeDetection;
10264
10307
  _this._formMaster = _formMaster;
10265
10308
  _this.excelExportService = excelExportService;
10266
10309
  _this.defaultTextAlign = exports.ColumnAlign.Left;
10267
10310
  _this.showAdd = false;
10268
10311
  _this.showDelete = false;
10312
+ _this.deselectAllowed = false;
10269
10313
  _this.editOnCellClick = true;
10270
10314
  _this.rightToolbar = false;
10271
10315
  _this.showGridSettings = false;
@@ -10309,7 +10353,7 @@
10309
10353
  this._nextAvailableCellToEdit(!event.shiftKey, this.editCellIndex)
10310
10354
  .then(function (index) {
10311
10355
  _this.editCellIndex = index;
10312
- _this._changeDetection.markForCheck();
10356
+ _this.changeDetection.markForCheck();
10313
10357
  });
10314
10358
  this._detectChanges();
10315
10359
  }
@@ -10425,9 +10469,16 @@
10425
10469
  if (emit === void 0) { emit = true; }
10426
10470
  if (this.selectedRowIndex === -1 || (this.selectedRowIndex !== index && ((this.editing && this.validateAndSave()) || !this.editing))) {
10427
10471
  this.selectedRowIndex = index;
10472
+ var absoluteIndex = this.rowsPerPage ? (this.currentPage - 1) * this.rowsPerPage + index : index;
10473
+ if (emit) {
10474
+ this.selectRow.next(this.data[absoluteIndex]);
10475
+ }
10428
10476
  }
10429
- if (emit) {
10430
- this.selectRow.next(this.data[this.selectedRowIndex]);
10477
+ else if (this.selectedRowIndex === index && this.deselectAllowed && ((this.editing && this.validateAndSave()) || !this.editing)) {
10478
+ this.selectedRowIndex = -1;
10479
+ if (emit) {
10480
+ this.deselectRow.next();
10481
+ }
10431
10482
  }
10432
10483
  this._detectChanges();
10433
10484
  };
@@ -10630,7 +10681,16 @@
10630
10681
  return hasSelectedTrue ? items.filter(function (item) { return item.selected === true; }) : items;
10631
10682
  };
10632
10683
  SimpleGridComponent.prototype.prepareDataRow = function (row, index) {
10633
- this.isRowDisabled(row, index);
10684
+ return __awaiter(this, void 0, void 0, function () {
10685
+ return __generator(this, function (_a) {
10686
+ switch (_a.label) {
10687
+ case 0: return [4 /*yield*/, this.isRowDisabled(row, index)];
10688
+ case 1:
10689
+ _a.sent();
10690
+ return [2 /*return*/];
10691
+ }
10692
+ });
10693
+ });
10634
10694
  };
10635
10695
  SimpleGridComponent.prototype._resetDblClick = function () {
10636
10696
  var _this = this;
@@ -10765,7 +10825,7 @@
10765
10825
  this.currentPage = page;
10766
10826
  };
10767
10827
  SimpleGridComponent.prototype._detectChanges = function () {
10768
- this._changeDetection.detectChanges();
10828
+ this.changeDetection.detectChanges();
10769
10829
  };
10770
10830
  SimpleGridComponent.prototype._resetEdit = function () {
10771
10831
  this._newRow = false;
@@ -10796,6 +10856,7 @@
10796
10856
  headerCells: [{ type: i0.ViewChildren, args: ['headerCell',] }],
10797
10857
  showAdd: [{ type: i0.Input }],
10798
10858
  showDelete: [{ type: i0.Input }],
10859
+ deselectAllowed: [{ type: i0.Input }],
10799
10860
  editOnCellClick: [{ type: i0.Input }],
10800
10861
  rightToolbar: [{ type: i0.Input }],
10801
10862
  showGridSettings: [{ type: i0.Input }],