@easydata/crud 1.4.0 → 1.4.2-rc01
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.
- package/dist/browser/easydata.css +4 -4
- package/dist/browser/easydata.css.map +1 -1
- package/dist/browser/easydata.js +62 -51
- package/dist/browser/easydata.js.map +1 -1
- package/dist/browser/easydata.min.css +1 -1
- package/dist/browser/easydata.min.js +1 -1
- package/dist/browser/easydata.min.js.map +1 -1
- package/dist/bundles/easydata.crud.js +62 -51
- package/dist/bundles/easydata.crud.js.map +1 -1
- package/dist/bundles/easydata.crud.min.js +1 -1
- package/dist/bundles/easydata.crud.min.js.map +1 -1
- package/dist/lib/form/entity_form_builder.js +11 -12
- package/dist/lib/form/entity_form_builder.js.map +1 -1
- package/dist/lib/main/data_context.d.ts +1 -1
- package/dist/lib/main/data_context.js +1 -1
- package/dist/lib/utils/utils.js +1 -1
- package/dist/lib/utils/utils.js.map +1 -1
- package/dist/lib/views/easy_data_view_dispatcher.d.ts +5 -4
- package/dist/lib/views/easy_data_view_dispatcher.js +44 -36
- package/dist/lib/views/easy_data_view_dispatcher.js.map +1 -1
- package/dist/lib/views/entity_data_view.js +3 -1
- package/dist/lib/views/entity_data_view.js.map +1 -1
- package/package.json +3 -3
|
@@ -1646,6 +1646,7 @@ var meta_entity_MetaEntityAttr = /** @class */ (function () {
|
|
|
1646
1646
|
this.lookupEntity = dto.lent;
|
|
1647
1647
|
this.dataAttr = dto.dattr;
|
|
1648
1648
|
this.lookupDataAttr = dto.ldattr;
|
|
1649
|
+
this.defaultValue = dto.defVal;
|
|
1649
1650
|
this.isNullable = utils_utils.getIfDefined(dto.nul, this.isNullable);
|
|
1650
1651
|
this.isEditable = utils_utils.getIfDefined(dto.ied, this.isEditable);
|
|
1651
1652
|
this.showOnView = utils_utils.getIfDefined(dto.ivis || dto.sov, this.showOnView);
|
|
@@ -2738,6 +2739,7 @@ var easy_data_table_EasyDataTable = /** @class */ (function () {
|
|
|
2738
2739
|
this.cachedRows = [];
|
|
2739
2740
|
this.total = 0;
|
|
2740
2741
|
this.needTotal = !this._elasticChunks;
|
|
2742
|
+
this.fireUpdated();
|
|
2741
2743
|
};
|
|
2742
2744
|
EasyDataTable.prototype.createRow = function (dataOrRow) {
|
|
2743
2745
|
var _this = this;
|
|
@@ -6844,7 +6846,7 @@ var getEditDateTimeFormat = function (dtype) {
|
|
|
6844
6846
|
};
|
|
6845
6847
|
var setLocation = function (path) {
|
|
6846
6848
|
var state = window.history.state;
|
|
6847
|
-
history.
|
|
6849
|
+
history.pushState(state, document.title, path);
|
|
6848
6850
|
window.dispatchEvent(new Event('ed_set_location'));
|
|
6849
6851
|
};
|
|
6850
6852
|
|
|
@@ -7276,7 +7278,9 @@ var entity_form_builder_EntityEditFormBuilder = /** @class */ (function () {
|
|
|
7276
7278
|
var lookupEntity = this.context.getMetaData().getRootEntity()
|
|
7277
7279
|
.subEntities.filter(function (ent) { return ent.id == attr.lookupEntity; })[0];
|
|
7278
7280
|
var dataAttr = this.context.getMetaData().getAttributeById(attr.dataAttr);
|
|
7279
|
-
|
|
7281
|
+
if (!dataAttr)
|
|
7282
|
+
return;
|
|
7283
|
+
readOnly = readOnly || !dataAttr.isEditable;
|
|
7280
7284
|
value = this.params.values
|
|
7281
7285
|
? this.params.values.getValue(dataAttr.id)
|
|
7282
7286
|
: undefined;
|
|
@@ -7571,9 +7575,11 @@ var entity_form_builder_EntityEditFormBuilder = /** @class */ (function () {
|
|
|
7571
7575
|
});
|
|
7572
7576
|
};
|
|
7573
7577
|
EntityEditFormBuilder.prototype.addFormField = function (parent, attr) {
|
|
7574
|
-
var value = this.params.values && attr.kind !== EntityAttrKind.Lookup
|
|
7578
|
+
var value = (this.params.values && attr.kind !== EntityAttrKind.Lookup)
|
|
7575
7579
|
? this.params.values.getValue(attr.id)
|
|
7576
|
-
:
|
|
7580
|
+
: !this.params.isEditForm
|
|
7581
|
+
? attr.defaultValue
|
|
7582
|
+
: undefined;
|
|
7577
7583
|
var editor = this.resolveEditor(attr);
|
|
7578
7584
|
var readOnly = this.params.isEditForm && (attr.isPrimaryKey || !attr.isEditable);
|
|
7579
7585
|
var required = !attr.isNullable;
|
|
@@ -7667,15 +7673,10 @@ var entity_form_builder_EntityEditFormBuilder = /** @class */ (function () {
|
|
|
7667
7673
|
this.form['setHtmlInt'](formHtml);
|
|
7668
7674
|
for (var _i = 0, _a = this.context.getActiveEntity().attributes; _i < _a.length; _i++) {
|
|
7669
7675
|
var attr = _a[_i];
|
|
7670
|
-
if (!attr.
|
|
7671
|
-
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
}
|
|
7675
|
-
else {
|
|
7676
|
-
if (!attr.showOnCreate)
|
|
7677
|
-
continue;
|
|
7678
|
-
}
|
|
7676
|
+
if (!this.params.isEditForm && !attr.showOnCreate)
|
|
7677
|
+
continue;
|
|
7678
|
+
if (!attr.isPrimaryKey && this.params.isEditForm && !attr.showOnEdit) {
|
|
7679
|
+
continue;
|
|
7679
7680
|
}
|
|
7680
7681
|
this.addFormField(fb.toDOM(), attr);
|
|
7681
7682
|
}
|
|
@@ -7778,7 +7779,7 @@ var data_context_DataContext = /** @class */ (function () {
|
|
|
7778
7779
|
DataContext.prototype.getActiveEntity = function () {
|
|
7779
7780
|
return this.activeEntity;
|
|
7780
7781
|
};
|
|
7781
|
-
DataContext.prototype.
|
|
7782
|
+
DataContext.prototype.setActiveSource = function (entityId) {
|
|
7782
7783
|
this.activeEntity = this.model.getRootEntity().subEntities
|
|
7783
7784
|
.filter(function (e) { return e.id == entityId; })[0];
|
|
7784
7785
|
};
|
|
@@ -8016,10 +8017,12 @@ var entity_data_view_EntityDataView = /** @class */ (function () {
|
|
|
8016
8017
|
showBackToEntities: true
|
|
8017
8018
|
};
|
|
8018
8019
|
this.defaultValidators = [new required_validator_RequiredValidator(), new type_validator_TypeValidator()];
|
|
8019
|
-
options = options || {};
|
|
8020
8020
|
this.options = utils_utils.assignDeep(this.options, options || {});
|
|
8021
8021
|
this.dlg = new DefaultDialogService();
|
|
8022
8022
|
var ent = this.context.getActiveEntity();
|
|
8023
|
+
if (!ent) {
|
|
8024
|
+
throw "Can't find active entity for " + window.location.pathname;
|
|
8025
|
+
}
|
|
8023
8026
|
this.slot.innerHTML += "<h1>" + (ent.captionPlural || ent.caption) + "</h1>";
|
|
8024
8027
|
if (this.options.showBackToEntities) {
|
|
8025
8028
|
domel(this.slot)
|
|
@@ -8272,51 +8275,66 @@ var root_data_view_RootDataView = /** @class */ (function () {
|
|
|
8272
8275
|
var easy_data_view_dispatcher_EasyDataViewDispatcher = /** @class */ (function () {
|
|
8273
8276
|
function EasyDataViewDispatcher(options) {
|
|
8274
8277
|
var _this = this;
|
|
8275
|
-
this.options = {
|
|
8278
|
+
this.options = {
|
|
8279
|
+
container: '#EasyDataContainer',
|
|
8280
|
+
basePath: 'easydata'
|
|
8281
|
+
};
|
|
8276
8282
|
this.onSetLocation = function () {
|
|
8277
8283
|
_this.setActiveView();
|
|
8278
8284
|
};
|
|
8279
|
-
|
|
8280
|
-
|
|
8281
|
-
|
|
8282
|
-
|
|
8283
|
-
|
|
8284
|
-
if (this.options.rootEntity)
|
|
8285
|
+
this.attach = function () {
|
|
8286
|
+
window.addEventListener('ed_set_location', _this.onSetLocation);
|
|
8287
|
+
window.addEventListener('popstate', _this.onSetLocation);
|
|
8288
|
+
};
|
|
8289
|
+
this.options = utils_utils.assign(this.options, options || {});
|
|
8290
|
+
if (this.options.rootEntity) {
|
|
8285
8291
|
this.options.showBackToEntities = false;
|
|
8286
|
-
|
|
8292
|
+
this.basePath = '/';
|
|
8293
|
+
}
|
|
8294
|
+
else {
|
|
8295
|
+
this.basePath = this.normalizeBasePath(this.options.basePath);
|
|
8296
|
+
}
|
|
8297
|
+
this.setContainer(this.options.container);
|
|
8287
8298
|
var progressBarSlot = document.createElement('div');
|
|
8288
8299
|
var bar = new ProgressBar(progressBarSlot);
|
|
8289
8300
|
var parent = this.container.parentElement;
|
|
8290
8301
|
parent.insertBefore(progressBarSlot, parent.firstElementChild);
|
|
8291
8302
|
this.context = new data_context_DataContext({
|
|
8292
|
-
endpoint: options.endpoint,
|
|
8293
|
-
dataTable: options.dataTable,
|
|
8303
|
+
endpoint: this.options.endpoint,
|
|
8304
|
+
dataTable: this.options.dataTable,
|
|
8294
8305
|
onProcessStart: function () { return bar.show(); },
|
|
8295
8306
|
onProcessEnd: function () { return bar.hide(); }
|
|
8296
8307
|
});
|
|
8297
|
-
this.basePath = this.getBasePath();
|
|
8298
8308
|
}
|
|
8299
|
-
EasyDataViewDispatcher.prototype.
|
|
8309
|
+
EasyDataViewDispatcher.prototype.normalizeBasePath = function (basePath) {
|
|
8310
|
+
basePath = this.trimSlashes(basePath);
|
|
8311
|
+
var fullPath = decodeURIComponent(window.location.pathname);
|
|
8312
|
+
var idx = fullPath.toLocaleLowerCase().indexOf(basePath);
|
|
8313
|
+
return idx >= 0 ? fullPath.substring(0, idx + basePath.length) : '/';
|
|
8314
|
+
};
|
|
8315
|
+
EasyDataViewDispatcher.prototype.trimSlashes = function (path) {
|
|
8300
8316
|
return path.replace(/^\/|\/$/g, '');
|
|
8301
8317
|
};
|
|
8302
8318
|
EasyDataViewDispatcher.prototype.setContainer = function (container) {
|
|
8303
8319
|
if (!container) {
|
|
8304
|
-
|
|
8305
|
-
return;
|
|
8320
|
+
throw 'Container is undefined';
|
|
8306
8321
|
}
|
|
8307
8322
|
if (typeof container === 'string') {
|
|
8308
8323
|
if (container.length) {
|
|
8309
|
-
if (container[0] === '
|
|
8310
|
-
this.container = document.getElementById(container.substring(1));
|
|
8311
|
-
}
|
|
8312
|
-
else if (container[0] === '.') {
|
|
8324
|
+
if (container[0] === '.') {
|
|
8313
8325
|
var result = document.getElementsByClassName(container.substring(1));
|
|
8314
8326
|
if (result.length)
|
|
8315
8327
|
this.container = result[0];
|
|
8316
8328
|
}
|
|
8317
8329
|
else {
|
|
8318
|
-
|
|
8319
|
-
|
|
8330
|
+
if (container[0] === '#') {
|
|
8331
|
+
container = container.substring(1);
|
|
8332
|
+
}
|
|
8333
|
+
this.container = document.getElementById(container);
|
|
8334
|
+
}
|
|
8335
|
+
if (!this.container) {
|
|
8336
|
+
throw Error('Unrecognized `container` parameter: ' + container + '\n'
|
|
8337
|
+
+ 'It must be an element ID, a class name (starting with .) or an HTMLElement object itself.');
|
|
8320
8338
|
}
|
|
8321
8339
|
}
|
|
8322
8340
|
}
|
|
@@ -8324,24 +8342,16 @@ var easy_data_view_dispatcher_EasyDataViewDispatcher = /** @class */ (function (
|
|
|
8324
8342
|
this.container = container;
|
|
8325
8343
|
}
|
|
8326
8344
|
};
|
|
8327
|
-
EasyDataViewDispatcher.prototype.
|
|
8345
|
+
EasyDataViewDispatcher.prototype.getActiveSourceId = function () {
|
|
8328
8346
|
if (this.options.rootEntity)
|
|
8329
8347
|
return this.options.rootEntity;
|
|
8330
|
-
var
|
|
8331
|
-
var
|
|
8332
|
-
|
|
8333
|
-
return typeName && typeName.toLocaleLowerCase() !== this.options.basePath
|
|
8334
|
-
? typeName
|
|
8335
|
-
: null;
|
|
8336
|
-
};
|
|
8337
|
-
EasyDataViewDispatcher.prototype.getBasePath = function () {
|
|
8338
|
-
var decodedUrl = decodeURIComponent(window.location.href);
|
|
8339
|
-
var optBasePathIndex = decodedUrl.toLocaleLowerCase().indexOf(this.options.basePath);
|
|
8340
|
-
return decodedUrl.substring(0, optBasePathIndex + this.options.basePath.length);
|
|
8348
|
+
var path = decodeURIComponent(window.location.pathname);
|
|
8349
|
+
var idIndex = this.basePath.length + 1;
|
|
8350
|
+
return idIndex < path.length ? path.substring(idIndex) : null;
|
|
8341
8351
|
};
|
|
8342
8352
|
EasyDataViewDispatcher.prototype.run = function () {
|
|
8343
8353
|
var _this = this;
|
|
8344
|
-
|
|
8354
|
+
this.attach();
|
|
8345
8355
|
return this.context.loadMetaData()
|
|
8346
8356
|
.then(function () {
|
|
8347
8357
|
_this.setActiveView();
|
|
@@ -8350,9 +8360,9 @@ var easy_data_view_dispatcher_EasyDataViewDispatcher = /** @class */ (function (
|
|
|
8350
8360
|
};
|
|
8351
8361
|
EasyDataViewDispatcher.prototype.setActiveView = function () {
|
|
8352
8362
|
this.clear();
|
|
8353
|
-
var
|
|
8354
|
-
if (
|
|
8355
|
-
this.context.
|
|
8363
|
+
var sourceId = this.getActiveSourceId();
|
|
8364
|
+
if (sourceId) {
|
|
8365
|
+
this.context.setActiveSource(sourceId);
|
|
8356
8366
|
window['EDView'] = new entity_data_view_EntityDataView(this.container, this.context, this.basePath, this.options);
|
|
8357
8367
|
}
|
|
8358
8368
|
else {
|
|
@@ -8365,6 +8375,7 @@ var easy_data_view_dispatcher_EasyDataViewDispatcher = /** @class */ (function (
|
|
|
8365
8375
|
};
|
|
8366
8376
|
EasyDataViewDispatcher.prototype.detach = function () {
|
|
8367
8377
|
window.removeEventListener('ed_set_location', this.onSetLocation);
|
|
8378
|
+
window.removeEventListener('popstate', this.onSetLocation);
|
|
8368
8379
|
};
|
|
8369
8380
|
return EasyDataViewDispatcher;
|
|
8370
8381
|
}());
|