@universis/ngx-tables 0.6.21 → 0.7.1

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.
Files changed (35) hide show
  1. package/bundles/universis-ngx-tables.umd.js +246 -10
  2. package/bundles/universis-ngx-tables.umd.js.map +1 -1
  3. package/bundles/universis-ngx-tables.umd.min.js +1 -1
  4. package/bundles/universis-ngx-tables.umd.min.js.map +1 -1
  5. package/esm2015/lib/actions/table.actions.js +28 -0
  6. package/esm2015/lib/components/advanced-table/advanced-table-search.component.js +8 -2
  7. package/esm2015/lib/components/advanced-table/advanced-table.component.js +31 -3
  8. package/esm2015/lib/directives/advance-search-state.directive.js +88 -0
  9. package/esm2015/lib/directives/advance-table-state.directive.js +59 -0
  10. package/esm2015/lib/reducers/index.js +31 -0
  11. package/esm2015/lib/tables.module.js +13 -4
  12. package/esm2015/public_api.js +1 -1
  13. package/esm2015/universis-ngx-tables.js +4 -1
  14. package/esm5/lib/actions/table.actions.js +34 -0
  15. package/esm5/lib/components/advanced-table/advanced-table-search.component.js +8 -2
  16. package/esm5/lib/components/advanced-table/advanced-table.component.js +31 -3
  17. package/esm5/lib/directives/advance-search-state.directive.js +96 -0
  18. package/esm5/lib/directives/advance-table-state.directive.js +62 -0
  19. package/esm5/lib/reducers/index.js +33 -0
  20. package/esm5/lib/tables.module.js +13 -4
  21. package/esm5/public_api.js +1 -1
  22. package/esm5/universis-ngx-tables.js +4 -1
  23. package/fesm2015/universis-ngx-tables.js +229 -12
  24. package/fesm2015/universis-ngx-tables.js.map +1 -1
  25. package/fesm5/universis-ngx-tables.js +240 -13
  26. package/fesm5/universis-ngx-tables.js.map +1 -1
  27. package/lib/actions/table.actions.d.ts +24 -0
  28. package/lib/components/advanced-table/advanced-table-search.component.d.ts +4 -0
  29. package/lib/components/advanced-table/advanced-table.component.d.ts +4 -0
  30. package/lib/directives/advance-search-state.directive.d.ts +16 -0
  31. package/lib/directives/advance-table-state.directive.d.ts +11 -0
  32. package/lib/reducers/index.d.ts +23 -0
  33. package/package.json +4 -1
  34. package/universis-ngx-tables.d.ts +3 -0
  35. package/universis-ngx-tables.metadata.json +1 -1
