@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.
@@ -4181,7 +4181,7 @@ var CellRendererType;
4181
4181
  })(CellRendererType || (CellRendererType = {}));
4182
4182
  var StringCellRendererDefault = function (value, column, cellValueElement, rowElement) {
4183
4183
  var text = value ? value.toString().replace(/\n/g, '\u21B5 ') : '';
4184
- cellValueElement.innerHTML = text;
4184
+ cellValueElement.innerText = text;
4185
4185
  cellValueElement.title = text;
4186
4186
  if (column.align == GridColumnAlign.NONE) {
4187
4187
  cellValueElement.classList.add(cssPrefix + "-cell-value-align-left");
@@ -4200,7 +4200,7 @@ var NumberCellRendererDefault = function (value, column, cellValueElement, rowEl
4200
4200
  strValue = value.toLocaleString();
4201
4201
  }
4202
4202
  }
4203
- cellValueElement.innerHTML = strValue;
4203
+ cellValueElement.innerText = strValue;
4204
4204
  cellValueElement.title = strValue;
4205
4205
  if (column.align == GridColumnAlign.NONE) {
4206
4206
  cellValueElement.classList.add(cssPrefix + "-cell-value-align-right");
@@ -4232,7 +4232,7 @@ var DateTimeCellRendererDefault = function (value, column, cellValueElement, row
4232
4232
  }
4233
4233
  }
4234
4234
  }
4235
- cellValueElement.innerHTML = strValue;
4235
+ cellValueElement.innerText = strValue;
4236
4236
  cellValueElement.title = strValue;
