@universis/ngx-tables 0.7.6 → 0.7.7

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.
@@ -15,14 +15,14 @@ import { TemplatePipe, LoadingService, ErrorService, DIALOG_BUTTONS, ModalServic
15
15
  import { RouterModalOkCancel, RouterModalModule } from '@universis/common/routing';
16
16
  import { ServiceUrlPreProcessor, TranslatePreProcessor, AdvancedFormsModule } from '@universis/forms';
17
17
  import { FormioModule } from 'angular-formio';
18
- import { ActivatedRoute, Router, NavigationStart, RouterModule } from '@angular/router';
19
18
  import { BsModalRef, BsModalService, ModalModule } from 'ngx-bootstrap/modal';
20
19
  import { ProgressbarModule } from 'ngx-bootstrap/progressbar';
21
20
  import { GroupByPipe, NgPipesModule } from 'ngx-pipes';
22
21
  import { __extends, __awaiter, __generator, __values, __assign, __spread } from 'tslib';
23
22
  import { Injectable, Directive, Optional, Input, Pipe, Component, ElementRef, ViewChild, ViewEncapsulation, EventEmitter, Output, NgModule, CUSTOM_ELEMENTS_SCHEMA, defineInjectable, inject, HostListener, ChangeDetectorRef, InjectionToken, Inject, Injector, ChangeDetectionStrategy } from '@angular/core';
23
+ import { ActivatedRoute, Router, NavigationStart, NavigationEnd, RouterModule } from '@angular/router';
24
24
  import { createFeatureSelector, createSelector, select, Store } from '@ngrx/store';
25
- import { first } from 'rxjs/operators';
25
+ import { first, filter } from 'rxjs/operators';
26
26
 
27
27
  var AdvancedColumnFormatter = /** @class */ (function () {
28
28
  function AdvancedColumnFormatter() {
@@ -481,20 +481,20 @@ var AdvancedFilterValueProvider = /** @class */ (function () {
481
481
  this.values = {};
482
482
  this._template = new TemplatePipe();
483
483
  }
484
- AdvancedFilterValueProvider.prototype.buildFilter = function (filter) {
485
- if (filter) {
486
- return this._template.transform(filter, this.values);
484
+ AdvancedFilterValueProvider.prototype.buildFilter = function (filter$$1) {
485
+ if (filter$$1) {
486
+ return this._template.transform(filter$$1, this.values);
487
487
  }
488
488
  };
489
- AdvancedFilterValueProvider.prototype.asyncBuildFilter = function (filter) {
489
+ AdvancedFilterValueProvider.prototype.asyncBuildFilter = function (filter$$1) {
490
490
  return __awaiter(this, void 0, void 0, function () {
491
491
  var _a, _b, _c;
492
492
  return __generator(this, function (_d) {
493
493
  switch (_d.label) {
494
494
  case 0:
495
- if (!filter) return [3 /*break*/, 2];
495
+ if (!filter$$1) return [3 /*break*/, 2];
496
496
  _b = (_a = this._template).transform;
497
- _c = [filter];
497
+ _c = [filter$$1];
498
498
  return [4 /*yield*/, this.getValues()];
499
499
  case 1: return [2 /*return*/, _b.apply(_a, _c.concat([_d.sent()]))];
500
500
  case 2: return [2 /*return*/];
@@ -767,13 +767,13 @@ var AdvancedTableComponent = /** @class */ (function () {
767
767
  // try to split words
768
768
  var words = searchText.split(' ');
769
769
  // join words to a single filter
770
- var filter = words.map(function (word) {
770
+ var filter$$1 = words.map(function (word) {
771
771
  return _this._template.transform(_this.config.searchExpression, {
772
772
  text: word,
773
773
  });
774
774
  }).join(' and ');
775
775
  // set filter
776
- this.query.setParam('$filter', filter);
776
+ this.query.setParam('$filter', filter$$1);
777
777
  }
778
778
  }
779
779
  else {
@@ -2169,8 +2169,8 @@ var AdvancedSearchFormComponent = /** @class */ (function (_super) {
2169
2169
  form: this.form
2170
2170
  });
2171
2171
  this.loading = false;
2172
- this.filterSubscription = this.filterChange.subscribe(function (filter) {
2173
- _this.submission.data = filter;
2172
+ this.filterSubscription = this.filterChange.subscribe(function (filter$$1) {
2173
+ _this.submission.data = filter$$1;
2174
2174
  _this.refreshForm.emit({
2175
2175
  submission: _this.submission
2176
2176
  });
@@ -2449,7 +2449,7 @@ var AdvancedTableModalBaseComponent = /** @class */ (function (_super) {
2449
2449
  * @param {object} filter The filter to use in the search
2450
2450
  *
2451
2451
  */
2452
- AdvancedTableModalBaseComponent.prototype.advancedSearch = function (filter) {
2452
+ AdvancedTableModalBaseComponent.prototype.advancedSearch = function (filter$$1) {
2453
2453
  return __awaiter(this, void 0, void 0, function () {
2454
2454
  var defaultFilterValues, err_1, expressions, predefinedCriteria, query;
2455
2455
  return __generator(this, function (_a) {
@@ -2473,9 +2473,9 @@ var AdvancedTableModalBaseComponent = /** @class */ (function (_super) {
2473
2473
  return [3 /*break*/, 4];
2474
2474
  case 4:
2475
2475
  expressions = [];
2476
- if (filter) {
2477
- this.defaultFilter = filter;
2478
- predefinedCriteria = this.getFilters(this.tableConfig, defaultFilterValues, filter);
2476
+ if (filter$$1) {
2477
+ this.defaultFilter = filter$$1;
2478
+ predefinedCriteria = this.getFilters(this.tableConfig, defaultFilterValues, filter$$1);
2479
2479
  }
2480
2480
  else {
2481
2481
  // Empty a falsy filter resets the results
@@ -4623,9 +4623,9 @@ var TableActionTypes;
4623
4623
  TableActionTypes["AppendState"] = "[Table] Append State";
4624
4624
  })(TableActionTypes || (TableActionTypes = {}));
4625
4625
  var AppendFilter = /** @class */ (function () {
4626
- function AppendFilter(id, filter) {
4626
+ function AppendFilter(id, filter$$1) {
4627
4627
  this.id = id;
4628
- this.filter = filter;
4628
+ this.filter = filter$$1;
4629
4629
  this.type = TableActionTypes.AppendFilter;
4630
4630
  }
4631
4631
  return AppendFilter;
@@ -4746,19 +4746,23 @@ var AdvancedSearchState = /** @class */ (function () {
4746
4746
  // set auto load to false
4747
4747
  this.search.table.autoLoad = false;
4748
4748
  // handle filtering
4749
- this.search.filterChange.subscribe(function (filter) {
4750
- _this.onSearchFilter(filter);
4749
+ this.filterChangeSubscription = this.search.filterChange.subscribe(function (filter$$1) {
4750
+ _this.onSearchFilter(filter$$1);
4751
4751
  });
4752
- // handle table state (via directive)
4753
- var tableState = new AdvancedTableState(this.search.table, this.store);
4754
- tableState.tableState = this.searchState;
4755
- tableState.ngOnInit();
4752
+ // apply table state
4753
+ this.applyTableState();
4756
4754
  // handle table init
4757
- this.search.table.init.subscribe(function () {
4755
+ this.tableInitSubscription = this.search.table.init.subscribe(function () {
4758
4756
  return _this.onTableInit();
4759
4757
  });
4760
4758
  }
4761
4759
  };
4760
+ AdvancedSearchState.prototype.applyTableState = function () {
4761
+ // handle table state (via directive)
4762
+ var tableState = new AdvancedTableState(this.search.table, this.store);
4763
+ tableState.tableState = this.searchState;
4764
+ tableState.ngOnInit();
4765
+ };
4762
4766
  AdvancedSearchState.prototype.onTableInit = function () {
4763
4767
  var _this = this;
4764
4768
  this.store.pipe(select(selectTable, { id: this.searchState }), first()).subscribe(function (state) {
@@ -4781,14 +4785,30 @@ var AdvancedSearchState = /** @class */ (function () {
4781
4785
  return _this.search.search();
4782
4786
  }
4783
4787
  if (state.filter) {
4784
- _this.search.filter = state.filter;
4788
+ if (Object.keys(state.filter).length) {
4789
+ // set collapsed to false (advanced search)
4790
+ _this.search.collapsed = false;
4791
+ _this.search.filter = state.filter;
4792
+ return _this.search.search();
4793
+ }
4785
4794
  }
4795
+ // ensure empty filter at this moment
4796
+ // because search() function triggers a store dispatch
4797
+ _this.search.filter = {};
4786
4798
  return _this.search.search();
4787
4799
  }
4788
4800
  });
4789
4801
  };
4790
- AdvancedSearchState.prototype.onSearchFilter = function (filter) {
4791
- this.store.dispatch(new AppendFilter(this.searchState, filter));
4802
+ AdvancedSearchState.prototype.onSearchFilter = function (filter$$1) {
4803
+ this.store.dispatch(new AppendFilter(this.searchState, filter$$1));
4804
+ };
4805
+ AdvancedSearchState.prototype.ngOnDestroy = function () {
4806
+ if (this.filterChangeSubscription) {
4807
+ this.filterChangeSubscription.unsubscribe();
4808
+ }
4809
+ if (this.tableInitSubscription) {
4810
+ this.tableInitSubscription.unsubscribe();
4811
+ }
4792
4812
  };
4793
4813
  AdvancedSearchState.decorators = [
4794
4814
  { type: Directive, args: [{
@@ -4807,6 +4827,68 @@ var AdvancedSearchState = /** @class */ (function () {
4807
4827
  return AdvancedSearchState;
4808
4828
  }());
4809
4829
 
4830
+ var AdvancedSearchRouterState = /** @class */ (function (_super) {
4831
+ __extends(AdvancedSearchRouterState, _super);
4832
+ function AdvancedSearchRouterState(search, store, _router) {
4833
+ var _this =
4834
+ // call super constructor
4835
+ _super.call(this, search, store) || this;
4836
+ _this.search = search;
4837
+ _this.store = store;
4838
+ _this._router = _router;
4839
+ _this._enteringState = true;
4840
+ _this._applyState = false;
4841
+ // set search state dynamically according to route
4842
+ _this._routerSubscription = _this._router.events
4843
+ .pipe(filter(function (event) {
4844
+ return event instanceof NavigationStart || event instanceof NavigationEnd;
4845
+ }))
4846
+ .subscribe(function (event) {
4847
+ // capture urls regarding tab changing while the component is active
4848
+ if (event instanceof NavigationStart && !_this._enteringState) {
4849
+ // set search state
4850
+ _this.searchState = event.url;
4851
+ // toogle applyState
4852
+ _this._applyState = true;
4853
+ }
4854
+ // capture url of the first activation of the component (e.g. coming from another route)
4855
+ if (event instanceof NavigationEnd && _this._enteringState) {
4856
+ // set search state
4857
+ _this.searchState = event.urlAfterRedirects;
4858
+ // toggle enteringState
4859
+ _this._enteringState = false;
4860
+ }
4861
+ if (_this._applyState) {
4862
+ // apply new table state
4863
+ _super.prototype.applyTableState.call(_this);
4864
+ _this._applyState = false;
4865
+ }
4866
+ });
4867
+ return _this;
4868
+ }
4869
+ AdvancedSearchRouterState.prototype.ngOnDestroy = function () {
4870
+ // destroy own subscriptions
4871
+ if (this._routerSubscription) {
4872
+ this._routerSubscription.unsubscribe();
4873
+ }
4874
+ // destroy parent subscriptions
4875
+ return _super.prototype.ngOnDestroy.call(this);
4876
+ };
4877
+ AdvancedSearchRouterState.decorators = [
4878
+ { type: Directive, args: [{
4879
+ // tslint:disable-next-line: directive-selector
4880
+ selector: "[routerSearchState]",
4881
+ },] }
4882
+ ];
4883
+ /** @nocollapse */
4884
+ AdvancedSearchRouterState.ctorParameters = function () { return [
4885
+ { type: AdvancedTableSearchComponent },
4886
+ { type: Store, decorators: [{ type: Optional }] },
4887
+ { type: Router }
4888
+ ]; };
4889
+ return AdvancedSearchRouterState;
4890
+ }(AdvancedSearchState));
4891
+
4810
4892
  var ɵ0 = FORMATTERS;
4811
4893
  var TablesModule = /** @class */ (function () {
4812
4894
  function TablesModule(_translateService) {
@@ -4872,7 +4954,8 @@ var TablesModule = /** @class */ (function () {
4872
4954
  ParseTitlePipe,
4873
4955
  AddItemsComponent,
4874
4956
  AdvancedSearchState,
4875
- AdvancedTableState
4957
+ AdvancedTableState,
4958
+ AdvancedSearchRouterState
4876
4959
  ],
4877
4960
  exports: [
4878
4961
  AdvancedTableComponent,
@@ -4890,7 +4973,8 @@ var TablesModule = /** @class */ (function () {
4890
4973
  AdvancedAggregatorListComponent,
4891
4974
  AddItemsComponent,
4892
4975
  AdvancedSearchState,
4893
- AdvancedTableState
4976
+ AdvancedTableState,
4977
+ AdvancedSearchRouterState
4894
4978
  ],
4895
4979
  entryComponents: [
4896
4980
  AdvancedTableModalBaseComponent,
@@ -4917,6 +5001,6 @@ var TablesModule = /** @class */ (function () {
4917
5001
  * Generated bundle index. Do not edit.
4918
5002
  */
4919
5003
 
4920
- export { AdvancedSearchState as ɵa, AdvancedTableState as ɵc, AdvancedListComponent, AdvancedRowActionComponent, AdvancedSearchFormComponent, AdvancedSelectComponent, AdvancedSelectService, AdvancedTableConfigurationResolver, AdvancedSearchConfigurationResolver, AdvancedColumnFormatter, NestedPropertyFormatter, ButtonFormatter, LinkFormatter, ActionLinkFormatter, ActionButtonFormatter, ActionSplitButtonFormatter, SelectRowFormatter, TemplateFormatter, TrueFalseFormatter, TranslationFormatter, DateTimeFormatter, NgClassFormatter, LanguageFormatter, COLUMN_FORMATTERS, AdvancedTableConfiguration, AdvancedTableComponent, AdvancedTableSettingsComponent, AdvancedTableSearchBaseComponent, AdvancedTableSearchComponent, FORMATTERS, AdvancedFilterValueProvider, AdvancedTableModalBaseTemplate, AdvancedTableModalBaseComponent, SimpleHeaderToolsComponent, TableSimpleHeaderComponent, AdvancedTableNotNullError, AdvancedTableEditorDirective, BtnExpDirective, AdvancedAggregatorComponent, AdvancedAggregatorListComponent, AddItemsComponent, AdvancedAggregatorPipe, ParseTitlePipe, AdvancedAggregatorService, TablesModule, ɵ0, ActivatedTableService, initialState, tableInitialState, tableReducer, tableReducers, featureName, getTablesState, selectTable };
5004
+ export { AdvancedSearchState as ɵa, AdvancedTableState as ɵc, AdvancedSearchRouterState as ɵd, AdvancedListComponent, AdvancedRowActionComponent, AdvancedSearchFormComponent, AdvancedSelectComponent, AdvancedSelectService, AdvancedTableConfigurationResolver, AdvancedSearchConfigurationResolver, AdvancedColumnFormatter, NestedPropertyFormatter, ButtonFormatter, LinkFormatter, ActionLinkFormatter, ActionButtonFormatter, ActionSplitButtonFormatter, SelectRowFormatter, TemplateFormatter, TrueFalseFormatter, TranslationFormatter, DateTimeFormatter, NgClassFormatter, LanguageFormatter, COLUMN_FORMATTERS, AdvancedTableConfiguration, AdvancedTableComponent, AdvancedTableSettingsComponent, AdvancedTableSearchBaseComponent, AdvancedTableSearchComponent, FORMATTERS, AdvancedFilterValueProvider, AdvancedTableModalBaseTemplate, AdvancedTableModalBaseComponent, SimpleHeaderToolsComponent, TableSimpleHeaderComponent, AdvancedTableNotNullError, AdvancedTableEditorDirective, BtnExpDirective, AdvancedAggregatorComponent, AdvancedAggregatorListComponent, AddItemsComponent, AdvancedAggregatorPipe, ParseTitlePipe, AdvancedAggregatorService, TablesModule, ɵ0, ActivatedTableService, initialState, tableInitialState, tableReducer, tableReducers, featureName, getTablesState, selectTable };
4921
5005
 
4922
5006
  //# sourceMappingURL=universis-ngx-tables.js.map