@@ -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/core'), 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')) :
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/core', '@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'], 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.core,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));
5
- }(this, (function (exports,ISO6391,rxjs,jQuery_,datatables_net,lodash,datatables_netScroller,combineLatest,http,client,i1,i0,common,core,forms,i2,routing,forms$1,angularFormio,i1$1,modal,progressbar,ngxPipes) { '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('@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';
6
6
 
7
7
  /*! *****************************************************************************
8
8
  Copyright (c) Microsoft Corporation.
@@ -781,6 +781,7 @@
781
781
  this.select = new i0.EventEmitter();
782
782
  this.draw = new i0.EventEmitter();
783
783
  this.page = new i0.EventEmitter();
784
+ this.order = new i0.EventEmitter();
784
785
  this.scroll = new i0.EventEmitter();
785
786
  this.selectedItems = new i0.EventEmitter();
786
787
  this.scrollable = true;
@@ -788,6 +789,7 @@
788
789
  this.lengthMenu = [50, 100, 200, 500];
789
790
  this.paging = true;
790
791
  this.pageLength = 25;
792
+ this.stateSave = false;
791
793
  this.scrollY = 800;
792
794
  this.scrollX = true;
793
795
  /**
@@ -1306,7 +1308,14 @@
1306
1308
  }, 0);
1307
1309
  }
1308
1310
  });
1309
- tableElement_1.on('draw.dt', function (event) {
1311
+ tableElement_1.on('order.dt', function (event) {
1312
+ if (_this.dataTable) {
1313
+ var order = _this.dataTable.order();
1314
+ if (order && order.length) {
1315
+ _this.order.emit(order);
1316
+ }
1317
+ }
1318
+ }).on('draw.dt', function (event) {
1310
1319
  _this.draw.emit();
1311
1320
  if (_this.dataTable) {
1312
1321
  var info = _this.dataTable.page.info();
@@ -1555,6 +1564,20 @@
1555
1564
  },
1556
1565
  language: Object.assign({}, self.translator.transform('Tables.DataTable'), { emptyTable: ' ' }),
1557
1566
  };
1567
+ var stateSettings = {
1568
+ stateSave: this.stateSave
1569
+ };
1570
+ if (this.stateLoadCallback) {
1571
+ Object.assign(stateSettings, {
1572
+ stateLoadCallback: this.stateLoadCallback
1573
+ });
1574
+ }
1575
+ if (this.stateSaveCallback) {
1576
+ Object.assign(stateSettings, {
1577
+ stateSaveCallback: this.stateSaveCallback
1578
+ });
1579
+ }
1580
+ Object.assign(settings, stateSettings);
1558
1581
  if (this.scrollable) {
1559
1582
  // set continuous scrolling
1560
1583
  Object.assign(settings, {
@@ -1589,8 +1612,8 @@
1589
1612
  });
1590
1613
  }
1591
1614
  });
1592
- _this.init.emit();
1593
1615
  }).DataTable(settings);
1616
+ this.init.emit();
1594
1617
  // show or hide header
1595
1618
  if (!this.showHeader) {
1596
1619
  this._element.nativeElement
@@ -1853,6 +1876,7 @@
1853
1876
  select: [{ type: i0.Output, args: ['select',] }],
1854
1877
  draw: [{ type: i0.Output, args: ['draw',] }],
1855
1878
  page: [{ type: i0.Output, args: ['page',] }],
1879
+ order: [{ type: i0.Output, args: ['order',] }],
1856
1880
  scroll: [{ type: i0.Output, args: ['scroll',] }],
1857
1881
  selectedItems: [{ type: i0.Output, args: ['selectedItems',] }],
1858
1882
  scrollable: [{ type: i0.Input }],
@@ -1860,6 +1884,9 @@
1860
1884
  lengthMenu: [{ type: i0.Input }],
1861
1885
  paging: [{ type: i0.Input }],
1862
1886
  pageLength: [{ type: i0.Input }],
1887
+ stateSave: [{ type: i0.Input }],
1888
+ stateLoadCallback: [{ type: i0.Input }],
1889
+ stateSaveCallback: [{ type: i0.Input }],
1863
1890
  scrollY: [{ type: i0.Input }],
1864
1891
  scrollX: [{ type: i0.Input }],
1865
1892
  selectable: [{ type: i0.Input }],
@@ -2981,6 +3008,7 @@
2981
3008
  _this.showMore = true;
2982
3009
  _this.mergeQueryParams = false;
2983
3010
  _this.viewChange = new i0.EventEmitter();
3011
+ _this.listChange = new i0.EventEmitter();
2984
3012
  _this.userSearchList = [];
2985
3013
  _this.selectedList = null;
2986
3014
  return _this;
@@ -3135,6 +3163,9 @@
3135
3163
  queryParamsHandling: 'merge',
3136
3164
  });
3137
3165
  }
3166
+ this.filterChange.emit({
3167
+ q: searchText
3168
+ });
3138
3169
  // otherwise do search
3139
3170
  this.table.search(searchText);
3140
3171
  return false;
@@ -3356,6 +3387,7 @@
3356
3387
  else {
3357
3388
  this.table.query = query;
3358
3389
  }
3390
+ this.filterChange.emit(this.filter);
3359
3391
  this.table.fetch();
3360
3392
  _a.label = 2;
3361
3393
  case 2: return [2 /*return*/];
@@ -3505,7 +3537,8 @@
3505
3537
  showMore: [{ type: i0.Input }],
3506
3538
  mergeQueryParams: [{ type: i0.Input }],
3507
3539
  searchText: [{ type: i0.ViewChild, args: ['searchText',] }],
3508
- viewChange: [{ type: i0.Output, args: ['viewChange',] }]
3540
+ viewChange: [{ type: i0.Output, args: ['viewChange',] }],
3541
+ listChange: [{ type: i0.Output, args: ['listChange',] }]
3509
3542
  };
3510
3543
  return AdvancedTableSearchComponent;
3511
3544
  }(AdvancedTableSearchBaseComponent));
@@ -4831,6 +4864,199 @@
4831
4864
  }
4832
4865
  };
4833
4866
 
