@wavemaker/app-ng-runtime 11.14.1-33.647787 → 11.14.1-34.647830

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.
Files changed (103) hide show
  1. package/build-task/bundles/index.umd.js +1 -1
  2. package/build-task/esm2022/data/form/form-field/form-field.build.mjs +2 -2
  3. package/build-task/fesm2022/index.mjs +1 -1
  4. package/build-task/fesm2022/index.mjs.map +1 -1
  5. package/components/base/bundles/index.umd.js +71 -17
  6. package/components/base/esm2022/pipes/custom-pipes.mjs +10 -10
  7. package/components/base/esm2022/utils/widget-utils.mjs +3 -3
  8. package/components/base/esm2022/widgets/common/base/base.component.mjs +51 -6
  9. package/components/base/esm2022/widgets/common/lazy-load/lazy-load.directive.mjs +7 -3
  10. package/components/base/esm2022/widgets/framework/property-change-handler.mjs +7 -2
  11. package/components/base/fesm2022/index.mjs +72 -18
  12. package/components/base/fesm2022/index.mjs.map +1 -1
  13. package/components/base/pipes/custom-pipes.d.ts +5 -5
  14. package/components/basic/label/bundles/index.umd.js +9 -1
  15. package/components/basic/label/esm2022/label.directive.mjs +10 -2
  16. package/components/basic/label/fesm2022/index.mjs +9 -1
  17. package/components/basic/label/fesm2022/index.mjs.map +1 -1
  18. package/components/basic/search/bundles/index.umd.js +2 -2
  19. package/components/basic/search/esm2022/search.component.mjs +3 -3
  20. package/components/basic/search/fesm2022/index.mjs +2 -2
  21. package/components/basic/search/fesm2022/index.mjs.map +1 -1
  22. package/components/chart/bundles/index.umd.js +2 -2
  23. package/components/chart/esm2022/chart.utils.mjs +3 -3
  24. package/components/chart/fesm2022/index.mjs +2 -2
  25. package/components/chart/fesm2022/index.mjs.map +1 -1
  26. package/components/containers/wizard/bundles/index.umd.js +21 -2
  27. package/components/containers/wizard/esm2022/wizard-step/wizard-step.component.mjs +3 -1
  28. package/components/containers/wizard/esm2022/wizard.component.mjs +20 -3
  29. package/components/containers/wizard/fesm2022/index.mjs +21 -2
  30. package/components/containers/wizard/fesm2022/index.mjs.map +1 -1
  31. package/components/containers/wizard/wizard-step/wizard-step.component.d.ts +2 -0
  32. package/components/data/pagination/bundles/index.umd.js +6 -1
  33. package/components/data/pagination/esm2022/pagination.component.mjs +7 -2
  34. package/components/data/pagination/fesm2022/index.mjs +6 -1
  35. package/components/data/pagination/fesm2022/index.mjs.map +1 -1
  36. package/components/data/table/bundles/index.umd.js +546 -28
  37. package/components/data/table/esm2022/table-action/table-action.directive.mjs +12 -2
  38. package/components/data/table/esm2022/table-column/table-column.directive.mjs +108 -4
  39. package/components/data/table/esm2022/table-column-group/table-column-group.directive.mjs +9 -1
  40. package/components/data/table/esm2022/table-cud.directive.mjs +22 -5
  41. package/components/data/table/esm2022/table-filter.directive.mjs +43 -4
  42. package/components/data/table/esm2022/table-row/table-row.directive.mjs +8 -1
  43. package/components/data/table/esm2022/table-row-action/table-row-action.directive.mjs +8 -1
  44. package/components/data/table/esm2022/table.component.mjs +345 -19
  45. package/components/data/table/fesm2022/index.mjs +548 -30
  46. package/components/data/table/fesm2022/index.mjs.map +1 -1
  47. package/components/data/table/table-action/table-action.directive.d.ts +3 -2
  48. package/components/data/table/table-column/table-column.directive.d.ts +3 -2
  49. package/components/data/table/table-column-group/table-column-group.directive.d.ts +3 -2
  50. package/components/data/table/table-cud.directive.d.ts +3 -1
  51. package/components/data/table/table-filter.directive.d.ts +3 -1
  52. package/components/data/table/table-row/table-row.directive.d.ts +3 -2
  53. package/components/data/table/table-row-action/table-row-action.directive.d.ts +3 -2
  54. package/components/data/table/table.component.d.ts +16 -2
  55. package/components/input/checkboxset/bundles/index.umd.js +2 -2
  56. package/components/input/checkboxset/esm2022/checkboxset.component.mjs +3 -3
  57. package/components/input/checkboxset/fesm2022/index.mjs +2 -2
  58. package/components/input/checkboxset/fesm2022/index.mjs.map +1 -1
  59. package/components/input/radioset/bundles/index.umd.js +2 -2
  60. package/components/input/radioset/esm2022/radioset.component.mjs +3 -3
  61. package/components/input/radioset/fesm2022/index.mjs +2 -2
  62. package/components/input/radioset/fesm2022/index.mjs.map +1 -1
  63. package/components/navigation/breadcrumb/bundles/index.umd.js +6 -6
  64. package/components/navigation/breadcrumb/esm2022/breadcrumb.component.mjs +4 -3
  65. package/components/navigation/breadcrumb/fesm2022/index.mjs +3 -2
  66. package/components/navigation/breadcrumb/fesm2022/index.mjs.map +1 -1
  67. package/components/navigation/menu/bundles/index.umd.js +5 -0
  68. package/components/navigation/menu/esm2022/menu.component.mjs +6 -1
  69. package/components/navigation/menu/fesm2022/index.mjs +5 -0
  70. package/components/navigation/menu/fesm2022/index.mjs.map +1 -1
  71. package/components/navigation/popover/bundles/index.umd.js +6 -6
  72. package/components/navigation/popover/esm2022/popover.component.mjs +4 -4
  73. package/components/navigation/popover/fesm2022/index.mjs +3 -3
  74. package/components/navigation/popover/fesm2022/index.mjs.map +1 -1
  75. package/components/navigation/popover/popover.component.d.ts +6 -0
  76. package/components/page/default/bundles/index.umd.js +1 -0
  77. package/components/page/default/esm2022/page.directive.mjs +2 -1
  78. package/components/page/default/fesm2022/index.mjs +1 -0
  79. package/components/page/default/fesm2022/index.mjs.map +1 -1
  80. package/core/bundles/index.umd.js +120 -15
  81. package/core/esm2022/public_api.mjs +2 -2
  82. package/core/esm2022/utils/utils.mjs +6 -2
  83. package/core/esm2022/utils/watcher.mjs +118 -15
  84. package/core/fesm2022/index.mjs +124 -15
  85. package/core/fesm2022/index.mjs.map +1 -1
  86. package/core/public_api.d.ts +1 -1
  87. package/core/utils/utils.d.ts +1 -0
  88. package/npm-shrinkwrap.json +2 -2
  89. package/package-lock.json +2 -2
  90. package/package.json +1 -1
  91. package/runtime/base/bundles/index.umd.js +23 -14
  92. package/runtime/base/components/base-prefab.component.d.ts +6 -4
  93. package/runtime/base/esm2022/components/base-page.component.mjs +2 -1
  94. package/runtime/base/esm2022/components/base-partial.component.mjs +2 -2
  95. package/runtime/base/esm2022/components/base-prefab.component.mjs +20 -12
  96. package/runtime/base/esm2022/services/pipe-provider.service.mjs +4 -4
  97. package/runtime/base/fesm2022/index.mjs +23 -14
  98. package/runtime/base/fesm2022/index.mjs.map +1 -1
  99. package/runtime/dynamic/bundles/index.umd.js +4 -0
  100. package/runtime/dynamic/esm2022/app/app.config.mjs +6 -2
  101. package/runtime/dynamic/fesm2022/index.mjs +5 -1
  102. package/runtime/dynamic/fesm2022/index.mjs.map +1 -1
  103. package/scripts/datatable/datatable.js +359 -35
