@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
|
@@ -667,32 +667,55 @@ class AdvancedTableComponent {
|
|
|
667
667
|
// simple search
|
|
668
668
|
search(searchText) {
|
|
669
669
|
this.query = this.query || this._context.model(this.config.model).asQueryable();
|
|
670
|
-
if (
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
670
|
+
if (this.serverSide) {
|
|
671
|
+
if (searchText && this.config.searchExpression) {
|
|
672
|
+
// validate search text in double quotes
|
|
673
|
+
if (/^"(.*?)"$/.test(searchText)) {
|
|
674
|
+
this.query.setParam('$filter', this._template.transform(this.config.searchExpression, {
|
|
675
|
+
text: searchText.replace(/^"|"$/g, ''),
|
|
676
|
+
}));
|
|
677
|
+
}
|
|
678
|
+
else {
|
|
679
|
+
// try to split words
|
|
680
|
+
const words = searchText.split(' ');
|
|
681
|
+
// join words to a single filter
|
|
682
|
+
const filter = words.map((word) => {
|
|
683
|
+
return this._template.transform(this.config.searchExpression, {
|
|
684
|
+
text: word,
|
|
685
|
+
});
|
|
686
|
+
}).join(' and ');
|
|
687
|
+
// set filter
|
|
688
|
+
this.query.setParam('$filter', filter);
|
|
689
|
+
}
|
|
676
690
|
}
|
|
677
691
|
else {
|
|
678
|
-
//
|
|
679
|
-
|
|
680
|
-
// join words to a single filter
|
|
681
|
-
const filter = words.map((word) => {
|
|
682
|
-
return this._template.transform(this.config.searchExpression, {
|
|
683
|
-
text: word,
|
|
684
|
-
});
|
|
685
|
-
}).join(' and ');
|
|
686
|
-
// set filter
|
|
687
|
-
this.query.setParam('$filter', filter);
|
|
692
|
+
// clear filter
|
|
693
|
+
this.query.setParam('$filter', null);
|
|
688
694
|
}
|
|
695
|
+
this._firstLoad = false;
|
|
696
|
+
this.dataTable.draw();
|
|
689
697
|
}
|
|
690
698
|
else {
|
|
691
|
-
//
|
|
692
|
-
this.
|
|
699
|
+
// ensure empty table layout
|
|
700
|
+
this.resetEmptyTable();
|
|
701
|
+
// search locally
|
|
702
|
+
this.dataTable.search(searchText.trim()).draw();
|
|
703
|
+
// get indexes of filtered rows
|
|
704
|
+
const indexes = Array.from(this.dataTable.context[0].aiDisplay);
|
|
705
|
+
// set recordsFiltered
|
|
706
|
+
const recordsFiltered = indexes.length;
|
|
707
|
+
// set recordsTotal
|
|
708
|
+
const recordsTotal = indexes.length;
|
|
709
|
+
// retrieve data from indexes
|
|
710
|
+
const rows = Array.from(this.dataTable.rows().data());
|
|
711
|
+
const data = indexes.map(index => rows[index]);
|
|
712
|
+
// emit results to load output
|
|
713
|
+
this.load.emit({
|
|
714
|
+
data: data,
|
|
715
|
+
recordsFiltered: recordsFiltered,
|
|
716
|
+
recordsTotal: recordsTotal
|
|
717
|
+
});
|
|
693
718
|
}
|
|
694
|
-
this._firstLoad = false;
|
|
695
|
-
this.dataTable.draw();
|
|
696
719
|
}
|
|
697
720
|
fetch(clearSelected) {
|
|
698
721
|
// if data table is null
|
|
@@ -1355,6 +1378,10 @@ class AdvancedTableComponent {
|
|
|
1355
1378
|
const query = this._context.model(this.config.model).asQueryable();
|
|
1356
1379
|
// select attributes
|
|
1357
1380
|
query.setParam('$select', this.lastQueryParams.$select);
|
|
1381
|
+
if (this.lastQueryParams.$expand) {
|
|
1382
|
+
// apply expand attributes
|
|
1383
|
+
query.setParam('$expand', this.lastQueryParams.$expand);
|
|
1384
|
+
}
|
|
1358
1385
|
// apply filter for row
|
|
1359
1386
|
findKeys.forEach((key) => {
|
|
1360
1387
|
const column = this.config.columns.find((col) => {
|
|
@@ -1441,7 +1468,8 @@ class AdvancedTableComponent {
|
|
|
1441
1468
|
// due to ng data binding
|
|
1442
1469
|
// empty table template has no translated text during ngOnInit()
|
|
1443
1470
|
if (this.dataTable && this.dataTable.context[0]) {
|
|
1444
|
-
this.dataTable.context[0].oLanguage.sEmptyTable =
|
|
1471
|
+
this.dataTable.context[0].oLanguage.sEmptyTable =
|
|
1472
|
+
this.dataTable.context[0].oLanguage.sZeroRecords = this.emptyTable.nativeElement.innerHTML;
|
|
1445
1473
|
}
|
|
1446
1474
|
}
|
|
1447
1475
|
clearEmptyTable() {
|
|
@@ -1983,7 +2011,10 @@ class AdvancedSearchFormComponent extends AdvancedTableSearchBaseComponent {
|
|
|
1983
2011
|
const value = this.formComponent.submission.data[key];
|
|
1984
2012
|
// the filter with type is a string and is not empty
|
|
1985
2013
|
const isEmptyString = typeof value === 'string' && value.length === 0;
|
|
1986
|
-
|
|
2014
|
+
// do not include empty objects in filter
|
|
2015
|
+
const isEmptyObject = typeof value === 'object' && Object.keys(value).length === 0;
|
|
2016
|
+
// make isEmptyString, isEmptyObject mutex
|
|
2017
|
+
if (!isEmptyString && !isEmptyObject) {
|
|
1987
2018
|
Object.defineProperty(this.filter, key, {
|
|
1988
2019
|
configurable: true,
|
|
1989
2020
|
enumerable: true,
|