@universis/ngx-tables 0.7.4 → 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.
@@ -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('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('ngx-bootstrap/modal'), require('ngx-bootstrap/progressbar'), require('ngx-pipes'), 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', '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', 'ngx-bootstrap/modal', 'ngx-bootstrap/progressbar', 'ngx-pipes', '@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,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.modal,global.progressbar,global.ngxPipes,global.ng.core,global.ng.router,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,modal,progressbar,ngxPipes,i0,i1$1,store,operators) { 'use strict';
6
6
 
7
7
  /*! *****************************************************************************
8
8
  Copyright (c) Microsoft Corporation.
@@ -1293,6 +1293,13 @@
1293
1293
  });
1294
1294
  // get table element
1295
1295
  var tableElement_1 = jQuery(this.table.nativeElement);
1296
+ jQuery(window).on('resize', function () {
1297
+ setTimeout(function () {
1298
+ if (_this.dataTable) {
1299
+ _this.dataTable.columns.adjust();
1300
+ }
1301
+ }, 1);
1302
+ });
1296
1303
  // tslint:disable-next-line: no-shadowed-variable
1297
1304
  tableElement_1.on('processing.dt', function (event, settings, processing) {
1298
1305
  if (processing) {
@@ -1308,6 +1315,7 @@
1308
1315
  }, 0);
1309
1316
  }
1310
1317
  });
1318
+ var drawIndex_1 = 1;
1311
1319
  tableElement_1.on('order.dt', function (event) {
1312
1320
  if (_this.dataTable) {
1313
1321
  var order = _this.dataTable.order();
@@ -1320,8 +1328,11 @@
1320
1328
  if (_this.dataTable) {
1321
1329
  var info = _this.dataTable.page.info();
1322
1330
  _this.page.emit(info);
1331
+ if (drawIndex_1 > 1)
1332
+ return;
1323
1333
  try {
1324
- _this.dataTable.columns.adjust();
1334
+ drawIndex_1++;
1335
+ setTimeout(function () { _this.dataTable.columns.adjust(); }, 1);
1325
1336
  }
1326
1337
  catch (err) {
1327
1338
  console.error('ERROR', 'An error occurred while adjusting table columns');
@@ -4998,19 +5009,23 @@
4998
5009
  // set auto load to false
4999
5010
  this.search.table.autoLoad = false;
5000
5011
  // handle filtering
5001
- this.search.filterChange.subscribe(function (filter) {
5012
+ this.filterChangeSubscription = this.search.filterChange.subscribe(function (filter) {
5002
5013
  _this.onSearchFilter(filter);
5003
5014
  });
5004
- // handle table state (via directive)
5005
- var tableState = new AdvancedTableState(this.search.table, this.store);
5006
- tableState.tableState = this.searchState;
5007
- tableState.ngOnInit();
5015
+ // apply table state
5016
+ this.applyTableState();
5008
5017
  // handle table init
5009
- this.search.table.init.subscribe(function () {
5018
+ this.tableInitSubscription = this.search.table.init.subscribe(function () {
5010
5019
  return _this.onTableInit();
5011
5020
  });
5012
5021
  }
5013
5022
  };
5023
+ AdvancedSearchState.prototype.applyTableState = function () {
5024
+ // handle table state (via directive)
5025
+ var tableState = new AdvancedTableState(this.search.table, this.store);
5026
+ tableState.tableState = this.searchState;
5027
+ tableState.ngOnInit();
5028
+ };
5014
5029
  AdvancedSearchState.prototype.onTableInit = function () {
5015
5030
  var _this = this;
5016
5031
  this.store.pipe(store.select(selectTable, { id: this.searchState }), operators.first()).subscribe(function (state) {
@@ -5033,8 +5048,16 @@
5033
5048
  return _this.search.search();
5034
5049
  }
5035
5050
  if (state.filter) {
5036
- _this.search.filter = state.filter;
5051
+ if (Object.keys(state.filter).length) {
5052
+ // set collapsed to false (advanced search)
5053
+ _this.search.collapsed = false;
5054
+ _this.search.filter = state.filter;
5055
+ return _this.search.search();
5056
+ }
5037
5057
  }
5058
+ // ensure empty filter at this moment
5059
+ // because search() function triggers a store dispatch
5060
+ _this.search.filter = {};
5038
5061
  return _this.search.search();
5039
5062
  }
5040
5063
  });
@@ -5042,6 +5065,14 @@
5042
5065
  AdvancedSearchState.prototype.onSearchFilter = function (filter) {
5043
5066
  this.store.dispatch(new AppendFilter(this.searchState, filter));
5044
5067
  };
5068
+ AdvancedSearchState.prototype.ngOnDestroy = function () {
5069
+ if (this.filterChangeSubscription) {
5070
+ this.filterChangeSubscription.unsubscribe();
5071
+ }
5072
+ if (this.tableInitSubscription) {
5073
+ this.tableInitSubscription.unsubscribe();
5074
+ }
5075
+ };
5045
5076
  AdvancedSearchState.decorators = [
5046
5077
  { type: i0.Directive, args: [{
5047
5078
  // tslint:disable-next-line: directive-selector
@@ -5061,6 +5092,70 @@
5061
5092
  return AdvancedSearchState;
5062
5093
  }());
5063
5094
 
5095
+ var AdvancedSearchRouterState = /** @class */ (function (_super) {
5096
+ __extends(AdvancedSearchRouterState, _super);
5097
+ function AdvancedSearchRouterState(search, store$$1, _router) {
5098
+ var _this =
5099
+ // call super constructor
5100
+ _super.call(this, search, store$$1) || this;
5101
+ _this.search = search;
5102
+ _this.store = store$$1;
5103
+ _this._router = _router;
5104
+ _this._enteringState = true;
5105
+ _this._applyState = false;
5106
+ // set search state dynamically according to route
5107
+ _this._routerSubscription = _this._router.events
5108
+ .pipe(operators.filter(function (event) {
5109
+ return event instanceof i1$1.NavigationStart || event instanceof i1$1.NavigationEnd;
5110
+ }))
5111
+ .subscribe(function (event) {
5112
+ // capture urls regarding tab changing while the component is active
5113
+ if (event instanceof i1$1.NavigationStart && !_this._enteringState) {
5114
+ // set search state
5115
+ _this.searchState = event.url;
5116
+ // toogle applyState
5117
+ _this._applyState = true;
5118
+ }
5119
+ // capture url of the first activation of the component (e.g. coming from another route)
5120
+ if (event instanceof i1$1.NavigationEnd && _this._enteringState) {
5121
+ // set search state
5122
+ _this.searchState = event.urlAfterRedirects;
5123
+ // toggle enteringState
5124
+ _this._enteringState = false;
5125
+ }
5126
+ if (_this._applyState) {
5127
+ // apply new table state
5128
+ _super.prototype.applyTableState.call(_this);
5129
+ _this._applyState = false;
5130
+ }
5131
+ });
5132
+ return _this;
5133
+ }
5134
+ AdvancedSearchRouterState.prototype.ngOnDestroy = function () {
5135
+ // destroy own subscriptions
5136
+ if (this._routerSubscription) {
5137
+ this._routerSubscription.unsubscribe();
5138
+ }
5139
+ // destroy parent subscriptions
5140
+ return _super.prototype.ngOnDestroy.call(this);
5141
+ };
5142
+ AdvancedSearchRouterState.decorators = [
5143
+ { type: i0.Directive, args: [{
5144
+ // tslint:disable-next-line: directive-selector
5145
+ selector: "[routerSearchState]",
5146
+ },] }
5147
+ ];
5148
+ /** @nocollapse */
5149
+ AdvancedSearchRouterState.ctorParameters = function () {
5150
+ return [
5151
+ { type: AdvancedTableSearchComponent },
5152
+ { type: store.Store, decorators: [{ type: i0.Optional }] },
5153
+ { type: i1$1.Router }
5154
+ ];
5155
+ };
5156
+ return AdvancedSearchRouterState;
5157
+ }(AdvancedSearchState));
5158
+
5064
5159
  var ɵ0 = FORMATTERS;
5065
5160
  var TablesModule = /** @class */ (function () {
5066
5161
  function TablesModule(_translateService) {
@@ -5126,7 +5221,8 @@
5126
5221
  ParseTitlePipe,
5127
5222
  AddItemsComponent,
5128
5223
  AdvancedSearchState,
5129
- AdvancedTableState
5224
+ AdvancedTableState,
5225
+ AdvancedSearchRouterState
5130
5226
  ],
5131
5227
  exports: [
5132
5228
  AdvancedTableComponent,
@@ -5144,7 +5240,8 @@
5144
5240
  AdvancedAggregatorListComponent,
5145
5241
  AddItemsComponent,
5146
5242
  AdvancedSearchState,
5147
- AdvancedTableState
5243
+ AdvancedTableState,
5244
+ AdvancedSearchRouterState
5148
5245
  ],
5149
5246
  entryComponents: [
5150
5247
  AdvancedTableModalBaseComponent,
@@ -5175,6 +5272,7 @@
5175
5272
 
5176
5273
  exports.ɵa = AdvancedSearchState;
5177
5274
  exports.ɵc = AdvancedTableState;
5275
+ exports.ɵd = AdvancedSearchRouterState;
5178
5276
  exports.AdvancedListComponent = AdvancedListComponent;
5179
5277
  exports.AdvancedRowActionComponent = AdvancedRowActionComponent;
5180
5278
  exports.AdvancedSearchFormComponent = AdvancedSearchFormComponent;