@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.
- package/bundles/universis-ngx-tables.umd.js +112 -14
- package/bundles/universis-ngx-tables.umd.js.map +1 -1
- package/bundles/universis-ngx-tables.umd.min.js +1 -1
- package/bundles/universis-ngx-tables.umd.min.js.map +1 -1
- package/esm2015/lib/components/advanced-table/advanced-table.component.js +13 -2
- package/esm2015/lib/directives/advance-search-state.directive.js +29 -9
- package/esm2015/lib/directives/advanced-search-router-state.directive.js +63 -0
- package/esm2015/lib/tables.module.js +6 -3
- package/esm2015/universis-ngx-tables.js +2 -1
- package/esm5/lib/components/advanced-table/advanced-table.component.js +13 -2
- package/esm5/lib/directives/advance-search-state.directive.js +29 -9
- package/esm5/lib/directives/advanced-search-router-state.directive.js +71 -0
- package/esm5/lib/tables.module.js +6 -3
- package/esm5/universis-ngx-tables.js +2 -1
- package/fesm2015/universis-ngx-tables.js +121 -32
- package/fesm2015/universis-ngx-tables.js.map +1 -1
- package/fesm5/universis-ngx-tables.js +127 -32
- package/fesm5/universis-ngx-tables.js.map +1 -1
- package/lib/directives/advance-search-state.directive.d.ts +8 -4
- package/lib/directives/advanced-search-router-state.directive.d.ts +16 -0
- package/package.json +1 -1
- package/universis-ngx-tables.d.ts +1 -0
- package/universis-ngx-tables.metadata.json +1 -1
|
@@ -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 {
|
|
@@ -1116,6 +1116,13 @@ var AdvancedTableComponent = /** @class */ (function () {
|
|
|
1116
1116
|
});
|
|
1117
1117
|
// get table element
|
|
1118
1118
|
var tableElement_1 = jQuery(this.table.nativeElement);
|
|
1119
|
+
jQuery(window).on('resize', function () {
|
|
1120
|
+
setTimeout(function () {
|
|
1121
|
+
if (_this.dataTable) {
|
|
1122
|
+
_this.dataTable.columns.adjust();
|
|
1123
|
+
}
|
|
1124
|
+
}, 1);
|
|
1125
|
+
});
|
|
1119
1126
|
// tslint:disable-next-line: no-shadowed-variable
|
|
1120
1127
|
tableElement_1.on('processing.dt', function (event, settings, processing) {
|
|
1121
1128
|
if (processing) {
|
|
@@ -1131,6 +1138,7 @@ var AdvancedTableComponent = /** @class */ (function () {
|
|
|
1131
1138
|
}, 0);
|
|
1132
1139
|
}
|
|
1133
1140
|
});
|
|
1141
|
+
var drawIndex_1 = 1;
|
|
1134
1142
|
tableElement_1.on('order.dt', function (event) {
|
|
1135
1143
|
if (_this.dataTable) {
|
|
1136
1144
|
var order = _this.dataTable.order();
|
|
@@ -1143,8 +1151,11 @@ var AdvancedTableComponent = /** @class */ (function () {
|
|
|
1143
1151
|
if (_this.dataTable) {
|
|
1144
1152
|
var info = _this.dataTable.page.info();
|
|
1145
1153
|
_this.page.emit(info);
|
|
1154
|
+
if (drawIndex_1 > 1)
|
|
1155
|
+
return;
|
|
1146
1156
|
try {
|
|
1147
|
-
|
|
1157
|
+
drawIndex_1++;
|
|
1158
|
+
setTimeout(function () { _this.dataTable.columns.adjust(); }, 1);
|
|
1148
1159
|
}
|
|
1149
1160
|
catch (err) {
|
|
1150
1161
|
console.error('ERROR', 'An error occurred while adjusting table columns');
|
|
@@ -2158,8 +2169,8 @@ var AdvancedSearchFormComponent = /** @class */ (function (_super) {
|
|
|
2158
2169
|
form: this.form
|
|
2159
2170
|
});
|
|
2160
2171
|
this.loading = false;
|
|
2161
|
-
this.filterSubscription = this.filterChange.subscribe(function (filter) {
|
|
2162
|
-
_this.submission.data = filter;
|
|
2172
|
+
this.filterSubscription = this.filterChange.subscribe(function (filter$$1) {
|
|
2173
|
+
_this.submission.data = filter$$1;
|
|
2163
2174
|
_this.refreshForm.emit({
|
|
2164
2175
|
submission: _this.submission
|
|
2165
2176
|
});
|
|
@@ -2438,7 +2449,7 @@ var AdvancedTableModalBaseComponent = /** @class */ (function (_super) {
|
|
|
2438
2449
|
* @param {object} filter The filter to use in the search
|
|
2439
2450
|
*
|
|
2440
2451
|
*/
|
|
2441
|
-
AdvancedTableModalBaseComponent.prototype.advancedSearch = function (filter) {
|
|
2452
|
+
AdvancedTableModalBaseComponent.prototype.advancedSearch = function (filter$$1) {
|
|
2442
2453
|
return __awaiter(this, void 0, void 0, function () {
|
|
2443
2454
|
var defaultFilterValues, err_1, expressions, predefinedCriteria, query;
|
|
2444
2455
|
return __generator(this, function (_a) {
|
|
@@ -2462,9 +2473,9 @@ var AdvancedTableModalBaseComponent = /** @class */ (function (_super) {
|
|
|
2462
2473
|
return [3 /*break*/, 4];
|
|
2463
2474
|
case 4:
|
|
2464
2475
|
expressions = [];
|
|
2465
|
-
if (filter) {
|
|
2466
|
-
this.defaultFilter = filter;
|
|
2467
|
-
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);
|
|
2468
2479
|
}
|
|
2469
2480
|
else {
|
|
2470
2481
|
// Empty a falsy filter resets the results
|
|
@@ -4612,9 +4623,9 @@ var TableActionTypes;
|
|
|
4612
4623
|
TableActionTypes["AppendState"] = "[Table] Append State";
|
|
4613
4624
|
})(TableActionTypes || (TableActionTypes = {}));
|
|
4614
4625
|
var AppendFilter = /** @class */ (function () {
|
|
4615
|
-
function AppendFilter(id, filter) {
|
|
4626
|
+
function AppendFilter(id, filter$$1) {
|
|
4616
4627
|
this.id = id;
|
|
4617
|
-
this.filter = filter;
|
|
4628
|
+
this.filter = filter$$1;
|
|
4618
4629
|
this.type = TableActionTypes.AppendFilter;
|
|
4619
4630
|
}
|
|
4620
4631
|
return AppendFilter;
|
|
@@ -4735,19 +4746,23 @@ var AdvancedSearchState = /** @class */ (function () {
|
|
|
4735
4746
|
// set auto load to false
|
|
4736
4747
|
this.search.table.autoLoad = false;
|
|
4737
4748
|
// handle filtering
|
|
4738
|
-
this.search.filterChange.subscribe(function (filter) {
|
|
4739
|
-
_this.onSearchFilter(filter);
|
|
4749
|
+
this.filterChangeSubscription = this.search.filterChange.subscribe(function (filter$$1) {
|
|
4750
|
+
_this.onSearchFilter(filter$$1);
|
|
4740
4751
|
});
|
|
4741
|
-
//
|
|
4742
|
-
|
|
4743
|
-
tableState.tableState = this.searchState;
|
|
4744
|
-
tableState.ngOnInit();
|
|
4752
|
+
// apply table state
|
|
4753
|
+
this.applyTableState();
|
|
4745
4754
|
// handle table init
|
|
4746
|
-
this.search.table.init.subscribe(function () {
|
|
4755
|
+
this.tableInitSubscription = this.search.table.init.subscribe(function () {
|
|
4747
4756
|
return _this.onTableInit();
|
|
4748
4757
|
});
|
|
4749
4758
|
}
|
|
4750
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
|
+
};
|
|
4751
4766
|
AdvancedSearchState.prototype.onTableInit = function () {
|
|
4752
4767
|
var _this = this;
|
|
4753
4768
|
this.store.pipe(select(selectTable, { id: this.searchState }), first()).subscribe(function (state) {
|
|
@@ -4770,14 +4785,30 @@ var AdvancedSearchState = /** @class */ (function () {
|
|
|
4770
4785
|
return _this.search.search();
|
|
4771
4786
|
}
|
|
4772
4787
|
if (state.filter) {
|
|
4773
|
-
|
|
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
|
+
}
|
|
4774
4794
|
}
|
|
4795
|
+
// ensure empty filter at this moment
|
|
4796
|
+
// because search() function triggers a store dispatch
|
|
4797
|
+
_this.search.filter = {};
|
|
4775
4798
|
return _this.search.search();
|
|
4776
4799
|
}
|
|
4777
4800
|
});
|
|
4778
4801
|
};
|
|
4779
|
-
AdvancedSearchState.prototype.onSearchFilter = function (filter) {
|
|
4780
|
-
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
|
+
}
|
|
4781
4812
|
};
|
|
4782
4813
|
AdvancedSearchState.decorators = [
|
|
4783
4814
|
{ type: Directive, args: [{
|
|
@@ -4796,6 +4827,68 @@ var AdvancedSearchState = /** @class */ (function () {
|
|
|
4796
4827
|
return AdvancedSearchState;
|
|
4797
4828
|
}());
|
|
4798
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
|
+
|
|
4799
4892
|
var ɵ0 = FORMATTERS;
|
|
4800
4893
|
var TablesModule = /** @class */ (function () {
|
|
4801
4894
|
function TablesModule(_translateService) {
|
|
@@ -4861,7 +4954,8 @@ var TablesModule = /** @class */ (function () {
|
|
|
4861
4954
|
ParseTitlePipe,
|
|
4862
4955
|
AddItemsComponent,
|
|
4863
4956
|
AdvancedSearchState,
|
|
4864
|
-
AdvancedTableState
|
|
4957
|
+
AdvancedTableState,
|
|
4958
|
+
AdvancedSearchRouterState
|
|
4865
4959
|
],
|
|
4866
4960
|
exports: [
|
|
4867
4961
|
AdvancedTableComponent,
|
|
@@ -4879,7 +4973,8 @@ var TablesModule = /** @class */ (function () {
|
|
|
4879
4973
|
AdvancedAggregatorListComponent,
|
|
4880
4974
|
AddItemsComponent,
|
|
4881
4975
|
AdvancedSearchState,
|
|
4882
|
-
AdvancedTableState
|
|
4976
|
+
AdvancedTableState,
|
|
4977
|
+
AdvancedSearchRouterState
|
|
4883
4978
|
],
|
|
4884
4979
|
entryComponents: [
|
|
4885
4980
|
AdvancedTableModalBaseComponent,
|
|
@@ -4906,6 +5001,6 @@ var TablesModule = /** @class */ (function () {
|
|
|
4906
5001
|
* Generated bundle index. Do not edit.
|
|
4907
5002
|
*/
|
|
4908
5003
|
|
|
4909
|
-
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 };
|
|
4910
5005
|
|
|
4911
5006
|
//# sourceMappingURL=universis-ngx-tables.js.map
|