@universis/ngx-tables 0.6.18 → 0.6.19
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/bundles/universis-ngx-tables.umd.js +53 -22
- package/bundles/universis-ngx-tables.umd.js.map +1 -1
- package/bundles/universis-ngx-tables.umd.min.js +1 -1
- package/bundles/universis-ngx-tables.umd.min.js.map +1 -1
- package/esm2015/lib/components/advanced-search-form/advanced-search-form.component.js +5 -2
- package/esm2015/lib/components/advanced-table/advanced-table.component.js +50 -22
- package/esm5/lib/components/advanced-search-form/advanced-search-form.component.js +5 -2
- package/esm5/lib/components/advanced-table/advanced-table.component.js +50 -22
- package/fesm2015/universis-ngx-tables.js +53 -22
- package/fesm2015/universis-ngx-tables.js.map +1 -1
- package/fesm5/universis-ngx-tables.js +53 -22
- package/fesm5/universis-ngx-tables.js.map +1 -1
- package/package.json +1 -1
|
@@ -927,32 +927,55 @@
|
|
|
927
927
|
AdvancedTableComponent.prototype.search = function (searchText) {
|
|
928
928
|
var _this = this;
|
|
929
929
|
this.query = this.query || this._context.model(this.config.model).asQueryable();
|
|
930
|
-
if (
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
930
|
+
if (this.serverSide) {
|
|
931
|
+
if (searchText && this.config.searchExpression) {
|
|
932
|
+
// validate search text in double quotes
|
|
933
|
+
if (/^"(.*?)"$/.test(searchText)) {
|
|
934
|
+
this.query.setParam('$filter', this._template.transform(this.config.searchExpression, {
|
|
935
|
+
text: searchText.replace(/^"|"$/g, ''),
|
|
936
|
+
}));
|
|
937
|
+
}
|
|
938
|
+
else {
|
|
939
|
+
// try to split words
|
|
940
|
+
var words = searchText.split(' ');
|
|
941
|
+
// join words to a single filter
|
|
942
|
+
var filter = words.map(function (word) {
|
|
943
|
+
return _this._template.transform(_this.config.searchExpression, {
|
|
944
|
+
text: word,
|
|
945
|
+
});
|
|
946
|
+
}).join(' and ');
|
|
947
|
+
// set filter
|
|
948
|
+
this.query.setParam('$filter', filter);
|
|
949
|
+
}
|
|
936
950
|
}
|
|
937
951
|
else {
|
|
938
|
-
//
|
|
939
|
-
|
|
940
|
-
// join words to a single filter
|
|
941
|
-
var filter = words.map(function (word) {
|
|
942
|
-
return _this._template.transform(_this.config.searchExpression, {
|
|
943
|
-
text: word,
|
|
944
|
-
});
|
|
945
|
-
}).join(' and ');
|
|
946
|
-
// set filter
|
|
947
|
-
this.query.setParam('$filter', filter);
|
|
952
|
+
// clear filter
|
|
953
|
+
this.query.setParam('$filter', null);
|
|
948
954
|
}
|
|
955
|
+
this._firstLoad = false;
|
|
956
|
+
this.dataTable.draw();
|
|
949
957
|
}
|
|
950
958
|
else {
|
|
951
|
-
//
|
|
952
|
-
this.
|
|
959
|
+
// ensure empty table layout
|
|
960
|
+
this.resetEmptyTable();
|
|
961
|
+
// search locally
|
|
962
|
+
this.dataTable.search(searchText.trim()).draw();
|
|
963
|
+
// get indexes of filtered rows
|
|
964
|
+
var indexes = Array.from(this.dataTable.context[0].aiDisplay);
|
|
965
|
+
// set recordsFiltered
|
|
966
|
+
var recordsFiltered = indexes.length;
|
|
967
|
+
// set recordsTotal
|
|
968
|
+
var recordsTotal = indexes.length;
|
|
969
|
+
// retrieve data from indexes
|
|
970
|
+
var rows_1 = Array.from(this.dataTable.rows().data());
|
|
971
|
+
var data = indexes.map(function (index) { return rows_1[index]; });
|
|
972
|
+
// emit results to load output
|
|
973
|
+
this.load.emit({
|
|
974
|
+
data: data,
|
|
975
|
+
recordsFiltered: recordsFiltered,
|
|
976
|
+
recordsTotal: recordsTotal
|
|
977
|
+
});
|
|
953
978
|
}
|
|
954
|
-
this._firstLoad = false;
|
|
955
|
-
this.dataTable.draw();
|
|
956
979
|
};
|
|
957
980
|
AdvancedTableComponent.prototype.fetch = function (clearSelected) {
|
|
958
981
|
// if data table is null
|
|
@@ -1622,6 +1645,10 @@
|
|
|
1622
1645
|
var query_1 = this._context.model(this.config.model).asQueryable();
|
|
1623
1646
|
// select attributes
|
|
1624
1647
|
query_1.setParam('$select', this.lastQueryParams.$select);
|
|
1648
|
+
if (this.lastQueryParams.$expand) {
|
|
1649
|
+
// apply expand attributes
|
|
1650
|
+
query_1.setParam('$expand', this.lastQueryParams.$expand);
|
|
1651
|
+
}
|
|
1625
1652
|
// apply filter for row
|
|
1626
1653
|
findKeys_1.forEach(function (key) {
|
|
1627
1654
|
var column = _this.config.columns.find(function (col) {
|
|
@@ -1708,7 +1735,8 @@
|
|
|
1708
1735
|
// due to ng data binding
|
|
1709
1736
|
// empty table template has no translated text during ngOnInit()
|
|
1710
1737
|
if (this.dataTable && this.dataTable.context[0]) {
|
|
1711
|
-
this.dataTable.context[0].oLanguage.sEmptyTable =
|
|
1738
|
+
this.dataTable.context[0].oLanguage.sEmptyTable =
|
|
1739
|
+
this.dataTable.context[0].oLanguage.sZeroRecords = this.emptyTable.nativeElement.innerHTML;
|
|
1712
1740
|
}
|
|
1713
1741
|
};
|
|
1714
1742
|
AdvancedTableComponent.prototype.clearEmptyTable = function () {
|
|
@@ -2268,7 +2296,10 @@
|
|
|
2268
2296
|
var value = _this.formComponent.submission.data[key];
|
|
2269
2297
|
// the filter with type is a string and is not empty
|
|
2270
2298
|
var isEmptyString = typeof value === 'string' && value.length === 0;
|
|
2271
|
-
|
|
2299
|
+
// do not include empty objects in filter
|
|
2300
|
+
var isEmptyObject = typeof value === 'object' && Object.keys(value).length === 0;
|
|
2301
|
+
// make isEmptyString, isEmptyObject mutex
|
|
2302
|
+
if (!isEmptyString && !isEmptyObject) {
|
|
2272
2303
|
Object.defineProperty(_this.filter, key, {
|
|
2273
2304
|
configurable: true,
|
|
2274
2305
|
enumerable: true,
|