@universis/ngx-tables 0.7.6 → 0.7.9

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.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('iso-639-1/build'), require('rxjs'), require('jquery'), require('datatables.net'), require('lodash'), require('datatables.net-scroller'), require('rxjs/add/observable/combineLatest'), require('@angular/common/http'), require('@themost/client'), require('@themost/angular'), require('@angular/common'), require('@ngx-translate/core'), require('@angular/forms'), require('@universis/common'), require('@universis/common/routing'), require('@universis/forms'), require('angular-formio'), require('@angular/router'), require('ngx-bootstrap/modal'), require('ngx-bootstrap/progressbar'), require('ngx-pipes'), require('@angular/core'), require('@ngrx/store'), require('rxjs/operators')) :
3
- typeof define === 'function' && define.amd ? define('@universis/ngx-tables', ['exports', 'iso-639-1/build', 'rxjs', 'jquery', 'datatables.net', 'lodash', 'datatables.net-scroller', 'rxjs/add/observable/combineLatest', '@angular/common/http', '@themost/client', '@themost/angular', '@angular/common', '@ngx-translate/core', '@angular/forms', '@universis/common', '@universis/common/routing', '@universis/forms', 'angular-formio', '@angular/router', 'ngx-bootstrap/modal', 'ngx-bootstrap/progressbar', 'ngx-pipes', '@angular/core', '@ngrx/store', 'rxjs/operators'], factory) :
4
- (factory((global.universis = global.universis || {}, global.universis['ngx-tables'] = {}),global.ISO6391,global.rxjs,global.jQuery_,null,global.lodash,null,global.rxjs['add/observable/combineLatest'],global.ng.common.http,global.client,global.i1,global.ng.common,global.core,global.ng.forms,global.i2,global.routing,global.forms$1,global.angularFormio,global.ng.router,global.modal,global.progressbar,global.ngxPipes,global.ng.core,global.store,global.rxjs.operators));
5
- }(this, (function (exports,ISO6391,rxjs,jQuery_,datatables_net,lodash,datatables_netScroller,combineLatest,http,client,i1,common,core,forms,i2,routing,forms$1,angularFormio,i1$1,modal,progressbar,ngxPipes,i0,store,operators) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('iso-639-1/build'), require('rxjs'), require('jquery'), require('datatables.net'), require('datatables.net-scroller'), require('rxjs/add/observable/combineLatest'), require('@angular/common/http'), require('@themost/client'), require('@themost/angular'), require('@angular/common'), require('@ngx-translate/core'), require('@angular/forms'), require('@universis/common'), require('@universis/common/routing'), require('@universis/forms'), require('angular-formio'), require('ngx-bootstrap/modal'), require('ngx-bootstrap/progressbar'), require('ngx-pipes'), require('lodash'), require('@angular/core'), require('@angular/router'), require('@ngrx/store'), require('rxjs/operators')) :
3
+ typeof define === 'function' && define.amd ? define('@universis/ngx-tables', ['exports', 'iso-639-1/build', 'rxjs', 'jquery', 'datatables.net', 'datatables.net-scroller', 'rxjs/add/observable/combineLatest', '@angular/common/http', '@themost/client', '@themost/angular', '@angular/common', '@ngx-translate/core', '@angular/forms', '@universis/common', '@universis/common/routing', '@universis/forms', 'angular-formio', 'ngx-bootstrap/modal', 'ngx-bootstrap/progressbar', 'ngx-pipes', 'lodash', '@angular/core', '@angular/router', '@ngrx/store', 'rxjs/operators'], factory) :
4
+ (factory((global.universis = global.universis || {}, global.universis['ngx-tables'] = {}),global.ISO6391,global.rxjs,global.jQuery_,null,null,global.rxjs['add/observable/combineLatest'],global.ng.common.http,global.client,global.i1,global.ng.common,global.core,global.ng.forms,global.i2,global.routing,global.forms$1,global.angularFormio,global.modal,global.progressbar,global.ngxPipes,global.lodash,global.ng.core,global.ng.router,global.store,global.rxjs.operators));
5
+ }(this, (function (exports,ISO6391,rxjs,jQuery_,datatables_net,datatables_netScroller,combineLatest,http,client,i1,common,core,forms,i2,routing,forms$1,angularFormio,modal,progressbar,ngxPipes,lodash,i0,i1$1,store,operators) { 'use strict';
6
6
 
7
7
  /*! *****************************************************************************
8
8
  Copyright (c) Microsoft Corporation.
@@ -1840,6 +1840,7 @@
1840
1840
  this._http.get(changes.configSrc.currentValue).toPromise().then(function (config) {
1841
1841
  // set configuration
1842
1842
  _this.config = config;
1843
+ _this.destroy();
1843
1844
  // fetch and redraw
1844
1845
  _this.fetch();
1845
1846
  }).catch(function (err) {
@@ -1850,6 +1851,12 @@
1850
1851
  }
1851
1852
  }
1852
1853
  };
1854
+ AdvancedTableComponent.prototype.reset = function (load) {
1855
+ this.query = null;
1856
+ this.destroy();
1857
+ this.autoLoad = !!load;
1858
+ this.ngOnInit();
1859
+ };
1853
1860
  AdvancedTableComponent.decorators = [
1854
1861
  { type: i0.Component, args: [{
1855
1862
  // tslint:disable-next-line: component-selector
@@ -4911,7 +4918,7 @@
4911
4918
  case TableActionTypes.LoadFilter:
4912
4919
  return state[action.id];
4913
4920
  case TableActionTypes.AppendFilter:
4914
- state[action.id] = __assign({}, state[action.id], { filter: action.filter });
4921
+ state[action.id] = __assign({}, state[action.id], { filter: lodash.cloneDeep(action.filter) });
4915
4922
  return state;
4916
4923
  case TableActionTypes.AppendState:
4917
4924
  state[action.id] = __assign({}, state[action.id], { table: action.data });
@@ -5009,19 +5016,23 @@
5009
5016
  // set auto load to false
5010
5017
  this.search.table.autoLoad = false;
5011
5018
  // handle filtering
5012
- this.search.filterChange.subscribe(function (filter) {
5019
+ this.filterChangeSubscription = this.search.filterChange.subscribe(function (filter) {
5013
5020
  _this.onSearchFilter(filter);
5014
5021
  });
5015
- // handle table state (via directive)
5016
- var tableState = new AdvancedTableState(this.search.table, this.store);
5017
- tableState.tableState = this.searchState;
5018
- tableState.ngOnInit();
5022
+ // apply table state
5023
+ this.applyTableState();
5019
5024
  // handle table init
5020
- this.search.table.init.subscribe(function () {
5025
+ this.tableInitSubscription = this.search.table.init.subscribe(function () {
5021
5026
  return _this.onTableInit();
5022
5027
  });
5023
5028
  }
5024
5029
  };
5030
+ AdvancedSearchState.prototype.applyTableState = function () {
5031
+ // handle table state (via directive)
5032
+ var tableState = new AdvancedTableState(this.search.table, this.store);
5033
+ tableState.tableState = this.searchState;
5034
+ tableState.ngOnInit();
5035
+ };
5025
5036
  AdvancedSearchState.prototype.onTableInit = function () {
5026
5037
  var _this = this;
5027
5038
  this.store.pipe(store.select(selectTable, { id: this.searchState }), operators.first()).subscribe(function (state) {
@@ -5044,8 +5055,16 @@
5044
5055
  return _this.search.search();
5045
5056
  }
5046
5057
  if (state.filter) {
5047
- _this.search.filter = state.filter;
5058
+ if (Object.keys(state.filter).length) {
5059
+ // set collapsed to false (advanced search)
5060
+ _this.search.collapsed = false;
5061
+ _this.search.filter = state.filter;
5062
+ return _this.search.search();
5063
+ }
5048
5064
  }
5065
+ // ensure empty filter at this moment
5066
+ // because search() function triggers a store dispatch
5067
+ _this.search.filter = {};
5049
5068
  return _this.search.search();
5050
5069
  }
5051
5070
  });
@@ -5053,6 +5072,14 @@
5053
5072
  AdvancedSearchState.prototype.onSearchFilter = function (filter) {
5054
5073
  this.store.dispatch(new AppendFilter(this.searchState, filter));
5055
5074
  };
5075
+ AdvancedSearchState.prototype.ngOnDestroy = function () {
5076
+ if (this.filterChangeSubscription) {
5077
+ this.filterChangeSubscription.unsubscribe();
5078
+ }
5079
+ if (this.tableInitSubscription) {
5080
+ this.tableInitSubscription.unsubscribe();
5081
+ }
5082
+ };
5056
5083
  AdvancedSearchState.decorators = [
5057
5084
  { type: i0.Directive, args: [{
5058
5085
  // tslint:disable-next-line: directive-selector
@@ -5072,6 +5099,70 @@
5072
5099
  return AdvancedSearchState;
5073
5100
  }());
5074
5101
 
5102
+ var AdvancedSearchRouterState = /** @class */ (function (_super) {
5103
+ __extends(AdvancedSearchRouterState, _super);
5104
+ function AdvancedSearchRouterState(search, store$$1, _router) {
5105
+ var _this =
5106
+ // call super constructor
5107
+ _super.call(this, search, store$$1) || this;
5108
+ _this.search = search;
5109
+ _this.store = store$$1;
5110
+ _this._router = _router;
5111
+ _this._enteringState = true;
5112
+ _this._applyState = false;
5113
+ // set search state dynamically according to route
5114
+ _this._routerSubscription = _this._router.events
5115
+ .pipe(operators.filter(function (event) {
5116
+ return event instanceof i1$1.NavigationStart || event instanceof i1$1.NavigationEnd;
5117
+ }))
5118
+ .subscribe(function (event) {
5119
+ // capture urls regarding tab changing while the component is active
5120
+ if (event instanceof i1$1.NavigationStart && !_this._enteringState) {
5121
+ // set search state
5122
+ _this.searchState = event.url;
5123
+ // toogle applyState
5124
+ _this._applyState = true;
5125
+ }
5126
+ // capture url of the first activation of the component (e.g. coming from another route)
5127
+ if (event instanceof i1$1.NavigationEnd && _this._enteringState) {
5128
+ // set search state
5129
+ _this.searchState = event.urlAfterRedirects;
5130
+ // toggle enteringState
5131
+ _this._enteringState = false;
5132
+ }
5133
+ if (_this._applyState) {
5134
+ // apply new table state
5135
+ _super.prototype.applyTableState.call(_this);
5136
+ _this._applyState = false;
5137
+ }
5138
+ });
5139
+ return _this;
5140
+ }
5141
+ AdvancedSearchRouterState.prototype.ngOnDestroy = function () {
5142
+ // destroy own subscriptions
5143
+ if (this._routerSubscription) {
5144
+ this._routerSubscription.unsubscribe();
5145
+ }
5146
+ // destroy parent subscriptions
5147
+ return _super.prototype.ngOnDestroy.call(this);
5148
+ };
5149
+ AdvancedSearchRouterState.decorators = [
5150
+ { type: i0.Directive, args: [{
5151
+ // tslint:disable-next-line: directive-selector
5152
+ selector: "[routerSearchState]",
5153
+ },] }
5154
+ ];
5155
+ /** @nocollapse */
5156
+ AdvancedSearchRouterState.ctorParameters = function () {
5157
+ return [
5158
+ { type: AdvancedTableSearchComponent },
5159
+ { type: store.Store, decorators: [{ type: i0.Optional }] },
5160
+ { type: i1$1.Router }
5161
+ ];
5162
+ };
5163
+ return AdvancedSearchRouterState;
5164
+ }(AdvancedSearchState));
5165
+
5075
5166
  var ɵ0 = FORMATTERS;
5076
5167
  var TablesModule = /** @class */ (function () {
5077
5168
  function TablesModule(_translateService) {
@@ -5137,7 +5228,8 @@
5137
5228
  ParseTitlePipe,
5138
5229
  AddItemsComponent,
5139
5230
  AdvancedSearchState,
5140
- AdvancedTableState
5231
+ AdvancedTableState,
5232
+ AdvancedSearchRouterState
5141
5233
  ],
5142
5234
  exports: [
5143
5235
  AdvancedTableComponent,
@@ -5155,7 +5247,8 @@
5155
5247
  AdvancedAggregatorListComponent,
5156
5248
  AddItemsComponent,
5157
5249
  AdvancedSearchState,
5158
- AdvancedTableState
5250
+ AdvancedTableState,
5251
+ AdvancedSearchRouterState
5159
5252
  ],
5160
5253
  entryComponents: [
5161
5254
  AdvancedTableModalBaseComponent,
@@ -5186,6 +5279,7 @@
5186
5279
 
5187
5280
  exports.ɵa = AdvancedSearchState;
5188
5281
  exports.ɵc = AdvancedTableState;
5282
+ exports.ɵd = AdvancedSearchRouterState;
5189
5283
  exports.AdvancedListComponent = AdvancedListComponent;
5190
5284
  exports.AdvancedRowActionComponent = AdvancedRowActionComponent;
5191
5285
  exports.AdvancedSearchFormComponent = AdvancedSearchFormComponent;