4867
+ var TableActionTypes;
4868
+ (function (TableActionTypes) {
4869
+ TableActionTypes["LoadFilter"] = "[Table] Load Filter";
4870
+ TableActionTypes["AppendFilter"] = "[Table] Append Filter";
4871
+ TableActionTypes["AppendState"] = "[Table] Append State";
4872
+ })(TableActionTypes || (TableActionTypes = {}));
4873
+ var AppendFilter = /** @class */ (function () {
4874
+ function AppendFilter(id, filter) {
4875
+ this.id = id;
4876
+ this.filter = filter;
4877
+ this.type = TableActionTypes.AppendFilter;
4878
+ }
4879
+ return AppendFilter;
4880
+ }());
4881
+ var AppendState = /** @class */ (function () {
4882
+ function AppendState(id, data) {
4883
+ this.id = id;
4884
+ this.data = data;
4885
+ this.type = TableActionTypes.AppendState;
4886
+ }
4887
+ return AppendState;
4888
+ }());
4889
+
4890
+ var initialState = {};
4891
+ function tableReducer(state, action) {
4892
+ if (state === void 0) {
4893
+ state = initialState;
4894
+ }
4895
+ switch (action.type) {
4896
+ case TableActionTypes.LoadFilter:
4897
+ return state[action.id];
4898
+ case TableActionTypes.AppendFilter:
4899
+ state[action.id] = __assign({}, state[action.id], { filter: action.filter });
4900
+ return state;
4901
+ case TableActionTypes.AppendState:
4902
+ state[action.id] = __assign({}, state[action.id], { table: action.data });
4903
+ return state;
4904
+ default:
4905
+ return state;
4906
+ }
4907
+ }
4908
+ var tableReducers = {
4909
+ tables: tableReducer,
4910
+ };
4911
+ var featureName = 'tables';
4912
+ var getTablesState = store.createFeatureSelector(featureName);
4913
+ var selectTable = store.createSelector(getTablesState, function (state, props) {
4914
+ return state.tables[props.id];
4915
+ });
4916
+
4917
+ var AdvancedTableState = /** @class */ (function () {
4918
+ function AdvancedTableState(table, store$$1) {
4919
+ this.table = table;
4920
+ this.store = store$$1;
4921
+ }
4922
+ AdvancedTableState.prototype.ngOnInit = function () {
4923
+ var _this = this;
4924
+ if (this.store == null) {
4925
+ return;
4926
+ }
4927
+ this.table.stateSave = true;
4928
+ this.table.stateLoadCallback = function (settings, callback) {
4929
+ _this.store.pipe(store.select(selectTable, { id: _this.tableState }), operators.first()).subscribe(function (state) {
4930
+ return callback(state && state.table);
4931
+ });
4932
+ };
4933
+ var firstDraw = true;
4934
+ this.table.draw.subscribe(function () {
4935
+ if (firstDraw === false) {
4936
+ return;
4937
+ }
4938
+ if (_this.table.dataTable == null) {
4939
+ return;
4940
+ }
4941
+ firstDraw = false;
4942
+ var loadeStateSettings = _this.table.dataTable.settings()[0];
4943
+ var scrollerSettings = loadeStateSettings.oSavedState &&
4944
+ loadeStateSettings.oSavedState.scroller;
4945
+ if (scrollerSettings && scrollerSettings.topRow) {
4946
+ var scroller = _this.table.dataTable.scroller();
4947
+ scroller.scrollToRow(scrollerSettings.topRow, true);
4948
+ }
4949
+ });
4950
+ this.table.stateSaveCallback = function (settings, data) {
4951
+ _this.store.dispatch(new AppendState(_this.tableState, data));
4952
+ };
4953
+ };
4954
+ AdvancedTableState.decorators = [
4955
+ { type: i0.Directive, args: [{
4956
+ // tslint:disable-next-line: directive-selector
4957
+ selector: '[tableState]',
4958
+ },] }
4959
+ ];
4960
+ /** @nocollapse */
4961
+ AdvancedTableState.ctorParameters = function () {
4962
+ return [
4963
+ { type: AdvancedTableComponent },
4964
+ { type: store.Store, decorators: [{ type: i0.Optional }] }
4965
+ ];
4966
+ };
4967
+ AdvancedTableState.propDecorators = {
4968
+ tableState: [{ type: i0.Input }]
4969
+ };
4970
+ return AdvancedTableState;
4971
+ }());
4972
+
4973
+ var AdvancedTableSearchComponentNotNull = /** @class */ (function (_super) {
4974
+ __extends(AdvancedTableSearchComponentNotNull, _super);
4975
+ function AdvancedTableSearchComponentNotNull() {
4976
+ return _super.call(this, 'Advanced table search component cannot be empty at this context.') || this;
4977
+ }
4978
+ return AdvancedTableSearchComponentNotNull;
4979
+ }(Error));
4980
+ var AdvancedSearchState = /** @class */ (function () {
4981
+ function AdvancedSearchState(search, store$$1) {
4982
+ this.search = search;
4983
+ this.store = store$$1;
4984
+ }
4985
+ AdvancedSearchState.prototype.ngOnInit = function () {
4986
+ var _this = this;
4987
+ if (this.store == null) {
4988
+ return;
4989
+ }
4990
+ if (this.search == null) {
4991
+ throw new AdvancedTableSearchComponentNotNull();
4992
+ }
4993
+ if (this.search.table) {
4994
+ // set auto load to false
4995
+ this.search.table.autoLoad = false;
4996
+ // handle filtering
4997
+ this.search.filterChange.subscribe(function (filter) {
4998
+ _this.onSearchFilter(filter);
4999
+ });
5000
+ // handle table state (via directive)
5001
+ var tableState = new AdvancedTableState(this.search.table, this.store);
5002
+ tableState.tableState = this.searchState;
5003
+ tableState.ngOnInit();
5004
+ // handle table init
5005
+ this.search.table.init.subscribe(function () {
5006
+ return _this.onTableInit();
5007
+ });
5008
+ }
5009
+ };
5010
+ AdvancedSearchState.prototype.onTableInit = function () {
5011
+ var _this = this;
5012
+ this.store.pipe(store.select(selectTable, { id: this.searchState }), operators.first()).subscribe(function (state) {
5013
+ // use order
5014
+ if (state) {
5015
+ if (state.order && state.order.length) {
5016
+ _this.search.table.dataTable.order(state.order);
5017
+ }
5018
+ // use text search
5019
+ if (state.filter && state.filter.q) {
5020
+ _this.search.text = state.filter.q;
5021
+ _this.search.collapsed = true;
5022
+ return _this.search.table.search(_this.search.text);
5023
+ }
5024
+ // use predefined search
5025
+ if (state.filter && state.filter.s) {
5026
+ _this.search.selectedList = _this.search.userSearchList.find(function (item) {
5027
+ return item.name === state.filter.s;
5028
+ });
5029
+ return _this.search.search();
5030
+ }
5031
+ if (state.filter) {
5032
+ _this.search.filter = state.filter;
5033
+ }
5034
+ return _this.search.search();
5035
+ }
5036
+ });
5037
+ };
5038
+ AdvancedSearchState.prototype.onSearchFilter = function (filter) {
5039
+ this.store.dispatch(new AppendFilter(this.searchState, filter));
5040
+ };
5041
+ AdvancedSearchState.decorators = [
5042
+ { type: i0.Directive, args: [{
5043
+ // tslint:disable-next-line: directive-selector
5044
+ selector: '[searchState]',
5045
+ },] }
5046
+ ];
5047
+ /** @nocollapse */
5048
+ AdvancedSearchState.ctorParameters = function () {
5049
+ return [
5050
+ { type: AdvancedTableSearchComponent },
5051
+ { type: store.Store, decorators: [{ type: i0.Optional }] }
5052
+ ];
5053
+ };
5054
+ AdvancedSearchState.propDecorators = {
5055
+ searchState: [{ type: i0.Input }]
5056
+ };
5057
+ return AdvancedSearchState;
5058
+ }());
5059
+
4834
5060
  var ɵ0 = FORMATTERS;
