@colijnit/corecomponents_v12 259.1.11 → 259.1.12

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.
@@ -9875,7 +9875,8 @@
9875
9875
  };
9876
9876
 
9877
9877
  var BaseSimpleGridComponent = /** @class */ (function () {
9878
- function BaseSimpleGridComponent() {
9878
+ function BaseSimpleGridComponent(changeDetection) {
9879
+ this.changeDetection = changeDetection;
9879
9880
  this.MIN_COLUMN_WIDTH = 50;
9880
9881
  this.dataChanged = new rxjs.Subject();
9881
9882
  this.dragDropEnabled = false;
@@ -9891,6 +9892,7 @@
9891
9892
  this.emitDragDrop = false;
9892
9893
  this.onDrop = new i0.EventEmitter();
9893
9894
  this.selectRow = new i0.EventEmitter();
9895
+ this.deselectRow = new i0.EventEmitter();
9894
9896
  this.dblClickRow = new i0.EventEmitter();
9895
9897
  this.saveRow = new i0.EventEmitter();
9896
9898
  this.deleteRow = new i0.EventEmitter();
@@ -9984,6 +9986,11 @@
9984
9986
  return row.singleColumnIndex;
9985
9987
  };
9986
9988
  BaseSimpleGridComponent.prototype.prepareDataRow = function (row, index) {
9989
+ return __awaiter(this, void 0, void 0, function () {
9990
+ return __generator(this, function (_a) {
9991
+ return [2 /*return*/];
9992
+ });
9993
+ });
9987
9994
  };
9988
9995
  BaseSimpleGridComponent.prototype._setColumns = function (columns) {
9989
9996
  var _a;
@@ -9991,34 +9998,66 @@
9991
9998
  this.columns.sort(function (a, b) { return a.order < b.order ? -1 : 1; });
9992
9999
  };
9993
10000
  BaseSimpleGridComponent.prototype._prepareData = function () {
9994
- if (this._prepared) {
9995
- return;
9996
- }
9997
- this.disabledRows.length = 0;
9998
- if (this.columns && this.columns.length > 0) {
9999
- this.headerColumns = this.columns.filter(function (c) { return !c.singleColumn; });
10000
- this.headerColumnsCopy = this.headerColumns;
10001
- var singleColumnIndex = -1;
10002
- for (var i = 0; i < this.columns.length; i++) {
10003
- if (this.columns[i].singleColumn) {
10004
- singleColumnIndex = i;
10005
- break;
10006
- }
10007
- }
10008
- // first check if there's single column data
10009
- if (singleColumnIndex > -1 && this.data && this.data.length > 0) {
10010
- var field = this.columns[singleColumnIndex].field;
10011
- for (var i = 0; i < this.data.length; i++) { // then mark row as single column row
10012
- if (this.data[i][field] !== undefined && this.data[i][field] !== null && this.data[i][field] !== "") {
10013
- // bit nasty to add prop, but cool for now
10014
- this.data[i].singleColumnIndex = singleColumnIndex;
10015
- }
10016
- this.prepareDataRow(this.data[i], i);
10001
+ return __awaiter(this, void 0, void 0, function () {
10002
+ var singleColumnIndex, i, field, i, j;
10003
+ return __generator(this, function (_a) {
10004
+ switch (_a.label) {
10005
+ case 0:
10006
+ if (this._prepared) {
10007
+ return [2 /*return*/];
10008
+ }
10009
+ this.disabledRows.length = 0;
10010
+ if (!(this.columns && this.columns.length > 0)) return [3 /*break*/, 10];
10011
+ this.headerColumns = this.columns.filter(function (c) { return !c.singleColumn; });
10012
+ this.headerColumnsCopy = this.headerColumns;
10013
+ singleColumnIndex = -1;
10014
+ for (i = 0; i < this.columns.length; i++) {
10015
+ if (this.columns[i].singleColumn) {
10016
+ singleColumnIndex = i;
10017
+ break;
10018
+ }
10019
+ }
10020
+ if (!(this.data && this.data.length > 0)) return [3 /*break*/, 9];
10021
+ if (!(singleColumnIndex > -1)) return [3 /*break*/, 5];
10022
+ field = this.columns[singleColumnIndex].field;
10023
+ i = 0;
10024
+ _a.label = 1;
10025
+ case 1:
10026
+ if (!(i < this.data.length)) return [3 /*break*/, 4];
10027
+ if (this.data[i][field] !== undefined && this.data[i][field] !== null && this.data[i][field] !== "") {
10028
+ // bit nasty to add prop, but cool for now
10029
+ this.data[i].singleColumnIndex = singleColumnIndex;
10030
+ }
10031
+ return [4 /*yield*/, this.prepareDataRow(this.data[i], i)];
10032
+ case 2:
10033
+ _a.sent();
10034
+ _a.label = 3;
10035
+ case 3:
10036
+ i++;
10037
+ return [3 /*break*/, 1];
10038
+ case 4: return [3 /*break*/, 9];
10039
+ case 5:
10040
+ j = 0;
10041
+ _a.label = 6;
10042
+ case 6:
10043
+ if (!(j < this.data.length)) return [3 /*break*/, 9];
10044
+ return [4 /*yield*/, this.prepareDataRow(this.data[j], j)];
10045
+ case 7:
10046
+ _a.sent();
10047
+ _a.label = 8;
10048
+ case 8:
10049
+ j++;
10050
+ return [3 /*break*/, 6];
10051
+ case 9:
10052
+ this._prepared = true;
10053
+ _a.label = 10;
10054
+ case 10:
10055
+ this._resizeColumnsToFit();
10056
+ this.changeDetection.detectChanges();
10057
+ return [2 /*return*/];
10017
10058
  }
10018
- }
10019
- this._prepared = true;
10020
- }
10021
- this._resizeColumnsToFit();
10059
+ });
10060
+ });
10022
10061
  };
10023
10062
  BaseSimpleGridComponent.prototype._resizeColumnsToFit = function () {
10024
10063
  var calculateColumns = this.columns.filter(function (c) { return !c.autoFit && !c.width; });
@@ -10039,6 +10078,9 @@
10039
10078
  BaseSimpleGridComponent.decorators = [
10040
10079
  { type: i0.Directive }
10041
10080
  ];
10081
+ BaseSimpleGridComponent.ctorParameters = function () { return [
10082
+ { type: i0.ChangeDetectorRef }
10083
+ ]; };
10042
10084
  BaseSimpleGridComponent.propDecorators = {
10043
10085
  content: [{ type: i0.ContentChildren, args: [SimpleGridColumnDirective,] }],
10044
10086
  data: [{ type: i0.Input }],
@@ -10053,6 +10095,7 @@
10053
10095
  extraColumns: [{ type: i0.Input }],
10054
10096
  onDrop: [{ type: i0.Output }],
10055
10097
  selectRow: [{ type: i0.Output }],
10098
+ deselectRow: [{ type: i0.Output }],
10056
10099
  dblClickRow: [{ type: i0.Output }],
10057
10100
  saveRow: [{ type: i0.Output }],
10058
10101
  deleteRow: [{ type: i0.Output }],
@@ -10064,14 +10107,15 @@
10064
10107
 
10065
10108
  var SimpleGridComponent = /** @class */ (function (_super) {
10066
10109
  __extends(SimpleGridComponent, _super);
10067
- function SimpleGridComponent(icons, _changeDetection, _formMaster) {
10068
- var _this = _super.call(this) || this;
10110
+ function SimpleGridComponent(icons, changeDetection, _formMaster) {
10111
+ var _this = _super.call(this, changeDetection) || this;
10069
10112
  _this.icons = icons;
10070
- _this._changeDetection = _changeDetection;
10113
+ _this.changeDetection = changeDetection;
10071
10114
  _this._formMaster = _formMaster;
10072
10115
  _this.defaultTextAlign = exports.ColumnAlign.Left;
10073
10116
  _this.showAdd = false;
10074
10117
  _this.showDelete = false;
10118
+ _this.deselectAllowed = false;
10075
10119
  _this.editOnCellClick = true;
10076
10120
  _this.rightToolbar = false;
10077
10121
  _this.showGridSettings = false;
@@ -10119,7 +10163,7 @@
10119
10163
  this._nextAvailableCellToEdit(!event.shiftKey, this.editCellIndex)
10120
10164
  .then(function (index) {
10121
10165
  _this.editCellIndex = index;
10122
- _this._changeDetection.markForCheck();
10166
+ _this.changeDetection.markForCheck();
10123
10167
  });
10124
10168
  this._detectChanges();
10125
10169
  }
@@ -10285,6 +10329,12 @@
10285
10329
  this.selectRow.next(this.data[absoluteIndex]);
10286
10330
  }
10287
10331
  }
10332
+ else if (this.selectedRowIndex === index && this.deselectAllowed && ((this.editing && this.validateAndSave()) || !this.editing)) {
10333
+ this.selectedRowIndex = -1;
10334
+ if (emit) {
10335
+ this.deselectRow.next();
10336
+ }
10337
+ }
10288
10338
  this._detectChanges();
10289
10339
  };
10290
10340
  SimpleGridComponent.prototype.handleDblClickRow = function (event, index, row) {
@@ -10519,7 +10569,16 @@
10519
10569
  return hasSelectedTrue ? items.filter(function (item) { return item.selected === true; }) : items;
10520
10570
  };
10521
10571
  SimpleGridComponent.prototype.prepareDataRow = function (row, index) {
10522
- this.isRowDisabled(row, index);
10572
+ return __awaiter(this, void 0, void 0, function () {
10573
+ return __generator(this, function (_c) {
10574
+ switch (_c.label) {
10575
+ case 0: return [4 /*yield*/, this.isRowDisabled(row, index)];
10576
+ case 1:
10577
+ _c.sent();
10578
+ return [2 /*return*/];
10579
+ }
10580
+ });
10581
+ });
10523
10582
  };
10524
10583
  SimpleGridComponent.prototype._resetDblClick = function () {
10525
10584
  var _this = this;
@@ -10662,7 +10721,7 @@
10662
10721
  this._detectChanges();
10663
10722
  };
10664
10723
  SimpleGridComponent.prototype._detectChanges = function () {
10665
- this._changeDetection.detectChanges();
10724
+ this.changeDetection.detectChanges();
10666
10725
  };
10667
10726
  SimpleGridComponent.prototype._resetEdit = function () {
10668
10727
  this._newRow = false;
@@ -10693,6 +10752,7 @@
10693
10752
  rowElements: [{ type: i0.ViewChildren, args: ['rowElement',] }],
10694
10753
  showAdd: [{ type: i0.Input }],
10695
10754
  showDelete: [{ type: i0.Input }],
10755
+ deselectAllowed: [{ type: i0.Input }],
10696
10756
  editOnCellClick: [{ type: i0.Input }],
10697
10757
  rightToolbar: [{ type: i0.Input }],
10698
10758
  showGridSettings: [{ type: i0.Input }],