4237
4237
  if (column.align == GridColumnAlign.NONE) {
4238
4238
  cellValueElement.classList.add(cssPrefix + "-cell-value-align-right");
@@ -7121,7 +7121,7 @@ var text_filter_widget_TextFilterWidget = /** @class */ (function () {
7121
7121
  };
7122
7122
  TextFilterWidget.prototype.inputKeydownHandler = function (ev) {
7123
7123
  if (ev.keyCode == 13) {
7124
- this.applyFilter();
7124
+ this.applyFilter(true);
7125
7125
  }
7126
7126
  };
7127
7127
  TextFilterWidget.prototype.inputKeyupHandler = function () {
@@ -7130,29 +7130,31 @@ var text_filter_widget_TextFilterWidget = /** @class */ (function () {
7130
7130
  clearTimeout(this.applyFilterTimeout);
7131
7131
  }
7132
7132
  this.applyFilterTimeout = setTimeout(function () {
7133
- _this.applyFilter();
7133
+ _this.applyFilter(true);
7134
7134
  }, this.options.instantTimeout);
7135
7135
  };
7136
7136
  TextFilterWidget.prototype.clearButtonClickHander = function () {
7137
7137
  this.filterInput.value = '';
7138
7138
  this.filterInput.focus();
7139
- this.applyFilter();
7139
+ this.applyFilter(true);
7140
7140
  };
7141
7141
  TextFilterWidget.prototype.searchButtonClickHandler = function () {
7142
- this.applyFilter();
7142
+ this.applyFilter(true);
7143
7143
  };
7144
- TextFilterWidget.prototype.applyFilter = function () {
7144
+ TextFilterWidget.prototype.applyFilter = function (checkChange) {
7145
7145
  var _this = this;
7146
7146
  if (this.applyFilterTimeout) {
7147
7147
  clearTimeout(this.applyFilterTimeout);
7148
7148
  }
7149
7149
  var filterValue = this.filter.getValue();
7150
- if (filterValue != this.filterInput.value) {
7150
+ if (!checkChange || filterValue != this.filterInput.value) {
7151
7151
  this.filter.apply(this.filterInput.value)
7152
7152
  .then(function (data) {
7153
7153
  _this.grid.setData(data);
7154
7154
  });
7155
+ return true;
7155
7156
  }
7157
+ return false;
7156
7158
  };
7157
7159
  TextFilterWidget.prototype.highlightCellRenderer = function (defaultRenderer, value, column, cellElement, rowElement) {
7158
7160
  if (utils_utils.isNumericType(column.type)
@@ -7167,7 +7169,12 @@ var text_filter_widget_TextFilterWidget = /** @class */ (function () {
7167
7169
  else {
7168
7170
  value = value.toLocaleString();
7169
7171
  }
7170
- value = this.highlightText(value.toString());
7172
+ var result = this.highlightText(value.toString());
7173
+ if (result instanceof HTMLElement) {
7174
+ cellElement.title = value;
7175
+ cellElement.appendChild(result);
7176
+ return;
7177
+ }
7171
7178
  }
7172
7179
  }
7173
7180
  defaultRenderer(value, column, cellElement, rowElement);
@@ -7176,8 +7183,6 @@ var text_filter_widget_TextFilterWidget = /** @class */ (function () {
7176
7183
  var normalizedContent = content.toLowerCase();
7177
7184
  var filterValue = this.filter.getValue().toString();
7178
7185
  if (filterValue && filterValue.length > 0 && content && content.length > 0) {
7179
- var insertValue1 = "<span style='background-color: yellow'>";
7180
- var insertValue2 = "</span>";
7181
7186
  var indexInMas = [];
7182
7187
  var words = filterValue.split('||').map(function (w) { return w.trim().toLowerCase(); });
7183
7188
  for (var i = 0; i < words.length; i++) {
@@ -7186,7 +7191,10 @@ var text_filter_widget_TextFilterWidget = /** @class */ (function () {
7186
7191
  if (!lowerWord.length)
7187
7192
  continue;
7188
7193
  if (lowerWord === normalizedContent) {
7189
- return insertValue1 + content + insertValue2;
7194
+ var highlightSpan = document.createElement('span');
7195
+ highlightSpan.style.backgroundColor = 'yellow';
7196
+ highlightSpan.innerText = content;
7197
+ return highlightSpan;
7190
7198
  }
7191
7199
  while (pos < content.length - 1) {
7192
7200
  var index = normalizedContent.indexOf(lowerWord, pos);
@@ -7226,24 +7234,24 @@ var text_filter_widget_TextFilterWidget = /** @class */ (function () {
7226
7234
  i++;
7227
7235
  }
7228
7236
  }
7229
- var result = '';
7237
+ var div = document.createElement('div');
7230
7238
  for (var i = 0; i < indexInMas.length; i++) {
7231
7239
  if (i === 0) {
7232
- result += content.substring(0, indexInMas[i].index);
7233
- }
7234
- result += insertValue1
7235
- + content.substring(indexInMas[i].index, indexInMas[i].index + indexInMas[i].length)
7236
- + insertValue2;
7237
- if (i < indexInMas.length - 1) {
7238
- result += content.substring(indexInMas[i].index
7239
- + indexInMas[i].length, indexInMas[i + 1].index);
7240
- }
7241
- else {
7242
- result += content.substring(indexInMas[i].index
7243
- + indexInMas[i].length);
7240
+ var text_1 = document.createTextNode(content.substring(0, indexInMas[i].index));
7241
+ div.appendChild(text_1);
7244
7242
  }
7243
+ var highlightSpan = document.createElement('span');
7244
+ highlightSpan.style.backgroundColor = 'yellow';
7245
+ highlightSpan.innerText = content.substring(indexInMas[i].index, indexInMas[i].index + indexInMas[i].length);
7246
+ div.appendChild(highlightSpan);
7247
+ var text = (i < indexInMas.length - 1)
7248
+ ? document.createTextNode(content.substring(indexInMas[i].index
7249
+ + indexInMas[i].length, indexInMas[i + 1].index))
7250
+ : document.createTextNode(content.substring(indexInMas[i].index
7251
+ + indexInMas[i].length));
7252
+ div.appendChild(text);
7245
7253
  }
7246
- content = result;
7254
+ return div;
7247
7255
  }
7248
7256
  }
7249
7257
  return content;
@@ -8086,7 +8094,7 @@ var entity_data_view_EntityDataView = /** @class */ (function () {
8086
8094
  }).toDOM();
8087
8095
  _this.slot.insertBefore(filterBarDiv, gridSlot);
8088
8096
  var dataFilter = _this.context.createFilter();
8089
- new text_filter_widget_TextFilterWidget(filterWidgetSlot_1, _this.grid, dataFilter);
8097
+ _this.filterWidget = new text_filter_widget_TextFilterWidget(filterWidgetSlot_1, _this.grid, dataFilter);
8090
8098
  }
8091
8099
  });
8092
8100
  };
@@ -8140,7 +8148,7 @@ var entity_data_view_EntityDataView = /** @class */ (function () {
8140
8148
  };
8141
8149
  EntityDataView.prototype.editClickHandler = function (ev, rowIndex) {
8142
8150
  var _this = this;
8143
- this.context.getData().getRow(rowIndex)
8151
+ this.grid.getData().getRow(rowIndex)
8144
8152
  .then(function (row) {
8145
8153
  if (row) {
8146
8154
  _this.showEditForm(row);
@@ -8179,7 +8187,7 @@ var entity_data_view_EntityDataView = /** @class */ (function () {
8179
8187
  };
8180
8188
  EntityDataView.prototype.deleteClickHandler = function (ev, rowIndex) {
8181
8189
  var _this = this;
8182
- this.context.getData().getRow(rowIndex)
8190
+ this.grid.getData().getRow(rowIndex)
8183
8191
  .then(function (row) {
8184
8192
  if (row) {
8185
8193
  var activeEntity = _this.context.getActiveEntity();
@@ -8220,7 +8228,13 @@ var entity_data_view_EntityDataView = /** @class */ (function () {
8220
8228
  var _this = this;
8221
8229
  return this.context.fetchDataset()
8222
8230
  .then(function () {
8223
- _this.grid.refresh();
8231
+ var processed = false;
8232
+ if (_this.filterWidget) {
8233
+ processed = _this.filterWidget.applyFilter(false);
8234
+ }
8235
+ if (!processed) {
8236
+ _this.grid.refresh();
8237
+ }
8224
8238
  });
8225
8239
  };
8226
8240
  return EntityDataView;