inviton-powerduck 0.0.78 → 0.0.80

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.
@@ -301,6 +301,7 @@ export interface TableColumn {
301
301
  mobileShouldRenderRow?: (row) => boolean;
302
302
  exportInclude?: boolean;
303
303
  exportValue?: (row) => any;
304
+ customValue?: (row) => string;
304
305
  customRender?: (h, row) => void;
305
306
  clientsideFilter?: (row: any, filterDefinition: DataTablePostBackFilterItem) => boolean;
306
307
  }
@@ -335,6 +336,10 @@ export class DataTableFilterItemCollection extends Array<DataTableFilterItem> {
335
336
  }
336
337
  }
337
338
 
339
+ export class DataTableConfig {
340
+ static filterMarking = false;
341
+ }
342
+
338
343
  @Component
339
344
  class TableButtonComponent extends TsxComponent<TableButton> implements TableButton {
340
345
  @Prop() title!: string;
@@ -452,9 +457,12 @@ class DataTableComponent extends TsxComponent<DataTableArgs> implements DataTabl
452
457
  this.currentMobileBehavior = this.mobileBehavior;
453
458
  this.performColumnRefresh();
454
459
  this.handleWindowResized();
455
- this.markInstance = new Mark(this.$el);
456
460
  window.addEventListener("resize", this.handleWindowResized, true);
457
461
 
462
+ if (DataTableConfig.filterMarking) {
463
+ this.markInstance = new Mark(this.$el);
464
+ }
465
+
458
466
  if (this.handleInitialFilter) {
459
467
  this.parseInitialFilter();
460
468
  }
@@ -880,11 +888,13 @@ class DataTableComponent extends TsxComponent<DataTableArgs> implements DataTabl
880
888
  regexBuilder += escapeRegExp(this.fullTextQuery);
881
889
  }
882
890
 
883
- this.markInstance.unmark({
884
- done: function () {
885
- mySelf.markInstance.markRegExp(new RegExp("(" + regexBuilder + ")", "i"));
886
- },
887
- });
891
+ if (DataTableConfig.filterMarking) {
892
+ this.markInstance.unmark({
893
+ done: function () {
894
+ mySelf.markInstance.markRegExp(new RegExp("(" + regexBuilder + ")", "i"));
895
+ },
896
+ });
897
+ }
888
898
  }
889
899
 
890
900
  addFilterItem(dtColumn: TableColumn, newFilter: DataTablePostBackFilterItem): void {
@@ -1132,6 +1142,8 @@ class DataTableComponent extends TsxComponent<DataTableArgs> implements DataTabl
1132
1142
  let val: any;
1133
1143
  if (column?.customFilterValue != null) {
1134
1144
  val = column.customFilterValue(p);
1145
+ } else if (column?.customValue != null) {
1146
+ val = column.customValue(p);
1135
1147
  } else {
1136
1148
  val = p[filterData.PropertyName];
1137
1149
  }
@@ -1151,6 +1163,8 @@ class DataTableComponent extends TsxComponent<DataTableArgs> implements DataTabl
1151
1163
  let propVal: any;
1152
1164
  if (column?.customFilterValue != null) {
1153
1165
  propVal = column.customFilterValue(p);
1166
+ } else if (column?.customValue != null) {
1167
+ propVal = column.customValue(p);
1154
1168
  } else {
1155
1169
  propVal = p[filterData.PropertyName];
1156
1170
  }
@@ -1175,6 +1189,8 @@ class DataTableComponent extends TsxComponent<DataTableArgs> implements DataTabl
1175
1189
  let propVal: any;
1176
1190
  if (column?.customFilterValue != null) {
1177
1191
  propVal = column.customFilterValue(p);
1192
+ } else if (column?.customValue != null) {
1193
+ propVal = column.customValue(p);
1178
1194
  } else {
1179
1195
  propVal = p[filterData.PropertyName];
1180
1196
  }
@@ -1195,6 +1211,8 @@ class DataTableComponent extends TsxComponent<DataTableArgs> implements DataTabl
1195
1211
  let propVal: any;
1196
1212
  if (column?.customFilterValue != null) {
1197
1213
  propVal = column.customFilterValue(p);
1214
+ } else if (column?.customValue != null) {
1215
+ propVal = column.customValue(p);
1198
1216
  } else {
1199
1217
  propVal = p[filterData.PropertyName];
1200
1218
  }
@@ -1219,6 +1237,8 @@ class DataTableComponent extends TsxComponent<DataTableArgs> implements DataTabl
1219
1237
 
1220
1238
  if (column?.customFilterValue != null) {
1221
1239
  propVal = column.customFilterValue(row);
1240
+ } else if (column?.customValue != null) {
1241
+ propVal = column.customValue(row);
1222
1242
  } else {
1223
1243
  propVal = row[propName];
1224
1244
  }
@@ -1305,33 +1325,43 @@ class DataTableComponent extends TsxComponent<DataTableArgs> implements DataTabl
1305
1325
  loadPromise = mySelf.customAjaxCall(mySelf.getAjaxArgs(paginationPosition, paginationLength));
1306
1326
  }
