@easydata/crud 1.4.0-rc02 → 1.4.1

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.
@@ -149,7 +149,7 @@ var EditorTag = {
149
149
  };
150
150
  //# sourceMappingURL=editor_tag.js.map
151
151
  // EXTERNAL MODULE: d:/a/easydata/easydata/easydata.js/packs/core/dist/lib/http/http_method.js
152
- var http_method = __webpack_require__(10);
152
+ var http_method = __webpack_require__(11);
153
153
 
154
154
  // EXTERNAL MODULE: d:/a/easydata/easydata/easydata.js/packs/core/dist/lib/http/http_request.js
155
155
  var http_request = __webpack_require__(16);
@@ -1710,7 +1710,7 @@ __webpack_require__.d(__webpack_exports__, "dialogs", function() { return /* bin
1710
1710
  var easy_grid = __webpack_require__(29);
1711
1711
 
1712
1712
  // EXTERNAL MODULE: d:/a/easydata/easydata/easydata.js/packs/ui/dist/lib/grid/easy_grid_options.js
1713
- var easy_grid_options = __webpack_require__(12);
1713
+ var easy_grid_options = __webpack_require__(10);
1714
1714
 
1715
1715
  // EXTERNAL MODULE: d:/a/easydata/easydata/easydata.js/packs/ui/dist/lib/grid/easy_grid_columns.js
1716
1716
  var easy_grid_columns = __webpack_require__(8);
@@ -2372,7 +2372,7 @@ var default_date_time_picker_DefaultDateTimePicker = /** @class */ (function (_s
2372
2372
  var browser_utils = __webpack_require__(18);
2373
2373
 
2374
2374
  // EXTERNAL MODULE: d:/a/easydata/easydata/easydata.js/packs/ui/dist/lib/utils/drag_manager.js
2375
- var drag_manager = __webpack_require__(11);
2375
+ var drag_manager = __webpack_require__(12);
2376
2376
 
2377
2377
  // EXTERNAL MODULE: d:/a/easydata/easydata/easydata.js/packs/ui/dist/lib/utils/mask.js
2378
2378
  var mask = __webpack_require__(19);
@@ -3715,7 +3715,7 @@ var getEditDateTimeFormat = function (dtype) {
3715
3715
  };
3716
3716
  var setLocation = function (path) {
3717
3717
  var state = window.history.state;
3718
- history.replaceState(state, document.title, path);
3718
+ history.pushState(state, document.title, path);
3719
3719
  window.dispatchEvent(new Event('ed_set_location'));
3720
3720
  };
3721
3721
  //# sourceMappingURL=utils.js.map
@@ -3905,6 +3905,20 @@ var Validator = /** @class */ (function () {
3905
3905
  /* 10 */
3906
3906
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3907
3907
 
3908
+ "use strict";
3909
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AutoResizeColumns; });
3910
+ var AutoResizeColumns;
3911
+ (function (AutoResizeColumns) {
3912
+ AutoResizeColumns[AutoResizeColumns["Always"] = 0] = "Always";
3913
+ AutoResizeColumns[AutoResizeColumns["Once"] = 1] = "Once";
3914
+ AutoResizeColumns[AutoResizeColumns["Never"] = 2] = "Never";
3915
+ })(AutoResizeColumns || (AutoResizeColumns = {}));
3916
+ //# sourceMappingURL=easy_grid_options.js.map
3917
+
3918
+ /***/ }),
3919
+ /* 11 */
3920
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
3921
+
3908
3922
  "use strict";
3909
3923
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return HttpMethod; });
3910
3924
  var HttpMethod;
@@ -3919,7 +3933,7 @@ var HttpMethod;
3919
3933
  //# sourceMappingURL=http_method.js.map
3920
3934
 
3921
3935
  /***/ }),
3922
- /* 11 */
3936
+ /* 12 */
3923
3937
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3924
3938
 
3925
3939
  "use strict";
