@easydata/crud 1.4.0-beta01 → 1.4.1-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 +7 -7
- package/dist/browser/easydata.css.map +1 -1
- package/dist/browser/easydata.js +811 -596
- 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.LICENSE.txt +0 -2
- package/dist/browser/easydata.min.js.map +1 -1
- package/dist/bundles/easydata.crud.js +549 -345
- 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.LICENSE.txt +0 -2
- package/dist/bundles/easydata.crud.min.js.map +1 -1
- package/dist/lib/filter/text_data_filter.d.ts +2 -2
- package/dist/lib/filter/text_data_filter.js +18 -19
- package/dist/lib/filter/text_data_filter.js.map +1 -1
- package/dist/lib/form/entity_edit_form.js.map +1 -1
- package/dist/lib/form/entity_form_builder.js +36 -25
- package/dist/lib/form/entity_form_builder.js.map +1 -1
- package/dist/lib/i18n/text_resources.js +2 -1
- package/dist/lib/i18n/text_resources.js.map +1 -1
- package/dist/lib/main/data_context.d.ts +13 -9
- package/dist/lib/main/data_context.js +38 -28
- package/dist/lib/main/data_context.js.map +1 -1
- package/dist/lib/main/easy_data_server_loader.js +2 -2
- package/dist/lib/main/easy_data_server_loader.js.map +1 -1
- package/dist/lib/views/easy_data_view_dispatcher.d.ts +4 -4
- package/dist/lib/views/easy_data_view_dispatcher.js +38 -34
- package/dist/lib/views/easy_data_view_dispatcher.js.map +1 -1
- package/dist/lib/views/entity_data_view.js +20 -16
- package/dist/lib/views/entity_data_view.js.map +1 -1
- package/dist/lib/views/options.d.ts +2 -0
- package/dist/lib/widgets/text_filter_widget.js.map +1 -1
- package/package.json +4 -4
|
@@ -842,7 +842,7 @@ var i18n_i18n;
|
|
|
842
842
|
var utils_utils;
|
|
843
843
|
(function (utils) {
|
|
844
844
|
function getAllDataTypes() {
|
|
845
|
-
return Object.values(DataType);
|
|
845
|
+
return Object.values(DataType).filter(function (item) { return typeof item === "number"; });
|
|
846
846
|
}
|
|
847
847
|
utils.getAllDataTypes = getAllDataTypes;
|
|
848
848
|
function getDateDataTypes() {
|
|
@@ -850,12 +850,16 @@ var utils_utils;
|
|
|
850
850
|
}
|
|
851
851
|
utils.getDateDataTypes = getDateDataTypes;
|
|
852
852
|
function getStringDataTypes() {
|
|
853
|
-
return [DataType.String, DataType.Memo];
|
|
853
|
+
return [DataType.String, DataType.Memo, DataType.FixedChar];
|
|
854
854
|
}
|
|
855
855
|
utils.getStringDataTypes = getStringDataTypes;
|
|
856
856
|
var _numericTypes = [DataType.Byte, DataType.Word, DataType.Int32,
|
|
857
|
-
DataType.Int64, DataType.Float, DataType.Currency];
|
|
858
|
-
|
|
857
|
+
DataType.Int64, DataType.Float, DataType.Currency, DataType.Autoinc];
|
|
858
|
+
function getNumericDataTypes() {
|
|
859
|
+
return _numericTypes;
|
|
860
|
+
}
|
|
861
|
+
utils.getNumericDataTypes = getNumericDataTypes;
|
|
862
|
+
var _intTypes = [DataType.Byte, DataType.Word, DataType.Int32, DataType.Int64, DataType.Autoinc];
|
|
859
863
|
//-------------- object functions -------------------
|
|
860
864
|
/**
|
|
861
865
|
* Copy the content of all objests passed in `args` parameters into `target`
|
|
@@ -920,7 +924,7 @@ var utils_utils;
|
|
|
920
924
|
hashSet.set(sourceVal, target[key]);
|
|
921
925
|
}
|
|
922
926
|
else {
|
|
923
|
-
if (typeof target[key] == 'undefined') {
|
|
927
|
+
if (typeof target[key] == 'undefined' || target[key] == null) {
|
|
924
928
|
target[key] = Object.create(Object.getPrototypeOf(sourceVal));
|
|
925
929
|
}
|
|
926
930
|
hashSet.set(sourceVal, target[key]);
|
|
@@ -1449,7 +1453,7 @@ var http_client_HttpClient = /** @class */ (function () {
|
|
|
1449
1453
|
var desc = {
|
|
1450
1454
|
method: method,
|
|
1451
1455
|
url: url,
|
|
1452
|
-
headers: __assign({}, this.defaultHeaders, options.headers || {}),
|
|
1456
|
+
headers: __assign(__assign({}, this.defaultHeaders), options.headers || {}),
|
|
1453
1457
|
queryParams: options.queryParams || {},
|
|
1454
1458
|
data: data
|
|
1455
1459
|
};
|
|
@@ -1595,6 +1599,12 @@ var MetaEntity = /** @class */ (function () {
|
|
|
1595
1599
|
};
|
|
1596
1600
|
internalProcessEntity(this);
|
|
1597
1601
|
};
|
|
1602
|
+
MetaEntity.prototype.getFirstPrimaryAttr = function () {
|
|
1603
|
+
return this.getPrimaryAttrs()[0];
|
|
1604
|
+
};
|
|
1605
|
+
MetaEntity.prototype.getPrimaryAttrs = function () {
|
|
1606
|
+
return this.attributes.filter(function (attr) { return attr.isPrimaryKey; });
|
|
1607
|
+
};
|
|
1598
1608
|
return MetaEntity;
|
|
1599
1609
|
}());
|
|
1600
1610
|
|
|
@@ -2213,9 +2223,9 @@ var meta_data_MetaData = /** @class */ (function () {
|
|
|
2213
2223
|
}());
|
|
2214
2224
|
|
|
2215
2225
|
//# sourceMappingURL=meta_data.js.map
|
|
2216
|
-
// CONCATENATED MODULE: d:/a/easydata/easydata/easydata.js/packs/core/dist/lib/data/
|
|
2217
|
-
var
|
|
2218
|
-
|
|
2226
|
+
// CONCATENATED MODULE: d:/a/easydata/easydata/easydata.js/packs/core/dist/lib/data/aggr_settings.js
|
|
2227
|
+
var aggr_settings_assign = (undefined && undefined.__assign) || function () {
|
|
2228
|
+
aggr_settings_assign = Object.assign || function(t) {
|
|
2219
2229
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
2220
2230
|
s = arguments[i];
|
|
2221
2231
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
@@ -2223,7 +2233,7 @@ var aggr_calculator_assign = (undefined && undefined.__assign) || function () {
|
|
|
2223
2233
|
}
|
|
2224
2234
|
return t;
|
|
2225
2235
|
};
|
|
2226
|
-
return
|
|
2236
|
+
return aggr_settings_assign.apply(this, arguments);
|
|
2227
2237
|
};
|
|
2228
2238
|
/**
|
|
2229
2239
|
* Defines aggregations settings for the current context.
|
|
@@ -2236,16 +2246,32 @@ var AggregationSettings = /** @class */ (function () {
|
|
|
2236
2246
|
this.groups = [];
|
|
2237
2247
|
this.useGrandTotals = false;
|
|
2238
2248
|
this.useRecordCount = false;
|
|
2239
|
-
this.
|
|
2249
|
+
this._caseSensitiveGroups = false;
|
|
2240
2250
|
this.COUNT_FIELD_NAME = 'GRPRECCNT';
|
|
2241
2251
|
}
|
|
2252
|
+
Object.defineProperty(AggregationSettings.prototype, "caseSensitiveGroups", {
|
|
2253
|
+
get: function () {
|
|
2254
|
+
return this._caseSensitiveGroups;
|
|
2255
|
+
},
|
|
2256
|
+
set: function (value) {
|
|
2257
|
+
this._caseSensitiveGroups = value;
|
|
2258
|
+
this.updateCompareProc();
|
|
2259
|
+
},
|
|
2260
|
+
enumerable: true,
|
|
2261
|
+
configurable: true
|
|
2262
|
+
});
|
|
2263
|
+
AggregationSettings.prototype.updateCompareProc = function () {
|
|
2264
|
+
this.compareValues = this._caseSensitiveGroups
|
|
2265
|
+
? this.strictCompare
|
|
2266
|
+
: this.caseInsensitiveCompare;
|
|
2267
|
+
};
|
|
2242
2268
|
AggregationSettings.prototype.addGroup = function (settings) {
|
|
2243
2269
|
var cols = settings.columns || this.colStore.getColumnIds(settings.from, settings.to);
|
|
2244
2270
|
if (!this.colStore.validateColumns(cols))
|
|
2245
2271
|
throw "Invalid columns: " + cols;
|
|
2246
2272
|
if (this.hasColumnsInUse(cols))
|
|
2247
2273
|
throw "Can't add same columns to different groups/aggregates";
|
|
2248
|
-
this.groups.push(
|
|
2274
|
+
this.groups.push(aggr_settings_assign({ columns: cols }, settings));
|
|
2249
2275
|
return this;
|
|
2250
2276
|
};
|
|
2251
2277
|
AggregationSettings.prototype.addAggregateColumn = function (colIndexOrId, funcId) {
|
|
@@ -2270,7 +2296,7 @@ var AggregationSettings = /** @class */ (function () {
|
|
|
2270
2296
|
var cols = [];
|
|
2271
2297
|
var mappedGrops = this.groups.map(function (grp) {
|
|
2272
2298
|
cols = cols.concat(grp.columns);
|
|
2273
|
-
return
|
|
2299
|
+
return aggr_settings_assign(aggr_settings_assign({}, grp), { columns: Array.from(cols), aggregates: Array.from(_this.aggregates) });
|
|
2274
2300
|
});
|
|
2275
2301
|
return mappedGrops;
|
|
2276
2302
|
};
|
|
@@ -2362,10 +2388,35 @@ var AggregationSettings = /** @class */ (function () {
|
|
|
2362
2388
|
}
|
|
2363
2389
|
}
|
|
2364
2390
|
};
|
|
2391
|
+
AggregationSettings.prototype.buildGroupKey = function (group, row) {
|
|
2392
|
+
var caseInsensitive = !this.caseSensitiveGroups;
|
|
2393
|
+
var result = {};
|
|
2394
|
+
if (group) {
|
|
2395
|
+
for (var _i = 0, _a = group.columns; _i < _a.length; _i++) {
|
|
2396
|
+
var colId = _a[_i];
|
|
2397
|
+
var keyVal = row.getValue(colId);
|
|
2398
|
+
if (caseInsensitive && typeof (keyVal) === 'string') {
|
|
2399
|
+
keyVal = keyVal.toLowerCase();
|
|
2400
|
+
}
|
|
2401
|
+
result[colId] = keyVal;
|
|
2402
|
+
}
|
|
2403
|
+
}
|
|
2404
|
+
return result;
|
|
2405
|
+
};
|
|
2406
|
+
//returns true if value1 == value2
|
|
2407
|
+
AggregationSettings.prototype.strictCompare = function (value1, value2) {
|
|
2408
|
+
return value1 === value2;
|
|
2409
|
+
};
|
|
2410
|
+
//makes a case insensative comparision of two values and return true if there are equal
|
|
2411
|
+
AggregationSettings.prototype.caseInsensitiveCompare = function (value1, value2) {
|
|
2412
|
+
var val1 = (typeof value1 === 'string') ? value1.toLowerCase() : value1;
|
|
2413
|
+
var val2 = (typeof value2 === 'string') ? value2.toLowerCase() : value2;
|
|
2414
|
+
return val1 === val2;
|
|
2415
|
+
};
|
|
2365
2416
|
return AggregationSettings;
|
|
2366
2417
|
}());
|
|
2367
2418
|
|
|
2368
|
-
//# sourceMappingURL=
|
|
2419
|
+
//# sourceMappingURL=aggr_settings.js.map
|
|
2369
2420
|
// CONCATENATED MODULE: d:/a/easydata/easydata/easydata.js/packs/core/dist/lib/data/data_column.js
|
|
2370
2421
|
|
|
2371
2422
|
|
|
@@ -2393,6 +2444,7 @@ var data_column_DataColumn = /** @class */ (function () {
|
|
|
2393
2444
|
this.groupFooterColumnTemplate = desc.gfct;
|
|
2394
2445
|
this.style = desc.style || {};
|
|
2395
2446
|
this.description = desc.description;
|
|
2447
|
+
this.calculatedWidth = 0;
|
|
2396
2448
|
}
|
|
2397
2449
|
return DataColumn;
|
|
2398
2450
|
}());
|
|
@@ -2432,9 +2484,10 @@ var data_column_DataColumnList = /** @class */ (function () {
|
|
|
2432
2484
|
.map(function (col, index) { return index; });
|
|
2433
2485
|
};
|
|
2434
2486
|
DataColumnList.prototype.put = function (index, col) {
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2487
|
+
if (index >= 0 && index < this.count) {
|
|
2488
|
+
this.items[index] = col;
|
|
2489
|
+
this.updateDateColumnIdx();
|
|
2490
|
+
}
|
|
2438
2491
|
};
|
|
2439
2492
|
DataColumnList.prototype.move = function (col, newIndex) {
|
|
2440
2493
|
var oldIndex = this.items.indexOf(col);
|
|
@@ -2444,8 +2497,12 @@ var data_column_DataColumnList = /** @class */ (function () {
|
|
|
2444
2497
|
}
|
|
2445
2498
|
};
|
|
2446
2499
|
DataColumnList.prototype.get = function (index) {
|
|
2447
|
-
|
|
2448
|
-
|
|
2500
|
+
if (index >= 0 && index < this.count) {
|
|
2501
|
+
return this.items[index];
|
|
2502
|
+
}
|
|
2503
|
+
else {
|
|
2504
|
+
return null;
|
|
2505
|
+
}
|
|
2449
2506
|
};
|
|
2450
2507
|
DataColumnList.prototype.getIndex = function (id) {
|
|
2451
2508
|
return this.mapper[id];
|
|
@@ -2529,16 +2586,23 @@ var easy_data_table_EasyDataTable = /** @class */ (function () {
|
|
|
2529
2586
|
function EasyDataTable(options) {
|
|
2530
2587
|
this._chunkSize = 1000;
|
|
2531
2588
|
this._elasticChunks = false;
|
|
2532
|
-
|
|
2533
|
-
this.chunkMap = {};
|
|
2589
|
+
this.cachedRows = [];
|
|
2534
2590
|
this.total = 0;
|
|
2535
2591
|
this.loader = null;
|
|
2536
2592
|
this.needTotal = true;
|
|
2593
|
+
this.isInMemory = false;
|
|
2537
2594
|
options = options || {};
|
|
2538
2595
|
this._chunkSize = options.chunkSize || this._chunkSize;
|
|
2539
2596
|
this._elasticChunks = options.elasticChunks || this._elasticChunks;
|
|
2540
2597
|
this.loader = options.loader;
|
|
2598
|
+
if (typeof options.inMemory !== 'undefined') {
|
|
2599
|
+
this.isInMemory = options.inMemory;
|
|
2600
|
+
}
|
|
2601
|
+
if (this.isInMemory) {
|
|
2602
|
+
this.needTotal = false;
|
|
2603
|
+
}
|
|
2541
2604
|
this._columns = new data_column_DataColumnList();
|
|
2605
|
+
this.onUpdate = options.onUpdate;
|
|
2542
2606
|
if (options.columns) {
|
|
2543
2607
|
for (var _i = 0, _a = options.columns; _i < _a.length; _i++) {
|
|
2544
2608
|
var colDesc = _a[_i];
|
|
@@ -2569,7 +2633,7 @@ var easy_data_table_EasyDataTable = /** @class */ (function () {
|
|
|
2569
2633
|
this._chunkSize = value;
|
|
2570
2634
|
this.total = 0;
|
|
2571
2635
|
this.needTotal = !this.elasticChunks;
|
|
2572
|
-
this.
|
|
2636
|
+
this.cachedRows = [];
|
|
2573
2637
|
},
|
|
2574
2638
|
enumerable: true,
|
|
2575
2639
|
configurable: true
|
|
@@ -2582,7 +2646,7 @@ var easy_data_table_EasyDataTable = /** @class */ (function () {
|
|
|
2582
2646
|
this._elasticChunks = value;
|
|
2583
2647
|
this.total = 0;
|
|
2584
2648
|
this.needTotal = !this.elasticChunks;
|
|
2585
|
-
this.
|
|
2649
|
+
this.cachedRows = [];
|
|
2586
2650
|
},
|
|
2587
2651
|
enumerable: true,
|
|
2588
2652
|
configurable: true
|
|
@@ -2610,22 +2674,12 @@ var easy_data_table_EasyDataTable = /** @class */ (function () {
|
|
|
2610
2674
|
endIndex = this.total;
|
|
2611
2675
|
}
|
|
2612
2676
|
}
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
var allChunksCached = true;
|
|
2616
|
-
for (var i = lbChunk; i <= ubChunk; i++) {
|
|
2617
|
-
if (!this.chunkMap[i]) {
|
|
2618
|
-
allChunksCached = false;
|
|
2619
|
-
break;
|
|
2620
|
-
}
|
|
2677
|
+
if (this.isInMemory && endIndex > this.cachedRows.length) {
|
|
2678
|
+
endIndex = this.cachedRows.length;
|
|
2621
2679
|
}
|
|
2680
|
+
var allChunksCached = endIndex <= this.cachedRows.length;
|
|
2622
2681
|
if (allChunksCached) {
|
|
2623
|
-
|
|
2624
|
-
for (var i = lbChunk; i <= ubChunk; i++) {
|
|
2625
|
-
resultArr = resultArr.concat(this.chunkMap[i].rows);
|
|
2626
|
-
}
|
|
2627
|
-
var firstChunkOffset = this.chunkMap[lbChunk].offset;
|
|
2628
|
-
return Promise.resolve(resultArr.slice(fromIndex - firstChunkOffset, endIndex - firstChunkOffset));
|
|
2682
|
+
return Promise.resolve(this.cachedRows.slice(fromIndex, endIndex));
|
|
2629
2683
|
}
|
|
2630
2684
|
//if loader is not defined
|
|
2631
2685
|
if (!this.loader) {
|
|
@@ -2636,53 +2690,34 @@ var easy_data_table_EasyDataTable = /** @class */ (function () {
|
|
|
2636
2690
|
if (this.needTotal) {
|
|
2637
2691
|
this.needTotal = false;
|
|
2638
2692
|
}
|
|
2639
|
-
var
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2693
|
+
var offset = this.cachedRows.length;
|
|
2694
|
+
var limit = endIndex - offset;
|
|
2695
|
+
if (limit < this._chunkSize) {
|
|
2696
|
+
limit = this._chunkSize;
|
|
2697
|
+
}
|
|
2698
|
+
var resultPromise = this.loader.loadChunk({
|
|
2699
|
+
offset: offset,
|
|
2644
2700
|
limit: limit,
|
|
2645
2701
|
needTotal: needTotal
|
|
2646
2702
|
})
|
|
2647
2703
|
.then(function (result) {
|
|
2648
|
-
var chunks = result.table.getCachedChunks();
|
|
2649
2704
|
if (needTotal) {
|
|
2650
2705
|
_this.total = result.total;
|
|
2651
|
-
if (endIndex > _this.total) {
|
|
2652
|
-
endIndex = _this.total;
|
|
2653
|
-
}
|
|
2654
2706
|
}
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
_this.chunkMap[index] = {
|
|
2659
|
-
offset: index * _this._chunkSize,
|
|
2660
|
-
rows: chunk.rows
|
|
2661
|
-
};
|
|
2662
|
-
index++;
|
|
2707
|
+
Array.prototype.push.apply(_this.cachedRows, result.table.getCachedRows());
|
|
2708
|
+
if (endIndex > _this.cachedRows.length) {
|
|
2709
|
+
endIndex = _this.cachedRows.length;
|
|
2663
2710
|
}
|
|
2664
2711
|
if (_this.elasticChunks) {
|
|
2665
2712
|
var count_1 = result.table.getCachedCount();
|
|
2666
|
-
if (count_1
|
|
2667
|
-
|
|
2668
|
-
if (count_1 === limit) {
|
|
2669
|
-
chunk.rows.splice(chunk.rows.length - 1, 1);
|
|
2670
|
-
if (chunk.rows.length == 0) {
|
|
2671
|
-
delete _this.chunkMap[index - 1];
|
|
2672
|
-
}
|
|
2673
|
-
}
|
|
2674
|
-
if (count_1 < limit) {
|
|
2675
|
-
_this.total = _this.getCachedCount();
|
|
2676
|
-
}
|
|
2713
|
+
if (count_1 < limit) {
|
|
2714
|
+
_this.total = _this.cachedRows.length;
|
|
2677
2715
|
}
|
|
2678
2716
|
}
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
resultArr = resultArr.concat(_this.chunkMap[i].rows);
|
|
2682
|
-
}
|
|
2683
|
-
var firstChunkOffset = _this.chunkMap[lbChunk].offset;
|
|
2684
|
-
return resultArr.slice(fromIndex - firstChunkOffset, endIndex - firstChunkOffset);
|
|
2717
|
+
_this.fireUpdated();
|
|
2718
|
+
return _this.cachedRows.slice(fromIndex, endIndex);
|
|
2685
2719
|
});
|
|
2720
|
+
return resultPromise;
|
|
2686
2721
|
};
|
|
2687
2722
|
EasyDataTable.prototype.getRow = function (index) {
|
|
2688
2723
|
return this.getRows({ offset: index, limit: 1 })
|
|
@@ -2694,16 +2729,16 @@ var easy_data_table_EasyDataTable = /** @class */ (function () {
|
|
|
2694
2729
|
EasyDataTable.prototype.setTotal = function (total) {
|
|
2695
2730
|
this.total = total;
|
|
2696
2731
|
this.needTotal = false;
|
|
2697
|
-
this.chunkMap = {};
|
|
2698
2732
|
};
|
|
2699
2733
|
EasyDataTable.prototype.getCachedCount = function () {
|
|
2700
|
-
return this.
|
|
2734
|
+
return this.cachedRows.length;
|
|
2701
2735
|
};
|
|
2702
2736
|
EasyDataTable.prototype.clear = function () {
|
|
2703
2737
|
this.columns.clear();
|
|
2704
|
-
this.
|
|
2738
|
+
this.cachedRows = [];
|
|
2705
2739
|
this.total = 0;
|
|
2706
2740
|
this.needTotal = !this._elasticChunks;
|
|
2741
|
+
this.fireUpdated();
|
|
2707
2742
|
};
|
|
2708
2743
|
EasyDataTable.prototype.createRow = function (dataOrRow) {
|
|
2709
2744
|
var _this = this;
|
|
@@ -2734,60 +2769,33 @@ var easy_data_table_EasyDataTable = /** @class */ (function () {
|
|
|
2734
2769
|
}
|
|
2735
2770
|
return null;
|
|
2736
2771
|
};
|
|
2737
|
-
EasyDataTable.prototype.addRow = function (
|
|
2772
|
+
EasyDataTable.prototype.addRow = function (rowOrValues) {
|
|
2738
2773
|
var newRow;
|
|
2739
|
-
if (Array.isArray(
|
|
2774
|
+
if (Array.isArray(rowOrValues)) {
|
|
2775
|
+
var values = rowOrValues;
|
|
2740
2776
|
var dateIdx = this._columns.getDateColumnIndexes();
|
|
2741
2777
|
if (dateIdx.length > 0) {
|
|
2742
2778
|
for (var _i = 0, dateIdx_1 = dateIdx; _i < dateIdx_1.length; _i++) {
|
|
2743
2779
|
var idx = dateIdx_1[_i];
|
|
2744
|
-
if (
|
|
2745
|
-
|
|
2780
|
+
if (values[idx]) {
|
|
2781
|
+
values[idx] = this.mapDate(values[idx], this._columns.get(idx).type);
|
|
2746
2782
|
}
|
|
2747
2783
|
}
|
|
2748
2784
|
}
|
|
2749
|
-
newRow = new DataRow(this._columns,
|
|
2785
|
+
newRow = new DataRow(this._columns, values);
|
|
2750
2786
|
}
|
|
2751
2787
|
else {
|
|
2752
|
-
newRow = this.createRow(
|
|
2788
|
+
newRow = this.createRow(rowOrValues);
|
|
2753
2789
|
}
|
|
2754
|
-
|
|
2755
|
-
if (!lastChunk || lastChunk.rows.length >= this._chunkSize) {
|
|
2756
|
-
lastChunk = this.createChunk();
|
|
2757
|
-
}
|
|
2758
|
-
lastChunk.rows.push(newRow);
|
|
2790
|
+
this.cachedRows.push(newRow);
|
|
2759
2791
|
var cachedTotal = this.getCachedCount();
|
|
2760
2792
|
if (cachedTotal > this.total) {
|
|
2761
2793
|
this.total = cachedTotal;
|
|
2762
2794
|
}
|
|
2763
2795
|
return newRow;
|
|
2764
2796
|
};
|
|
2765
|
-
EasyDataTable.prototype.createChunk = function (index) {
|
|
2766
|
-
if (typeof index == 'undefined') {
|
|
2767
|
-
index = this.getLastChunkIndex() + 1;
|
|
2768
|
-
}
|
|
2769
|
-
var chunk = { offset: index * this._chunkSize, rows: [] };
|
|
2770
|
-
this.chunkMap[index] = chunk;
|
|
2771
|
-
return chunk;
|
|
2772
|
-
};
|
|
2773
|
-
EasyDataTable.prototype.getLastChunkIndex = function () {
|
|
2774
|
-
var keys = Object.keys(this.chunkMap);
|
|
2775
|
-
return keys.length > 0
|
|
2776
|
-
? parseInt(keys[keys.length - 1])
|
|
2777
|
-
: -1;
|
|
2778
|
-
};
|
|
2779
|
-
EasyDataTable.prototype.getLastChunk = function () {
|
|
2780
|
-
var index = this.getLastChunkIndex();
|
|
2781
|
-
return index > -1
|
|
2782
|
-
? this.chunkMap[index]
|
|
2783
|
-
: null;
|
|
2784
|
-
};
|
|
2785
2797
|
EasyDataTable.prototype.getCachedRows = function () {
|
|
2786
|
-
return this.
|
|
2787
|
-
.reduce(function (acc, v) { return acc.concat(v.rows); }, []);
|
|
2788
|
-
};
|
|
2789
|
-
EasyDataTable.prototype.getCachedChunks = function () {
|
|
2790
|
-
return Object.values(this.chunkMap);
|
|
2798
|
+
return this.cachedRows;
|
|
2791
2799
|
};
|
|
2792
2800
|
EasyDataTable.prototype.totalIsKnown = function () {
|
|
2793
2801
|
if (this.elasticChunks) {
|
|
@@ -2796,6 +2804,11 @@ var easy_data_table_EasyDataTable = /** @class */ (function () {
|
|
|
2796
2804
|
}
|
|
2797
2805
|
return !this.needTotal;
|
|
2798
2806
|
};
|
|
2807
|
+
EasyDataTable.prototype.fireUpdated = function () {
|
|
2808
|
+
if (this.onUpdate) {
|
|
2809
|
+
this.onUpdate(this);
|
|
2810
|
+
}
|
|
2811
|
+
};
|
|
2799
2812
|
return EasyDataTable;
|
|
2800
2813
|
}());
|
|
2801
2814
|
|
|
@@ -2980,7 +2993,6 @@ i18n_i18n.resetLocales();
|
|
|
2980
2993
|
|
|
2981
2994
|
|
|
2982
2995
|
|
|
2983
|
-
//data
|
|
2984
2996
|
|
|
2985
2997
|
|
|
2986
2998
|
|
|
@@ -3026,11 +3038,11 @@ var text_data_filter_assign = (undefined && undefined.__assign) || function () {
|
|
|
3026
3038
|
};
|
|
3027
3039
|
|
|
3028
3040
|
var text_data_filter_TextDataFilter = /** @class */ (function () {
|
|
3029
|
-
function TextDataFilter(loader, sourceTable,
|
|
3041
|
+
function TextDataFilter(loader, sourceTable, sourceId, isLookup) {
|
|
3030
3042
|
if (isLookup === void 0) { isLookup = false; }
|
|
3031
3043
|
this.loader = loader;
|
|
3032
3044
|
this.sourceTable = sourceTable;
|
|
3033
|
-
this.
|
|
3045
|
+
this.sourceId = sourceId;
|
|
3034
3046
|
this.isLookup = isLookup;
|
|
3035
3047
|
this.filterValue = '';
|
|
3036
3048
|
//turns off client-side search
|
|
@@ -3067,7 +3079,7 @@ var text_data_filter_TextDataFilter = /** @class */ (function () {
|
|
|
3067
3079
|
limit: this.sourceTable.chunkSize,
|
|
3068
3080
|
needTotal: true,
|
|
3069
3081
|
filters: filters_1,
|
|
3070
|
-
|
|
3082
|
+
sourceId: this.sourceId,
|
|
3071
3083
|
lookup: this.isLookup
|
|
3072
3084
|
})
|
|
3073
3085
|
.then(function (data) {
|
|
@@ -3075,7 +3087,7 @@ var text_data_filter_TextDataFilter = /** @class */ (function () {
|
|
|
3075
3087
|
chunkSize: _this.sourceTable.chunkSize,
|
|
3076
3088
|
loader: {
|
|
3077
3089
|
loadChunk: function (params) { return _this.loader
|
|
3078
|
-
.loadChunk(text_data_filter_assign({}, params, { filters: filters_1,
|
|
3090
|
+
.loadChunk(text_data_filter_assign(text_data_filter_assign({}, params), { filters: filters_1, sourceId: _this.sourceId, lookup: _this.isLookup })); }
|
|
3079
3091
|
}
|
|
3080
3092
|
});
|
|
3081
3093
|
for (var _i = 0, _a = _this.sourceTable.columns.getItems(); _i < _a.length; _i++) {
|
|
@@ -3096,26 +3108,26 @@ var text_data_filter_TextDataFilter = /** @class */ (function () {
|
|
|
3096
3108
|
return new Promise(function (resolve, reject) {
|
|
3097
3109
|
var filteredTable = new easy_data_table_EasyDataTable({
|
|
3098
3110
|
chunkSize: _this.sourceTable.chunkSize,
|
|
3111
|
+
inMemory: true
|
|
3099
3112
|
});
|
|
3100
3113
|
for (var _i = 0, _a = _this.sourceTable.columns.getItems(); _i < _a.length; _i++) {
|
|
3101
3114
|
var col = _a[_i];
|
|
3102
3115
|
filteredTable.columns.add(col);
|
|
3103
3116
|
}
|
|
3104
3117
|
var words = _this.filterValue.split('||').map(function (w) { return w.trim().toLowerCase(); });
|
|
3118
|
+
var suitableColumns = _this.sourceTable.columns.getItems()
|
|
3119
|
+
.filter(function (col) { return utils_utils.isIntType(col.type)
|
|
3120
|
+
|| utils_utils.getStringDataTypes().indexOf(col.type) >= 0; });
|
|
3105
3121
|
var hasEnterance = function (row) {
|
|
3106
|
-
for (var _i = 0,
|
|
3107
|
-
var col =
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
var
|
|
3111
|
-
|
|
3112
|
-
var
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
var word = words_1[_b];
|
|
3116
|
-
if (normalized.indexOf(word) >= 0) {
|
|
3117
|
-
return true;
|
|
3118
|
-
}
|
|
3122
|
+
for (var _i = 0, suitableColumns_1 = suitableColumns; _i < suitableColumns_1.length; _i++) {
|
|
3123
|
+
var col = suitableColumns_1[_i];
|
|
3124
|
+
var value = row.getValue(col.id);
|
|
3125
|
+
if (value) {
|
|
3126
|
+
var normalized = value.toString().toLowerCase();
|
|
3127
|
+
for (var _a = 0, words_1 = words; _a < words_1.length; _a++) {
|
|
3128
|
+
var word = words_1[_a];
|
|
3129
|
+
if (normalized.indexOf(word) >= 0) {
|
|
3130
|
+
return true;
|
|
3119
3131
|
}
|
|
3120
3132
|
}
|
|
3121
3133
|
}
|
|
@@ -3128,8 +3140,7 @@ var text_data_filter_TextDataFilter = /** @class */ (function () {
|
|
|
3128
3140
|
filteredTable.addRow(row);
|
|
3129
3141
|
}
|
|
3130
3142
|
}
|
|
3131
|
-
|
|
3132
|
-
filteredTable.setTotal(0);
|
|
3143
|
+
filteredTable.setTotal(filteredTable.getCachedCount());
|
|
3133
3144
|
resolve(filteredTable);
|
|
3134
3145
|
});
|
|
3135
3146
|
};
|
|
@@ -3479,6 +3490,13 @@ var dom_elem_builder_extends = (undefined && undefined.__extends) || (function (
|
|
|
3479
3490
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
3480
3491
|
};
|
|
3481
3492
|
})();
|
|
3493
|
+
var __spreadArrays = (undefined && undefined.__spreadArrays) || function () {
|
|
3494
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
3495
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
3496
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
3497
|
+
r[k] = a[j];
|
|
3498
|
+
return r;
|
|
3499
|
+
};
|
|
3482
3500
|
|
|
3483
3501
|
var DomElementBuilder = /** @class */ (function () {
|
|
3484
3502
|
function DomElementBuilder(tag, parent) {
|
|
@@ -3549,7 +3567,7 @@ var DomElementBuilder = /** @class */ (function () {
|
|
|
3549
3567
|
classNames[_i - 1] = arguments[_i];
|
|
3550
3568
|
}
|
|
3551
3569
|
if (className) {
|
|
3552
|
-
var fullList = className.trim().split(" ")
|
|
3570
|
+
var fullList = __spreadArrays(className.trim().split(" "), classNames);
|
|
3553
3571
|
for (var i = 0; i < fullList.length; i++)
|
|
3554
3572
|
this.element.classList.add(fullList[i]);
|
|
3555
3573
|
}
|
|
@@ -3561,7 +3579,7 @@ var DomElementBuilder = /** @class */ (function () {
|
|
|
3561
3579
|
classNames[_i - 1] = arguments[_i];
|
|
3562
3580
|
}
|
|
3563
3581
|
if (className) {
|
|
3564
|
-
var fullList = className.trim().split(" ")
|
|
3582
|
+
var fullList = __spreadArrays(className.trim().split(" "), classNames);
|
|
3565
3583
|
for (var i = 0; i < fullList.length; i++)
|
|
3566
3584
|
this.element.classList.remove(fullList[i]);
|
|
3567
3585
|
}
|
|
@@ -4128,6 +4146,14 @@ var drag_manager_DragManager = /** @class */ (function () {
|
|
|
4128
4146
|
//global variable
|
|
4129
4147
|
var eqDragManager = new drag_manager_DragManager();
|
|
4130
4148
|
//# sourceMappingURL=drag_manager.js.map
|
|
4149
|
+
// CONCATENATED MODULE: d:/a/easydata/easydata/easydata.js/packs/ui/dist/lib/grid/easy_grid_options.js
|
|
4150
|
+
var AutoResizeColumns;
|
|
4151
|
+
(function (AutoResizeColumns) {
|
|
4152
|
+
AutoResizeColumns[AutoResizeColumns["Always"] = 0] = "Always";
|
|
4153
|
+
AutoResizeColumns[AutoResizeColumns["Once"] = 1] = "Once";
|
|
4154
|
+
AutoResizeColumns[AutoResizeColumns["Never"] = 2] = "Never";
|
|
4155
|
+
})(AutoResizeColumns || (AutoResizeColumns = {}));
|
|
4156
|
+
//# sourceMappingURL=easy_grid_options.js.map
|
|
4131
4157
|
// CONCATENATED MODULE: d:/a/easydata/easydata/easydata.js/packs/ui/dist/lib/grid/easy_grid_cell_renderer.js
|
|
4132
4158
|
|
|
4133
4159
|
|
|
@@ -4279,13 +4305,7 @@ var easy_grid_cell_renderer_GridCellRendererStore = /** @class */ (function () {
|
|
|
4279
4305
|
// CONCATENATED MODULE: d:/a/easydata/easydata/easydata.js/packs/ui/dist/lib/grid/easy_grid_columns.js
|
|
4280
4306
|
|
|
4281
4307
|
|
|
4282
|
-
var DEFAULT_WIDTH = 150;
|
|
4283
|
-
var DEFAULT_WIDTH_NUMBER = 120;
|
|
4284
|
-
var DEFAULT_WIDTH_DATE = 200;
|
|
4285
|
-
var DEFAULT_WIDTH_BOOL = 80;
|
|
4286
4308
|
var DEFAULT_WIDTH_STRING = 250;
|
|
4287
|
-
var MIN_WIDTH_STRING = 100;
|
|
4288
|
-
var MAX_WIDTH_STRING = 500;
|
|
4289
4309
|
var ROW_NUM_WIDTH = 60;
|
|
4290
4310
|
var GridColumnAlign;
|
|
4291
4311
|
(function (GridColumnAlign) {
|
|
@@ -4317,31 +4337,18 @@ var easy_grid_columns_GridColumn = /** @class */ (function () {
|
|
|
4317
4337
|
this.isRowNum = false;
|
|
4318
4338
|
this.dataColumn = column;
|
|
4319
4339
|
this.grid = grid;
|
|
4340
|
+
var widthOptions = grid.options.columnWidths || {};
|
|
4320
4341
|
if (column) {
|
|
4321
4342
|
if (column.style.alignment) {
|
|
4322
4343
|
this.align = MapAlignment(column.style.alignment);
|
|
4323
4344
|
}
|
|
4324
|
-
|
|
4325
|
-
var cellType = this.grid.cellRendererStore.getCellType(coltype);
|
|
4326
|
-
switch (cellType) {
|
|
4327
|
-
case CellRendererType.NUMBER:
|
|
4328
|
-
this.width = DEFAULT_WIDTH_NUMBER;
|
|
4329
|
-
break;
|
|
4330
|
-
case CellRendererType.DATETIME:
|
|
4331
|
-
this.width = DEFAULT_WIDTH_DATE;
|
|
4332
|
-
break;
|
|
4333
|
-
case CellRendererType.BOOL:
|
|
4334
|
-
this.width = DEFAULT_WIDTH_BOOL;
|
|
4335
|
-
break;
|
|
4336
|
-
default:
|
|
4337
|
-
this.width = DEFAULT_WIDTH_STRING;
|
|
4338
|
-
}
|
|
4345
|
+
this.width = (widthOptions && widthOptions[this.type]) ? widthOptions[this.type].default : DEFAULT_WIDTH_STRING;
|
|
4339
4346
|
this.cellRenderer = this.grid.cellRendererStore.getDefaultRenderer(column.type);
|
|
4340
4347
|
this._description = column.description;
|
|
4341
4348
|
}
|
|
4342
4349
|
else if (isRowNum) {
|
|
4343
4350
|
this.isRowNum = true;
|
|
4344
|
-
this.width = ROW_NUM_WIDTH;
|
|
4351
|
+
this.width = (widthOptions && widthOptions.rowNumColumn) ? widthOptions.rowNumColumn.default : ROW_NUM_WIDTH;
|
|
4345
4352
|
this._label = '';
|
|
4346
4353
|
this.cellRenderer = this.grid.cellRendererStore.getDefaultRendererByType(CellRendererType.NUMBER);
|
|
4347
4354
|
}
|
|
@@ -4387,9 +4394,10 @@ var easy_grid_columns_GridColumnList = /** @class */ (function () {
|
|
|
4387
4394
|
GridColumnList.prototype.sync = function (columnList, hasRowNumCol) {
|
|
4388
4395
|
if (hasRowNumCol === void 0) { hasRowNumCol = true; }
|
|
4389
4396
|
this.clear();
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4397
|
+
var rowNumCol = new easy_grid_columns_GridColumn(null, this.grid, true);
|
|
4398
|
+
this.add(rowNumCol);
|
|
4399
|
+
if (!hasRowNumCol) {
|
|
4400
|
+
rowNumCol.isVisible = false;
|
|
4393
4401
|
}
|
|
4394
4402
|
if (columnList) {
|
|
4395
4403
|
for (var _i = 0, _a = columnList.getItems(); _i < _a.length; _i++) {
|
|
@@ -4463,6 +4471,14 @@ var easy_grid_assign = (undefined && undefined.__assign) || function () {
|
|
|
4463
4471
|
};
|
|
4464
4472
|
return easy_grid_assign.apply(this, arguments);
|
|
4465
4473
|
};
|
|
4474
|
+
var easy_grid_spreadArrays = (undefined && undefined.__spreadArrays) || function () {
|
|
4475
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
4476
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
4477
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
4478
|
+
r[k] = a[j];
|
|
4479
|
+
return r;
|
|
4480
|
+
};
|
|
4481
|
+
|
|
4466
4482
|
|
|
4467
4483
|
|
|
4468
4484
|
|
|
@@ -4495,14 +4511,42 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
4495
4511
|
pageSize: 30,
|
|
4496
4512
|
pageSizeItems: [20, 30, 50, 100, 200]
|
|
4497
4513
|
},
|
|
4498
|
-
|
|
4514
|
+
columnWidths: {
|
|
4515
|
+
autoResize: AutoResizeColumns.Always,
|
|
4516
|
+
stringColumns: {
|
|
4517
|
+
min: 100,
|
|
4518
|
+
max: 500,
|
|
4519
|
+
default: 250
|
|
4520
|
+
},
|
|
4521
|
+
numberColumns: {
|
|
4522
|
+
min: 60,
|
|
4523
|
+
default: 120
|
|
4524
|
+
},
|
|
4525
|
+
boolColumns: {
|
|
4526
|
+
min: 50,
|
|
4527
|
+
default: 80
|
|
4528
|
+
},
|
|
4529
|
+
dateColumns: {
|
|
4530
|
+
min: 80,
|
|
4531
|
+
default: 200
|
|
4532
|
+
},
|
|
4533
|
+
otherColumns: {
|
|
4534
|
+
min: 100,
|
|
4535
|
+
max: 500,
|
|
4536
|
+
default: 250
|
|
4537
|
+
},
|
|
4538
|
+
rowNumColumn: {
|
|
4539
|
+
min: 40,
|
|
4540
|
+
default: 60
|
|
4541
|
+
}
|
|
4542
|
+
},
|
|
4543
|
+
showPlusButton: false,
|
|
4499
4544
|
viewportRowsCount: null,
|
|
4500
4545
|
showActiveRow: true
|
|
4501
4546
|
};
|
|
4502
4547
|
this.rowsOnPagePromise = null;
|
|
4503
4548
|
this.containerInitialHeight = 0;
|
|
4504
4549
|
this.firstRender = true;
|
|
4505
|
-
this.compareValues = this.strictCompare;
|
|
4506
4550
|
this.prevRowTotals = null;
|
|
4507
4551
|
this.landingIndex = -1;
|
|
4508
4552
|
this.landingSlot = domel('div')
|
|
@@ -4514,7 +4558,8 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
4514
4558
|
if (options && options.paging) {
|
|
4515
4559
|
options.paging = utils_utils.assign(this.defaultDataGridOptions.paging, options.paging);
|
|
4516
4560
|
}
|
|
4517
|
-
this.options =
|
|
4561
|
+
this.options = this.mergeOptions(options);
|
|
4562
|
+
this.processColumnWidthsOptions();
|
|
4518
4563
|
if (!this.options.slot)
|
|
4519
4564
|
throw Error('"slot" parameter is required to initialize EasyDataGrid');
|
|
4520
4565
|
if (!this.options.dataTable)
|
|
@@ -4526,6 +4571,42 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
4526
4571
|
this.setSlot(this.options.slot);
|
|
4527
4572
|
this.init(this.options);
|
|
4528
4573
|
}
|
|
4574
|
+
EasyGrid.prototype.mergeOptions = function (options) {
|
|
4575
|
+
var colWidthOptions = utils_utils.assignDeep({}, this.defaultDataGridOptions.columnWidths, options.columnWidths);
|
|
4576
|
+
var pagingOptions = utils_utils.assignDeep({}, this.defaultDataGridOptions.paging, options.paging);
|
|
4577
|
+
var result = utils_utils.assign({}, this.defaultDataGridOptions, options);
|
|
4578
|
+
result.columnWidths = colWidthOptions;
|
|
4579
|
+
result.paging = pagingOptions;
|
|
4580
|
+
return result;
|
|
4581
|
+
};
|
|
4582
|
+
EasyGrid.prototype.processColumnWidthsOptions = function () {
|
|
4583
|
+
var widthOptions = this.options.columnWidths;
|
|
4584
|
+
if (!widthOptions)
|
|
4585
|
+
return;
|
|
4586
|
+
//string columns
|
|
4587
|
+
utils_utils.getStringDataTypes().forEach(function (dataType) {
|
|
4588
|
+
widthOptions[dataType] = easy_grid_assign(easy_grid_assign({}, widthOptions.stringColumns), widthOptions[dataType]);
|
|
4589
|
+
});
|
|
4590
|
+
//numeric columns
|
|
4591
|
+
utils_utils.getNumericDataTypes().forEach(function (dataType) {
|
|
4592
|
+
widthOptions[dataType] = easy_grid_assign(easy_grid_assign({}, widthOptions.numberColumns), widthOptions[dataType]);
|
|
4593
|
+
});
|
|
4594
|
+
//bool columns
|
|
4595
|
+
widthOptions[DataType.Bool] = easy_grid_assign(easy_grid_assign({}, widthOptions.boolColumns), widthOptions[DataType.Bool]);
|
|
4596
|
+
//date columns
|
|
4597
|
+
utils_utils.getDateDataTypes().forEach(function (dataType) {
|
|
4598
|
+
widthOptions[dataType] = easy_grid_assign(easy_grid_assign({}, widthOptions.dateColumns), widthOptions[dataType]);
|
|
4599
|
+
});
|
|
4600
|
+
//other columns
|
|
4601
|
+
var knownTypes = easy_grid_spreadArrays(utils_utils.getStringDataTypes(), utils_utils.getNumericDataTypes(), utils_utils.getDateDataTypes(), [
|
|
4602
|
+
DataType.Bool
|
|
4603
|
+
]);
|
|
4604
|
+
utils_utils.getAllDataTypes().forEach(function (dataType) {
|
|
4605
|
+
if (!(dataType in knownTypes)) {
|
|
4606
|
+
widthOptions[dataType] = easy_grid_assign(easy_grid_assign({}, widthOptions.otherColumns), widthOptions[dataType]);
|
|
4607
|
+
}
|
|
4608
|
+
});
|
|
4609
|
+
};
|
|
4529
4610
|
EasyGrid.prototype.setSlot = function (slot) {
|
|
4530
4611
|
if (typeof slot === 'string') {
|
|
4531
4612
|
if (slot.length) {
|
|
@@ -4558,8 +4639,8 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
4558
4639
|
if (options.onRowDbClick) {
|
|
4559
4640
|
this.addEventListener('rowDbClick', options.onRowDbClick);
|
|
4560
4641
|
}
|
|
4561
|
-
if (options.
|
|
4562
|
-
this.addEventListener('
|
|
4642
|
+
if (options.onPlusButtonClick) {
|
|
4643
|
+
this.addEventListener('plusButtonClick', options.onPlusButtonClick);
|
|
4563
4644
|
}
|
|
4564
4645
|
if (options.onColumnChanged) {
|
|
4565
4646
|
this.addEventListener('columnChanged', options.onColumnChanged);
|
|
@@ -4645,7 +4726,7 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
4645
4726
|
};
|
|
4646
4727
|
EasyGrid.prototype.render = function () {
|
|
4647
4728
|
var _this = this;
|
|
4648
|
-
if (!this.hasData() && !this.options.
|
|
4729
|
+
if (!this.hasData() && !this.options.showPlusButton)
|
|
4649
4730
|
return;
|
|
4650
4731
|
this.containerInitialHeight = this.slot.clientHeight;
|
|
4651
4732
|
this.rootDiv = document.createElement('div');
|
|
@@ -4662,6 +4743,7 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
4662
4743
|
gridContainer.classList.add(this.cssPrefix + "-container");
|
|
4663
4744
|
gridContainer.appendChild(this.rootDiv);
|
|
4664
4745
|
this.slot.appendChild(gridContainer);
|
|
4746
|
+
var needAutoResize = this.options.columnWidths.autoResize !== AutoResizeColumns.Never;
|
|
4665
4747
|
if (this.rowsOnPagePromise) {
|
|
4666
4748
|
this.rowsOnPagePromise
|
|
4667
4749
|
.then(function () { return _this.updateHeight(); })
|
|
@@ -4672,8 +4754,13 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
4672
4754
|
}
|
|
4673
4755
|
else {
|
|
4674
4756
|
setTimeout(function () {
|
|
4675
|
-
_this.updateHeight()
|
|
4676
|
-
|
|
4757
|
+
_this.updateHeight()
|
|
4758
|
+
.then(function () {
|
|
4759
|
+
_this.firstRender = false;
|
|
4760
|
+
if (needAutoResize) {
|
|
4761
|
+
_this.resizeColumns();
|
|
4762
|
+
}
|
|
4763
|
+
});
|
|
4677
4764
|
}, 100);
|
|
4678
4765
|
}
|
|
4679
4766
|
};
|
|
@@ -4684,14 +4771,14 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
4684
4771
|
var firstRow = _this.bodyCellContainerDiv.firstElementChild;
|
|
4685
4772
|
var rowHeight = firstRow ? firstRow.offsetHeight : DEFAULT_ROW_HEIGHT;
|
|
4686
4773
|
var rowCount = _this.options.viewportRowsCount; // || DEFAULT_ROW_COUNT;
|
|
4687
|
-
var
|
|
4688
|
-
domel(_this.
|
|
4689
|
-
.setStyle('height',
|
|
4774
|
+
var viewportHeight_1 = rowHeight * rowCount;
|
|
4775
|
+
domel(_this.bodyViewportDiv)
|
|
4776
|
+
.setStyle('height', viewportHeight_1 + "px");
|
|
4690
4777
|
setTimeout(function () {
|
|
4691
4778
|
var sbHeight = _this.bodyViewportDiv.offsetHeight - _this.bodyViewportDiv.clientHeight;
|
|
4692
|
-
|
|
4693
|
-
domel(_this.
|
|
4694
|
-
.setStyle('height',
|
|
4779
|
+
viewportHeight_1 = viewportHeight_1 + sbHeight;
|
|
4780
|
+
domel(_this.bodyViewportDiv)
|
|
4781
|
+
.setStyle('height', viewportHeight_1 + "px");
|
|
4695
4782
|
resolve();
|
|
4696
4783
|
}, 100);
|
|
4697
4784
|
return;
|
|
@@ -4738,7 +4825,7 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
4738
4825
|
_this.headerRowDiv.appendChild(hd);
|
|
4739
4826
|
if (column.isRowNum) {
|
|
4740
4827
|
domel(hd)
|
|
4741
|
-
.addChildElement(_this.
|
|
4828
|
+
.addChildElement(_this.renderHeaderButtons());
|
|
4742
4829
|
}
|
|
4743
4830
|
});
|
|
4744
4831
|
var containerWidth = this.getContainerWidth();
|
|
@@ -4752,7 +4839,7 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
4752
4839
|
var _this = this;
|
|
4753
4840
|
var colBuilder = domel('div')
|
|
4754
4841
|
.addClass(this.cssPrefix + "-header-cell")
|
|
4755
|
-
.data('col-idx', "" +
|
|
4842
|
+
.data('col-idx', "" + index)
|
|
4756
4843
|
.setStyle('width', column.width + "px");
|
|
4757
4844
|
if (column.dataColumn) {
|
|
4758
4845
|
colBuilder
|
|
@@ -4790,14 +4877,6 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
4790
4877
|
}
|
|
4791
4878
|
return colDiv;
|
|
4792
4879
|
};
|
|
4793
|
-
EasyGrid.prototype.strictCompare = function (value1, value2) {
|
|
4794
|
-
return value1 !== value2;
|
|
4795
|
-
};
|
|
4796
|
-
EasyGrid.prototype.caseInsensitiveCompare = function (value1, value2) {
|
|
4797
|
-
var val1 = (typeof value1 === 'string') ? value1.toLowerCase() : value1;
|
|
4798
|
-
var val2 = (typeof value2 === 'string') ? value2.toLowerCase() : value2;
|
|
4799
|
-
return val1 !== val2;
|
|
4800
|
-
};
|
|
4801
4880
|
EasyGrid.prototype.renderBody = function () {
|
|
4802
4881
|
var _this = this;
|
|
4803
4882
|
this.bodyDiv = domel('div')
|
|
@@ -4811,10 +4890,6 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
4811
4890
|
.addClass(this.cssPrefix + "-cell-container")
|
|
4812
4891
|
.toDOM();
|
|
4813
4892
|
var showAggrs = this.canShowAggregates();
|
|
4814
|
-
this.compareValues = this.caseInsensitiveCompare;
|
|
4815
|
-
if (showAggrs && this.options.aggregates.settings.caseSensitiveGroups) {
|
|
4816
|
-
this.compareValues = this.strictCompare;
|
|
4817
|
-
}
|
|
4818
4893
|
if (this.dataTable) {
|
|
4819
4894
|
this.showProgress();
|
|
4820
4895
|
this.rowsOnPagePromise = this.getRowsToRender()
|
|
@@ -4824,15 +4899,22 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
4824
4899
|
//prevent double rendering (bad solution, we have to figure out how to avoid this behavior properly)
|
|
4825
4900
|
_this.bodyCellContainerDiv.innerHTML = '';
|
|
4826
4901
|
_this.prevRowTotals = null;
|
|
4902
|
+
var rowsToRender = 0;
|
|
4827
4903
|
if (rows.length) {
|
|
4828
4904
|
var groups_1 = showAggrs
|
|
4829
4905
|
? _this.options.aggregates.settings.getGroups()
|
|
4830
4906
|
: [];
|
|
4907
|
+
rowsToRender = (rows.length < _this.pagination.pageSize)
|
|
4908
|
+
? rows.length
|
|
4909
|
+
: _this.pagination.pageSize;
|
|
4831
4910
|
rows.forEach(function (row, index) {
|
|
4832
4911
|
if (showAggrs)
|
|
4833
4912
|
_this.updateTotalsState(groups_1, row);
|
|
4834
|
-
|
|
4835
|
-
|
|
4913
|
+
//we don't actually render the last row
|
|
4914
|
+
if (index < rowsToRender) {
|
|
4915
|
+
var tr = _this.renderRow(row, index);
|
|
4916
|
+
_this.bodyCellContainerDiv.appendChild(tr);
|
|
4917
|
+
}
|
|
4836
4918
|
});
|
|
4837
4919
|
var showGrandTotalsOnEachPage = _this.options.aggregates && _this.options.aggregates.showGrandTotalsOnEachPage;
|
|
4838
4920
|
if (showAggrs && (_this.isLastPage() || showGrandTotalsOnEachPage)) {
|
|
@@ -4840,10 +4922,16 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
4840
4922
|
_this.updateTotalsState(groups_1, row, true);
|
|
4841
4923
|
}
|
|
4842
4924
|
}
|
|
4843
|
-
var
|
|
4844
|
-
|
|
4845
|
-
.
|
|
4846
|
-
|
|
4925
|
+
var needAutoResize = _this.options.columnWidths.autoResize !== AutoResizeColumns.Never;
|
|
4926
|
+
if (needAutoResize) {
|
|
4927
|
+
_this.resizeColumns();
|
|
4928
|
+
}
|
|
4929
|
+
else {
|
|
4930
|
+
var containerWidth = _this.getContainerWidth();
|
|
4931
|
+
domel(_this.bodyCellContainerDiv)
|
|
4932
|
+
.setStyle('width', containerWidth + "px");
|
|
4933
|
+
}
|
|
4934
|
+
return rowsToRender;
|
|
4847
4935
|
})
|
|
4848
4936
|
.catch(function (error) { console.error(error); return 0; });
|
|
4849
4937
|
}
|
|
@@ -4851,7 +4939,7 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
4851
4939
|
domel(_this.headerViewportDiv)
|
|
4852
4940
|
.setStyle('margin-left', "-" + _this.bodyViewportDiv.scrollLeft + "px");
|
|
4853
4941
|
});
|
|
4854
|
-
this.bodyViewportDiv.addEventListener('keydown', this.
|
|
4942
|
+
this.bodyViewportDiv.addEventListener('keydown', this.onViewportKeydown.bind(this));
|
|
4855
4943
|
};
|
|
4856
4944
|
EasyGrid.prototype.isLastPage = function () {
|
|
4857
4945
|
if (this.dataTable.elasticChunks) {
|
|
@@ -4877,7 +4965,7 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
4877
4965
|
var group = groups[level - 1];
|
|
4878
4966
|
for (var _i = 0, _a = group.columns; _i < _a.length; _i++) {
|
|
4879
4967
|
var col = _a[_i];
|
|
4880
|
-
if (
|
|
4968
|
+
if (!aggrSettings.compareValues(this.prevRowTotals.getValue(col), newRow.getValue(col))) {
|
|
4881
4969
|
changeLevel = level;
|
|
4882
4970
|
break;
|
|
4883
4971
|
}
|
|
@@ -4938,8 +5026,8 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
4938
5026
|
});
|
|
4939
5027
|
var aggrContainer = this.options.aggregates.calculator.getAggrContainer();
|
|
4940
5028
|
var aggrCols = aggrSettings.getAggregates().map(function (c) { return c.colId; });
|
|
4941
|
-
var key =
|
|
4942
|
-
aggrContainer.
|
|
5029
|
+
var key = aggrSettings.buildGroupKey(group, row);
|
|
5030
|
+
aggrContainer.getAggregateData(level, key)
|
|
4943
5031
|
.then(function (values) {
|
|
4944
5032
|
for (var _i = 0, aggrCols_1 = aggrCols; _i < aggrCols_1.length; _i++) {
|
|
4945
5033
|
var aggrColId = aggrCols_1[_i];
|
|
@@ -4980,34 +5068,20 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
4980
5068
|
}
|
|
4981
5069
|
}
|
|
4982
5070
|
if (groupFooterTemplate) {
|
|
4983
|
-
var cellDiv_1 = _this.renderCell(column,
|
|
5071
|
+
var cellDiv_1 = _this.renderCell(column, index, val, rowElement);
|
|
4984
5072
|
var innerCell = cellDiv_1.firstChild;
|
|
4985
5073
|
val = innerCell.innerHTML;
|
|
4986
5074
|
val = _this.applyGroupColumnTemplate(groupFooterTemplate, val, values[aggrSettings.COUNT_FIELD_NAME]);
|
|
4987
5075
|
}
|
|
4988
5076
|
}
|
|
4989
|
-
var cellDiv = _this.renderCell(column,
|
|
5077
|
+
var cellDiv = _this.renderCell(column, index, val, rowElement);
|
|
4990
5078
|
rowElement.appendChild(cellDiv);
|
|
4991
5079
|
});
|
|
4992
5080
|
})
|
|
4993
5081
|
.catch(function (error) { return console.error(error); });
|
|
4994
5082
|
return rowElement;
|
|
4995
5083
|
};
|
|
4996
|
-
EasyGrid.prototype.
|
|
4997
|
-
var aggrSettings = this.options.aggregates.settings;
|
|
4998
|
-
var caseInsensitive = aggrSettings && !aggrSettings.caseSensitiveGroups;
|
|
4999
|
-
var result = {};
|
|
5000
|
-
for (var _i = 0, _a = group.columns; _i < _a.length; _i++) {
|
|
5001
|
-
var colId = _a[_i];
|
|
5002
|
-
var keyVal = row.getValue(colId);
|
|
5003
|
-
if (caseInsensitive && typeof (keyVal) === 'string') {
|
|
5004
|
-
keyVal = keyVal.toLowerCase();
|
|
5005
|
-
}
|
|
5006
|
-
result[colId] = keyVal;
|
|
5007
|
-
}
|
|
5008
|
-
return result;
|
|
5009
|
-
};
|
|
5010
|
-
EasyGrid.prototype.onVieportKeydown = function (ev) {
|
|
5084
|
+
EasyGrid.prototype.onViewportKeydown = function (ev) {
|
|
5011
5085
|
if (this.options.showActiveRow) {
|
|
5012
5086
|
var rowCount = this.bodyCellContainerDiv.querySelectorAll("." + this.cssPrefix + "-row").length;
|
|
5013
5087
|
var newValue = void 0;
|
|
@@ -5061,13 +5135,17 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
5061
5135
|
}
|
|
5062
5136
|
}
|
|
5063
5137
|
};
|
|
5138
|
+
/** Returns a promise with the list of the rows to render on one page.
|
|
5139
|
+
* The list contains pageSize+1 row to make it possible
|
|
5140
|
+
* to render the totals row (if it appears to be on the edge between pages)
|
|
5141
|
+
*/
|
|
5064
5142
|
EasyGrid.prototype.getRowsToRender = function () {
|
|
5065
5143
|
if (this.options.paging.enabled === false) {
|
|
5066
5144
|
return Promise.resolve(this.dataTable.getCachedRows());
|
|
5067
5145
|
}
|
|
5068
5146
|
return this.dataTable.getRows({
|
|
5069
|
-
|
|
5070
|
-
|
|
5147
|
+
offset: (this.pagination.page - 1) * this.pagination.pageSize,
|
|
5148
|
+
limit: this.pagination.pageSize + 1
|
|
5071
5149
|
})
|
|
5072
5150
|
.catch(function (error) {
|
|
5073
5151
|
console.error(error);
|
|
@@ -5092,23 +5170,26 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
5092
5170
|
var pageInfoDiv = domel('div')
|
|
5093
5171
|
.addClass(this.cssPrefix + "-page-info")
|
|
5094
5172
|
.toDOM();
|
|
5095
|
-
var
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
var
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
.
|
|
5111
|
-
|
|
5173
|
+
var rowCount = this.dataTable.getTotal();
|
|
5174
|
+
if (rowCount > 0) {
|
|
5175
|
+
var fistPageRecordNum = count
|
|
5176
|
+
? (this.pagination.page - 1) * this.pagination.pageSize + 1
|
|
5177
|
+
: 0;
|
|
5178
|
+
var lastPageRecordNum = count
|
|
5179
|
+
? fistPageRecordNum + count - 1
|
|
5180
|
+
: 0;
|
|
5181
|
+
var totalStr = this.dataTable.getTotal().toString();
|
|
5182
|
+
if (this.dataTable.elasticChunks) {
|
|
5183
|
+
var count_1 = this.dataTable.getCachedCount();
|
|
5184
|
+
var total = this.dataTable.getTotal();
|
|
5185
|
+
if (count_1 !== total)
|
|
5186
|
+
totalStr = '?';
|
|
5187
|
+
}
|
|
5188
|
+
pageInfoDiv.innerHTML = i18n_i18n.getText('GridPageInfo')
|
|
5189
|
+
.replace('{FirstPageRecordNum}', "<span>" + fistPageRecordNum.toString() + "</span>")
|
|
5190
|
+
.replace('{LastPageRecordNum}', "<span>" + lastPageRecordNum.toString() + "</span>")
|
|
5191
|
+
.replace('{Total}', "<span>" + totalStr + "</span>");
|
|
5192
|
+
}
|
|
5112
5193
|
return pageInfoDiv;
|
|
5113
5194
|
};
|
|
5114
5195
|
EasyGrid.prototype.showProgress = function () {
|
|
@@ -5163,13 +5244,13 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
5163
5244
|
if (this.options.showActiveRow && index == this.activeRowIndex) {
|
|
5164
5245
|
rowBuilder.addClass(this.cssPrefix + "-row-active");
|
|
5165
5246
|
}
|
|
5166
|
-
this.columns.getItems().forEach(function (column) {
|
|
5247
|
+
this.columns.getItems().forEach(function (column, index) {
|
|
5167
5248
|
if (!column.isVisible) {
|
|
5168
5249
|
return;
|
|
5169
5250
|
}
|
|
5170
5251
|
var colindex = column.isRowNum ? -1 : _this.dataTable.columns.getIndex(column.dataColumn.id);
|
|
5171
5252
|
var val = column.isRowNum ? indexGlobal + 1 : row.getValue(colindex);
|
|
5172
|
-
rowElement.appendChild(_this.renderCell(column,
|
|
5253
|
+
rowElement.appendChild(_this.renderCell(column, index, val, rowElement));
|
|
5173
5254
|
});
|
|
5174
5255
|
return rowElement;
|
|
5175
5256
|
};
|
|
@@ -5203,7 +5284,8 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
5203
5284
|
var _this = this;
|
|
5204
5285
|
var paginateDiv = document.createElement('div');
|
|
5205
5286
|
paginateDiv.className = this.cssPrefix + "-pagination-wrapper";
|
|
5206
|
-
|
|
5287
|
+
var rowCount = this.dataTable.getTotal();
|
|
5288
|
+
if (this.options.paging && this.options.paging.enabled && rowCount > 0) {
|
|
5207
5289
|
var prefix_1 = this.paginationOptions.useBootstrap ? '' : this.cssPrefix + "-";
|
|
5208
5290
|
var buttonClickHandler_1 = function (ev) {
|
|
5209
5291
|
var element = ev.target;
|
|
@@ -5329,18 +5411,18 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
5329
5411
|
EasyGrid.prototype.removeEventListener = function (eventType, handlerId) {
|
|
5330
5412
|
this.eventEmitter.unsubscribe(eventType, handlerId);
|
|
5331
5413
|
};
|
|
5332
|
-
EasyGrid.prototype.
|
|
5414
|
+
EasyGrid.prototype.renderHeaderButtons = function () {
|
|
5333
5415
|
var _this = this;
|
|
5334
|
-
if (this.options.
|
|
5416
|
+
if (this.options.showPlusButton) {
|
|
5335
5417
|
return domel('div')
|
|
5336
|
-
.addClass(this.cssPrefix + "-
|
|
5337
|
-
.title(this.options.
|
|
5418
|
+
.addClass(this.cssPrefix + "-header-btn-plus")
|
|
5419
|
+
.title(this.options.plusButtonTitle || 'Add')
|
|
5338
5420
|
.addChild('a', function (builder) { return builder
|
|
5339
5421
|
.attr('href', 'javascript:void(0)')
|
|
5340
5422
|
.on('click', function (e) {
|
|
5341
5423
|
e.preventDefault();
|
|
5342
5424
|
_this.fireEvent({
|
|
5343
|
-
type: '
|
|
5425
|
+
type: 'plusButtonClick',
|
|
5344
5426
|
sourceEvent: e
|
|
5345
5427
|
});
|
|
5346
5428
|
}); })
|
|
@@ -5441,6 +5523,97 @@ var easy_grid_EasyGrid = /** @class */ (function () {
|
|
|
5441
5523
|
EasyGrid.prototype.focus = function () {
|
|
5442
5524
|
this.bodyViewportDiv.focus();
|
|
5443
5525
|
};
|
|
5526
|
+
EasyGrid.prototype.resizeColumns = function () {
|
|
5527
|
+
if (this.options.columnWidths.autoResize === AutoResizeColumns.Never)
|
|
5528
|
+
return;
|
|
5529
|
+
var containerWidth = this.bodyCellContainerDiv.style.width;
|
|
5530
|
+
this.bodyCellContainerDiv.style.visibility = 'hidden';
|
|
5531
|
+
this.bodyCellContainerDiv.style.width = '1px';
|
|
5532
|
+
//this.headerRowDiv.style.visibility = 'hidden';
|
|
5533
|
+
this.headerRowDiv.style.width = '1px';
|
|
5534
|
+
var sumWidth = 0;
|
|
5535
|
+
var columns = this.columns.getItems();
|
|
5536
|
+
var headerCells = this.headerCellContainerDiv.querySelectorAll("." + this.cssPrefix + "-header-cell");
|
|
5537
|
+
var headerIdx = 0;
|
|
5538
|
+
var _loop_1 = function (idx) {
|
|
5539
|
+
var column = columns[idx];
|
|
5540
|
+
if (!column.isVisible)
|
|
5541
|
+
return "continue";
|
|
5542
|
+
var calculatedWidth = this_1.options.columnWidths.autoResize !== AutoResizeColumns.Always && column.dataColumn
|
|
5543
|
+
? column.dataColumn.calculatedWidth
|
|
5544
|
+
: 0;
|
|
5545
|
+
var cellValues = this_1.bodyCellContainerDiv.querySelectorAll("." + this_1.cssPrefix + "-cell[data-col-idx=\"" + idx + "\"] > ." + this_1.cssPrefix + "-cell-value");
|
|
5546
|
+
var maxWidth = 0;
|
|
5547
|
+
if (calculatedWidth > 0) {
|
|
5548
|
+
sumWidth += calculatedWidth;
|
|
5549
|
+
column.width = calculatedWidth;
|
|
5550
|
+
cellValues.forEach(function (value) {
|
|
5551
|
+
value.parentElement.style.width = calculatedWidth + "px";
|
|
5552
|
+
});
|
|
5553
|
+
headerCells[headerIdx].style.width = calculatedWidth + "px";
|
|
5554
|
+
}
|
|
5555
|
+
else {
|
|
5556
|
+
if (cellValues.length == 0) {
|
|
5557
|
+
headerCells[headerIdx].style.width = null;
|
|
5558
|
+
headerCells[headerIdx].style.whiteSpace = 'nowrap';
|
|
5559
|
+
}
|
|
5560
|
+
maxWidth = headerCells[headerIdx].offsetWidth;
|
|
5561
|
+
if (cellValues.length > 0) {
|
|
5562
|
+
cellValues.forEach(function (value) {
|
|
5563
|
+
value.parentElement.style.width = null;
|
|
5564
|
+
var width = value.parentElement.offsetWidth;
|
|
5565
|
+
if (width > maxWidth) {
|
|
5566
|
+
maxWidth = width;
|
|
5567
|
+
}
|
|
5568
|
+
});
|
|
5569
|
+
maxWidth += 3;
|
|
5570
|
+
var maxOption = column.isRowNum
|
|
5571
|
+
? this_1.options.columnWidths.rowNumColumn.max || 500
|
|
5572
|
+
: this_1.options.columnWidths[column.dataColumn.type].max || 2000;
|
|
5573
|
+
var minOption = column.isRowNum
|
|
5574
|
+
? this_1.options.columnWidths.rowNumColumn.min || 0
|
|
5575
|
+
: this_1.options.columnWidths[column.dataColumn.type].min || 20;
|
|
5576
|
+
if (maxWidth > maxOption) {
|
|
5577
|
+
maxWidth = maxOption;
|
|
5578
|
+
}
|
|
5579
|
+
if (maxWidth < minOption) {
|
|
5580
|
+
maxWidth = minOption;
|
|
5581
|
+
}
|
|
5582
|
+
if (utils_utils.isNumericType(column.type)) {
|
|
5583
|
+
//increase the calculated width in 1.3 times for numeric columns
|
|
5584
|
+
maxWidth = Math.round(maxWidth * 1.3);
|
|
5585
|
+
}
|
|
5586
|
+
sumWidth += maxWidth;
|
|
5587
|
+
column.width = maxWidth;
|
|
5588
|
+
cellValues.forEach(function (value) {
|
|
5589
|
+
value.parentElement.style.width = maxWidth + "px";
|
|
5590
|
+
});
|
|
5591
|
+
headerCells[headerIdx].style.width = maxWidth + "px";
|
|
5592
|
+
if (column.dataColumn) {
|
|
5593
|
+
column.dataColumn.calculatedWidth = maxWidth;
|
|
5594
|
+
}
|
|
5595
|
+
}
|
|
5596
|
+
else {
|
|
5597
|
+
sumWidth += maxWidth;
|
|
5598
|
+
}
|
|
5599
|
+
}
|
|
5600
|
+
headerIdx++;
|
|
5601
|
+
};
|
|
5602
|
+
var this_1 = this;
|
|
5603
|
+
for (var idx = 0; idx < this.columns.count; idx++) {
|
|
5604
|
+
_loop_1(idx);
|
|
5605
|
+
}
|
|
5606
|
+
if (sumWidth > 0) {
|
|
5607
|
+
this.bodyCellContainerDiv.style.width = sumWidth + "px";
|
|
5608
|
+
this.headerCellContainerDiv.style.width = sumWidth + "px";
|
|
5609
|
+
}
|
|
5610
|
+
else {
|
|
5611
|
+
this.bodyCellContainerDiv.style.width = containerWidth;
|
|
5612
|
+
this.headerCellContainerDiv.style.width = containerWidth;
|
|
5613
|
+
}
|
|
5614
|
+
this.bodyCellContainerDiv.style.visibility = null;
|
|
5615
|
+
this.headerRowDiv.removeAttribute('style');
|
|
5616
|
+
};
|
|
5444
5617
|
return EasyGrid;
|
|
5445
5618
|
}());
|
|
5446
5619
|
|
|
@@ -6627,6 +6800,7 @@ addEasyDataUITexts();
|
|
|
6627
6800
|
|
|
6628
6801
|
|
|
6629
6802
|
|
|
6803
|
+
|
|
6630
6804
|
//datetimepicker
|
|
6631
6805
|
|
|
6632
6806
|
|
|
@@ -7132,12 +7306,13 @@ var entity_form_builder_EntityEditFormBuilder = /** @class */ (function () {
|
|
|
7132
7306
|
var lookupTable = new easy_data_table_EasyDataTable({
|
|
7133
7307
|
loader: {
|
|
7134
7308
|
loadChunk: function (chunkParams) { return _this.context.getDataLoader()
|
|
7135
|
-
.loadChunk(entity_form_builder_assign({}, chunkParams, { id: lookupEntity.id })); }
|
|
7309
|
+
.loadChunk(entity_form_builder_assign(entity_form_builder_assign({}, chunkParams), { id: lookupEntity.id })); }
|
|
7136
7310
|
}
|
|
7137
7311
|
});
|
|
7138
7312
|
_this.context.getDataLoader()
|
|
7139
|
-
.loadChunk({ offset: 0, limit: 1000, needTotal: true,
|
|
7313
|
+
.loadChunk({ offset: 0, limit: 1000, needTotal: true, sourceId: lookupEntity.id })
|
|
7140
7314
|
.then(function (data) {
|
|
7315
|
+
var _a;
|
|
7141
7316
|
var _loop_1 = function (col) {
|
|
7142
7317
|
var attrs = lookupEntity.attributes.filter(function (attr) {
|
|
7143
7318
|
return attr.id == col.id && (attr.isPrimaryKey || attr.showInLookup);
|
|
@@ -7146,13 +7321,13 @@ var entity_form_builder_EntityEditFormBuilder = /** @class */ (function () {
|
|
|
7146
7321
|
lookupTable.columns.add(col);
|
|
7147
7322
|
}
|
|
7148
7323
|
};
|
|
7149
|
-
for (var _i = 0,
|
|
7150
|
-
var col =
|
|
7324
|
+
for (var _i = 0, _b = data.table.columns.getItems(); _i < _b.length; _i++) {
|
|
7325
|
+
var col = _b[_i];
|
|
7151
7326
|
_loop_1(col);
|
|
7152
7327
|
}
|
|
7153
7328
|
lookupTable.setTotal(data.total);
|
|
7154
|
-
for (var
|
|
7155
|
-
var row = _c
|
|
7329
|
+
for (var _c = 0, _d = data.table.getCachedRows(); _c < _d.length; _c++) {
|
|
7330
|
+
var row = _d[_c];
|
|
7156
7331
|
lookupTable.addRow(row);
|
|
7157
7332
|
}
|
|
7158
7333
|
var ds = new DefaultDialogService();
|
|
@@ -7191,7 +7366,9 @@ var entity_form_builder_EntityEditFormBuilder = /** @class */ (function () {
|
|
|
7191
7366
|
.join(', ');
|
|
7192
7367
|
};
|
|
7193
7368
|
if (selectedValue) {
|
|
7194
|
-
|
|
7369
|
+
var attr_1 = lookupEntity.getFirstPrimaryAttr();
|
|
7370
|
+
var key = attr_1.id.substring(attr_1.id.lastIndexOf('.') + 1);
|
|
7371
|
+
_this.context.fetchRecord((_a = {}, _a[key] = selectedValue, _a), lookupEntity.id)
|
|
7195
7372
|
.then(function (data) {
|
|
7196
7373
|
if (data.entity) {
|
|
7197
7374
|
updateSelectedValue(data.entity);
|
|
@@ -7239,7 +7416,7 @@ var entity_form_builder_EntityEditFormBuilder = /** @class */ (function () {
|
|
|
7239
7416
|
}); });
|
|
7240
7417
|
});
|
|
7241
7418
|
};
|
|
7242
|
-
EntityEditFormBuilder.prototype.setupDateTimeField = function (parent, attr, readOnly,
|
|
7419
|
+
EntityEditFormBuilder.prototype.setupDateTimeField = function (parent, attr, value, readOnly, hidden) {
|
|
7243
7420
|
var _this = this;
|
|
7244
7421
|
var horizClass = isIE
|
|
7245
7422
|
? 'kfrm-fields-ie is-horizontal'
|
|
@@ -7260,6 +7437,8 @@ var entity_form_builder_EntityEditFormBuilder = /** @class */ (function () {
|
|
|
7260
7437
|
.addClass(horizClass)
|
|
7261
7438
|
.addChild('input', function (b) {
|
|
7262
7439
|
inputEl = b.toDOM();
|
|
7440
|
+
b.name(attr.id);
|
|
7441
|
+
b.type(hidden ? 'hidden' : _this.resolveInputType(attr.dataType));
|
|
7263
7442
|
if (readOnly) {
|
|
7264
7443
|
b.attr('readonly', '');
|
|
7265
7444
|
}
|
|
@@ -7283,8 +7462,6 @@ var entity_form_builder_EntityEditFormBuilder = /** @class */ (function () {
|
|
|
7283
7462
|
}
|
|
7284
7463
|
});
|
|
7285
7464
|
}
|
|
7286
|
-
b.name(attr.id);
|
|
7287
|
-
b.type(_this.resolveInputType(attr.dataType));
|
|
7288
7465
|
b.value((utils_utils.IsDefinedAndNotNull(value)
|
|
7289
7466
|
? utils_utils.dateTimeToStr(value, editFormat)
|
|
7290
7467
|
: ''));
|
|
@@ -7326,7 +7503,7 @@ var entity_form_builder_EntityEditFormBuilder = /** @class */ (function () {
|
|
|
7326
7503
|
}).toDOM(); });
|
|
7327
7504
|
});
|
|
7328
7505
|
};
|
|
7329
|
-
EntityEditFormBuilder.prototype.setupListField = function (parent, attr,
|
|
7506
|
+
EntityEditFormBuilder.prototype.setupListField = function (parent, attr, value, values, readOnly) {
|
|
7330
7507
|
var _this = this;
|
|
7331
7508
|
domel(parent)
|
|
7332
7509
|
.addChild('div', function (b) { return b
|
|
@@ -7359,12 +7536,14 @@ var entity_form_builder_EntityEditFormBuilder = /** @class */ (function () {
|
|
|
7359
7536
|
b.attr('accept', accept);
|
|
7360
7537
|
});
|
|
7361
7538
|
};
|
|
7362
|
-
EntityEditFormBuilder.prototype.setupTextField = function (parent, attr, readOnly,
|
|
7539
|
+
EntityEditFormBuilder.prototype.setupTextField = function (parent, attr, value, readOnly, hidden) {
|
|
7363
7540
|
var _this = this;
|
|
7364
7541
|
domel(parent)
|
|
7365
7542
|
.addChild('input', function (b) {
|
|
7366
|
-
if (readOnly)
|
|
7543
|
+
if (readOnly) {
|
|
7367
7544
|
b.attr('readonly', '');
|
|
7545
|
+
}
|
|
7546
|
+
b.type(hidden ? 'hidden' : _this.resolveInputType(attr.dataType));
|
|
7368
7547
|
b.name(attr.id)
|
|
7369
7548
|
.type(_this.resolveInputType(attr.dataType));
|
|
7370
7549
|
if (attr.dataType == DataType.Bool) {
|
|
@@ -7379,7 +7558,7 @@ var entity_form_builder_EntityEditFormBuilder = /** @class */ (function () {
|
|
|
7379
7558
|
}
|
|
7380
7559
|
});
|
|
7381
7560
|
};
|
|
7382
|
-
EntityEditFormBuilder.prototype.setupTextArea = function (parent, attr,
|
|
7561
|
+
EntityEditFormBuilder.prototype.setupTextArea = function (parent, attr, value, readOnly) {
|
|
7383
7562
|
// feature: modify size in value editor ??
|
|
7384
7563
|
domel(parent)
|
|
7385
7564
|
.addChild('textarea', function (b) {
|
|
@@ -7387,6 +7566,9 @@ var entity_form_builder_EntityEditFormBuilder = /** @class */ (function () {
|
|
|
7387
7566
|
b.attr('readonly', '');
|
|
7388
7567
|
b.attr('name', attr.id);
|
|
7389
7568
|
b.setStyle('height', "120px");
|
|
7569
|
+
b.value(utils_utils.IsDefinedAndNotNull(value)
|
|
7570
|
+
? value.toString()
|
|
7571
|
+
: '');
|
|
7390
7572
|
});
|
|
7391
7573
|
};
|
|
7392
7574
|
EntityEditFormBuilder.prototype.addFormField = function (parent, attr) {
|
|
@@ -7413,16 +7595,17 @@ var entity_form_builder_EntityEditFormBuilder = /** @class */ (function () {
|
|
|
7413
7595
|
.setStyle('display', 'inline-block'); });
|
|
7414
7596
|
}
|
|
7415
7597
|
});
|
|
7598
|
+
var hidden = attr.isPrimaryKey;
|
|
7416
7599
|
if (attr.kind === EntityAttrKind.Lookup) {
|
|
7417
7600
|
this.setupLookupField(parent, attr, readOnly, value);
|
|
7418
7601
|
return;
|
|
7419
7602
|
}
|
|
7420
7603
|
switch (editor.tag) {
|
|
7421
7604
|
case EditorTag.DateTime:
|
|
7422
|
-
this.setupDateTimeField(parent, attr, readOnly,
|
|
7605
|
+
this.setupDateTimeField(parent, attr, value, readOnly, hidden);
|
|
7423
7606
|
break;
|
|
7424
7607
|
case EditorTag.List:
|
|
7425
|
-
this.setupListField(parent, attr,
|
|
7608
|
+
this.setupListField(parent, attr, value, editor.values, readOnly);
|
|
7426
7609
|
break;
|
|
7427
7610
|
case EditorTag.File:
|
|
7428
7611
|
this.setupFileField(parent, attr, readOnly, editor.accept);
|
|
@@ -7430,10 +7613,10 @@ var entity_form_builder_EntityEditFormBuilder = /** @class */ (function () {
|
|
|
7430
7613
|
case EditorTag.Edit:
|
|
7431
7614
|
default:
|
|
7432
7615
|
if (editor.multiline) {
|
|
7433
|
-
this.setupTextArea(parent, attr,
|
|
7616
|
+
this.setupTextArea(parent, attr, value, readOnly);
|
|
7434
7617
|
}
|
|
7435
7618
|
else {
|
|
7436
|
-
this.setupTextField(parent, attr, readOnly,
|
|
7619
|
+
this.setupTextField(parent, attr, value, readOnly, hidden);
|
|
7437
7620
|
}
|
|
7438
7621
|
break;
|
|
7439
7622
|
}
|
|
@@ -7485,13 +7668,15 @@ var entity_form_builder_EntityEditFormBuilder = /** @class */ (function () {
|
|
|
7485
7668
|
this.form['setHtmlInt'](formHtml);
|
|
7486
7669
|
for (var _i = 0, _a = this.context.getActiveEntity().attributes; _i < _a.length; _i++) {
|
|
7487
7670
|
var attr = _a[_i];
|
|
7488
|
-
if (
|
|
7489
|
-
if (
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
7671
|
+
if (!attr.isPrimaryKey) {
|
|
7672
|
+
if (this.params.isEditForm) {
|
|
7673
|
+
if (!attr.showOnEdit)
|
|
7674
|
+
continue;
|
|
7675
|
+
}
|
|
7676
|
+
else {
|
|
7677
|
+
if (!attr.showOnCreate)
|
|
7678
|
+
continue;
|
|
7679
|
+
}
|
|
7495
7680
|
}
|
|
7496
7681
|
this.addFormField(fb.toDOM(), attr);
|
|
7497
7682
|
}
|
|
@@ -7526,8 +7711,8 @@ var easy_data_server_loader_EasyDataServerLoader = /** @class */ (function () {
|
|
|
7526
7711
|
}
|
|
7527
7712
|
EasyDataServerLoader.prototype.loadChunk = function (params) {
|
|
7528
7713
|
var _this = this;
|
|
7529
|
-
var url = this.context.resolveEndpoint('
|
|
7530
|
-
delete params.
|
|
7714
|
+
var url = this.context.resolveEndpoint('FetchDataset', { sourceId: params.sourceId || this.context.getActiveEntity().id });
|
|
7715
|
+
delete params.sourceId;
|
|
7531
7716
|
this.context.startProcess();
|
|
7532
7717
|
var http = this.context.getHttpClient();
|
|
7533
7718
|
return http.post(url, params)
|
|
@@ -7564,6 +7749,17 @@ var easy_data_server_loader_EasyDataServerLoader = /** @class */ (function () {
|
|
|
7564
7749
|
|
|
7565
7750
|
|
|
7566
7751
|
// CONCATENATED MODULE: ./src/main/data_context.ts
|
|
7752
|
+
var data_context_assign = (undefined && undefined.__assign) || function () {
|
|
7753
|
+
data_context_assign = Object.assign || function(t) {
|
|
7754
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
7755
|
+
s = arguments[i];
|
|
7756
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7757
|
+
t[p] = s[p];
|
|
7758
|
+
}
|
|
7759
|
+
return t;
|
|
7760
|
+
};
|
|
7761
|
+
return data_context_assign.apply(this, arguments);
|
|
7762
|
+
};
|
|
7567
7763
|
|
|
7568
7764
|
|
|
7569
7765
|
|
|
@@ -7576,15 +7772,14 @@ var data_context_DataContext = /** @class */ (function () {
|
|
|
7576
7772
|
this.model = new meta_data_MetaData();
|
|
7577
7773
|
this.model.id = options.metaDataId || '__default';
|
|
7578
7774
|
this.dataLoader = new easy_data_server_loader_EasyDataServerLoader(this);
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
});
|
|
7775
|
+
var dataTableOptions = data_context_assign({ loader: this.dataLoader }, options.dataTable);
|
|
7776
|
+
this.data = new easy_data_table_EasyDataTable(dataTableOptions);
|
|
7582
7777
|
this.setDefaultEndpoints(this.options.endpoint || '/api/easydata');
|
|
7583
7778
|
}
|
|
7584
7779
|
DataContext.prototype.getActiveEntity = function () {
|
|
7585
7780
|
return this.activeEntity;
|
|
7586
7781
|
};
|
|
7587
|
-
DataContext.prototype.
|
|
7782
|
+
DataContext.prototype.setActiveSource = function (entityId) {
|
|
7588
7783
|
this.activeEntity = this.model.getRootEntity().subEntities
|
|
7589
7784
|
.filter(function (e) { return e.id == entityId; })[0];
|
|
7590
7785
|
};
|
|
@@ -7597,8 +7792,8 @@ var data_context_DataContext = /** @class */ (function () {
|
|
|
7597
7792
|
DataContext.prototype.getDataLoader = function () {
|
|
7598
7793
|
return this.dataLoader;
|
|
7599
7794
|
};
|
|
7600
|
-
DataContext.prototype.createFilter = function (
|
|
7601
|
-
return new text_data_filter_TextDataFilter(this.dataLoader, data || this.getData(),
|
|
7795
|
+
DataContext.prototype.createFilter = function (sourceId, data, isLookup) {
|
|
7796
|
+
return new text_data_filter_TextDataFilter(this.dataLoader, data || this.getData(), sourceId || this.activeEntity.id, isLookup);
|
|
7602
7797
|
};
|
|
7603
7798
|
DataContext.prototype.loadMetaData = function () {
|
|
7604
7799
|
var _this = this;
|
|
@@ -7622,7 +7817,7 @@ var data_context_DataContext = /** @class */ (function () {
|
|
|
7622
7817
|
DataContext.prototype.getHttpClient = function () {
|
|
7623
7818
|
return this.http;
|
|
7624
7819
|
};
|
|
7625
|
-
DataContext.prototype.
|
|
7820
|
+
DataContext.prototype.fetchDataset = function () {
|
|
7626
7821
|
var _this = this;
|
|
7627
7822
|
this.data.clear();
|
|
7628
7823
|
return this.dataLoader.loadChunk({ offset: 0, limit: this.data.chunkSize, needTotal: true })
|
|
@@ -7639,33 +7834,33 @@ var data_context_DataContext = /** @class */ (function () {
|
|
|
7639
7834
|
return _this.data;
|
|
7640
7835
|
});
|
|
7641
7836
|
};
|
|
7642
|
-
DataContext.prototype.
|
|
7837
|
+
DataContext.prototype.fetchRecord = function (keys, sourceId) {
|
|
7643
7838
|
var _this = this;
|
|
7644
|
-
var url = this.resolveEndpoint('
|
|
7645
|
-
entityId: entityId || this.activeEntity.id });
|
|
7839
|
+
var url = this.resolveEndpoint('FetchRecord', { sourceId: sourceId || this.activeEntity.id });
|
|
7646
7840
|
this.startProcess();
|
|
7647
|
-
return this.http.get(url)
|
|
7841
|
+
return this.http.get(url, { queryParams: keys })
|
|
7648
7842
|
.finally(function () { return _this.endProcess(); });
|
|
7649
7843
|
};
|
|
7650
|
-
DataContext.prototype.
|
|
7844
|
+
DataContext.prototype.createRecord = function (obj, sourceId) {
|
|
7651
7845
|
var _this = this;
|
|
7652
|
-
var url = this.resolveEndpoint('
|
|
7846
|
+
var url = this.resolveEndpoint('CreateRecord', { sourceId: sourceId || this.activeEntity.id });
|
|
7653
7847
|
this.startProcess();
|
|
7654
|
-
return this.http.post(url, obj, { dataType: 'json' })
|
|
7848
|
+
return this.http.post(url, obj, { dataType: 'json' })
|
|
7849
|
+
.finally(function () { return _this.endProcess(); });
|
|
7655
7850
|
};
|
|
7656
|
-
DataContext.prototype.
|
|
7851
|
+
DataContext.prototype.updateRecord = function (obj, sourceId) {
|
|
7657
7852
|
var _this = this;
|
|
7658
|
-
var url = this.resolveEndpoint('
|
|
7659
|
-
entityId: entityId || this.activeEntity.id });
|
|
7853
|
+
var url = this.resolveEndpoint('UpdateRecord', { sourceId: sourceId || this.activeEntity.id });
|
|
7660
7854
|
this.startProcess();
|
|
7661
|
-
return this.http.post(url, obj, { dataType: 'json' })
|
|
7855
|
+
return this.http.post(url, obj, { dataType: 'json' })
|
|
7856
|
+
.finally(function () { return _this.endProcess(); });
|
|
7662
7857
|
};
|
|
7663
|
-
DataContext.prototype.
|
|
7858
|
+
DataContext.prototype.deleteRecord = function (obj, sourceId) {
|
|
7664
7859
|
var _this = this;
|
|
7665
|
-
var url = this.resolveEndpoint('
|
|
7666
|
-
entityId: entityId || this.activeEntity.id });
|
|
7860
|
+
var url = this.resolveEndpoint('DeleteRecord', { sourceId: sourceId || this.activeEntity.id });
|
|
7667
7861
|
this.startProcess();
|
|
7668
|
-
return this.http.post(url,
|
|
7862
|
+
return this.http.post(url, obj, { dataType: 'json' })
|
|
7863
|
+
.finally(function () { return _this.endProcess(); });
|
|
7669
7864
|
};
|
|
7670
7865
|
DataContext.prototype.setEndpoint = function (key, value) {
|
|
7671
7866
|
this.endpoints.set(key, value);
|
|
@@ -7690,7 +7885,7 @@ var data_context_DataContext = /** @class */ (function () {
|
|
|
7690
7885
|
if (opt == 'modelId') {
|
|
7691
7886
|
optVal = this.model.getId();
|
|
7692
7887
|
}
|
|
7693
|
-
else if (opt == '
|
|
7888
|
+
else if (opt == 'sourceId') {
|
|
7694
7889
|
optVal = this.activeEntity.id;
|
|
7695
7890
|
}
|
|
7696
7891
|
else {
|
|
@@ -7712,11 +7907,11 @@ var data_context_DataContext = /** @class */ (function () {
|
|
|
7712
7907
|
};
|
|
7713
7908
|
DataContext.prototype.setDefaultEndpoints = function (endpointBase) {
|
|
7714
7909
|
this.setEnpointIfNotExist('GetMetaData', combinePath(endpointBase, 'models/{modelId}'));
|
|
7715
|
-
this.setEnpointIfNotExist('
|
|
7716
|
-
this.setEnpointIfNotExist('
|
|
7717
|
-
this.setEnpointIfNotExist('
|
|
7718
|
-
this.setEnpointIfNotExist('
|
|
7719
|
-
this.setEnpointIfNotExist('
|
|
7910
|
+
this.setEnpointIfNotExist('FetchDataset', combinePath(endpointBase, 'models/{modelId}/sources/{sourceId}/fetch'));
|
|
7911
|
+
this.setEnpointIfNotExist('FetchRecord', combinePath(endpointBase, 'models/{modelId}/sources/{sourceId}/fetch'));
|
|
7912
|
+
this.setEnpointIfNotExist('CreateRecord', combinePath(endpointBase, 'models/{modelId}/sources/{sourceId}/create'));
|
|
7913
|
+
this.setEnpointIfNotExist('UpdateRecord', combinePath(endpointBase, 'models/{modelId}/sources/{sourceId}/update'));
|
|
7914
|
+
this.setEnpointIfNotExist('DeleteRecord', combinePath(endpointBase, 'models/{modelId}/sources/{sourceId}/delete'));
|
|
7720
7915
|
};
|
|
7721
7916
|
return DataContext;
|
|
7722
7917
|
}());
|
|
@@ -7822,10 +8017,12 @@ var entity_data_view_EntityDataView = /** @class */ (function () {
|
|
|
7822
8017
|
showBackToEntities: true
|
|
7823
8018
|
};
|
|
7824
8019
|
this.defaultValidators = [new required_validator_RequiredValidator(), new type_validator_TypeValidator()];
|
|
7825
|
-
options = options || {};
|
|
7826
8020
|
this.options = utils_utils.assignDeep(this.options, options || {});
|
|
7827
8021
|
this.dlg = new DefaultDialogService();
|
|
7828
8022
|
var ent = this.context.getActiveEntity();
|
|
8023
|
+
if (!ent) {
|
|
8024
|
+
throw "Can't find active entity for " + window.location.pathname;
|
|
8025
|
+
}
|
|
7829
8026
|
this.slot.innerHTML += "<h1>" + (ent.captionPlural || ent.caption) + "</h1>";
|
|
7830
8027
|
if (this.options.showBackToEntities) {
|
|
7831
8028
|
domel(this.slot)
|
|
@@ -7849,7 +8046,7 @@ var entity_data_view_EntityDataView = /** @class */ (function () {
|
|
|
7849
8046
|
};
|
|
7850
8047
|
EntityDataView.prototype.renderGrid = function () {
|
|
7851
8048
|
var _this = this;
|
|
7852
|
-
this.context.
|
|
8049
|
+
this.context.fetchDataset()
|
|
7853
8050
|
.then(function (result) {
|
|
7854
8051
|
var gridSlot = document.createElement('div');
|
|
7855
8052
|
_this.slot.appendChild(gridSlot);
|
|
@@ -7862,10 +8059,10 @@ var entity_data_view_EntityDataView = /** @class */ (function () {
|
|
|
7862
8059
|
allowPageSizeChange: true,
|
|
7863
8060
|
pageSizeItems: [15, 30, 50, 100, 200]
|
|
7864
8061
|
},
|
|
7865
|
-
|
|
7866
|
-
|
|
8062
|
+
showPlusButton: _this.context.getActiveEntity().isEditable,
|
|
8063
|
+
plusButtonTitle: i18n_i18n.getText('AddRecordBtnTitle'),
|
|
7867
8064
|
showActiveRow: false,
|
|
7868
|
-
|
|
8065
|
+
onPlusButtonClick: _this.addClickHandler.bind(_this),
|
|
7869
8066
|
onGetCellRenderer: _this.manageCellRenderer.bind(_this),
|
|
7870
8067
|
onRowDbClick: _this.rowDbClickHandler.bind(_this),
|
|
7871
8068
|
onSyncGridColumn: _this.syncGridColumnHandler.bind(_this)
|
|
@@ -7920,7 +8117,7 @@ var entity_data_view_EntityDataView = /** @class */ (function () {
|
|
|
7920
8117
|
if (!form.validate())
|
|
7921
8118
|
return false;
|
|
7922
8119
|
form.getData()
|
|
7923
|
-
.then(function (obj) { return _this.context.
|
|
8120
|
+
.then(function (obj) { return _this.context.createRecord(obj); })
|
|
7924
8121
|
.then(function () {
|
|
7925
8122
|
return _this.refreshData();
|
|
7926
8123
|
})
|
|
@@ -7951,12 +8148,10 @@ var entity_data_view_EntityDataView = /** @class */ (function () {
|
|
|
7951
8148
|
.replace('{entity}', activeEntity.caption),
|
|
7952
8149
|
body: form.getHtml(),
|
|
7953
8150
|
onSubmit: function () {
|
|
7954
|
-
var keyAttrs = activeEntity.attributes.filter(function (attr) { return attr.isPrimaryKey; });
|
|
7955
|
-
var keys = keyAttrs.map(function (attr) { return row.getValue(attr.id); });
|
|
7956
8151
|
if (!form.validate())
|
|
7957
8152
|
return false;
|
|
7958
8153
|
form.getData()
|
|
7959
|
-
.then(function (obj) { return _this.context.
|
|
8154
|
+
.then(function (obj) { return _this.context.updateRecord(obj); })
|
|
7960
8155
|
.then(function () {
|
|
7961
8156
|
return _this.refreshData();
|
|
7962
8157
|
})
|
|
@@ -7977,16 +8172,20 @@ var entity_data_view_EntityDataView = /** @class */ (function () {
|
|
|
7977
8172
|
.then(function (row) {
|
|
7978
8173
|
if (row) {
|
|
7979
8174
|
var activeEntity = _this.context.getActiveEntity();
|
|
7980
|
-
var keyAttrs = activeEntity.
|
|
7981
|
-
var
|
|
7982
|
-
var
|
|
8175
|
+
var keyAttrs = activeEntity.getPrimaryAttrs();
|
|
8176
|
+
var keyVals_1 = keyAttrs.map(function (attr) { return row.getValue(attr.id); });
|
|
8177
|
+
var keys_1 = keyAttrs.reduce(function (val, attr, index) {
|
|
8178
|
+
var property = attr.id.substring(attr.id.lastIndexOf('.') + 1);
|
|
8179
|
+
val[property] = keyVals_1[index];
|
|
8180
|
+
return val;
|
|
8181
|
+
}, {});
|
|
7983
8182
|
_this.dlg.openConfirm(i18n_i18n.getText('DeleteDlgCaption')
|
|
7984
8183
|
.replace('{entity}', activeEntity.caption), i18n_i18n.getText('DeleteDlgMessage')
|
|
7985
|
-
.replace('{
|
|
8184
|
+
.replace('{recordId}', Object.keys(keys_1)
|
|
8185
|
+
.map(function (key) { return key + ":" + keys_1[key]; }).join(';')))
|
|
7986
8186
|
.then(function (result) {
|
|
7987
8187
|
if (result) {
|
|
7988
|
-
|
|
7989
|
-
_this.context.deleteEntity(keys_1.join(':'))
|
|
8188
|
+
_this.context.deleteRecord(keys_1)
|
|
7990
8189
|
.then(function () {
|
|
7991
8190
|
return _this.refreshData();
|
|
7992
8191
|
})
|
|
@@ -8008,7 +8207,7 @@ var entity_data_view_EntityDataView = /** @class */ (function () {
|
|
|
8008
8207
|
};
|
|
8009
8208
|
EntityDataView.prototype.refreshData = function () {
|
|
8010
8209
|
var _this = this;
|
|
8011
|
-
return this.context.
|
|
8210
|
+
return this.context.fetchDataset()
|
|
8012
8211
|
.then(function () {
|
|
8013
8212
|
_this.grid.refresh();
|
|
8014
8213
|
});
|
|
@@ -8076,50 +8275,62 @@ var root_data_view_RootDataView = /** @class */ (function () {
|
|
|
8076
8275
|
var easy_data_view_dispatcher_EasyDataViewDispatcher = /** @class */ (function () {
|
|
8077
8276
|
function EasyDataViewDispatcher(options) {
|
|
8078
8277
|
var _this = this;
|
|
8079
|
-
this.options = {
|
|
8278
|
+
this.options = {
|
|
8279
|
+
container: '#EasyDataContainer',
|
|
8280
|
+
basePath: 'easydata'
|
|
8281
|
+
};
|
|
8080
8282
|
this.onSetLocation = function () {
|
|
8081
8283
|
_this.setActiveView();
|
|
8082
8284
|
};
|
|
8083
|
-
options = options || {};
|
|
8084
|
-
|
|
8085
|
-
this.options.basePath = (!this.options.rootEntity)
|
|
8086
|
-
? this.pretiffyPath(this.options.basePath)
|
|
8087
|
-
: this.pretiffyPath(window.location.pathname);
|
|
8088
|
-
if (this.options.rootEntity)
|
|
8285
|
+
this.options = utils_utils.assign(this.options, options || {});
|
|
8286
|
+
if (this.options.rootEntity) {
|
|
8089
8287
|
this.options.showBackToEntities = false;
|
|
8090
|
-
|
|
8288
|
+
this.basePath = '/';
|
|
8289
|
+
}
|
|
8290
|
+
else {
|
|
8291
|
+
this.basePath = this.normalizeBasePath(this.options.basePath);
|
|
8292
|
+
}
|
|
8293
|
+
this.setContainer(this.options.container);
|
|
8091
8294
|
var progressBarSlot = document.createElement('div');
|
|
8092
8295
|
var bar = new ProgressBar(progressBarSlot);
|
|
8093
8296
|
var parent = this.container.parentElement;
|
|
8094
8297
|
parent.insertBefore(progressBarSlot, parent.firstElementChild);
|
|
8095
8298
|
this.context = new data_context_DataContext({
|
|
8096
|
-
endpoint: options.endpoint,
|
|
8299
|
+
endpoint: this.options.endpoint,
|
|
8300
|
+
dataTable: this.options.dataTable,
|
|
8097
8301
|
onProcessStart: function () { return bar.show(); },
|
|
8098
8302
|
onProcessEnd: function () { return bar.hide(); }
|
|
8099
8303
|
});
|
|
8100
|
-
this.basePath = this.getBasePath();
|
|
8101
8304
|
}
|
|
8102
|
-
EasyDataViewDispatcher.prototype.
|
|
8305
|
+
EasyDataViewDispatcher.prototype.normalizeBasePath = function (basePath) {
|
|
8306
|
+
basePath = this.trimSlashes(basePath);
|
|
8307
|
+
var fullPath = decodeURIComponent(window.location.pathname);
|
|
8308
|
+
var idx = fullPath.toLocaleLowerCase().indexOf(basePath);
|
|
8309
|
+
return idx >= 0 ? fullPath.substring(0, idx + basePath.length) : '/';
|
|
8310
|
+
};
|
|
8311
|
+
EasyDataViewDispatcher.prototype.trimSlashes = function (path) {
|
|
8103
8312
|
return path.replace(/^\/|\/$/g, '');
|
|
8104
8313
|
};
|
|
8105
8314
|
EasyDataViewDispatcher.prototype.setContainer = function (container) {
|
|
8106
8315
|
if (!container) {
|
|
8107
|
-
|
|
8108
|
-
return;
|
|
8316
|
+
throw 'Container is undefined';
|
|
8109
8317
|
}
|
|
8110
8318
|
if (typeof container === 'string') {
|
|
8111
8319
|
if (container.length) {
|
|
8112
|
-
if (container[0] === '
|
|
8113
|
-
this.container = document.getElementById(container.substring(1));
|
|
8114
|
-
}
|
|
8115
|
-
else if (container[0] === '.') {
|
|
8320
|
+
if (container[0] === '.') {
|
|
8116
8321
|
var result = document.getElementsByClassName(container.substring(1));
|
|
8117
8322
|
if (result.length)
|
|
8118
8323
|
this.container = result[0];
|
|
8119
8324
|
}
|
|
8120
8325
|
else {
|
|
8121
|
-
|
|
8122
|
-
|
|
8326
|
+
if (container[0] === '#') {
|
|
8327
|
+
container = container.substring(1);
|
|
8328
|
+
}
|
|
8329
|
+
this.container = document.getElementById(container);
|
|
8330
|
+
}
|
|
8331
|
+
if (!this.container) {
|
|
8332
|
+
throw Error('Unrecognized `container` parameter: ' + container + '\n'
|
|
8333
|
+
+ 'It must be an element ID, a class name (starting with .) or an HTMLElement object itself.');
|
|
8123
8334
|
}
|
|
8124
8335
|
}
|
|
8125
8336
|
}
|
|
@@ -8127,20 +8338,12 @@ var easy_data_view_dispatcher_EasyDataViewDispatcher = /** @class */ (function (
|
|
|
8127
8338
|
this.container = container;
|
|
8128
8339
|
}
|
|
8129
8340
|
};
|
|
8130
|
-
EasyDataViewDispatcher.prototype.
|
|
8341
|
+
EasyDataViewDispatcher.prototype.getActiveSourceId = function () {
|
|
8131
8342
|
if (this.options.rootEntity)
|
|
8132
8343
|
return this.options.rootEntity;
|
|
8133
|
-
var
|
|
8134
|
-
var
|
|
8135
|
-
|
|
8136
|
-
return typeName && typeName.toLocaleLowerCase() !== this.options.basePath
|
|
8137
|
-
? typeName
|
|
8138
|
-
: null;
|
|
8139
|
-
};
|
|
8140
|
-
EasyDataViewDispatcher.prototype.getBasePath = function () {
|
|
8141
|
-
var decodedUrl = decodeURIComponent(window.location.href);
|
|
8142
|
-
var optBasePathIndex = decodedUrl.toLocaleLowerCase().indexOf(this.options.basePath);
|
|
8143
|
-
return decodedUrl.substring(0, optBasePathIndex + this.options.basePath.length);
|
|
8344
|
+
var path = decodeURIComponent(window.location.pathname);
|
|
8345
|
+
var idIndex = this.basePath.length + 1;
|
|
8346
|
+
return idIndex < path.length ? path.substring(idIndex) : null;
|
|
8144
8347
|
};
|
|
8145
8348
|
EasyDataViewDispatcher.prototype.run = function () {
|
|
8146
8349
|
var _this = this;
|
|
@@ -8153,9 +8356,9 @@ var easy_data_view_dispatcher_EasyDataViewDispatcher = /** @class */ (function (
|
|
|
8153
8356
|
};
|
|
8154
8357
|
EasyDataViewDispatcher.prototype.setActiveView = function () {
|
|
8155
8358
|
this.clear();
|
|
8156
|
-
var
|
|
8157
|
-
if (
|
|
8158
|
-
this.context.
|
|
8359
|
+
var sourceId = this.getActiveSourceId();
|
|
8360
|
+
if (sourceId) {
|
|
8361
|
+
this.context.setActiveSource(sourceId);
|
|
8159
8362
|
window['EDView'] = new entity_data_view_EntityDataView(this.container, this.context, this.basePath, this.options);
|
|
8160
8363
|
}
|
|
8161
8364
|
else {
|
|
@@ -8188,13 +8391,14 @@ function addEasyDataCRUDTexts() {
|
|
|
8188
8391
|
CalendarBtnTitle: 'Open calendar',
|
|
8189
8392
|
TimerBtnTitle: 'Open timer',
|
|
8190
8393
|
AddBtnTitle: 'Add',
|
|
8394
|
+
AddRecordBtnTitle: 'Add record',
|
|
8191
8395
|
EditBtn: 'Edit',
|
|
8192
8396
|
DeleteBtn: 'Delete',
|
|
8193
8397
|
SelectLink: '[ select ]',
|
|
8194
8398
|
AddDlgCaption: 'Create {entity}',
|
|
8195
8399
|
EditDlgCaption: 'Edit {entity}',
|
|
8196
8400
|
DeleteDlgCaption: 'Delete {entity}',
|
|
8197
|
-
DeleteDlgMessage: 'Are you
|
|
8401
|
+
DeleteDlgMessage: 'Are you sure you want to remove this record: {{recordId}}?',
|
|
8198
8402
|
EntityMenuDesc: 'Click on an entity to view/edit its content',
|
|
8199
8403
|
BackToEntities: 'Back to entities',
|
|
8200
8404
|
SearchBtn: 'Search',
|