1307
1327
 
1308
- loadPromise
1309
- .then((data: any) => {
1328
+ const unmark = (cb: () => void) => {
1329
+ if (DataTableConfig.filterMarking) {
1310
1330
  mySelf.markInstance.unmark({
1311
1331
  done: function () {
1312
- mySelf.enforceBodyRedraw = true;
1313
- mySelf.$nextTick(() => {
1314
- mySelf.enforceBodyRedraw = false;
1315
- mySelf.isLoading = false;
1316
-
1317
- if (mySelf.parseLoadedRowset != null) {
1318
- let rowset = mySelf.parseLoadedRowset(data);
1319
- mySelf.totalCount = rowset.TotalCount;
1320
- mySelf.totalFilteredCount = rowset.TotalFilteredCount;
1321
- mySelf.rows = rowset.Rows;
1322
- } else {
1323
- mySelf.totalCount = data.TotalCount;
1324
- mySelf.totalFilteredCount = data.TotalFilteredCount;
1325
- mySelf.rows = data.Rows;
1326
- }
1327
-
1328
- mySelf.loadedRows = mySelf.rows;
1329
- mySelf.$forceUpdate();
1330
- mySelf.$nextTick(() => mySelf.markSelection());
1331
- resolve(data);
1332
- });
1332
+ cb();
1333
1333
  },
1334
1334
  });
1335
+ } else {
1336
+ cb();
1337
+ }
1338
+ }
1339
+
1340
+ loadPromise
1341
+ .then((data: any) => {
1342
+ unmark(() => {
1343
+ mySelf.enforceBodyRedraw = true;
1344
+ mySelf.$nextTick(() => {
1345
+ mySelf.enforceBodyRedraw = false;
1346
+ mySelf.isLoading = false;
1347
+
1348
+ if (mySelf.parseLoadedRowset != null) {
1349
+ let rowset = mySelf.parseLoadedRowset(data);
1350
+ mySelf.totalCount = rowset.TotalCount;
1351
+ mySelf.totalFilteredCount = rowset.TotalFilteredCount;
1352
+ mySelf.rows = rowset.Rows;
1353
+ } else {
1354
+ mySelf.totalCount = data.TotalCount;
1355
+ mySelf.totalFilteredCount = data.TotalFilteredCount;
1356
+ mySelf.rows = data.Rows;
1357
+ }
1358
+
1359
+ mySelf.loadedRows = mySelf.rows;
1360
+ mySelf.$forceUpdate();
1361
+ mySelf.$nextTick(() => mySelf.markSelection());
1362
+ resolve(data);
1363
+ });
1364
+ });
1335
1365
  })
1336
1366
  .catch((err) => {
1337
1367
  mySelf.isLoading = false;
@@ -1756,6 +1786,10 @@ class DataTableComponent extends TsxComponent<DataTableArgs> implements DataTabl
1756
1786
 
1757
1787
  shouldRenderMobileRowColumn(row, dtColumn: TableColumn): boolean {
1758
1788
  if (dtColumn.customRender == null) {
1789
+ if (dtColumn.customValue != null) {
1790
+ return dtColumn.customValue(row) != null;
1791
+ }
1792
+
1759
1793
  return row[dtColumn.id] != null;
1760
1794
  }
1761
1795
 
@@ -2025,7 +2059,7 @@ class DataTableComponent extends TsxComponent<DataTableArgs> implements DataTabl
2025
2059
  </td>
2026
2060
 
2027
2061
  {columns.map((dtColumn, j) => (
2028
- <td class={this.getTableItemCssClass(dtColumn, j)}>{dtColumn.customRender == null ? row[dtColumn.id] : dtColumn.customRender(h, row)}</td>
2062
+ <td class={this.getTableItemCssClass(dtColumn, j)}>{dtColumn.customRender == null ? (dtColumn.customValue == null ? row[dtColumn.id] : dtColumn.customValue(row)) : dtColumn.customRender(h, row)}</td>
2029
2063
  ))}
2030
2064
  </tr>
2031
2065
  ))}
@@ -2051,7 +2085,7 @@ class DataTableComponent extends TsxComponent<DataTableArgs> implements DataTabl
2051
2085
  </td>
2052
2086
 
2053
2087
  {columns.map((dtColumn, j) => (
2054
- <td class={this.getTableItemCssClass(dtColumn, j)}>{dtColumn.customRender == null ? row[dtColumn.id] : dtColumn.customRender(h, row)}</td>
2088
+ <td class={this.getTableItemCssClass(dtColumn, j)}>{dtColumn.customRender == null ? (dtColumn.customValue == null ? row[dtColumn.id] : dtColumn.customValue(row)) : dtColumn.customRender(h, row)}</td>
2055
2089
  ))}
2056
2090
  </tr>
2057
2091
  ))}