@@ -4297,20 +4311,6 @@ var DragManager = /** @class */ (function () {
4297
4311
  var eqDragManager = new DragManager();
4298
4312
  //# sourceMappingURL=drag_manager.js.map
4299
4313
 
4300
- /***/ }),
4301
- /* 12 */
4302
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
4303
-
4304
- "use strict";
4305
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AutoResizeColumns; });
4306
- var AutoResizeColumns;
4307
- (function (AutoResizeColumns) {
4308
- AutoResizeColumns[AutoResizeColumns["Always"] = 0] = "Always";
4309
- AutoResizeColumns[AutoResizeColumns["Once"] = 1] = "Once";
4310
- AutoResizeColumns[AutoResizeColumns["Never"] = 2] = "Never";
4311
- })(AutoResizeColumns || (AutoResizeColumns = {}));
4312
- //# sourceMappingURL=easy_grid_options.js.map
4313
-
4314
4314
  /***/ }),
4315
4315
  /* 13 */
4316
4316
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
@@ -5758,7 +5758,7 @@ var EntityEditForm = /** @class */ (function () {
5758
5758
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return HttpClient; });
5759
5759
  /* harmony import */ var _utils_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
5760
5760
  /* harmony import */ var _http_action_result__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(32);
5761
- /* harmony import */ var _http_method__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(10);
5761
+ /* harmony import */ var _http_method__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(11);
5762
5762
  /* harmony import */ var _http_request__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(16);
