@easydata/crud 1.4.4 → 1.4.5

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.
@@ -4340,7 +4340,7 @@ var CellRendererType;
4340
4340
  })(CellRendererType || (CellRendererType = {}));
4341
4341
  var StringCellRendererDefault = function (value, column, cellValueElement, rowElement) {
4342
4342
  var text = value ? value.toString().replace(/\n/g, '\u21B5 ') : '';
4343
- cellValueElement.innerHTML = text;
4343
+ cellValueElement.innerText = text;
4344
4344
  cellValueElement.title = text;
4345
4345
  if (column.align == _easy_grid_columns__WEBPACK_IMPORTED_MODULE_1__[/* GridColumnAlign */ "b"].NONE) {
4346
4346
  cellValueElement.classList.add(cssPrefix + "-cell-value-align-left");
@@ -4359,7 +4359,7 @@ var NumberCellRendererDefault = function (value, column, cellValueElement, rowEl
4359
4359
  strValue = value.toLocaleString();
4360
4360
  }
4361
4361
  }
4362
- cellValueElement.innerHTML = strValue;
4362
+ cellValueElement.innerText = strValue;
4363
4363
  cellValueElement.title = strValue;
4364
4364
  if (column.align == _easy_grid_columns__WEBPACK_IMPORTED_MODULE_1__[/* GridColumnAlign */ "b"].NONE) {
4365
4365
  cellValueElement.classList.add(cssPrefix + "-cell-value-align-right");
@@ -4391,7 +4391,7 @@ var DateTimeCellRendererDefault = function (value, column, cellValueElement, row
4391
4391
  }
4392
4392
  }
4393
4393
  }
4394
- cellValueElement.innerHTML = strValue;
4394
+ cellValueElement.innerText = strValue;
4395
4395
  cellValueElement.title = strValue;