@@ -2151,7 +2185,7 @@ class DataTableComponent extends TsxComponent<DataTableArgs> implements DataTabl
2151
2185
  {columns.map((dtColumn, j) => (
2152
2186
  <div class="dt-vert-item" style={this.getTableColumnOrderStyle(dtColumn, row)}>
2153
2187
  <div class="dt-vert-caption">{dtColumn.caption}</div>
2154
- <div class="dt-vert-value">{dtColumn.customRender == null ? row[dtColumn.id] : dtColumn.customRender(h, row)}</div>
2188
+ <div class="dt-vert-value">{dtColumn.customRender == null ? (dtColumn.customValue == null ? row[dtColumn.id] : dtColumn.customValue(row)) : dtColumn.customRender(h, row)}</div>
2155
2189
  </div>
2156
2190
  ))}
2157
2191
  </div>
@@ -2211,7 +2245,7 @@ class DataTableComponent extends TsxComponent<DataTableArgs> implements DataTabl
2211
2245
  <div class="dt-mobile-item-inner">
2212
2246
  {dtColumn.mobileCaption != false && <div class="dt-mobile-caption">{dtColumn.caption}</div>}
2213
2247
 
2214
- <div class="dt-mobile-value">{dtColumn.customRender == null ? row[dtColumn.id] : dtColumn.customRender(h, row)}</div>
2248
+ <div class="dt-mobile-value">{dtColumn.customRender == null ? (dtColumn.customValue == null ? row[dtColumn.id] : dtColumn.customValue(row)) : dtColumn.customRender(h, row)}</div>
2215
2249
  </div>
2216
2250
  )}
2217
2251
  {dtColumn.mobileRender && dtColumn.mobileRender(h, row)}
@@ -2279,7 +2313,7 @@ class DataTableComponent extends TsxComponent<DataTableArgs> implements DataTabl
2279
2313
 
2280
2314
  protected renderColumnValue(h, dtColumn: TableColumn, row) {
2281
2315
  if (dtColumn.customRender == null) {
2282
- return row[dtColumn.id];
2316
+ return (dtColumn.customValue == null ? row[dtColumn.id] : dtColumn.customValue(row));
2283
2317
  } else {
2284
2318
  return dtColumn.customRender(h, row);
2285
2319
  }
@@ -17,8 +17,8 @@ interface TableExportModalArgs {
17
17
  apiClient: IWebApiClient
18
18
  apiMethod: WebClientApiMethod
19
19
  apiArgs?: any
20
- exportConfig: DataTableExportConfig
21
- paginationOffset?: number;
20
+ exportConfig: DataTableExportConfig
21
+ paginationOffset?: number;
22
22
  paginationLength: number;
23
23
  totalFilteredCount: number;
24
24
  }
@@ -73,20 +73,20 @@ class TableExportModalComponent extends TsxComponent<TableExportModalBindingArgs
73
73
  ajaxArgs.PaginationPosition = steps + 1;
74
74
  ajaxArgs.PaginationLength = paginationLength || STEP_COUNT;
75
75
 
76
- if (exportConfig != null) {
77
- if (exportConfig.limitName != null) {
78
- ajaxArgs[exportConfig.limitName] = paginationLength || STEP_COUNT;
79
- }
76
+ if (exportConfig != null) {
77
+ if (exportConfig.limitName != null) {
78
+ ajaxArgs[exportConfig.limitName] = paginationLength || STEP_COUNT;
79
+ }
80
80
 
81
- if (exportConfig.pageName != null) {
82
- ajaxArgs[exportConfig.pageName] = steps + 1;
83
- }
84
- }
81
+ if (exportConfig.pageName != null) {
82
+ ajaxArgs[exportConfig.pageName] = steps + 1;
83
+ }
84
+ }
85
85
 
86
86
  var mySelf = this;
87
87
  apiClient[apiMethod](ajaxArgs).then((data: any) => {
88
- const attrName = exportConfig != null && exportConfig.attrName != null ? exportConfig.attrName : 'Rows';
89
- const rows = data[attrName];
88
+ const attrName = exportConfig != null && exportConfig.attrName != null ? exportConfig.attrName : 'Rows';
89
+ const rows = data[attrName];
90
90
 
91
91
  rows.forEach(function (row) {
92
92
  mySelf.rows.push(row);
@@ -150,6 +150,8 @@ class TableExportModalComponent extends TsxComponent<TableExportModalBindingArgs
150
150
  if (col.exportInclude != false) {
151
151
  if (col.exportValue != null) {
152
152
  rowExportData.push(col.exportValue(row));
153
+ } else if (col.customValue != null) {
154
+ rowExportData.push(col.customValue(row));
153
155
  } else {
154
156
  rowExportData.push(row[col.id]);
155
157
  }
@@ -196,5 +198,5 @@ class TableExportModalComponent extends TsxComponent<TableExportModalBindingArgs
196
198
  }
197
199
  }
198
200
 
199
- const TableExportModal = toNative(TableExportModalComponent)
200
- export default TableExportModal
201
+ const TableExportModal = toNative(TableExportModalComponent)
202
+ export default TableExportModal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inviton-powerduck",
3
- "version": "0.0.78",
3
+ "version": "0.0.80",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": " vite build && vue-tsc --declaration --emitDeclarationOnly",