@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.
@@ -748,32 +748,55 @@ var AdvancedTableComponent = /** @class */ (function () {
748
748
  AdvancedTableComponent.prototype.search = function (searchText) {
749
749
  var _this = this;
750
750
  this.query = this.query || this._context.model(this.config.model).asQueryable();
751
- if (searchText && this.config.searchExpression) {
752
- // validate search text in double quotes
753
- if (/^"(.*?)"$/.test(searchText)) {
754
- this.query.setParam('$filter', this._template.transform(this.config.searchExpression, {
755
- text: searchText.replace(/^"|"$/g, ''),
756
- }));
751
+ if (this.serverSide) {
752
+ if (searchText && this.config.searchExpression) {
753
+ // validate search text in double quotes
754
+ if (/^"(.*?)"$/.test(searchText)) {
755
+ this.query.setParam('$filter', this._template.transform(this.config.searchExpression, {
756
+ text: searchText.replace(/^"|"$/g, ''),
757
+ }));
758
+ }
759
+ else {
760
+ // try to split words
761
+ var words = searchText.split(' ');
762
+ // join words to a single filter
763
+ var filter = words.map(function (word) {
764
+ return _this._template.transform(_this.config.searchExpression, {
765
+ text: word,
766
+ });
767
+ }).join(' and ');
768
+ // set filter
769
+ this.query.setParam('$filter', filter);
770
+ }
757
771
  }
758
772
  else {
759
- // try to split words
760
- var words = searchText.split(' ');
761
- // join words to a single filter
762
- var filter = words.map(function (word) {
763
- return _this._template.transform(_this.config.searchExpression, {
764
- text: word,
765
- });
766
- }).join(' and ');
767
- // set filter
768
- this.query.setParam('$filter', filter);
773
+ // clear filter
774
+ this.query.setParam('$filter', null);
769
775
  }
776
+ this._firstLoad = false;
777
+ this.dataTable.draw();
770
778
  }
771
779
  else {
772
- // clear filter
773
- this.query.setParam('$filter', null);
780
+ // ensure empty table layout
781
+ this.resetEmptyTable();
782
+ // search locally
783
+ this.dataTable.search(searchText.trim()).draw();
784
+ // get indexes of filtered rows
785
+ var indexes = Array.from(this.dataTable.context[0].aiDisplay);
786
+ // set recordsFiltered
787
+ var recordsFiltered = indexes.length;
788
+ // set recordsTotal
789
+ var recordsTotal = indexes.length;
790
+ // retrieve data from indexes
791
+ var rows_1 = Array.from(this.dataTable.rows().data());
792
+ var data = indexes.map(function (index) { return rows_1[index]; });
793
+ // emit results to load output
794
+ this.load.emit({
795
+ data: data,
796
+ recordsFiltered: recordsFiltered,
797
+ recordsTotal: recordsTotal
798
+ });
774
799
  }
775
- this._firstLoad = false;
776
- this.dataTable.draw();
777
800
  };
778
801
  AdvancedTableComponent.prototype.fetch = function (clearSelected) {
779
802
  // if data table is null
@@ -1443,6 +1466,10 @@ var AdvancedTableComponent = /** @class */ (function () {
1443
1466
  var query_1 = this._context.model(this.config.model).asQueryable();
1444
1467
  // select attributes
1445
1468
  query_1.setParam('$select', this.lastQueryParams.$select);
1469
+ if (this.lastQueryParams.$expand) {
1470
+ // apply expand attributes
1471
+ query_1.setParam('$expand', this.lastQueryParams.$expand);
1472
+ }
1446
1473
  // apply filter for row
1447
1474
  findKeys_1.forEach(function (key) {
1448
1475
  var column = _this.config.columns.find(function (col) {
@@ -1529,7 +1556,8 @@ var AdvancedTableComponent = /** @class */ (function () {
1529
1556
  // due to ng data binding
1530
1557
  // empty table template has no translated text during ngOnInit()
1531
1558
  if (this.dataTable && this.dataTable.context[0]) {
1532
- this.dataTable.context[0].oLanguage.sEmptyTable = this.emptyTable.nativeElement.innerHTML;
1559
+ this.dataTable.context[0].oLanguage.sEmptyTable =
1560
+ this.dataTable.context[0].oLanguage.sZeroRecords = this.emptyTable.nativeElement.innerHTML;
1533
1561
  }
1534
1562
  };
1535
1563
  AdvancedTableComponent.prototype.clearEmptyTable = function () {
@@ -2083,7 +2111,10 @@ var AdvancedSearchFormComponent = /** @class */ (function (_super) {
2083
2111
  var value = _this.formComponent.submission.data[key];
2084
2112
  // the filter with type is a string and is not empty
2085
2113
  var isEmptyString = typeof value === 'string' && value.length === 0;
2086
- if (!isEmptyString) {
2114
+ // do not include empty objects in filter
2115
+ var isEmptyObject = typeof value === 'object' && Object.keys(value).length === 0;
2116
+ // make isEmptyString, isEmptyObject mutex
2117
+ if (!isEmptyString && !isEmptyObject) {
2087
2118
  Object.defineProperty(_this.filter, key, {
2088
2119
  configurable: true,
2089
2120
  enumerable: true,