4835
5061
  var TablesModule = /** @class */ (function () {
4836
5062
  function TablesModule(_translateService) {
@@ -4864,7 +5090,8 @@
4864
5090
  i2.SharedModule,
4865
5091
  modal.ModalModule,
4866
5092
  progressbar.ProgressbarModule,
4867
- ngxPipes.NgPipesModule
5093
+ ngxPipes.NgPipesModule,
5094
+ store.StoreModule.forFeature(featureName, tableReducers)
4868
5095
  ],
4869
5096
  providers: [common.DatePipe, i2.TemplatePipe,
4870
5097
  {
@@ -4894,7 +5121,9 @@
4894
5121
  AdvancedAggregatorListComponent,
4895
5122
  AdvancedAggregatorPipe,
4896
5123
  ParseTitlePipe,
4897
- AddItemsComponent
5124
+ AddItemsComponent,
5125
+ AdvancedSearchState,
5126
+ AdvancedTableState
4898
5127
  ],
4899
5128
  exports: [
4900
5129
  AdvancedTableComponent,
@@ -4910,7 +5139,9 @@
4910
5139
  AdvancedTableEditorDirective,
4911
5140
  AdvancedAggregatorComponent,
4912
5141
  AdvancedAggregatorListComponent,
4913
- AddItemsComponent
5142
+ AddItemsComponent,
5143
+ AdvancedSearchState,
5144
+ AdvancedTableState
4914
5145
  ],
4915
5146
  entryComponents: [
4916
5147
  AdvancedTableModalBaseComponent,
@@ -4939,6 +5170,11 @@
4939
5170
  * Generated bundle index. Do not edit.
4940
5171
  */
4941
5172
 
5173
+ exports.ɵe = AdvancedSearchState;
5174
+ exports.ɵf = AdvancedTableState;
5175
+ exports.ɵd = featureName;
5176
+ exports.ɵa = tableReducer;
5177
+ exports.ɵc = tableReducers;
4942
5178
  exports.AdvancedListComponent = AdvancedListComponent;
4943
5179
  exports.AdvancedRowActionComponent = AdvancedRowActionComponent;
4944
5180
  exports.AdvancedSearchFormComponent = AdvancedSearchFormComponent;