@easydata/crud 1.4.21 → 1.5.2

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.
@@ -1,6 +1,6 @@
1
1
 
2
2
  /*
3
- * EasyData.JS CRUD v1.4.21
3
+ * EasyData.JS CRUD v1.5.2
4
4
  * Copyright 2020-2024 Korzh.com
5
5
  * Licensed under MIT
6
6
  */
@@ -286,7 +286,7 @@ class TextFilterWidget {
286
286
  instantMode: false,
287
287
  instantTimeout: 1000
288
288
  };
289
- this.options = core.utils.assignDeep(this.options, options || {});
289
+ this.options = core.utils.assign(this.options, options || {});
290
290
  const stringDefRenderer = this.grid.cellRendererStore
291
291
  .getDefaultRendererByType(ui.CellRendererType.STRING);
292
292
  this.grid.cellRendererStore
@@ -298,10 +298,10 @@ class TextFilterWidget {
298
298
  this.render();
299
299
  }
300
300
  render() {
301
- const horizClass = ui.browserUtils.IsIE()
301
+ const horizClass = ui.browserUtils.isIE()
302
302
  ? 'kfrm-fields-ie is-horizontal'
303
303
  : 'kfrm-fields is-horizontal';
304
- const isEdgeOrIE = ui.browserUtils.IsIE() || ui.browserUtils.IsEdge();
304
+ const isEdgeOrIE = ui.browserUtils.isIE() || ui.browserUtils.isEdge();
305
305
  ui.domel(this.slot)
306
306
  .addClass(horizClass)
307
307
  .addChild('div', b => {
@@ -478,7 +478,7 @@ class TextFilterWidget {
478
478
  }
479
479
  }
480
480
 
481
- const isIE = ui.browserUtils.IsIE();
481
+ const isIE = ui.browserUtils.isIE();
482
482
  class EntityEditFormBuilder {
483
483
  constructor(context, params) {
484
484
  this.context = context;
@@ -1166,7 +1166,7 @@ class EntityDataView {
1166
1166
  const gridSlot = document.createElement('div');
1167
1167
  this.slot.appendChild(gridSlot);
1168
1168
  gridSlot.id = 'Grid';
1169
- this.grid = new ui.EasyGrid(core.utils.assignDeep({
1169
+ let gridOptions = {
1170
1170
  slot: gridSlot,
1171
1171
  dataTable: result,
1172
1172
  paging: {
@@ -1181,7 +1181,10 @@ class EntityDataView {
1181
1181
  onGetCellRenderer: this.manageCellRenderer.bind(this),
1182
1182
  onRowDbClick: this.rowDbClickHandler.bind(this),
1183
1183
  onSyncGridColumn: this.syncGridColumnHandler.bind(this)
1184
- }, this.options.grid || {}));
1184
+ };
1185
+ const sourceOptions = this.options.grid || {};
1186
+ gridOptions = core.utils.assignDeep(gridOptions, sourceOptions);
1187
+ this.grid = new ui.EasyGrid(gridOptions);
1185
1188
  if (this.options.showFilterBox) {
1186
1189
  let filterWidgetSlot;
1187
1190
  const filterBarDiv = ui.domel('div')
@@ -1328,12 +1331,16 @@ class EntityDataView {
1328
1331
  }
1329
1332
 
1330
1333
  class RootDataView {
1331
- constructor(slot, context, basePath) {
1334
+ constructor(slot, context, basePath, options) {
1332
1335
  this.slot = slot;
1333
1336
  this.context = context;
1334
1337
  this.basePath = basePath;
1338
+ this.options = {
1339
+ usePluralNames: true
1340
+ };
1335
1341
  this.metaData = this.context.getMetaData();
1336
1342
  this.slot.innerHTML += `<h1>${core.i18n.getText('RootViewTitle')}</h1>`;
1343
+ core.utils.assign(this.options, options);
1337
1344
  this.renderEntitySelector();
1338
1345
  }
1339
1346
  renderEntitySelector() {
@@ -1348,6 +1355,9 @@ class RootDataView {
1348
1355
  .addChild('ul', b => {
1349
1356
  b.addClass('ed-entity-menu');
1350
1357
  entities.forEach(ent => {
1358
+ const entCaption = this.options.usePluralNames && ent.captionPlural
1359
+ ? ent.captionPlural
1360
+ : ent.caption;
1351
1361
  b.addChild('li', b => {
1352
1362
  b.addClass('ed-entity-item')
1353
1363
  .on('click', () => {
@@ -1355,7 +1365,7 @@ class RootDataView {
1355
1365
  })
1356
1366
  .addChild('div', b => {
1357
1367
  b.addClass('ed-entity-item-caption')
1358
- .addText(ent.captionPlural || ent.caption);
1368
+ .addText(entCaption);
1359
1369
  });
1360
1370
  if (ent.description) {
1361
1371
  b.addChild('div', b => {
@@ -1462,7 +1472,11 @@ class EasyDataViewDispatcher {
1462
1472
  window['EDView'] = new EntityDataView(this.container, this.context, this.basePath, this.options);
1463
1473
  }
1464
1474
  else {
1465
- window['EDView'] = new RootDataView(this.container, this.context, this.basePath);
1475
+ const rootViewOptions = {};
1476
+ if (typeof this.options.usePluralNames !== 'undefined') {
1477
+ rootViewOptions.usePluralNames = this.options.usePluralNames;
1478
+ }
1479
+ window['EDView'] = new RootDataView(this.container, this.context, this.basePath, rootViewOptions);
1466
1480
  }
1467
1481
  }
1468
1482
  clear() {
@@ -1,6 +1,6 @@
1
1
 
2
2
  /*
3
- * EasyData.JS CRUD v1.4.21
3
+ * EasyData.JS CRUD v1.5.2
4
4
  * Copyright 2020-2024 Korzh.com
5
5
  * Licensed under MIT
6
6
  */
@@ -284,7 +284,7 @@ class TextFilterWidget {
284
284
  instantMode: false,
285
285
  instantTimeout: 1000
286
286
  };
287
- this.options = utils.assignDeep(this.options, options || {});
287
+ this.options = utils.assign(this.options, options || {});
288
288
  const stringDefRenderer = this.grid.cellRendererStore
289
289
  .getDefaultRendererByType(CellRendererType.STRING);
290
290
  this.grid.cellRendererStore
@@ -296,10 +296,10 @@ class TextFilterWidget {
296
296
  this.render();
297
297
  }
298
298
  render() {
299
- const horizClass = browserUtils.IsIE()
299
+ const horizClass = browserUtils.isIE()
300
300
  ? 'kfrm-fields-ie is-horizontal'
301
301
  : 'kfrm-fields is-horizontal';
302
- const isEdgeOrIE = browserUtils.IsIE() || browserUtils.IsEdge();
302
+ const isEdgeOrIE = browserUtils.isIE() || browserUtils.isEdge();
303
303
  domel(this.slot)
304
304
  .addClass(horizClass)
305
305
  .addChild('div', b => {
@@ -476,7 +476,7 @@ class TextFilterWidget {
476
476
  }
477
477
  }
478
478
 
479
- const isIE = browserUtils.IsIE();
479
+ const isIE = browserUtils.isIE();
480
480
  class EntityEditFormBuilder {
481
481
  constructor(context, params) {
482
482
  this.context = context;
@@ -1164,7 +1164,7 @@ class EntityDataView {
1164
1164
  const gridSlot = document.createElement('div');
1165
1165
  this.slot.appendChild(gridSlot);
1166
1166
  gridSlot.id = 'Grid';
1167
- this.grid = new EasyGrid(utils.assignDeep({
1167
+ let gridOptions = {
1168
1168
  slot: gridSlot,
1169
1169
  dataTable: result,
1170
1170
  paging: {
@@ -1179,7 +1179,10 @@ class EntityDataView {
1179
1179
  onGetCellRenderer: this.manageCellRenderer.bind(this),
1180
1180
  onRowDbClick: this.rowDbClickHandler.bind(this),
1181
1181
  onSyncGridColumn: this.syncGridColumnHandler.bind(this)
1182
- }, this.options.grid || {}));
1182
+ };
1183
+ const sourceOptions = this.options.grid || {};
1184
+ gridOptions = utils.assignDeep(gridOptions, sourceOptions);
1185
+ this.grid = new EasyGrid(gridOptions);
1183
1186
  if (this.options.showFilterBox) {
1184
1187
  let filterWidgetSlot;
1185
1188
  const filterBarDiv = domel('div')
@@ -1326,12 +1329,16 @@ class EntityDataView {
1326
1329
  }
1327
1330
 
1328
1331
  class RootDataView {
1329
- constructor(slot, context, basePath) {
1332
+ constructor(slot, context, basePath, options) {
1330
1333
  this.slot = slot;
1331
1334
  this.context = context;
1332
1335
  this.basePath = basePath;
1336
+ this.options = {
1337
+ usePluralNames: true
1338
+ };
1333
1339
  this.metaData = this.context.getMetaData();
1334
1340
  this.slot.innerHTML += `<h1>${i18n.getText('RootViewTitle')}</h1>`;
1341
+ utils.assign(this.options, options);
1335
1342
  this.renderEntitySelector();
1336
1343
  }
1337
1344
  renderEntitySelector() {
@@ -1346,6 +1353,9 @@ class RootDataView {
1346
1353
  .addChild('ul', b => {
1347
1354
  b.addClass('ed-entity-menu');
1348
1355
  entities.forEach(ent => {
1356
+ const entCaption = this.options.usePluralNames && ent.captionPlural
1357
+ ? ent.captionPlural
1358
+ : ent.caption;
1349
1359
  b.addChild('li', b => {
1350
1360
  b.addClass('ed-entity-item')
1351
1361
  .on('click', () => {
@@ -1353,7 +1363,7 @@ class RootDataView {
1353
1363
  })
1354
1364
  .addChild('div', b => {
1355
1365
  b.addClass('ed-entity-item-caption')
1356
- .addText(ent.captionPlural || ent.caption);
1366
+ .addText(entCaption);
1357
1367
  });
1358
1368
  if (ent.description) {
1359
1369
  b.addChild('div', b => {
@@ -1460,7 +1470,11 @@ class EasyDataViewDispatcher {
1460
1470
  window['EDView'] = new EntityDataView(this.container, this.context, this.basePath, this.options);
1461
1471
  }
1462
1472
  else {
1463
- window['EDView'] = new RootDataView(this.container, this.context, this.basePath);
1473
+ const rootViewOptions = {};
1474
+ if (typeof this.options.usePluralNames !== 'undefined') {
1475
+ rootViewOptions.usePluralNames = this.options.usePluralNames;
1476
+ }
1477
+ window['EDView'] = new RootDataView(this.container, this.context, this.basePath, rootViewOptions);
1464
1478
  }
1465
1479
  }
1466
1480
  clear() {
@@ -11,4 +11,5 @@ export interface EasyDataViewDispatcherOptions extends EasyDataViewOptions {
11
11
  basePath?: string;
12
12
  rootEntity?: string;
13
13
  container?: HTMLElement | string;
14
+ usePluralNames?: boolean;
14
15
  }
@@ -1,9 +1,13 @@
1
1
  import { DataContext } from '../main/data_context';
2
+ export interface RootDataViewOptions {
3
+ usePluralNames?: boolean;
4
+ }
2
5
  export declare class RootDataView {
3
6
  private slot;
4
7
  private context;
5
8
  private basePath;
6
9
  private metaData;
7
- constructor(slot: HTMLElement, context: DataContext, basePath: string);
10
+ private options;
11
+ constructor(slot: HTMLElement, context: DataContext, basePath: string, options?: RootDataViewOptions);
8
12
  private renderEntitySelector;
9
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easydata/crud",
3
- "version": "1.4.21",
3
+ "version": "1.5.2",
4
4
  "description": "EasyData.JS UI widgets and views for CRUD manipulations",
5
5
  "types": "./dist/types/public_api.d.ts",
6
6
  "main": "./dist/easydata.crud.cjs.js",
@@ -31,8 +31,8 @@
31
31
  "defaults and supports es6-module"
32
32
  ],
33
33
  "peerDependencies": {
34
- "@easydata/core": "1.4.21",
35
- "@easydata/ui": "1.4.21"
34
+ "@easydata/core": "^1.5.2",
35
+ "@easydata/ui": "^1.5.2"
36
36
  },
37
37
  "files": [
38
38
  "dist"