5763
5763
  var __extends = (undefined && undefined.__extends) || (function () {
5764
5764
  var extendStatics = function (d, b) {
@@ -7469,6 +7469,7 @@ var EasyDataTable = /** @class */ (function () {
7469
7469
  this.cachedRows = [];
7470
7470
  this.total = 0;
7471
7471
  this.needTotal = !this._elasticChunks;
7472
+ this.fireUpdated();
7472
7473
  };
7473
7474
  EasyDataTable.prototype.createRow = function (dataOrRow) {
7474
7475
  var _this = this;
@@ -7552,10 +7553,10 @@ var EasyDataTable = /** @class */ (function () {
7552
7553
  "use strict";
7553
7554
  /* WEBPACK VAR INJECTION */(function(Promise) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return EasyGrid; });
7554
7555
  /* harmony import */ var _easydata_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
7555
- /* harmony import */ var _utils_drag_manager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(11);
7556
+ /* harmony import */ var _utils_drag_manager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(12);
7556
7557
  /* harmony import */ var _utils_dom_elem_builder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1);
7557
7558
  /* harmony import */ var _utils_ui_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6);
7558
- /* harmony import */ var _easy_grid_options__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(12);
7559
+ /* harmony import */ var _easy_grid_options__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(10);
7559
7560
  /* harmony import */ var _easy_grid_columns__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8);
7560
7561
  /* harmony import */ var _easy_grid_cell_renderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(13);
7561
7562
  var __assign = (undefined && undefined.__assign) || function () {
@@ -7610,7 +7611,7 @@ var EasyGrid = /** @class */ (function () {
7610
7611
  pageSizeItems: [20, 30, 50, 100, 200]
7611
7612
  },
7612
7613
  columnWidths: {
7613
- autoResize: _easy_grid_options__WEBPACK_IMPORTED_MODULE_4__[/* AutoResizeColumns */ "a"].Once,
7614
+ autoResize: _easy_grid_options__WEBPACK_IMPORTED_MODULE_4__[/* AutoResizeColumns */ "a"].Always,
7614
7615
  stringColumns: {
7615
7616
  min: 100,
7616
7617
  max: 500,
@@ -7848,9 +7849,6 @@ var EasyGrid = /** @class */ (function () {
7848
7849
  .then(function () {
7849
7850
  _this.firstRender = false;
7850
7851
  _this.rowsOnPagePromise = null;
7851
- if (needAutoResize) {
7852
- _this.resizeColumns();
7853
- }
7854
7852
  });
7855
7853
  }
7856
7854
  else {
@@ -8023,9 +8021,15 @@ var EasyGrid = /** @class */ (function () {
8023
8021
  _this.updateTotalsState(groups_1, row, true);
8024
8022
  }
8025
8023
  }
8026
- var containerWidth = _this.getContainerWidth();
8027
- Object(_utils_dom_elem_builder__WEBPACK_IMPORTED_MODULE_2__[/* domel */ "e"])(_this.bodyCellContainerDiv)
8028
- .setStyle('width', containerWidth + "px");
8024
+ var needAutoResize = _this.options.columnWidths.autoResize !== _easy_grid_options__WEBPACK_IMPORTED_MODULE_4__[/* AutoResizeColumns */ "a"].Never;
8025
+ if (needAutoResize) {
8026
+ _this.resizeColumns();
8027
+ }
8028
+ else {
8029
+ var containerWidth = _this.getContainerWidth();
8030
+ Object(_utils_dom_elem_builder__WEBPACK_IMPORTED_MODULE_2__[/* domel */ "e"])(_this.bodyCellContainerDiv)
8031
+ .setStyle('width', containerWidth + "px");
8032
+ }
8029
8033
  return rowsToRender;
8030
8034
  })
8031
8035
  .catch(function (error) { console.error(error); return 0; });
@@ -11702,7 +11706,9 @@ var entity_form_builder_EntityEditFormBuilder = /** @class */ (function () {
11702
11706
  var lookupEntity = this.context.getMetaData().getRootEntity()
11703
11707
  .subEntities.filter(function (ent) { return ent.id == attr.lookupEntity; })[0];
11704
11708
  var dataAttr = this.context.getMetaData().getAttributeById(attr.dataAttr);
11705
- readOnly = readOnly && dataAttr.isEditable;
11709
+ if (!dataAttr)
11710
+ return;
11711
+ readOnly = readOnly || !dataAttr.isEditable;
11706
11712
  value = this.params.values
11707
11713
  ? this.params.values.getValue(dataAttr.id)
11708
11714
  : undefined;
@@ -12093,15 +12099,10 @@ var entity_form_builder_EntityEditFormBuilder = /** @class */ (function () {
12093
12099
  this.form['setHtmlInt'](formHtml);
12094
12100
  for (var _i = 0, _a = this.context.getActiveEntity().attributes; _i < _a.length; _i++) {
12095
12101
  var attr = _a[_i];
12096
- if (!attr.isPrimaryKey) {
12097
- if (this.params.isEditForm) {
12098
- if (!attr.showOnEdit)
12099
- continue;
12100
- }
12101
- else {
12102
- if (!attr.showOnCreate)
12103
- continue;
12104
- }
12102
+ if (!this.params.isEditForm && !attr.showOnCreate)
12103
+ continue;
12104
+ if (!attr.isPrimaryKey && this.params.isEditForm && !attr.showOnEdit) {
12105
+ continue;
12105
12106
  }
12106
12107
  this.addFormField(fb.toDOM(), attr);
12107
12108
  }
@@ -12204,7 +12205,7 @@ var data_context_DataContext = /** @class */ (function () {
12204
12205
  DataContext.prototype.getActiveEntity = function () {
12205
12206
  return this.activeEntity;
12206
12207
  };
12207
- DataContext.prototype.setActiveEntity = function (entityId) {
12208
+ DataContext.prototype.setActiveSource = function (entityId) {
12208
12209
  this.activeEntity = this.model.getRootEntity().subEntities
12209
12210
  .filter(function (e) { return e.id == entityId; })[0];
12210
12211
  };
@@ -12445,10 +12446,12 @@ var entity_data_view_EntityDataView = /** @class */ (function () {
12445
12446
  showBackToEntities: true
12446
12447
  };
12447
12448
  this.defaultValidators = [new required_validator_RequiredValidator(), new type_validator_TypeValidator()];
12448
- options = options || {};
12449
12449
  this.options = public_api["utils"].assignDeep(this.options, options || {});
12450
12450
  this.dlg = new lib_public_api["DefaultDialogService"]();
12451
12451
  var ent = this.context.getActiveEntity();
12452
+ if (!ent) {
12453
+ throw "Can't find active entity for " + window.location.pathname;
12454
+ }
12452
12455
  this.slot.innerHTML += "<h1>" + (ent.captionPlural || ent.caption) + "</h1>";
12453
12456
  if (this.options.showBackToEntities) {
12454
12457
  Object(lib_public_api["domel"])(this.slot)
@@ -12701,51 +12704,66 @@ var root_data_view_RootDataView = /** @class */ (function () {
12701
12704
  var easy_data_view_dispatcher_EasyDataViewDispatcher = /** @class */ (function () {
12702
12705
  function EasyDataViewDispatcher(options) {
12703
12706
  var _this = this;
12704
- this.options = { basePath: 'easydata' };
12707
+ this.options = {
12708
+ container: '#EasyDataContainer',
12709
+ basePath: 'easydata'
12710
+ };
12705
12711
  this.onSetLocation = function () {
12706
12712
  _this.setActiveView();
12707
12713
  };
12708
- options = options || {};
12709
- this.options = public_api["utils"].assign(this.options, options);
12710
- this.options.basePath = (!this.options.rootEntity)
12711
- ? this.pretiffyPath(this.options.basePath)
12712
- : this.pretiffyPath(window.location.pathname);
12713
- if (this.options.rootEntity)
12714
+ this.attach = function () {
12715
+ window.addEventListener('ed_set_location', _this.onSetLocation);
12716
+ window.addEventListener('popstate', _this.onSetLocation);
12717
+ };
12718
+ this.options = public_api["utils"].assign(this.options, options || {});
12719
+ if (this.options.rootEntity) {
12714
12720
  this.options.showBackToEntities = false;
12715
- this.setContainer(options.container);
12721
+ this.basePath = '/';
12722
+ }
12723
+ else {
12724
+ this.basePath = this.normalizeBasePath(this.options.basePath);
12725
+ }
12726
+ this.setContainer(this.options.container);
12716
12727
  var progressBarSlot = document.createElement('div');
12717
12728
  var bar = new ProgressBar(progressBarSlot);
12718
12729
  var parent = this.container.parentElement;
12719
12730
  parent.insertBefore(progressBarSlot, parent.firstElementChild);
12720
12731
  this.context = new data_context_DataContext({
12721
- endpoint: options.endpoint,
12722
- dataTable: options.dataTable,
12732
+ endpoint: this.options.endpoint,
12733
+ dataTable: this.options.dataTable,
12723
12734
  onProcessStart: function () { return bar.show(); },
12724
12735
  onProcessEnd: function () { return bar.hide(); }
12725
12736
  });
12726
- this.basePath = this.getBasePath();
12727
12737
  }
12728
- EasyDataViewDispatcher.prototype.pretiffyPath = function (path) {
12738
+ EasyDataViewDispatcher.prototype.normalizeBasePath = function (basePath) {
12739
+ basePath = this.trimSlashes(basePath);
12740
+ var fullPath = decodeURIComponent(window.location.pathname);
12741
+ var idx = fullPath.toLocaleLowerCase().indexOf(basePath);
12742
+ return idx >= 0 ? fullPath.substring(0, idx + basePath.length) : '/';
12743
+ };
12744
+ EasyDataViewDispatcher.prototype.trimSlashes = function (path) {
12729
12745
  return path.replace(/^\/|\/$/g, '');
12730
12746
  };
12731
12747
  EasyDataViewDispatcher.prototype.setContainer = function (container) {
12732
12748
  if (!container) {
12733
- this.container = document.getElementById('EasyDataContainer');
12734
- return;
12749
+ throw 'Container is undefined';
12735
12750
  }
12736
12751
  if (typeof container === 'string') {
12737
12752
  if (container.length) {
12738
- if (container[0] === '#') {
12739
- this.container = document.getElementById(container.substring(1));
12740
- }
12741
- else if (container[0] === '.') {
12753
+ if (container[0] === '.') {
12742
12754
  var result = document.getElementsByClassName(container.substring(1));
12743
12755
  if (result.length)
12744
12756
  this.container = result[0];
12745
12757
  }
12746
12758
  else {
12747
- throw Error('Unrecognized container parameter ' +
12748
- '(Must be an element ID, a class name or HTMLElement object itself): ' + container);
12759
+ if (container[0] === '#') {
12760
+ container = container.substring(1);
12761
+ }
12762
+ this.container = document.getElementById(container);
12763
+ }
12764
+ if (!this.container) {
12765
+ throw Error('Unrecognized `container` parameter: ' + container + '\n'
12766
+ + 'It must be an element ID, a class name (starting with .) or an HTMLElement object itself.');
12749
12767
  }
12750
12768
  }
12751
12769
  }
@@ -12753,24 +12771,16 @@ var easy_data_view_dispatcher_EasyDataViewDispatcher = /** @class */ (function (
12753
12771
  this.container = container;
12754
12772
  }
12755
12773
  };
12756
- EasyDataViewDispatcher.prototype.getActiveEntityId = function () {
12774
+ EasyDataViewDispatcher.prototype.getActiveSourceId = function () {
12757
12775
  if (this.options.rootEntity)
12758
12776
  return this.options.rootEntity;
12759
- var decodedUrl = decodeURIComponent(window.location.href);
12760
- var splitIndex = decodedUrl.lastIndexOf('/');
12761
- var typeName = decodedUrl.substring(splitIndex + 1);
12762
- return typeName && typeName.toLocaleLowerCase() !== this.options.basePath
12763
- ? typeName
12764
- : null;
12765
- };
12766
- EasyDataViewDispatcher.prototype.getBasePath = function () {
12767
- var decodedUrl = decodeURIComponent(window.location.href);
12768
- var optBasePathIndex = decodedUrl.toLocaleLowerCase().indexOf(this.options.basePath);
12769
- return decodedUrl.substring(0, optBasePathIndex + this.options.basePath.length);
12777
+ var path = decodeURIComponent(window.location.pathname);
12778
+ var idIndex = this.basePath.length + 1;
12779
+ return idIndex < path.length ? path.substring(idIndex) : null;
12770
12780
  };
12771
12781
  EasyDataViewDispatcher.prototype.run = function () {
12772
12782
  var _this = this;
12773
- window.addEventListener('ed_set_location', this.onSetLocation);
12783
+ this.attach();
12774
12784
  return this.context.loadMetaData()
12775
12785
  .then(function () {
12776
12786
  _this.setActiveView();
@@ -12779,9 +12789,9 @@ var easy_data_view_dispatcher_EasyDataViewDispatcher = /** @class */ (function (
12779
12789
  };
12780
12790
  EasyDataViewDispatcher.prototype.setActiveView = function () {
12781
12791
  this.clear();
12782
- var activeEntityId = this.getActiveEntityId();
12783
- if (activeEntityId) {
12784
- this.context.setActiveEntity(activeEntityId);
12792
+ var sourceId = this.getActiveSourceId();
12793
+ if (sourceId) {
12794
+ this.context.setActiveSource(sourceId);
12785
12795
  window['EDView'] = new entity_data_view_EntityDataView(this.container, this.context, this.basePath, this.options);
12786
12796
  }
12787
12797
  else {
@@ -12794,6 +12804,7 @@ var easy_data_view_dispatcher_EasyDataViewDispatcher = /** @class */ (function (
12794
12804
  };
12795
12805
  EasyDataViewDispatcher.prototype.detach = function () {
12796
12806
  window.removeEventListener('ed_set_location', this.onSetLocation);
12807
+ window.removeEventListener('popstate', this.onSetLocation);
12797
12808
  };
12798
12809
  return EasyDataViewDispatcher;
12799
12810
  }());