@@ -345,6 +345,9 @@ $.widget('wm.datatable', {
345
345
  if (field === 'radio') {
346
346
  $th.attr('aria-label', "Select row");
347
347
  }
348
+ if (field === '__expand') {
349
+ $th.append('<span class="sr-only">Expand row</span>');
350
+ }
348
351
  $th.append('<span class="header-data">' + headerLabel + '</span>');
349
352
  if (sortEnabled) { //If sort info is present, show the sort icon for that column on grid render
350
353
  $sortSpan = $('<span class="sort-buttons-container"></span>');
@@ -507,7 +510,22 @@ $.widget('wm.datatable', {
507
510
 
508
511
  /* function to get start index of the current active page */
509
512
  getPageStartIndex: function() {
510
- var currentPage = this.options.getCurrentPage(), pagesize = this.options.getPageSize();
513
+ // Guard against undefined getCurrentPage or getPageSize functions
514
+ var getCurrentPageFn = this.options.getCurrentPage;
515
+ var getPageSizeFn = this.options.getPageSize;
516
+ var currentPage, pagesize;
517
+ if (!getCurrentPageFn || typeof getCurrentPageFn !== 'function') {
518
+ // Default to page 1 if getCurrentPage is not available
519
+ currentPage = 1;
520
+ } else {
521
+ currentPage = getCurrentPageFn();
522
+ }
523
+ if (!getPageSizeFn || typeof getPageSizeFn !== 'function') {
524
+ // Default to 10 if getPageSize is not available
525
+ pagesize = 10;
526
+ } else {
527
+ pagesize = getPageSizeFn();
528
+ }
511
529
  var isPrevPageUpdated = this.options.actionRowPage < currentPage;
512
530
  var pageIndex = isPrevPageUpdated ? this.options.actionRowPage : currentPage;
513
531
  return ((pageIndex - 1) * pagesize);
@@ -568,6 +586,8 @@ $.widget('wm.datatable', {
568
586
  var self = this, preparedData,$tbody,pageStartIndex = self.getPageStartIndex(),
569
587
  startRowIndex = self.options.startRowIndex,
570
588
  isScrollorOnDemand = self.options.isNavTypeScrollOrOndemand();
589
+ var $activeRow = self.gridElement.find('tr.row-editing:not(.always-new-row)').first();
590
+ var index = $activeRow.index();
571
591
  if(isScrollorOnDemand) {
572
592
  $tbody = this.gridElement;
573
593
  if(this.renderTableOnViewLess) {
@@ -623,6 +643,16 @@ $.widget('wm.datatable', {
623
643
  this.options.setIsDataUpdatedByUser(false);
624
644
  this.options.clearActionRowIndex();
625
645
  }
646
+ if(this.options.editmode===this.CONSTANTS.QUICK_EDIT){
647
+ if (index>=0) {
648
+ const $newActiveRow = self.gridElement.find('tr').eq(index);
649
+ if ($newActiveRow && $newActiveRow.length) {
650
+ $newActiveRow.addClass('active');
651
+ $newActiveRow.trigger('click', [undefined, {action: 'edit', skipFocus:false}]);
652
+ self.setActiveRow($newActiveRow);
653
+ self.focusActiveRow();
654
+ }
655
+ }}
626
656
  return $tbody;
627
657
  },
628
658
 
@@ -693,6 +723,7 @@ $.widget('wm.datatable', {
693
723
  <label>
694
724
  <input type="radio" rowSelectInput name="" value="" ${checked} ${disabled}>
695
725
  <span class="caption"></span>
726
+ <span class="sr-only">Select row</span>
696
727
  </label>
697
728
  </div>`;
698
729
  },
@@ -709,6 +740,10 @@ $.widget('wm.datatable', {
709
740
  colExpression = colDef.customExpression,
710
741
  styles = "text-align: " + colDef.textAlignment + ";position: relative;"
711
742
 
743
+ if (!_.isUndefined(colDef.show) && !colDef.show) {
744
+ styles += "display: none;";
745
+ }
746
+
712
747
  $htm = $('<td class="' + classes + '" data-col-id="' + colId + '" role="cell" tabindex="0"></td>');
713
748
  this._setStyles($htm, styles);
714
749
 
@@ -1042,7 +1077,9 @@ $.widget('wm.datatable', {
1042
1077
  'value': '',
1043
1078
  'event': null
1044
1079
  },
1045
- compiledCellTemplates: {}
1080
+ compiledCellTemplates: {},
1081
+ // MEMORY LEAK FIX: Store bound function for proper event listener cleanup
1082
+ // boundRowClickHandlerOnCapture: null
1046
1083
  });
1047
1084
  // TODO: Variable loading status is getting updated before dataset update. This is resulting in loader going off before data is rendered.
1048
1085
  // Need to update code with suitable fix. For now 250ms is added as workaround
@@ -1102,6 +1139,144 @@ $.widget('wm.datatable', {
1102
1139
  this._setGridEditMode(false);
1103
1140
  this.toggleNewRowActions(false);
1104
1141
  },
1142
+ /*
1143
+ * Updates internal state (options.data, preparedData, custom expressions,
1144
+ * conditional class watchers, and summary row) without a full DOM re-render.
1145
+ * Used during quickedit inline save for model variables to avoid focus loss.
1146
+ */
1147
+ softRefreshData: function (newData) {
1148
+ // With pagination, navigator / selection can emit the same page twice in one
1149
+ // save cycle. Full refresh skipped duplicate data via isEqual on option set;
1150
+ // soft refresh must do the same or onDataRender (datarender) fires twice.
1151
+ if (this.options.data && newData && _.isEqual(this.options.data, newData)) {
1152
+ return;
1153
+ }
1154
+
1155
+ var self = this,
1156
+ isScrollOrOnDemand = this.options.isNavTypeScrollOrOndemand(),
1157
+ pageStartIndex = this.getPageStartIndex(),
1158
+ startRowIndex = this.options.startRowIndex || 0,
1159
+ selectedMap = {},
1160
+ preparedData;
1161
+
1162
+ // Preserve _selected state before _prepareData rebuilds preparedData
1163
+ this.preparedData.forEach(function (data, i) {
1164
+ if (data._selected) {
1165
+ selectedMap[i] = true;
1166
+ }
1167
+ });
1168
+
1169
+ this.options.data = newData;
1170
+ this._prepareData();
1171
+
1172
+ // Restore _selected state on new preparedData
1173
+ Object.keys(selectedMap).forEach(function (i) {
1174
+ if (self.preparedData[i]) {
1175
+ self.preparedData[i]._selected = true;
1176
+ }
1177
+ });
1178
+
1179
+ if (isScrollOrOnDemand) {
1180
+ preparedData = this.preparedData.slice(pageStartIndex);
1181
+ } else {
1182
+ preparedData = this.preparedData;
1183
+ }
1184
+
1185
+ // Update existing custom expression view contexts in-place
1186
+ // so Angular change detection picks up new data without DOM manipulation.
1187
+ if (_.isFunction(this.options.updateCustomExpressionContexts)) {
1188
+ this.options.updateCustomExpressionContexts(preparedData);
1189
+ }
1190
+
1191
+ // Update plain text cells with fresh data from preparedData.
1192
+ // hideRowEditMode runs before softRefreshData and may restore cells
1193
+ // before preparedData is updated, leaving them with stale values.
1194
+ self.gridElement.find('tr.' + self.options.cssClassNames.tableRow + ':not(.always-new-row)').each(function () {
1195
+ var $row = $(this),
1196
+ rowId = +$row.attr('data-row-id'),
1197
+ rowData = self.preparedData[rowId];
1198
+ if (!rowData) return;
1199
+
1200
+ $row.find('td.' + self.options.cssClassNames.tableCell + ':not(.cell-editing)').each(function () {
1201
+ var $cell = $(this),
1202
+ colId = +$cell.attr('data-col-id'),
1203
+ colDef = self.preparedHeaderData[colId],
1204
+ value;
1205
+
1206
+ if (colDef && !colDef.customExpression && colDef.type !== 'custom') {
1207
+ value = _.get(rowData, colDef.field);
1208
+ var newText;
1209
+ if (self.Utils.isDefined(value) && value !== null) {
1210
+ newText = '' + value;
1211
+ } else if (self.options.filterNullRecords && value === null) {
1212
+ newText = 'null';
1213
+ } else {
1214
+ newText = '';
1215
+ }
1216
+ if ($cell.text() !== newText) {
1217
+ $cell.text(newText);
1218
+ $cell.attr('title', newText);
1219
+ }
1220
+ }
1221
+ });
1222
+ });
1223
+
1224
+ // Re-register conditional class watchers with fresh row clones
1225
+ _.forEach(preparedData, function (row, index) {
1226
+ var _row = _.clone(row),
1227
+ rowIndex = isScrollOrOnDemand ? startRowIndex + index - 1 : index;
1228
+ _row.$index = rowIndex + 1;
1229
+
1230
+ self.options.registerRowNgClassWatcher(_row, rowIndex);
1231
+
1232
+ self.preparedHeaderData.forEach(function (colDef, colId) {
1233
+ self.options.registerColNgClassWatcher(_row, colDef, rowIndex, colId);
1234
+ });
1235
+ });
1236
+
1237
+ // Reset action state flags (mirrors _getGridTemplate cleanup)
1238
+ if (!this.options.isdynamictable) {
1239
+ this.options.setLastActionPerformed(this.options.ACTIONS.DEFAULT);
1240
+ this.options.setIsDataUpdatedByUser(false);
1241
+ this.options.clearActionRowIndex();
1242
+ }
1243
+
1244
+ // Refresh row action buttons and expansion buttons with updated row data.
1245
+ // Scope to data rows only — exclude always-new-row which has no backing data entry.
1246
+ var $dataRows = self.gridElement.find('tr.' + self.options.cssClassNames.tableRow + ':not(.always-new-row)');
1247
+ this.options.clearRowActions();
1248
+ this._appendRowExpansionButtons($dataRows);
1249
+ this._appendRowActions($dataRows);
1250
+ // Regenerated action / expansion DOM — re-bind handlers (attachEventHandlers only runs on full render).
1251
+ this._bindRowActionsAndExpansionClickHandlers($dataRows);
1252
+
1253
+ // Re-render summary row if present
1254
+ if (this.options.summaryRow) {
1255
+ var $summaryRowHtm = $(this._getSummaryRowTemplate());
1256
+ this.tableContainer.find('tfoot').remove();
1257
+ if (this.options.data.length) {
1258
+ this.tableContainer.append($summaryRowHtm);
1259
+ }
1260
+ this.gridFooter = this.tableContainer.find('tfoot');
1261
+ }
1262
+
1263
+ // Invalidate row detail (expansion) cache so collapse+re-expand
1264
+ // creates fresh views with updated data.
1265
+ if (_.isFunction(this.options.invalidateRowDetailCache)) {
1266
+ this.options.invalidateRowDetailCache(preparedData);
1267
+ }
1268
+
1269
+ // Refresh this.items with fresh data references from the updated dataset
1270
+ // so that selecteditem / currentItem reflect the new values.
1271
+ if (_.isFunction(this.options.refreshSelectedItems)) {
1272
+ this.options.refreshSelectedItems();
1273
+ }
1274
+
1275
+ // Fire datarender event callback
1276
+ if (_.isFunction(this.options.onDataRender)) {
1277
+ this.options.onDataRender();
1278
+ }
1279
+ },
1105
1280
  //Populate row data with default data
1106
1281
  setDefaultRowData: function (rowData) {
1107
1282
  _.forEach(this.preparedHeaderData, function (colDef) {
@@ -1264,7 +1439,9 @@ $.widget('wm.datatable', {
1264
1439
  this.element.find('.loading-data-msg').hide();
1265
1440
  this.element.find('.on-demand-load-btn').text(this.options.ondemandmessage);
1266
1441
  this.element.find('.on-demand-load-btn').show();
1267
- } else if((this.options.getCurrentPage() == this.options.getPageCount()) && this.options.showviewlessbutton) {
1442
+ } else if(this.options.getCurrentPage && typeof this.options.getCurrentPage === 'function' &&
1443
+ this.options.getPageCount && typeof this.options.getPageCount === 'function' &&
1444
+ (this.options.getCurrentPage() == this.options.getPageCount()) && this.options.showviewlessbutton) {
1268
1445
  this.element.find('.on-demand-load-btn').show().text(this.options.viewlessmessage);
1269
1446
  this.element.find('.loading-data-msg').hide();
1270
1447
  if(infScroll) {
@@ -1319,6 +1496,12 @@ $.widget('wm.datatable', {
1319
1496
  }
1320
1497
  }
1321
1498
  },
1499
+ refreshColumnWidths: function () {
1500
+ if (this.gridContainer.width() > 0) {
1501
+ this.tableContainer.children('colgroup').children('col').css('width', '');
1502
+ }
1503
+ this.setColGroupWidths();
1504
+ },
1322
1505
  /*Set the default widths for the colgroup*/
1323
1506
  setColGroupWidths: function () {
1324
1507
  var self = this,
@@ -1652,8 +1835,8 @@ $.widget('wm.datatable', {
1652
1835
  },
1653
1836
 
1654
1837
  /* Selects a row. */
1655
- selectRow: function (row, value) {
1656
- var rowIndex = _.isNumber(row) ? row : this.Utils.getObjectIndex(this.options.data, row),
1838
+ selectRow: function (row, value,index) {
1839
+ var rowIndex =index?index:( _.isNumber(row) ? row : this.Utils.getObjectIndex(this.options.data, row)),
1657
1840
  selector,
1658
1841
  $row;
1659
1842
  if (rowIndex !== -1) {
@@ -1965,8 +2148,8 @@ $.widget('wm.datatable', {
1965
2148
  var $firstEl,
1966
2149
  $target = e && $(e.target),
1967
2150
  $focusEl;
1968
- //If focused directly on the cell, focus the input in the cell
1969
- if ($target && $target.hasClass('app-datagrid-cell')) {
2151
+ //If focused directly on the cell, focus the input in the cell (only when the element is still in the DOM)
2152
+ if ($target && $target.hasClass('app-datagrid-cell') && document.body.contains($target[0])) {
1970
2153
  $firstEl = $target.find('input');
1971
2154
  } else {
1972
2155
  if (!$el) {
@@ -1982,7 +2165,7 @@ $.widget('wm.datatable', {
1982
2165
  if (!$firstEl.length) {
1983
2166
  $firstEl = $($el).first().find('select');
1984
2167
  }
1985
- if(!($(e.target).find('td').first().hasClass('td.cell-editing'))){
2168
+ if(!($(e?.target).find('td').first().hasClass('td.cell-editing'))){
1986
2169
  $firstEl=$el.find('td');
1987
2170
  }
1988
2171
  }
@@ -2018,9 +2201,9 @@ $.widget('wm.datatable', {
2018
2201
  this.toggleNewRowActions(false);
2019
2202
  },
2020
2203
  //Method to save a row which is in editable state
2021
- saveRow: function (callBack) {
2204
+ saveRow: function (callBack, skipFocus) {
2022
2205
  this.gridElement.find('tr.app-datagrid-row.row-editing:not(.always-new-row)').each(function () {
2023
- $(this).trigger('click', [undefined, {action: 'save', skipSelect: true, noMsg: true, success: callBack}]);
2206
+ $(this).trigger('click', [undefined, {action: 'save', skipSelect: true, noMsg: true, skipFocus: skipFocus, success: callBack}]);
2024
2207
  });
2025
2208
  },
2026
2209
  //Method to make row editable with widgets
@@ -2078,10 +2261,11 @@ $.widget('wm.datatable', {
2078
2261
  });
2079
2262
 
2080
2263
  $editableElements = $row.find('td.cell-editing');
2081
- $editableElements.on('click', function (e) {
2264
+ // PERFORMANCE FIX: Use event delegation on row instead of individual cell listeners
2265
+ $row.on('click.cellEdit', 'td.cell-editing', function (e) {
2082
2266
  e.stopPropagation();
2083
2267
  });
2084
- $editableElements.on('keydown', function (e) {
2268
+ $row.on('keydown.cellEdit', 'td.cell-editing', function (e) {
2085
2269
  //To prevent up and down arrows, navigating to other rows in edit mode
2086
2270
  if ((e.which === 38 || e.which === 40) && (e.currentTarget && !e.currentTarget.closest('.always-new-row'))) {
2087
2271
  e.stopPropagation();
@@ -2123,6 +2307,10 @@ $.widget('wm.datatable', {
2123
2307
  var rowId = parseInt($row.attr('data-row-id'), 10);
2124
2308
  return rowId >= this.preparedData.length || $row.hasClass('always-new-row');
2125
2309
  },
2310
+ _getWmVariableRowLocator: function (rowId) {
2311
+ var liveRow = this.options.data[parseInt(rowId, 10)];
2312
+ return (liveRow && liveRow.$$wmSourceListIndex != null) ? liveRow.$$wmSourceListIndex : (liveRow || parseInt(rowId, 10));
2313
+ },
2126
2314
  /* Toggles the edit state of a row. */
2127
2315
  toggleEditRow: function (e, options) {
2128
2316
  if($(e.target).closest('.app-menu').length) {
@@ -2150,7 +2338,8 @@ $.widget('wm.datatable', {
2150
2338
  $requiredEls,
2151
2339
  alwaysNewRow = $row.hasClass('always-new-row'),
2152
2340
  advancedEdit = self.options.editmode === self.CONSTANTS.QUICK_EDIT,
2153
- editOptions = {};
2341
+ editOptions = {},
2342
+ rowindex=$row.attr('data-row-id');
2154
2343
 
2155
2344
  // when a row is edited set actionrow variables
2156
2345
  this.options.setActionRowIndex($row.attr('data-row-id'));
@@ -2161,7 +2350,8 @@ $.widget('wm.datatable', {
2161
2350
  if (_.isFunction(options.success)) {
2162
2351
  options.success(skipFocus, error);
2163
2352
  }
2164
- if (!advancedEdit || self.options.actionsEnabled.edit) {
2353
+ // [WMS-31104] Do not refocus this table when the save was initiated from outside (e.g. clicking another table).
2354
+ if (!skipFocus && !options.skipFocus && (!advancedEdit || self.options.actionsEnabled.edit)) {
2165
2355
  self.focusActiveRow();
2166
2356
  }
2167
2357
  }
@@ -2172,7 +2362,7 @@ $.widget('wm.datatable', {
2172
2362
  }
2173
2363
  //Select the current edited row
2174
2364
  if (options.selectRow) {
2175
- this.selectRow(rowData, true);
2365
+ this.selectRow(rowData, true,rowindex);
2176
2366
  }
2177
2367
  e = e || {};
2178
2368
  e.data = e.data || {};
@@ -2188,6 +2378,43 @@ $.widget('wm.datatable', {
2188
2378
  });
2189
2379
  return;
2190
2380
  }
2381
+ if (advancedEdit) {
2382
+ // [WMS-31104] Close/save row in another quick-edit table before editing this row.
2383
+ $(document).find('tr.app-datagrid-row.always-new-row.row-editing').filter(function () {
2384
+ return $(this).closest(self.element).length === 0;
2385
+ }).each(function () {
2386
+ var $newRow = $(this),
2387
+ $otherGrid = $newRow.closest('.app-datagrid');
2388
+ if ($otherGrid.length) {
2389
+ $otherGrid.datatable('resetNewRow', $newRow);
2390
+ }
2391
+ });
2392
+ // [WMS-31104] Save the editing row in another table before opening the clicked row in this table.
2393
+ var $otherEditingRow = $(document).find('tr.app-datagrid-row.row-editing:not(.always-new-row)').filter(function () {
2394
+ return $(this).closest(self.element).length === 0;
2395
+ }).first();
2396
+ if ($otherEditingRow.length) {
2397
+ var rowId = $row.attr('data-row-id');
2398
+ $otherEditingRow.trigger('click', [undefined, {
2399
+ action: 'save',
2400
+ $row: $otherEditingRow,
2401
+ skipSelect: true,
2402
+ noMsg: true,
2403
+ skipFocus: true,
2404
+ success: function () {
2405
+ var $liveRow = self.gridElement.find('tr.app-datagrid-row[data-row-id="' + rowId + '"]');
2406
+ var $targetRow = $liveRow.length ? $liveRow : $row;
2407
+ self.toggleEditRow(e, _.extend({}, options, {
2408
+ action: 'edit',
2409
+ $row: $targetRow,
2410
+ skipFocus: true,
2411
+ focusAfterCrossTableSave: true
2412
+ }));
2413
+ }
2414
+ }]);
2415
+ return;
2416
+ }
2417
+ }
2191
2418
  $row.addClass('row-editing');
2192
2419
  if (_.isFunction(this.options.beforeRowUpdate)) {
2193
2420
  this.options.beforeRowUpdate(rowData, e);
@@ -2228,6 +2455,12 @@ $.widget('wm.datatable', {
2228
2455
  if (_.isFunction(this.options.onFormRender)) {
2229
2456
  this.options.onFormRender($row, e, options.operation || action, $row.hasClass('always-new-row'));
2230
2457
  }
2458
+ // [WMS-31104] Focus target row after widgets render when edit opened from another table save.
2459
+ if (options.focusAfterCrossTableSave) {
2460
+ self.options.timeoutCall(function () {
2461
+ self.setFocusOnElement(undefined, $row.find('td.cell-editing'), true);
2462
+ });
2463
+ }
2231
2464
  } else {
2232
2465
  $editableElements = $row.find('td.cell-editing');
2233
2466
  isNewRow = self._isNewRow($row);
@@ -2240,6 +2473,10 @@ $.widget('wm.datatable', {
2240
2473
  }
2241
2474
 
2242
2475
  if (isDataChanged) {
2476
+ editOptions.skipFocus = options.skipFocus;
2477
+ if (options.skipFocus) {
2478
+ self.options.activeRow = undefined;
2479
+ }
2243
2480
  $editableElements.each(function () {
2244
2481
  var $el = $(this),
2245
2482
  colId = $el.attr('data-col-id'),
@@ -2327,6 +2564,10 @@ $.widget('wm.datatable', {
2327
2564
  return;
2328
2565
  }
2329
2566
  }
2567
+ var ds = this.options.getDataSource && this.options.getDataSource();
2568
+ if (ds && ds.category === 'wm.Variable') {
2569
+ editOptions.rowindex = self._getWmVariableRowLocator(rowindex);
2570
+ }
2330
2571
  this.options.afterRowUpdate(rowData, e, onSaveSuccess, editOptions);
2331
2572
  }
2332
2573
  } else {
@@ -2363,6 +2604,8 @@ $.widget('wm.datatable', {
2363
2604
 
2364
2605
  this.disableActions(false);
2365
2606
  $row.removeClass('row-editing');
2607
+ // PERFORMANCE FIX: Remove namespaced event listeners from row
2608
+ $row.off('.cellEdit');
2366
2609
  $editableElements.off('click');
2367
2610
  $editableElements.each(function () {
2368
2611
  var $el = $(this),
@@ -2411,6 +2654,8 @@ $.widget('wm.datatable', {
2411
2654
  $saveButton = $row.find('.save-edit-row-button'),
2412
2655
  self = this;
2413
2656
  $row.removeClass('row-editing');
2657
+ // PERFORMANCE FIX: Remove namespaced event listeners from row
2658
+ $row.off('.cellEdit');
2414
2659
  $editableElements.off('click');
2415
2660
  this.disableActions(false);
2416
2661
  this._setGridEditMode(false);
@@ -2474,6 +2719,10 @@ $.widget('wm.datatable', {
2474
2719
  return;
2475
2720
  }
2476
2721
  }
2722
+ var deleteDs = this.options.getDataSource && this.options.getDataSource();
2723
+ if (deleteDs && deleteDs.category === 'wm.Variable') {
2724
+ options.rowindex = this._getWmVariableRowLocator(rowId);
2725
+ }
2477
2726
  if (_.isFunction(this.options.onRowDelete)) {
2478
2727
  className = this.options.cssClassNames.deleteRow;
2479
2728
  isActiveRow = $row.attr('class').indexOf('active') !== -1;
@@ -2831,7 +3080,7 @@ $.widget('wm.datatable', {
2831
3080
  var $cell = $target.closest('td.app-datagrid-cell'),
2832
3081
  $editCells;
2833
3082
 
2834
- if ($cell.is(':last-child')) {
3083
+ if ($cell.is(':last-child') || $cell.nextAll('td.app-datagrid-cell:visible').length === 0) {
2835
3084
  return true;
2836
3085
  }
2837
3086
 
@@ -2852,6 +3101,28 @@ $.widget('wm.datatable', {
2852
3101
  this.sortHandler(event);
2853
3102
  }
2854
3103
  },
3104
+ /**
3105
+ * Binds jQuery handlers on save/cancel row-action buttons and row-expansion controls.
3106
+ * Must run after DOM for those controls is replaced (e.g. softRefreshData).
3107
+ */
3108
+ _bindRowActionsAndExpansionClickHandlers: function ($scope) {
3109
+ var self = this;
3110
+ if (this.options.rowActions.length) {
3111
+ $scope.find('.cancel-edit-row-button').off('click');
3112
+ $scope.find('.save-edit-row-button').off('click');
3113
+ $scope.find('.cancel-edit-row-button').on('click', {action: 'cancel'}, this.toggleEditRow.bind(this));
3114
+ $scope.find('.save-edit-row-button').on('click', {action: 'save'}, this.toggleEditRow.bind(this));
3115
+ }
3116
+ $scope.find('[data-identifier="rowExpansionButtons"]').off('click');
3117
+ $scope.find('[data-identifier="rowExpansionButtons"]').on('click', function (e) {
3118
+ var $row = $(e.target).closest('tr.app-datagrid-row');
3119
+ if ($(this).find('.app-button').attr('disabled')) {
3120
+ return;
3121
+ }
3122
+ self.toggleExpandRow(+$row.attr('data-row-id'), undefined, e);
3123
+ });
3124
+ },
3125
+
2855
3126
  /* Attaches all event handlers for the table. */
2856
3127
  attachEventHandlers: function ($htm) {
2857
3128
  var $header = this.gridHeaderElement,
@@ -2859,8 +3130,17 @@ $.widget('wm.datatable', {
2859
3130
 
2860
3131
  if (this.options.enableRowSelection) {
2861
3132
  $htm[0].removeEventListener('click', this.rowClickHandlerOnCapture.bind(this));
3133
+ // MEMORY LEAK FIX: Remove old listener if exists before adding new one
3134
+ // if (this.boundRowClickHandlerOnCapture && $htm[0]) {
3135
+ // $htm[0].removeEventListener('click', this.boundRowClickHandlerOnCapture, true);
3136
+ // }
2862
3137
  $htm.off();
2863
3138
  $htm[0].addEventListener('click', this.rowClickHandlerOnCapture.bind(this));
3139
+
3140
+ // MEMORY LEAK FIX: Store bound function reference for proper removal
3141
+ // this.boundRowClickHandlerOnCapture = this.rowClickHandlerOnCapture.bind(this);
3142
+ // $htm[0].addEventListener('click', this.boundRowClickHandlerOnCapture, true);
3143
+
2864
3144
  // add js click handler for capture phase in order to first listen on grid and
2865
3145
  // assign selectedItems so that any child actions can have access to the selectedItems.
2866
3146
  $htm.on('click', this.rowSelectionHandler.bind(this));
@@ -2896,16 +3176,14 @@ $.widget('wm.datatable', {
2896
3176
  }
2897
3177
  }
2898
3178
  }
2899
- if (this.options.rowActions.length) {
2900
- $htm.find('.cancel-edit-row-button').off('click');
2901
- $htm.find('.save-edit-row-button').off('click');
2902
- $htm.find('.cancel-edit-row-button').on('click', {action: 'cancel'}, this.toggleEditRow.bind(this));
2903
- $htm.find('.save-edit-row-button').on('click', {action: 'save'}, this.toggleEditRow.bind(this));
2904
- }
3179
+ this._bindRowActionsAndExpansionClickHandlers($htm);
2905
3180
  if (self.options.editmode === self.CONSTANTS.QUICK_EDIT) {
2906
3181
  $htm.on('focus', 'tr.app-datagrid-row', function (e) {
2907
3182
  var $row = $(e.currentTarget);
2908
3183
  if (!$row.hasClass('row-editing')) {
3184
+ if(e.target===e.currentTarget && (e.which===0||!e.which)) {
3185
+ return;
3186
+ }
2909
3187
  self.toggleEditRow(e, { $row: $row, action: 'edit'});
2910
3188
  }
2911
3189
  });
@@ -2921,6 +3199,25 @@ $.widget('wm.datatable', {
2921
3199
  isRelatedTargetGridAction = $relatedTarget.closest('div.app-datagrid-actions').length>0,
2922
3200
  invalidTargets = '.row-editing:not(".always-new-row"), .row-action-button, .app-datagrid-cell, .caption, button.btn-time, button.btn-date';
2923
3201
 
3202
+ // [WMS-31104] Do not insert the new row when focus moves to another table; that table's row-click handler will reset it.
3203
+ if ($row.hasClass('always-new-row')
3204
+ && $relatedTarget.length
3205
+ && !$relatedTarget.closest(self.element).length
3206
+ && $relatedTarget.closest('.app-datagrid').length) {
3207
+ return;
3208
+ }
3209
+ // Focus moved to a date/time picker — the row is still being edited, do not save.
3210
+ if ($relatedTarget.closest('bs-datepicker-container, .btn-date, .btn-time').length) {
3211
+ return;
3212
+ }
3213
+ // [WMS-31104] For regular rows, do not save on focusout when focus leaves this table; the outside-click handler handles it.
3214
+ // The new row (always-new-row) is excluded from this guard so Tab-key save still works when focus moves to pagination.
3215
+ if (!$row.hasClass('always-new-row')
3216
+ && $relatedTarget.length
3217
+ && !$relatedTarget.closest(self.element).length) {
3218
+ return;
3219
+ }
3220
+
2924
3221
  //Check if the focus out element is outside the grid or some special elements
2925
3222
  function isInvalidTarget() {
2926
3223
  if (!$relatedTarget.closest('.app-grid').length) {
@@ -2944,7 +3241,7 @@ $.widget('wm.datatable', {
2944
3241
  // triggered from the Row Actions
2945
3242
  if (!isTargetGridAction && !isTargetRowAction) {
2946
3243
  //Save the row on last column of the data table. Do not save the row if focus is out of input file.
2947
- if (!isLastColumn || (isLastColumn && e.relatedTarget === null) || $target.hasClass("file-upload")) {
3244
+ if (!isLastColumn || (isLastColumn && (e.relatedTarget === null || $(e.target).is('tr.app-datagrid-row'))) || $target.hasClass("file-upload")) {
2948
3245
  return;
2949
3246
  }
2950
3247
  }
@@ -2962,15 +3259,6 @@ $.widget('wm.datatable', {
2962
3259
  });
2963
3260
  }
2964
3261
 
2965
- // row selection
2966
- $htm.find('[data-identifier="rowExpansionButtons"]').off("click");
2967
- $htm.find('[data-identifier="rowExpansionButtons"]').on('click', function (e) {
2968
- var $row = $(e.target).closest('tr.app-datagrid-row');
2969
- if ($(this).find('.app-button').attr('disabled')) {
2970
- return;
2971
- }
2972
- self.toggleExpandRow(+$row.attr('data-row-id'), undefined, e);
2973
- });
2974
3262
  },
2975
3263
  expandRow: function(rowId) {
2976
3264
  this.toggleExpandRow(rowId, true)
@@ -3494,7 +3782,11 @@ $.widget('wm.datatable', {
3494
3782
  this.dataStatusContainer.hide();
3495
3783
  } else {
3496
3784
  // [WMS-23839] always show load more btn if show view less btn is true
3497
- if (this.options.isNavTypeScrollOrOndemand() && (state === 'nodata' || ((this.options.getCurrentPage() == this.options.getPageCount()) && !this.options.showviewlessbutton))) {
3785
+ if (this.options.isNavTypeScrollOrOndemand() &&
3786
+ (state === 'nodata' ||
3787
+ (this.options.getCurrentPage && typeof this.options.getCurrentPage === 'function' &&
3788
+ this.options.getPageCount && typeof this.options.getPageCount === 'function' &&
3789
+ (this.options.getCurrentPage() == this.options.getPageCount()) && !this.options.showviewlessbutton))) {
3498
3790
  this.element.find('.on-demand-datagrid a').hide();
3499
3791
  }
3500
3792
  this.dataStatusContainer.show();
@@ -3504,7 +3796,9 @@ $.widget('wm.datatable', {
3504
3796
  if (state === 'nodata') {
3505
3797
  this.dataStatusContainer.css('height', 'auto');
3506
3798
  this.dataStatus.contentHeight = 0;
3507
- } else if (this.options.isNavTypeScrollOrOndemand() && this.options.getCurrentPage() > 1){
3799
+ } else if (this.options.isNavTypeScrollOrOndemand() &&
3800
+ this.options.getCurrentPage && typeof this.options.getCurrentPage === 'function' &&
3801
+ this.options.getCurrentPage() > 1){
3508
3802
  // showing the loading icon only for the first page
3509
3803
  // from second page there is another loader which is being shown instead of LoadMore btn
3510
3804
  this.dataStatusContainer.hide();
@@ -3514,7 +3808,9 @@ $.widget('wm.datatable', {
3514
3808
  this.dataStatusContainer.css('height', this.dataStatus.height > this.dataStatus.contentHeight ? 'auto' : this.dataStatus.contentHeight);
3515
3809
  }
3516
3810
  }
3517
- if (!isScrollOrOndemand || (isScrollOrOndemand && this.options.getCurrentPage() === 1)) {
3811
+ if (!isScrollOrOndemand || (isScrollOrOndemand &&
3812
+ this.options.getCurrentPage && typeof this.options.getCurrentPage === 'function' &&
3813
+ this.options.getCurrentPage() === 1)) {
3518
3814
  this.gridContainer.addClass("show-msg");
3519
3815
  }
3520
3816
  } else {
@@ -3633,6 +3929,34 @@ $.widget('wm.datatable', {
3633
3929
  },
3634
3930
 
3635
3931
  _destroy: function () {
3932
+ // MEMORY LEAK FIX: Remove native event listener using stored bound function
3933
+ // if (this.gridElement && this.gridElement[0] && this.boundRowClickHandlerOnCapture) {
3934
+ // this.gridElement[0].removeEventListener('click', this.boundRowClickHandlerOnCapture, true);
3935
+ // this.boundRowClickHandlerOnCapture = null;
3936
+ // }
3937
+
3938
+ // MEMORY LEAK FIX: Remove all jQuery event handlers
3939
+ if (this.gridHeaderElement) {
3940
+ this.gridHeaderElement.off();
3941
+ }
3942
+ if (this.gridElement) {
3943
+ this.gridElement.off();
3944
+ }
3945
+ if (this.gridSearch) {
3946
+ this.gridSearch.off();
3947
+ }
3948
+ if (this.tableContainer) {
3949
+ this.tableContainer.off();
3950
+ }
3951
+ if (this.gridContainer) {
3952
+ this.gridContainer.off();
3953
+ }
3954
+
3955
+ // MEMORY LEAK FIX: Clear all internal structures
3956
+ this.preparedData = [];
3957
+ this.preparedHeaderData = [];
3958
+ this.compiledCellTemplates = {};
3959
+
3636
3960
  this.element.text('');
3637
3961
  window.clearTimeout(this.refreshGridTimeout);
3638
3962
  }