@colijnit/corecomponents_v12 258.1.22 → 258.1.23

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.
@@ -9936,7 +9936,8 @@
9936
9936
  };
9937
9937
 
9938
9938
  var BaseSimpleGridComponent = /** @class */ (function () {
9939
- function BaseSimpleGridComponent() {
9939
+ function BaseSimpleGridComponent(changeDetection) {
9940
+ this.changeDetection = changeDetection;
9940
9941
  this.MIN_COLUMN_WIDTH = 50;
9941
9942
  this.dataChanged = new rxjs.Subject();
9942
9943
  this.dragDropEnabled = false;
@@ -9952,6 +9953,7 @@
9952
9953
  this.emitDragDrop = false;
9953
9954
  this.onDrop = new i0.EventEmitter();
9954
9955
  this.selectRow = new i0.EventEmitter();
9956
+ this.deselectRow = new i0.EventEmitter();
9955
9957
  this.dblClickRow = new i0.EventEmitter();
9956
9958
  this.saveRow = new i0.EventEmitter();
9957
9959
  this.deleteRow = new i0.EventEmitter();
@@ -10045,6 +10047,11 @@
10045
10047
  return row.singleColumnIndex;
10046
10048
  };
10047
10049
  BaseSimpleGridComponent.prototype.prepareDataRow = function (row, index) {
10050
+ return __awaiter(this, void 0, void 0, function () {
10051
+ return __generator(this, function (_a) {
10052
+ return [2 /*return*/];
10053
+ });
10054
+ });
10048
10055
  };
10049
10056
  BaseSimpleGridComponent.prototype._setColumns = function (columns) {
10050
10057
  var _a;
@@ -10052,34 +10059,66 @@
10052
10059
  this.columns.sort(function (a, b) { return a.order < b.order ? -1 : 1; });
10053
10060
  };
10054
10061
  BaseSimpleGridComponent.prototype._prepareData = function () {
10055
- if (this._prepared) {
10056
- return;
10057
- }
10058
- this.disabledRows.length = 0;
10059
- if (this.columns && this.columns.length > 0) {
10060
- this.headerColumns = this.columns.filter(function (c) { return !c.singleColumn; });
10061
- this.headerColumnsCopy = this.headerColumns;
10062
- var singleColumnIndex = -1;
10063
- for (var i = 0; i < this.columns.length; i++) {
10064
- if (this.columns[i].singleColumn) {
10065
- singleColumnIndex = i;
10066
- break;
10067
- }
10068
- }
10069
- // first check if there's single column data
10070
- if (singleColumnIndex > -1 && this.data && this.data.length > 0) {
10071
- var field = this.columns[singleColumnIndex].field;
10072
- for (var i = 0; i < this.data.length; i++) { // then mark row as single column row
10073
- if (this.data[i][field] !== undefined && this.data[i][field] !== null && this.data[i][field] !== "") {
10074
- // bit nasty to add prop, but cool for now
10075
- this.data[i].singleColumnIndex = singleColumnIndex;
10076
- }
10077
- this.prepareDataRow(this.data[i], i);
10062
+ return __awaiter(this, void 0, void 0, function () {
10063
+ var singleColumnIndex, i, field, i, j;
10064
+ return __generator(this, function (_a) {
10065
+ switch (_a.label) {
10066
+ case 0:
10067
+ if (this._prepared) {
10068
+ return [2 /*return*/];
10069
+ }
10070
+ this.disabledRows.length = 0;
10071
+ if (!(this.columns && this.columns.length > 0)) return [3 /*break*/, 10];
10072
+ this.headerColumns = this.columns.filter(function (c) { return !c.singleColumn; });
10073
+ this.headerColumnsCopy = this.headerColumns;
10074
+ singleColumnIndex = -1;
10075
+ for (i = 0; i < this.columns.length; i++) {
10076
+ if (this.columns[i].singleColumn) {
10077
+ singleColumnIndex = i;
10078
+ break;
10079
+ }
10080
+ }
10081
+ if (!(this.data && this.data.length > 0)) return [3 /*break*/, 9];
10082
+ if (!(singleColumnIndex > -1)) return [3 /*break*/, 5];
10083
+ field = this.columns[singleColumnIndex].field;
10084
+ i = 0;
10085
+ _a.label = 1;
10086
+ case 1:
10087
+ if (!(i < this.data.length)) return [3 /*break*/, 4];
10088
+ if (this.data[i][field] !== undefined && this.data[i][field] !== null && this.data[i][field] !== "") {
10089
+ // bit nasty to add prop, but cool for now
10090
+ this.data[i].singleColumnIndex = singleColumnIndex;
10091
+ }
10092
+ return [4 /*yield*/, this.prepareDataRow(this.data[i], i)];
10093
+ case 2:
10094
+ _a.sent();
10095
+ _a.label = 3;
10096
+ case 3:
10097
+ i++;
10098
+ return [3 /*break*/, 1];
10099
+ case 4: return [3 /*break*/, 9];
10100
+ case 5:
10101
+ j = 0;
10102
+ _a.label = 6;
10103
+ case 6:
10104
+ if (!(j < this.data.length)) return [3 /*break*/, 9];
10105
+ return [4 /*yield*/, this.prepareDataRow(this.data[j], j)];
10106
+ case 7:
10107
+ _a.sent();
10108
+ _a.label = 8;
10109
+ case 8:
10110
+ j++;
10111
+ return [3 /*break*/, 6];
10112
+ case 9:
10113
+ this._prepared = true;
10114
+ _a.label = 10;
10115
+ case 10:
10116
+ this._resizeColumnsToFit();
10117
+ this.changeDetection.detectChanges();
10118
+ return [2 /*return*/];
10078
10119
  }
10079
- }
10080
- this._prepared = true;
10081
- }
10082
- this._resizeColumnsToFit();
10120
+ });
10121
+ });
10083
10122
  };
10084
10123
  BaseSimpleGridComponent.prototype._resizeColumnsToFit = function () {
10085
10124
  var calculateColumns = this.columns.filter(function (c) { return !c.autoFit && !c.width; });
@@ -10100,6 +10139,9 @@
10100
10139
  BaseSimpleGridComponent.decorators = [
10101
10140
  { type: i0.Directive }
10102
10141
  ];
10142
+ BaseSimpleGridComponent.ctorParameters = function () { return [
10143
+ { type: i0.ChangeDetectorRef }
10144
+ ]; };
10103
10145
  BaseSimpleGridComponent.propDecorators = {
10104
10146
  content: [{ type: i0.ContentChildren, args: [SimpleGridColumnDirective,] }],
10105
10147
  data: [{ type: i0.Input }],
@@ -10114,6 +10156,7 @@
10114
10156
  extraColumns: [{ type: i0.Input }],
10115
10157
  onDrop: [{ type: i0.Output }],
10116
10158
  selectRow: [{ type: i0.Output }],
10159
+ deselectRow: [{ type: i0.Output }],
10117
10160
  dblClickRow: [{ type: i0.Output }],
10118
10161
  saveRow: [{ type: i0.Output }],
10119
10162
  deleteRow: [{ type: i0.Output }],
@@ -10125,14 +10168,15 @@
10125
10168
 
10126
10169
  var SimpleGridComponent = /** @class */ (function (_super) {
10127
10170
  __extends(SimpleGridComponent, _super);
10128
- function SimpleGridComponent(icons, _changeDetection, _formMaster) {
10129
- var _this = _super.call(this) || this;
10171
+ function SimpleGridComponent(icons, changeDetection, _formMaster) {
10172
+ var _this = _super.call(this, changeDetection) || this;
10130
10173
  _this.icons = icons;
10131
- _this._changeDetection = _changeDetection;
10174
+ _this.changeDetection = changeDetection;
10132
10175
  _this._formMaster = _formMaster;
10133
10176
  _this.defaultTextAlign = exports.ColumnAlign.Left;
10134
10177
  _this.showAdd = false;
10135
10178
  _this.showDelete = false;
10179
+ _this.deselectAllowed = false;
10136
10180
  _this.editOnCellClick = true;
10137
10181
  _this.rightToolbar = false;
10138
10182
  _this.showGridSettings = false;
@@ -10180,7 +10224,7 @@
10180
10224
  this._nextAvailableCellToEdit(!event.shiftKey, this.editCellIndex)
10181
10225
  .then(function (index) {
10182
10226
  _this.editCellIndex = index;
10183
- _this._changeDetection.markForCheck();
10227
+ _this.changeDetection.markForCheck();
10184
10228
  });
10185
10229
  this._detectChanges();
10186
10230
  }
@@ -10341,10 +10385,16 @@
10341
10385
  if (emit === void 0) { emit = true; }
10342
10386
  if (this.selectedRowIndex === -1 || (this.selectedRowIndex !== index && ((this.editing && this.validateAndSave()) || !this.editing))) {
10343
10387
  this.selectedRowIndex = index;
10388
+ var absoluteIndex = this.rowsPerPage ? (this.currentPage - 1) * this.rowsPerPage + index : index;
10389
+ if (emit) {
10390
+ this.selectRow.next(this.data[absoluteIndex]);
10391
+ }
10344
10392
  }
10345
- var absoluteIndex = this.rowsPerPage ? (this.currentPage - 1) * this.rowsPerPage + index : index;
10346
- if (emit) {
10347
- this.selectRow.next(this.data[absoluteIndex]);
10393
+ else if (this.selectedRowIndex === index && this.deselectAllowed && ((this.editing && this.validateAndSave()) || !this.editing)) {
10394
+ this.selectedRowIndex = -1;
10395
+ if (emit) {
10396
+ this.deselectRow.next();
10397
+ }
10348
10398
  }
10349
10399
  this._detectChanges();
10350
10400
  };
@@ -10564,7 +10614,16 @@
10564
10614
  return hasSelectedTrue ? items.filter(function (item) { return item.selected === true; }) : items;
10565
10615
  };
10566
10616
  SimpleGridComponent.prototype.prepareDataRow = function (row, index) {
10567
- this.isRowDisabled(row, index);
10617
+ return __awaiter(this, void 0, void 0, function () {
10618
+ return __generator(this, function (_c) {
10619
+ switch (_c.label) {
10620
+ case 0: return [4 /*yield*/, this.isRowDisabled(row, index)];
10621
+ case 1:
10622
+ _c.sent();
10623
+ return [2 /*return*/];
10624
+ }
10625
+ });
10626
+ });
10568
10627
  };
10569
10628
  SimpleGridComponent.prototype._resetDblClick = function () {
10570
10629
  var _this = this;
@@ -10716,7 +10775,7 @@
10716
10775
  this.currentPage = page;
10717
10776
  };
10718
10777
  SimpleGridComponent.prototype._detectChanges = function () {
10719
- this._changeDetection.detectChanges();
10778
+ this.changeDetection.detectChanges();
10720
10779
  };
10721
10780
  SimpleGridComponent.prototype._resetEdit = function () {
10722
10781
  this._newRow = false;
@@ -10754,6 +10813,7 @@
10754
10813
  rowElements: [{ type: i0.ViewChildren, args: ['rowElement',] }],
10755
10814
  showAdd: [{ type: i0.Input }],
10756
10815
  showDelete: [{ type: i0.Input }],
10816
+ deselectAllowed: [{ type: i0.Input }],
10757
10817
  editOnCellClick: [{ type: i0.Input }],
10758
10818
  rightToolbar: [{ type: i0.Input }],
10759
10819
  showGridSettings: [{ type: i0.Input }],