@easydata/crud 1.4.0-rc01 → 1.4.0-rc02

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.
@@ -4539,7 +4539,7 @@ var easy_grid_EasyGrid = /** @class */ (function () {
4539
4539
  default: 60
4540
4540
  }
4541
4541
  },
4542
- addColumns: false,
4542
+ showPlusButton: false,
4543
4543
  viewportRowsCount: null,
4544
4544
  showActiveRow: true
4545
4545
  };
@@ -4638,8 +4638,8 @@ var easy_grid_EasyGrid = /** @class */ (function () {
4638
4638
  if (options.onRowDbClick) {
4639
4639
  this.addEventListener('rowDbClick', options.onRowDbClick);
4640
4640
  }
4641
- if (options.onAddColumnClick) {
4642
- this.addEventListener('addColumnClick', options.onAddColumnClick);
4641
+ if (options.onPlusButtonClick) {
4642
+ this.addEventListener('plusButtonClick', options.onPlusButtonClick);
4643
4643
  }
4644
4644
  if (options.onColumnChanged) {
4645
4645
  this.addEventListener('columnChanged', options.onColumnChanged);
@@ -4725,7 +4725,7 @@ var easy_grid_EasyGrid = /** @class */ (function () {
4725
4725
  };
4726
4726
  EasyGrid.prototype.render = function () {
4727
4727
  var _this = this;
4728
- if (!this.hasData() && !this.options.addColumns)
4728
+ if (!this.hasData() && !this.options.showPlusButton)
4729
4729
  return;
4730
4730
  this.containerInitialHeight = this.slot.clientHeight;
4731
4731
  this.rootDiv = document.createElement('div');
@@ -4742,12 +4742,16 @@ var easy_grid_EasyGrid = /** @class */ (function () {
4742
4742
  gridContainer.classList.add(this.cssPrefix + "-container");
4743
4743
  gridContainer.appendChild(this.rootDiv);
4744
4744
  this.slot.appendChild(gridContainer);
4745
+ var needAutoResize = this.options.columnWidths.autoResize !== AutoResizeColumns.Never;
4745
4746
  if (this.rowsOnPagePromise) {
4746
4747
  this.rowsOnPagePromise
4747
4748
  .then(function () { return _this.updateHeight(); })
4748
4749
  .then(function () {
4749
4750
  _this.firstRender = false;
4750
4751
  _this.rowsOnPagePromise = null;
4752
+ if (needAutoResize) {
4753
+ _this.resizeColumns();
4754
+ }
4751
4755
  });
4752
4756
  }
4753
4757
  else {
@@ -4755,17 +4759,12 @@ var easy_grid_EasyGrid = /** @class */ (function () {
4755
4759
  _this.updateHeight()
4756
4760
  .then(function () {
4757
4761
  _this.firstRender = false;
4762
+ if (needAutoResize) {
4763
+ _this.resizeColumns();
4764
+ }
4758
4765
  });
4759
4766
  }, 100);
4760
4767
  }
4761
- var needAutoResize = this.options.columnWidths.autoResize !== AutoResizeColumns.Never;
4762
- if (needAutoResize) {
4763
- this.bodyCellContainerDiv.style.visibility = 'hidden';
4764
- setTimeout(function () {
4765
- _this.resizeColumns();
4766
- _this.bodyCellContainerDiv.style.visibility = null;
4767
- }, 20);
4768
- }
4769
4768
  };
4770
4769
  EasyGrid.prototype.updateHeight = function () {
4771
4770
  var _this = this;
@@ -4774,14 +4773,14 @@ var easy_grid_EasyGrid = /** @class */ (function () {
4774
4773
  var firstRow = _this.bodyCellContainerDiv.firstElementChild;
4775
4774
  var rowHeight = firstRow ? firstRow.offsetHeight : DEFAULT_ROW_HEIGHT;
4776
4775
  var rowCount = _this.options.viewportRowsCount; // || DEFAULT_ROW_COUNT;
4777
- var bodyHeight_1 = rowHeight * rowCount;
4778
- domel(_this.bodyDiv)
4779
- .setStyle('height', bodyHeight_1 + "px");
4776
+ var viewportHeight_1 = rowHeight * rowCount;
4777
+ domel(_this.bodyViewportDiv)
4778
+ .setStyle('height', viewportHeight_1 + "px");
4780
4779
  setTimeout(function () {
4781
4780
  var sbHeight = _this.bodyViewportDiv.offsetHeight - _this.bodyViewportDiv.clientHeight;
4782
- bodyHeight_1 = bodyHeight_1 + sbHeight;
4783
- domel(_this.bodyDiv)
4784
- .setStyle('height', bodyHeight_1 + "px");
4781
+ viewportHeight_1 = viewportHeight_1 + sbHeight;
4782
+ domel(_this.bodyViewportDiv)
4783
+ .setStyle('height', viewportHeight_1 + "px");
4785
4784
  resolve();
4786
4785
  }, 100);
4787
4786
  return;
@@ -4828,7 +4827,7 @@ var easy_grid_EasyGrid = /** @class */ (function () {
4828
4827
  _this.headerRowDiv.appendChild(hd);
4829
4828
  if (column.isRowNum) {
4830
4829
  domel(hd)
4831
- .addChildElement(_this.renderAddColumnButton());
4830
+ .addChildElement(_this.renderHeaderButtons());
4832
4831
  }
4833
4832
  });
4834
4833
  var containerWidth = this.getContainerWidth();
@@ -5167,23 +5166,26 @@ var easy_grid_EasyGrid = /** @class */ (function () {
5167
5166
  var pageInfoDiv = domel('div')
5168
5167
  .addClass(this.cssPrefix + "-page-info")
5169
5168
  .toDOM();
5170
- var fistPageRecordNum = count
5171
- ? (this.pagination.page - 1) * this.pagination.pageSize + 1
5172
- : 0;
5173
- var lastPageRecordNum = count
5174
- ? fistPageRecordNum + count - 1
5175
- : 0;
5176
- var totalStr = this.dataTable.getTotal().toString();
5177
- if (this.dataTable.elasticChunks) {
5178
- var count_1 = this.dataTable.getCachedCount();
5179
- var total = this.dataTable.getTotal();
5180
- if (count_1 !== total)
5181
- totalStr = '?';
5182
- }
5183
- pageInfoDiv.innerHTML = i18n_i18n.getText('GridPageInfo')
5184
- .replace('{FirstPageRecordNum}', "<span>" + fistPageRecordNum.toString() + "</span>")
5185
- .replace('{LastPageRecordNum}', "<span>" + lastPageRecordNum.toString() + "</span>")
5186
- .replace('{Total}', "<span>" + totalStr + "</span>");
5169
+ var rowCount = this.dataTable.getTotal();
5170
+ if (rowCount > 0) {
5171
+ var fistPageRecordNum = count
5172
+ ? (this.pagination.page - 1) * this.pagination.pageSize + 1
5173
+ : 0;
5174
+ var lastPageRecordNum = count
5175
+ ? fistPageRecordNum + count - 1
5176
+ : 0;
5177
+ var totalStr = this.dataTable.getTotal().toString();
5178
+ if (this.dataTable.elasticChunks) {
5179
+ var count_1 = this.dataTable.getCachedCount();
5180
+ var total = this.dataTable.getTotal();
5181
+ if (count_1 !== total)
5182
+ totalStr = '?';
5183
+ }
5184
+ pageInfoDiv.innerHTML = i18n_i18n.getText('GridPageInfo')
5185
+ .replace('{FirstPageRecordNum}', "<span>" + fistPageRecordNum.toString() + "</span>")
5186
+ .replace('{LastPageRecordNum}', "<span>" + lastPageRecordNum.toString() + "</span>")
5187
+ .replace('{Total}', "<span>" + totalStr + "</span>");
5188
+ }
5187
5189
  return pageInfoDiv;
5188
5190
  };
5189
5191
  EasyGrid.prototype.showProgress = function () {
@@ -5278,7 +5280,8 @@ var easy_grid_EasyGrid = /** @class */ (function () {
5278
5280
  var _this = this;
5279
5281
  var paginateDiv = document.createElement('div');
5280
5282
  paginateDiv.className = this.cssPrefix + "-pagination-wrapper";
5281
- if (this.options.paging && this.options.paging.enabled) {
5283
+ var rowCount = this.dataTable.getTotal();
5284
+ if (this.options.paging && this.options.paging.enabled && rowCount > 0) {
5282
5285
  var prefix_1 = this.paginationOptions.useBootstrap ? '' : this.cssPrefix + "-";
5283
5286
  var buttonClickHandler_1 = function (ev) {
5284
5287
  var element = ev.target;
@@ -5404,18 +5407,18 @@ var easy_grid_EasyGrid = /** @class */ (function () {
5404
5407
  EasyGrid.prototype.removeEventListener = function (eventType, handlerId) {
5405
5408
  this.eventEmitter.unsubscribe(eventType, handlerId);
5406
5409
  };
5407
- EasyGrid.prototype.renderAddColumnButton = function () {
5410
+ EasyGrid.prototype.renderHeaderButtons = function () {
5408
5411
  var _this = this;
5409
- if (this.options.addColumns) {
5412
+ if (this.options.showPlusButton) {
5410
5413
  return domel('div')
5411
- .addClass(this.cssPrefix + "-addrow")
5412
- .title(this.options.addColumnsTitle || 'Add column')
5414
+ .addClass(this.cssPrefix + "-header-btn-plus")
5415
+ .title(this.options.plusButtonTitle || 'Add')
5413
5416
  .addChild('a', function (builder) { return builder
5414
5417
  .attr('href', 'javascript:void(0)')
5415
5418
  .on('click', function (e) {
5416
5419
  e.preventDefault();
5417
5420
  _this.fireEvent({
5418
- type: 'addColumnClick',
5421
+ type: 'plusButtonClick',
5419
5422
  sourceEvent: e
5420
5423
  });
5421
5424
  }); })
@@ -5522,6 +5525,8 @@ var easy_grid_EasyGrid = /** @class */ (function () {
5522
5525
  var containerWidth = this.bodyCellContainerDiv.style.width;
5523
5526
  this.bodyCellContainerDiv.style.visibility = 'hidden';
5524
5527
  this.bodyCellContainerDiv.style.width = '1px';
5528
+ //this.headerRowDiv.style.visibility = 'hidden';
5529
+ this.headerRowDiv.style.width = '1px';
5525
5530
  var sumWidth = 0;
5526
5531
  var columns = this.columns.getItems();
5527
5532
  var headerCells = this.headerCellContainerDiv.querySelectorAll("." + this.cssPrefix + "-header-cell");
@@ -5542,44 +5547,53 @@ var easy_grid_EasyGrid = /** @class */ (function () {
5542
5547
  value.parentElement.style.width = calculatedWidth + "px";
5543
5548
  });
5544
5549
  headerCells[headerIdx].style.width = calculatedWidth + "px";
5545
- headerIdx++;
5546
5550
  }
5547
- else if (cellValues.length > 0) {
5548
- cellValues.forEach(function (value) {
5549
- value.parentElement.style.width = null;
5550
- var width = value.parentElement.offsetWidth;
5551
- if (width > maxWidth) {
5552
- maxWidth = width;
5553
- }
5554
- });
5555
- maxWidth += 3;
5556
- var maxOption = column.isRowNum
5557
- ? this_1.options.columnWidths.rowNumColumn.max || 500
5558
- : this_1.options.columnWidths[column.dataColumn.type].max || 2000;
5559
- var minOption = column.isRowNum
5560
- ? this_1.options.columnWidths.rowNumColumn.min || 0
5561
- : this_1.options.columnWidths[column.dataColumn.type].min || 20;
5562
- if (maxWidth > maxOption) {
5563
- maxWidth = maxOption;
5564
- }
5565
- if (maxWidth < minOption) {
5566
- maxWidth = minOption;
5551
+ else {
5552
+ if (cellValues.length == 0) {
5553
+ headerCells[headerIdx].style.width = null;
5554
+ headerCells[headerIdx].style.whiteSpace = 'nowrap';
5567
5555
  }
5568
- if (utils_utils.isNumericType(column.type)) {
5569
- //increase the calculated width in 1.3 times for numeric columns
5570
- maxWidth = Math.round(maxWidth * 1.3);
5556
+ maxWidth = headerCells[headerIdx].offsetWidth;
5557
+ if (cellValues.length > 0) {
5558
+ cellValues.forEach(function (value) {
5559
+ value.parentElement.style.width = null;
5560
+ var width = value.parentElement.offsetWidth;
5561
+ if (width > maxWidth) {
5562
+ maxWidth = width;
5563
+ }
5564
+ });
5565
+ maxWidth += 3;
5566
+ var maxOption = column.isRowNum
5567
+ ? this_1.options.columnWidths.rowNumColumn.max || 500
5568
+ : this_1.options.columnWidths[column.dataColumn.type].max || 2000;
5569
+ var minOption = column.isRowNum
5570
+ ? this_1.options.columnWidths.rowNumColumn.min || 0
5571
+ : this_1.options.columnWidths[column.dataColumn.type].min || 20;
5572
+ if (maxWidth > maxOption) {
5573
+ maxWidth = maxOption;
5574
+ }
5575
+ if (maxWidth < minOption) {
5576
+ maxWidth = minOption;
5577
+ }
5578
+ if (utils_utils.isNumericType(column.type)) {
5579
+ //increase the calculated width in 1.3 times for numeric columns
5580
+ maxWidth = Math.round(maxWidth * 1.3);
5581
+ }
5582
+ sumWidth += maxWidth;
5583
+ column.width = maxWidth;
5584
+ cellValues.forEach(function (value) {
5585
+ value.parentElement.style.width = maxWidth + "px";
5586
+ });
5587
+ headerCells[headerIdx].style.width = maxWidth + "px";
5588
+ if (column.dataColumn) {
5589
+ column.dataColumn.calculatedWidth = maxWidth;
5590
+ }
5571
5591
  }
5572
- sumWidth += maxWidth;
5573
- column.width = maxWidth;
5574
- cellValues.forEach(function (value) {
5575
- value.parentElement.style.width = maxWidth + "px";
5576
- });
5577
- headerCells[headerIdx].style.width = maxWidth + "px";
5578
- headerIdx++;
5579
- if (column.dataColumn) {
5580
- column.dataColumn.calculatedWidth = maxWidth;
5592
+ else {
5593
+ sumWidth += maxWidth;
5581
5594
  }
5582
5595
  }
5596
+ headerIdx++;
5583
5597
  };
5584
5598
  var this_1 = this;
5585
5599
  for (var idx = 0; idx < this.columns.count; idx++) {
@@ -5594,6 +5608,7 @@ var easy_grid_EasyGrid = /** @class */ (function () {
5594
5608
  this.headerCellContainerDiv.style.width = containerWidth;
5595
5609
  }
5596
5610
  this.bodyCellContainerDiv.style.visibility = null;
5611
+ this.headerRowDiv.removeAttribute('style');
5597
5612
  };
5598
5613
  return EasyGrid;
5599
5614
  }());
@@ -8038,10 +8053,10 @@ var entity_data_view_EntityDataView = /** @class */ (function () {
8038
8053
  allowPageSizeChange: true,
8039
8054
  pageSizeItems: [15, 30, 50, 100, 200]
8040
8055
  },
8041
- addColumns: _this.context.getActiveEntity().isEditable,
8042
- addColumnsTitle: i18n_i18n.getText('AddBtnTitle'),
8056
+ showPlusButton: _this.context.getActiveEntity().isEditable,
8057
+ plusButtonTitle: i18n_i18n.getText('AddRecordBtnTitle'),
8043
8058
  showActiveRow: false,
8044
- onAddColumnClick: _this.addClickHandler.bind(_this),
8059
+ onPlusButtonClick: _this.addClickHandler.bind(_this),
8045
8060
  onGetCellRenderer: _this.manageCellRenderer.bind(_this),
8046
8061
  onRowDbClick: _this.rowDbClickHandler.bind(_this),
8047
8062
  onSyncGridColumn: _this.syncGridColumnHandler.bind(_this)
@@ -8367,6 +8382,7 @@ function addEasyDataCRUDTexts() {
8367
8382
  CalendarBtnTitle: 'Open calendar',
8368
8383
  TimerBtnTitle: 'Open timer',
8369
8384
  AddBtnTitle: 'Add',
8385
+ AddRecordBtnTitle: 'Add record',
8370
8386
  EditBtn: 'Edit',
8371
8387
  DeleteBtn: 'Delete',
8372
8388
  SelectLink: '[ select ]',