4396
4396
  if (column.align == _easy_grid_columns__WEBPACK_IMPORTED_MODULE_1__[/* GridColumnAlign */ "b"].NONE) {
4397
4397
  cellValueElement.classList.add(cssPrefix + "-cell-value-align-right");
@@ -11549,7 +11549,7 @@ var text_filter_widget_TextFilterWidget = /** @class */ (function () {
11549
11549
  };
11550
11550
  TextFilterWidget.prototype.inputKeydownHandler = function (ev) {
11551
11551
  if (ev.keyCode == 13) {
11552
- this.applyFilter();
11552
+ this.applyFilter(true);
11553
11553
  }
11554
11554
  };
11555
11555
  TextFilterWidget.prototype.inputKeyupHandler = function () {
@@ -11558,29 +11558,31 @@ var text_filter_widget_TextFilterWidget = /** @class */ (function () {
11558
11558
  clearTimeout(this.applyFilterTimeout);
11559
11559
  }
11560
11560
  this.applyFilterTimeout = setTimeout(function () {
11561
- _this.applyFilter();
11561
+ _this.applyFilter(true);
11562
11562
  }, this.options.instantTimeout);
11563
11563
  };
11564
11564
  TextFilterWidget.prototype.clearButtonClickHander = function () {
11565
11565
  this.filterInput.value = '';
11566
11566
  this.filterInput.focus();
11567
- this.applyFilter();
11567
+ this.applyFilter(true);
11568
11568
  };
11569
11569
  TextFilterWidget.prototype.searchButtonClickHandler = function () {
11570
- this.applyFilter();
11570
+ this.applyFilter(true);
11571
11571
  };
11572
- TextFilterWidget.prototype.applyFilter = function () {
11572
+ TextFilterWidget.prototype.applyFilter = function (checkChange) {
11573
11573
  var _this = this;
11574
11574
  if (this.applyFilterTimeout) {
11575
11575
  clearTimeout(this.applyFilterTimeout);
11576
11576
  }
11577
11577
  var filterValue = this.filter.getValue();
11578
- if (filterValue != this.filterInput.value) {
11578
+ if (!checkChange || filterValue != this.filterInput.value) {
11579
11579
  this.filter.apply(this.filterInput.value)
11580
11580
  .then(function (data) {
11581
11581
  _this.grid.setData(data);
11582
11582
  });
11583
+ return true;
11583
11584
  }
11585
+ return false;
11584
11586
  };
11585
11587
  TextFilterWidget.prototype.highlightCellRenderer = function (defaultRenderer, value, column, cellElement, rowElement) {
11586
11588
  if (public_api["utils"].isNumericType(column.type)
@@ -11595,7 +11597,12 @@ var text_filter_widget_TextFilterWidget = /** @class */ (function () {
11595
11597
  else {
11596
11598
  value = value.toLocaleString();
11597
11599
  }
11598
- value = this.highlightText(value.toString());
11600
+ var result = this.highlightText(value.toString());
11601
+ if (result instanceof HTMLElement) {
11602
+ cellElement.title = value;
11603
+ cellElement.appendChild(result);
11604
+ return;
11605
+ }
11599
11606
  }
11600
11607
  }
11601
11608
  defaultRenderer(value, column, cellElement, rowElement);
@@ -11604,8 +11611,6 @@ var text_filter_widget_TextFilterWidget = /** @class */ (function () {
11604
11611
  var normalizedContent = content.toLowerCase();
11605
11612
  var filterValue = this.filter.getValue().toString();
11606
11613
  if (filterValue && filterValue.length > 0 && content && content.length > 0) {
11607
- var insertValue1 = "<span style='background-color: yellow'>";
11608
- var insertValue2 = "</span>";
11609
11614
  var indexInMas = [];
11610
11615
  var words = filterValue.split('||').map(function (w) { return w.trim().toLowerCase(); });
11611
11616
  for (var i = 0; i < words.length; i++) {
@@ -11614,7 +11619,10 @@ var text_filter_widget_TextFilterWidget = /** @class */ (function () {
11614
11619
  if (!lowerWord.length)
11615
11620
  continue;
11616
11621
  if (lowerWord === normalizedContent) {
11617
- return insertValue1 + content + insertValue2;
11622
+ var highlightSpan = document.createElement('span');
11623
+ highlightSpan.style.backgroundColor = 'yellow';
11624
+ highlightSpan.innerText = content;
11625
+ return highlightSpan;
11618
11626
  }
11619
11627
  while (pos < content.length - 1) {
11620
11628
  var index = normalizedContent.indexOf(lowerWord, pos);
@@ -11654,24 +11662,24 @@ var text_filter_widget_TextFilterWidget = /** @class */ (function () {
11654
11662
  i++;
11655
11663
  }
11656
11664
  }
11657
- var result = '';
11665
+ var div = document.createElement('div');
11658
11666
  for (var i = 0; i < indexInMas.length; i++) {
11659
11667
  if (i === 0) {
11660
- result += content.substring(0, indexInMas[i].index);
11661
- }
11662
- result += insertValue1
11663
- + content.substring(indexInMas[i].index, indexInMas[i].index + indexInMas[i].length)
11664
- + insertValue2;
11665
- if (i < indexInMas.length - 1) {
11666
- result += content.substring(indexInMas[i].index
11667
- + indexInMas[i].length, indexInMas[i + 1].index);
11668
- }
11669
- else {
11670
- result += content.substring(indexInMas[i].index
11671
- + indexInMas[i].length);
11668
+ var text_1 = document.createTextNode(content.substring(0, indexInMas[i].index));
11669
+ div.appendChild(text_1);
11672
11670
  }
11671
+ var highlightSpan = document.createElement('span');
11672
+ highlightSpan.style.backgroundColor = 'yellow';
11673
+ highlightSpan.innerText = content.substring(indexInMas[i].index, indexInMas[i].index + indexInMas[i].length);
11674
+ div.appendChild(highlightSpan);
11675
+ var text = (i < indexInMas.length - 1)
11676
+ ? document.createTextNode(content.substring(indexInMas[i].index
11677
+ + indexInMas[i].length, indexInMas[i + 1].index))
11678
+ : document.createTextNode(content.substring(indexInMas[i].index
11679
+ + indexInMas[i].length));
11680
+ div.appendChild(text);
11673
11681
  }
11674
- content = result;
11682
+ return div;
11675
11683
  }
11676
11684
  }
11677
11685
  return content;
@@ -12517,7 +12525,7 @@ var entity_data_view_EntityDataView = /** @class */ (function () {
12517
12525
  }).toDOM();
12518
12526
  _this.slot.insertBefore(filterBarDiv, gridSlot);
12519
12527
  var dataFilter = _this.context.createFilter();
12520
- new text_filter_widget_TextFilterWidget(filterWidgetSlot_1, _this.grid, dataFilter);
12528
+ _this.filterWidget = new text_filter_widget_TextFilterWidget(filterWidgetSlot_1, _this.grid, dataFilter);
12521
12529
  }
12522
12530
  });
12523
12531
  };
@@ -12571,7 +12579,7 @@ var entity_data_view_EntityDataView = /** @class */ (function () {
12571
12579
  };
12572
12580
  EntityDataView.prototype.editClickHandler = function (ev, rowIndex) {
12573
12581
  var _this = this;
12574
- this.context.getData().getRow(rowIndex)
12582
+ this.grid.getData().getRow(rowIndex)
12575
12583
  .then(function (row) {
12576
12584
  if (row) {
12577
12585
  _this.showEditForm(row);
@@ -12610,7 +12618,7 @@ var entity_data_view_EntityDataView = /** @class */ (function () {
12610
12618
  };
12611
12619
  EntityDataView.prototype.deleteClickHandler = function (ev, rowIndex) {
12612
12620
  var _this = this;
12613
- this.context.getData().getRow(rowIndex)
12621
+ this.grid.getData().getRow(rowIndex)
12614
12622
  .then(function (row) {
12615
12623
  if (row) {
12616
12624
  var activeEntity = _this.context.getActiveEntity();
@@ -12651,7 +12659,13 @@ var entity_data_view_EntityDataView = /** @class */ (function () {
12651
12659
  var _this = this;
12652
12660
  return this.context.fetchDataset()
12653
12661
  .then(function () {
12654
- _this.grid.refresh();
12662
+ var processed = false;
12663
+ if (_this.filterWidget) {
12664
+ processed = _this.filterWidget.applyFilter(false);
12665
+ }
12666
+ if (!processed) {
12667
+ _this.grid.refresh();
12668
+ }
12655
12669
  });
12656
12670
  };
12657
12671
  return EntityDataView;