@universis/ngx-tables 0.6.0
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/LICENSE +163 -0
- package/README.md +121 -0
- package/bundles/universis-ngx-tables.umd.js +4591 -0
- package/bundles/universis-ngx-tables.umd.js.map +1 -0
- package/bundles/universis-ngx-tables.umd.min.js +2 -0
- package/bundles/universis-ngx-tables.umd.min.js.map +1 -0
- package/esm2015/lib/components/add-items/add-items.component.js +142 -0
- package/esm2015/lib/components/advanced-aggregator/advanced-aggregator.component.js +120 -0
- package/esm2015/lib/components/advanced-aggregator-list/advanced-aggregator-list.component.js +53 -0
- package/esm2015/lib/components/advanced-list/advanced-list.component.js +173 -0
- package/esm2015/lib/components/advanced-row-action/advanced-row-action.component.js +175 -0
- package/esm2015/lib/components/advanced-search-form/advanced-search-form.component.js +134 -0
- package/esm2015/lib/components/advanced-select/advanced-select.component.js +51 -0
- package/esm2015/lib/components/advanced-select/advanced-select.service.js +40 -0
- package/esm2015/lib/components/advanced-table/advanced-filter-value-provider.service.js +37 -0
- package/esm2015/lib/components/advanced-table/advanced-table-resolvers.js +44 -0
- package/esm2015/lib/components/advanced-table/advanced-table-search-base.js +23 -0
- package/esm2015/lib/components/advanced-table/advanced-table-search.component.js +519 -0
- package/esm2015/lib/components/advanced-table/advanced-table-settings.component.js +109 -0
- package/esm2015/lib/components/advanced-table/advanced-table.component.js +1007 -0
- package/esm2015/lib/components/advanced-table/advanced-table.formatters.interface.js +16 -0
- package/esm2015/lib/components/advanced-table/advanced-table.formatters.js +271 -0
- package/esm2015/lib/components/advanced-table/advanced-table.interfaces.js +2 -0
- package/esm2015/lib/components/advanced-table-modal/advanced-table-modal-base.component.js +379 -0
- package/esm2015/lib/components/table-simple-header/table-simple-header.component.js +52 -0
- package/esm2015/lib/directives/advanced-table-editor.directive.js +157 -0
- package/esm2015/lib/directives/btnexp.directive.js +225 -0
- package/esm2015/lib/i18n/tables.el.js +104 -0
- package/esm2015/lib/i18n/tables.en.js +103 -0
- package/esm2015/lib/pipes/advanced-aggregator.pipe.js +35 -0
- package/esm2015/lib/pipes/advansed-aggregator-list-title-parse.pipe.js +46 -0
- package/esm2015/lib/services/advanced-aggregator/advanced-aggregator.service.js +117 -0
- package/esm2015/lib/tables.activated-table.service.js +36 -0
- package/esm2015/lib/tables.module.js +134 -0
- package/esm2015/public_api.js +22 -0
- package/esm2015/universis-ngx-tables.js +14 -0
- package/esm5/lib/components/add-items/add-items.component.js +153 -0
- package/esm5/lib/components/advanced-aggregator/advanced-aggregator.component.js +169 -0
- package/esm5/lib/components/advanced-aggregator-list/advanced-aggregator-list.component.js +56 -0
- package/esm5/lib/components/advanced-list/advanced-list.component.js +185 -0
- package/esm5/lib/components/advanced-row-action/advanced-row-action.component.js +179 -0
- package/esm5/lib/components/advanced-search-form/advanced-search-form.component.js +137 -0
- package/esm5/lib/components/advanced-select/advanced-select.component.js +56 -0
- package/esm5/lib/components/advanced-select/advanced-select.service.js +43 -0
- package/esm5/lib/components/advanced-table/advanced-filter-value-provider.service.js +50 -0
- package/esm5/lib/components/advanced-table/advanced-table-resolvers.js +48 -0
- package/esm5/lib/components/advanced-table/advanced-table-search-base.js +29 -0
- package/esm5/lib/components/advanced-table/advanced-table-search.component.js +556 -0
- package/esm5/lib/components/advanced-table/advanced-table-settings.component.js +115 -0
- package/esm5/lib/components/advanced-table/advanced-table.component.js +1035 -0
- package/esm5/lib/components/advanced-table/advanced-table.formatters.interface.js +16 -0
- package/esm5/lib/components/advanced-table/advanced-table.formatters.js +313 -0
- package/esm5/lib/components/advanced-table/advanced-table.interfaces.js +2 -0
- package/esm5/lib/components/advanced-table-modal/advanced-table-modal-base.component.js +295 -0
- package/esm5/lib/components/table-simple-header/table-simple-header.component.js +58 -0
- package/esm5/lib/directives/advanced-table-editor.directive.js +175 -0
- package/esm5/lib/directives/btnexp.directive.js +253 -0
- package/esm5/lib/i18n/tables.el.js +104 -0
- package/esm5/lib/i18n/tables.en.js +103 -0
- package/esm5/lib/pipes/advanced-aggregator.pipe.js +39 -0
- package/esm5/lib/pipes/advansed-aggregator-list-title-parse.pipe.js +49 -0
- package/esm5/lib/services/advanced-aggregator/advanced-aggregator.service.js +130 -0
- package/esm5/lib/tables.activated-table.service.js +43 -0
- package/esm5/lib/tables.module.js +139 -0
- package/esm5/public_api.js +22 -0
- package/esm5/universis-ngx-tables.js +14 -0
- package/fesm2015/universis-ngx-tables.js +4127 -0
- package/fesm2015/universis-ngx-tables.js.map +1 -0
- package/fesm5/universis-ngx-tables.js +4313 -0
- package/fesm5/universis-ngx-tables.js.map +1 -0
- package/lib/advanced-aggregator.d.ts +124 -0
- package/lib/components/add-items/add-items.component.d.ts +44 -0
- package/lib/components/advanced-aggregator/advanced-aggregator.component.d.ts +45 -0
- package/lib/components/advanced-aggregator-list/advanced-aggregator-list.component.d.ts +25 -0
- package/lib/components/advanced-list/advanced-list.component.d.ts +42 -0
- package/lib/components/advanced-row-action/advanced-row-action.component.d.ts +42 -0
- package/lib/components/advanced-search-form/advanced-search-form.component.d.ts +27 -0
- package/lib/components/advanced-select/advanced-select.component.d.ts +14 -0
- package/lib/components/advanced-select/advanced-select.service.d.ts +9 -0
- package/lib/components/advanced-table/advanced-filter-value-provider.service.d.ts +8 -0
- package/lib/components/advanced-table/advanced-table-resolvers.d.ts +12 -0
- package/lib/components/advanced-table/advanced-table-search-base.d.ts +7 -0
- package/lib/components/advanced-table/advanced-table-search.component.d.ts +80 -0
- package/lib/components/advanced-table/advanced-table-settings.component.d.ts +35 -0
- package/lib/components/advanced-table/advanced-table.component.d.ts +142 -0
- package/lib/components/advanced-table/advanced-table.formatters.d.ts +62 -0
- package/lib/components/advanced-table/advanced-table.formatters.interface.d.ts +15 -0
- package/lib/components/advanced-table/advanced-table.interfaces.d.ts +27 -0
- package/lib/components/advanced-table-modal/advanced-table-modal-base.component.d.ts +82 -0
- package/lib/components/table-simple-header/table-simple-header.component.d.ts +14 -0
- package/lib/directives/advanced-table-editor.directive.d.ts +25 -0
- package/lib/directives/btnexp.directive.d.ts +68 -0
- package/lib/i18n/tables.el.d.ts +102 -0
- package/lib/i18n/tables.en.d.ts +101 -0
- package/lib/pipes/advanced-aggregator.pipe.d.ts +21 -0
- package/lib/pipes/advansed-aggregator-list-title-parse.pipe.d.ts +21 -0
- package/lib/services/advanced-aggregator/advanced-aggregator.service.d.ts +32 -0
- package/lib/tables.activated-table.service.d.ts +9 -0
- package/lib/tables.module.d.ts +7 -0
- package/package.json +51 -0
- package/public_api.d.ts +18 -0
- package/universis-ngx-tables.d.ts +12 -0
- package/universis-ngx-tables.metadata.json +1 -0
|
@@ -0,0 +1,4591 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash'), 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('@angular/common'), require('@themost/client'), require('@angular/forms'), require('@universis/forms'), require('angular-formio'), require('ngx-bootstrap/modal'), require('ngx-bootstrap/dropdown'), require('ngx-bootstrap/progressbar'), require('ngx-pipes'), require('@angular/core'), require('@universis/common/routing'), require('@angular/router'), require('@ngx-translate/core'), require('@themost/angular'), require('@universis/common')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@universis/ngx-tables', ['exports', 'lodash', 'iso-639-1/build', 'rxjs', 'jquery', 'datatables.net', 'datatables.net-scroller', 'rxjs/add/observable/combineLatest', '@angular/common/http', '@angular/common', '@themost/client', '@angular/forms', '@universis/forms', 'angular-formio', 'ngx-bootstrap/modal', 'ngx-bootstrap/dropdown', 'ngx-bootstrap/progressbar', 'ngx-pipes', '@angular/core', '@universis/common/routing', '@angular/router', '@ngx-translate/core', '@themost/angular', '@universis/common'], factory) :
|
|
4
|
+
(factory((global.universis = global.universis || {}, global.universis['ngx-tables'] = {}),global.lodash,global.ISO6391,global.rxjs,global.jQuery_,null,null,global.rxjs['add/observable/combineLatest'],global.ng.common.http,global.ng.common,global.client,global.ng.forms,global.forms$1,global.angularFormio,global.modal,global.dropdown,global.progressbar,global.ngxPipes,global.ng.core,global.routing,global.ng.router,global.core,global.i1$1,global.i2));
|
|
5
|
+
}(this, (function (exports,lodash,ISO6391,rxjs,jQuery_,datatables_net,datatables_netScroller,combineLatest,http,common,client,forms,forms$1,angularFormio,modal,dropdown,progressbar,ngxPipes,i0,routing,i1,core,i1$1,i2) { 'use strict';
|
|
6
|
+
|
|
7
|
+
/*! *****************************************************************************
|
|
8
|
+
Copyright (c) Microsoft Corporation.
|
|
9
|
+
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
+
purpose with or without fee is hereby granted.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
+
***************************************************************************** */
|
|
21
|
+
/* global Reflect, Promise */
|
|
22
|
+
var extendStatics = function (d, b) {
|
|
23
|
+
extendStatics = Object.setPrototypeOf ||
|
|
24
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
25
|
+
function (d, b) { for (var p in b)
|
|
26
|
+
if (b.hasOwnProperty(p))
|
|
27
|
+
d[p] = b[p]; };
|
|
28
|
+
return extendStatics(d, b);
|
|
29
|
+
};
|
|
30
|
+
function __extends(d, b) {
|
|
31
|
+
extendStatics(d, b);
|
|
32
|
+
function __() { this.constructor = d; }
|
|
33
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
34
|
+
}
|
|
35
|
+
var __assign = function () {
|
|
36
|
+
__assign = Object.assign || function __assign(t) {
|
|
37
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
38
|
+
s = arguments[i];
|
|
39
|
+
for (var p in s)
|
|
40
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
41
|
+
t[p] = s[p];
|
|
42
|
+
}
|
|
43
|
+
return t;
|
|
44
|
+
};
|
|
45
|
+
return __assign.apply(this, arguments);
|
|
46
|
+
};
|
|
47
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
48
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
49
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
50
|
+
function fulfilled(value) { try {
|
|
51
|
+
step(generator.next(value));
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
reject(e);
|
|
55
|
+
} }
|
|
56
|
+
function rejected(value) { try {
|
|
57
|
+
step(generator["throw"](value));
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
reject(e);
|
|
61
|
+
} }
|
|
62
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
63
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function __generator(thisArg, body) {
|
|
67
|
+
var _ = { label: 0, sent: function () { if (t[0] & 1)
|
|
68
|
+
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
69
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
70
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
71
|
+
function step(op) {
|
|
72
|
+
if (f)
|
|
73
|
+
throw new TypeError("Generator is already executing.");
|
|
74
|
+
while (_)
|
|
75
|
+
try {
|
|
76
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
77
|
+
return t;
|
|
78
|
+
if (y = 0, t)
|
|
79
|
+
op = [op[0] & 2, t.value];
|
|
80
|
+
switch (op[0]) {
|
|
81
|
+
case 0:
|
|
82
|
+
case 1:
|
|
83
|
+
t = op;
|
|
84
|
+
break;
|
|
85
|
+
case 4:
|
|
86
|
+
_.label++;
|
|
87
|
+
return { value: op[1], done: false };
|
|
88
|
+
case 5:
|
|
89
|
+
_.label++;
|
|
90
|
+
y = op[1];
|
|
91
|
+
op = [0];
|
|
92
|
+
continue;
|
|
93
|
+
case 7:
|
|
94
|
+
op = _.ops.pop();
|
|
95
|
+
_.trys.pop();
|
|
96
|
+
continue;
|
|
97
|
+
default:
|
|
98
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
99
|
+
_ = 0;
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
103
|
+
_.label = op[1];
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
107
|
+
_.label = t[1];
|
|
108
|
+
t = op;
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
if (t && _.label < t[2]) {
|
|
112
|
+
_.label = t[2];
|
|
113
|
+
_.ops.push(op);
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
if (t[2])
|
|
117
|
+
_.ops.pop();
|
|
118
|
+
_.trys.pop();
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
op = body.call(thisArg, _);
|
|
122
|
+
}
|
|
123
|
+
catch (e) {
|
|
124
|
+
op = [6, e];
|
|
125
|
+
y = 0;
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
f = t = 0;
|
|
129
|
+
}
|
|
130
|
+
if (op[0] & 5)
|
|
131
|
+
throw op[1];
|
|
132
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function __values(o) {
|
|
136
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
137
|
+
if (m)
|
|
138
|
+
return m.call(o);
|
|
139
|
+
if (o && typeof o.length === "number")
|
|
140
|
+
return {
|
|
141
|
+
next: function () {
|
|
142
|
+
if (o && i >= o.length)
|
|
143
|
+
o = void 0;
|
|
144
|
+
return { value: o && o[i++], done: !o };
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
148
|
+
}
|
|
149
|
+
function __read(o, n) {
|
|
150
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
151
|
+
if (!m)
|
|
152
|
+
return o;
|
|
153
|
+
var i = m.call(o), r, ar = [], e;
|
|
154
|
+
try {
|
|
155
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
156
|
+
ar.push(r.value);
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
e = { error: error };
|
|
160
|
+
}
|
|
161
|
+
finally {
|
|
162
|
+
try {
|
|
163
|
+
if (r && !r.done && (m = i["return"]))
|
|
164
|
+
m.call(i);
|
|
165
|
+
}
|
|
166
|
+
finally {
|
|
167
|
+
if (e)
|
|
168
|
+
throw e.error;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return ar;
|
|
172
|
+
}
|
|
173
|
+
function __spread() {
|
|
174
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
175
|
+
ar = ar.concat(__read(arguments[i]));
|
|
176
|
+
return ar;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
var AdvancedColumnFormatter = /** @class */ (function () {
|
|
180
|
+
function AdvancedColumnFormatter() {
|
|
181
|
+
}
|
|
182
|
+
return AdvancedColumnFormatter;
|
|
183
|
+
}());
|
|
184
|
+
var NestedPropertyFormatter = /** @class */ (function (_super) {
|
|
185
|
+
__extends(NestedPropertyFormatter, _super);
|
|
186
|
+
function NestedPropertyFormatter() {
|
|
187
|
+
return _super.call(this) || this;
|
|
188
|
+
}
|
|
189
|
+
NestedPropertyFormatter.prototype.render = function (data, type, row, meta) {
|
|
190
|
+
// get column
|
|
191
|
+
var column = meta.settings.aoColumns[meta.col];
|
|
192
|
+
if (column && column.data) {
|
|
193
|
+
return lodash.at(row, column.data.replace(/\//g, '.'));
|
|
194
|
+
}
|
|
195
|
+
return data;
|
|
196
|
+
};
|
|
197
|
+
return NestedPropertyFormatter;
|
|
198
|
+
}(AdvancedColumnFormatter));
|
|
199
|
+
var ButtonFormatter = /** @class */ (function (_super) {
|
|
200
|
+
__extends(ButtonFormatter, _super);
|
|
201
|
+
function ButtonFormatter() {
|
|
202
|
+
return _super.call(this) || this;
|
|
203
|
+
}
|
|
204
|
+
ButtonFormatter.prototype.render = function (data, type, row, meta) {
|
|
205
|
+
var _this = this;
|
|
206
|
+
if (data == null) {
|
|
207
|
+
return '';
|
|
208
|
+
}
|
|
209
|
+
// get column
|
|
210
|
+
var column = meta.settings.aoColumns[meta.col];
|
|
211
|
+
// get format options
|
|
212
|
+
var formatOptions = Object.assign({
|
|
213
|
+
buttonClass: 'btn btn-default'
|
|
214
|
+
}, this.formatOptions);
|
|
215
|
+
// get text content
|
|
216
|
+
var buttonText;
|
|
217
|
+
var buttonTitle = '';
|
|
218
|
+
if (formatOptions.buttonText) {
|
|
219
|
+
buttonText = this.injector.get(core.TranslateService).instant(formatOptions.buttonText);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
buttonText = formatOptions.buttonContent;
|
|
223
|
+
}
|
|
224
|
+
if (formatOptions.buttonTitle) {
|
|
225
|
+
buttonTitle = this.injector.get(core.TranslateService).instant(formatOptions.buttonTitle);
|
|
226
|
+
}
|
|
227
|
+
if (Array.isArray(this.formatOptions.commands)) {
|
|
228
|
+
var activatedRoute = this.injector.get(i1.ActivatedRoute);
|
|
229
|
+
var router = this.injector.get(i1.Router);
|
|
230
|
+
var commands = this.formatOptions.commands.map(function (command) {
|
|
231
|
+
if (typeof command === 'string') {
|
|
232
|
+
return new i2.TemplatePipe().transform(command, row);
|
|
233
|
+
}
|
|
234
|
+
if (command.outlets) {
|
|
235
|
+
var commandOutlets_1 = {};
|
|
236
|
+
Object.keys(command.outlets).forEach(function (key) {
|
|
237
|
+
if (Object.prototype.hasOwnProperty.call(command.outlets, key)) {
|
|
238
|
+
var outlet = command.outlets[key];
|
|
239
|
+
if (Array.isArray(outlet)) {
|
|
240
|
+
Object.defineProperty(commandOutlets_1, key, {
|
|
241
|
+
enumerable: true,
|
|
242
|
+
configurable: true,
|
|
243
|
+
writable: true,
|
|
244
|
+
value: outlet.map(function (x) {
|
|
245
|
+
return new i2.TemplatePipe().transform(x, row);
|
|
246
|
+
})
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
Object.defineProperty(commandOutlets_1, key, {
|
|
251
|
+
enumerable: true,
|
|
252
|
+
configurable: true,
|
|
253
|
+
writable: true,
|
|
254
|
+
value: outlet
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
return {
|
|
260
|
+
outlets: commandOutlets_1
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
return command;
|
|
264
|
+
});
|
|
265
|
+
var queryParams_1 = {};
|
|
266
|
+
var replaceUrl = true;
|
|
267
|
+
if (this.formatOptions.navigationExtras && this.formatOptions.navigationExtras.queryParams) {
|
|
268
|
+
Object.keys(this.formatOptions.navigationExtras.queryParams).map(function (key) {
|
|
269
|
+
queryParams_1[key] = new i2.TemplatePipe().transform(_this.formatOptions.navigationExtras.queryParams[key], row);
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
if (this.formatOptions.navigationExtras && typeof this.formatOptions.navigationExtras.replaceUrl !== 'undefined') {
|
|
273
|
+
replaceUrl = this.formatOptions.navigationExtras.replaceUrl;
|
|
274
|
+
}
|
|
275
|
+
var skipLocationChange = false;
|
|
276
|
+
if (this.formatOptions.navigationExtras && typeof this.formatOptions.navigationExtras.skipLocationChange !== 'undefined') {
|
|
277
|
+
skipLocationChange = this.formatOptions.navigationExtras.skipLocationChange;
|
|
278
|
+
}
|
|
279
|
+
var routerLink = router.createUrlTree(commands, {
|
|
280
|
+
relativeTo: activatedRoute,
|
|
281
|
+
queryParams: queryParams_1,
|
|
282
|
+
replaceUrl: replaceUrl,
|
|
283
|
+
skipLocationChange: skipLocationChange
|
|
284
|
+
}).toString();
|
|
285
|
+
return "<a class=\"" + formatOptions.buttonClass + "\" title=\"" + buttonTitle + "\" href=\"#" + routerLink + "\">" + buttonText + "</a>";
|
|
286
|
+
}
|
|
287
|
+
// and return button
|
|
288
|
+
var href = new i2.TemplatePipe().transform(this.formatString, row);
|
|
289
|
+
return "<a class=\"" + formatOptions.buttonClass + "\" title=\"" + buttonTitle + "\" href=\"" + href + "\">" + buttonText + "</a>";
|
|
290
|
+
};
|
|
291
|
+
return ButtonFormatter;
|
|
292
|
+
}(AdvancedColumnFormatter));
|
|
293
|
+
var LinkFormatter = /** @class */ (function (_super) {
|
|
294
|
+
__extends(LinkFormatter, _super);
|
|
295
|
+
function LinkFormatter() {
|
|
296
|
+
return _super.call(this) || this;
|
|
297
|
+
}
|
|
298
|
+
LinkFormatter.prototype.render = function (data, type, row, meta) {
|
|
299
|
+
// get column
|
|
300
|
+
var column = meta.settings.aoColumns[meta.col];
|
|
301
|
+
if (column && column.data) {
|
|
302
|
+
return "<a href=\"" + (new i2.TemplatePipe().transform(this.formatString, row)) + "\">" + data + "</a>";
|
|
303
|
+
}
|
|
304
|
+
return data;
|
|
305
|
+
};
|
|
306
|
+
return LinkFormatter;
|
|
307
|
+
}(AdvancedColumnFormatter));
|
|
308
|
+
var ActionLinkFormatter = /** @class */ (function (_super) {
|
|
309
|
+
__extends(ActionLinkFormatter, _super);
|
|
310
|
+
function ActionLinkFormatter() {
|
|
311
|
+
return _super.call(this) || this;
|
|
312
|
+
}
|
|
313
|
+
ActionLinkFormatter.prototype.render = function (data, type, row, meta) {
|
|
314
|
+
var _this = this;
|
|
315
|
+
// get column
|
|
316
|
+
var column = meta.settings.aoColumns[meta.col];
|
|
317
|
+
if (column && column.data) {
|
|
318
|
+
this.actions = this.actions || [];
|
|
319
|
+
var allowedActions = this.actions.filter(function (x) {
|
|
320
|
+
if (x.access && x.access.length > 0) {
|
|
321
|
+
var access = x.access;
|
|
322
|
+
access = access.filter(function (y) {
|
|
323
|
+
if (y.studentStatuses) {
|
|
324
|
+
return y.studentStatuses.find(function (z) { return z.alternateName === row.studentStatus; });
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
if (access && access.length > 0) {
|
|
328
|
+
return x;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
return x;
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
// return the dropdown menu with 3 dots
|
|
336
|
+
return new i2.TemplatePipe().transform("<div class='dropdown details-control' data-id='" + data + "' data-type='student' >\n <a id=\"dropdownMenuButton-" + data + "\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\">\n <span class=\"fa-2x text-dots\"></span></a>\n <div class=\"dropdown-menu\" aria-labelledby=\"dropdownMenuButton-" + data + "\">\n " + allowedActions.map(function (x) { return "<a data-name='" + x.name + "' class=\"dropdown-item\" href=\"" + x.href + "\">\n " + _this.injector.get(core.TranslateService).instant(new i2.TemplatePipe().transform(x.title, ({ value: data }))) + "\n </a>"; })
|
|
337
|
+
.join('') + "\n </div>\n </div>", row);
|
|
338
|
+
}
|
|
339
|
+
return data;
|
|
340
|
+
};
|
|
341
|
+
return ActionLinkFormatter;
|
|
342
|
+
}(AdvancedColumnFormatter));
|
|
343
|
+
var SelectRowFormatter = /** @class */ (function (_super) {
|
|
344
|
+
__extends(SelectRowFormatter, _super);
|
|
345
|
+
function SelectRowFormatter() {
|
|
346
|
+
return _super.call(this) || this;
|
|
347
|
+
}
|
|
348
|
+
SelectRowFormatter.prototype.render = function (data, type, row, meta) {
|
|
349
|
+
// get column
|
|
350
|
+
var column = meta.settings.aoColumns[meta.col];
|
|
351
|
+
if (column && column.data) {
|
|
352
|
+
var _tpl = "<input class=\"checkbox checkbox-theme\" type=\"checkbox\"\n id=\"s-" + meta.row + "\" /><label for=\"s-" + meta.row + "\"> </label>";
|
|
353
|
+
return new i2.TemplatePipe().transform(_tpl, row);
|
|
354
|
+
}
|
|
355
|
+
return data;
|
|
356
|
+
};
|
|
357
|
+
return SelectRowFormatter;
|
|
358
|
+
}(AdvancedColumnFormatter));
|
|
359
|
+
var TemplateFormatter = /** @class */ (function (_super) {
|
|
360
|
+
__extends(TemplateFormatter, _super);
|
|
361
|
+
function TemplateFormatter() {
|
|
362
|
+
return _super.call(this) || this;
|
|
363
|
+
}
|
|
364
|
+
TemplateFormatter.prototype.render = function (data, type, row, meta) {
|
|
365
|
+
// get column
|
|
366
|
+
var column = meta.settings.aoColumns[meta.col];
|
|
367
|
+
if (column && column.data) {
|
|
368
|
+
return new i2.TemplatePipe().transform(this.formatString, row);
|
|
369
|
+
}
|
|
370
|
+
return data;
|
|
371
|
+
};
|
|
372
|
+
return TemplateFormatter;
|
|
373
|
+
}(AdvancedColumnFormatter));
|
|
374
|
+
var TrueFalseFormatter = /** @class */ (function (_super) {
|
|
375
|
+
__extends(TrueFalseFormatter, _super);
|
|
376
|
+
function TrueFalseFormatter() {
|
|
377
|
+
return _super.call(this) || this;
|
|
378
|
+
}
|
|
379
|
+
TrueFalseFormatter.prototype.render = function (data, type, row, meta) {
|
|
380
|
+
return data ? this.injector.get(core.TranslateService).instant('TrueFalse.long.Yes') :
|
|
381
|
+
this.injector.get(core.TranslateService).instant('TrueFalse.long.No');
|
|
382
|
+
};
|
|
383
|
+
return TrueFalseFormatter;
|
|
384
|
+
}(AdvancedColumnFormatter));
|
|
385
|
+
var TranslationFormatter = /** @class */ (function (_super) {
|
|
386
|
+
__extends(TranslationFormatter, _super);
|
|
387
|
+
function TranslationFormatter() {
|
|
388
|
+
return _super.call(this) || this;
|
|
389
|
+
}
|
|
390
|
+
TranslationFormatter.prototype.render = function (data, type, row, meta) {
|
|
391
|
+
// get column
|
|
392
|
+
var column = meta.settings.aoColumns[meta.col];
|
|
393
|
+
if (column && data != null) {
|
|
394
|
+
return this.injector.get(core.TranslateService).instant(new i2.TemplatePipe().transform(this.formatString, { value: data }));
|
|
395
|
+
}
|
|
396
|
+
return this.injector.get(core.TranslateService).instant('Unknown');
|
|
397
|
+
};
|
|
398
|
+
return TranslationFormatter;
|
|
399
|
+
}(AdvancedColumnFormatter));
|
|
400
|
+
var DateTimeFormatter = /** @class */ (function (_super) {
|
|
401
|
+
__extends(DateTimeFormatter, _super);
|
|
402
|
+
function DateTimeFormatter() {
|
|
403
|
+
return _super.call(this) || this;
|
|
404
|
+
}
|
|
405
|
+
DateTimeFormatter.prototype.render = function (data, type, row, meta) {
|
|
406
|
+
// get column
|
|
407
|
+
var column = meta.settings.aoColumns[meta.col];
|
|
408
|
+
if (column && column.data) {
|
|
409
|
+
var datePipe = new common.DatePipe(this.injector.get(core.TranslateService).currentLang);
|
|
410
|
+
if (typeof data === 'string' && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}$/.test(data)) {
|
|
411
|
+
return datePipe.transform(new Date(data + ':00'), this.formatString);
|
|
412
|
+
}
|
|
413
|
+
return datePipe.transform(data, this.formatString);
|
|
414
|
+
}
|
|
415
|
+
return data;
|
|
416
|
+
};
|
|
417
|
+
return DateTimeFormatter;
|
|
418
|
+
}(AdvancedColumnFormatter));
|
|
419
|
+
var NgClassFormatter = /** @class */ (function (_super) {
|
|
420
|
+
__extends(NgClassFormatter, _super);
|
|
421
|
+
function NgClassFormatter() {
|
|
422
|
+
return _super.call(this) || this;
|
|
423
|
+
}
|
|
424
|
+
NgClassFormatter.prototype.render = function (data, type, row, meta) {
|
|
425
|
+
var e_1, _a;
|
|
426
|
+
// get column
|
|
427
|
+
var column = meta.settings.aoColumns[meta.col];
|
|
428
|
+
if (column && column.data) {
|
|
429
|
+
// get formatOptions
|
|
430
|
+
if (this.formatOptions) {
|
|
431
|
+
var ngClass = this.formatOptions.ngClass;
|
|
432
|
+
try {
|
|
433
|
+
// check condition for each key
|
|
434
|
+
for (var _b = __values(Object.keys(ngClass)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
435
|
+
var key = _c.value;
|
|
436
|
+
var result = new i2.TemplatePipe().transform(ngClass[key], row);
|
|
437
|
+
var fn = new Function("return " + result + ";");
|
|
438
|
+
// if condition returns true add class
|
|
439
|
+
if (fn() === true) {
|
|
440
|
+
return "<span class=\"" + key + "\">" + data + "</span>";
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
catch (e_1_1) {
|
|
445
|
+
e_1 = { error: e_1_1 };
|
|
446
|
+
}
|
|
447
|
+
finally {
|
|
448
|
+
try {
|
|
449
|
+
if (_c && !_c.done && (_a = _b.return))
|
|
450
|
+
_a.call(_b);
|
|
451
|
+
}
|
|
452
|
+
finally {
|
|
453
|
+
if (e_1)
|
|
454
|
+
throw e_1.error;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return data;
|
|
459
|
+
}
|
|
460
|
+
return data;
|
|
461
|
+
};
|
|
462
|
+
return NgClassFormatter;
|
|
463
|
+
}(AdvancedColumnFormatter));
|
|
464
|
+
var LanguageFormatter = /** @class */ (function (_super) {
|
|
465
|
+
__extends(LanguageFormatter, _super);
|
|
466
|
+
function LanguageFormatter() {
|
|
467
|
+
return _super.call(this) || this;
|
|
468
|
+
}
|
|
469
|
+
LanguageFormatter.prototype.render = function (data, type, row, meta) {
|
|
470
|
+
if (data) {
|
|
471
|
+
return ISO6391.getNativeName(data);
|
|
472
|
+
}
|
|
473
|
+
return data;
|
|
474
|
+
};
|
|
475
|
+
return LanguageFormatter;
|
|
476
|
+
}(AdvancedColumnFormatter));
|
|
477
|
+
|
|
478
|
+
var AdvancedFilterValueProvider = /** @class */ (function () {
|
|
479
|
+
function AdvancedFilterValueProvider() {
|
|
480
|
+
this.values = {};
|
|
481
|
+
this._template = new i2.TemplatePipe();
|
|
482
|
+
}
|
|
483
|
+
AdvancedFilterValueProvider.prototype.buildFilter = function (filter) {
|
|
484
|
+
if (filter) {
|
|
485
|
+
return this._template.transform(filter, this.values);
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
AdvancedFilterValueProvider.prototype.asyncBuildFilter = function (filter) {
|
|
489
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
490
|
+
var _a, _b, _c;
|
|
491
|
+
return __generator(this, function (_d) {
|
|
492
|
+
switch (_d.label) {
|
|
493
|
+
case 0:
|
|
494
|
+
if (!filter)
|
|
495
|
+
return [3 /*break*/, 2];
|
|
496
|
+
_b = (_a = this._template).transform;
|
|
497
|
+
_c = [filter];
|
|
498
|
+
return [4 /*yield*/, this.getValues()];
|
|
499
|
+
case 1: return [2 /*return*/, _b.apply(_a, _c.concat([_d.sent()]))];
|
|
500
|
+
case 2: return [2 /*return*/];
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
});
|
|
504
|
+
};
|
|
505
|
+
AdvancedFilterValueProvider.prototype.getValues = function () {
|
|
506
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
507
|
+
return __generator(this, function (_a) {
|
|
508
|
+
return [2 /*return*/, this.values];
|
|
509
|
+
});
|
|
510
|
+
});
|
|
511
|
+
};
|
|
512
|
+
AdvancedFilterValueProvider.decorators = [
|
|
513
|
+
{ type: i0.Injectable, args: [{
|
|
514
|
+
providedIn: 'root'
|
|
515
|
+
},] }
|
|
516
|
+
];
|
|
517
|
+
/** @nocollapse */
|
|
518
|
+
AdvancedFilterValueProvider.ctorParameters = function () { return []; };
|
|
519
|
+
AdvancedFilterValueProvider.ngInjectableDef = i0.defineInjectable({ factory: function AdvancedFilterValueProvider_Factory() { return new AdvancedFilterValueProvider(); }, token: AdvancedFilterValueProvider, providedIn: "root" });
|
|
520
|
+
return AdvancedFilterValueProvider;
|
|
521
|
+
}());
|
|
522
|
+
|
|
523
|
+
// restore jquery import to avoid Cannot call a namespace ('jquery') error
|
|
524
|
+
var jQuery = jQuery_;
|
|
525
|
+
var DataTablesApi = jQuery.fn.dataTable.Api;
|
|
526
|
+
DataTablesApi.register('processing()', function (show) {
|
|
527
|
+
return this.iterator('table', function (ctx) {
|
|
528
|
+
ctx.oApi._fnProcessingDisplay(ctx, show);
|
|
529
|
+
});
|
|
530
|
+
});
|
|
531
|
+
var TableTranslationChangeDetector = /** @class */ (function (_super) {
|
|
532
|
+
__extends(TableTranslationChangeDetector, _super);
|
|
533
|
+
function TableTranslationChangeDetector() {
|
|
534
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
535
|
+
}
|
|
536
|
+
TableTranslationChangeDetector.prototype.checkNoChanges = function () {
|
|
537
|
+
};
|
|
538
|
+
TableTranslationChangeDetector.prototype.detach = function () {
|
|
539
|
+
};
|
|
540
|
+
TableTranslationChangeDetector.prototype.detectChanges = function () {
|
|
541
|
+
};
|
|
542
|
+
TableTranslationChangeDetector.prototype.markForCheck = function () {
|
|
543
|
+
};
|
|
544
|
+
TableTranslationChangeDetector.prototype.reattach = function () {
|
|
545
|
+
};
|
|
546
|
+
return TableTranslationChangeDetector;
|
|
547
|
+
}(i0.ChangeDetectorRef));
|
|
548
|
+
var COLUMN_FORMATTERS = new i0.InjectionToken('column.formatters');
|
|
549
|
+
var ColumnFormatter = /** @class */ (function (_super) {
|
|
550
|
+
__extends(ColumnFormatter, _super);
|
|
551
|
+
function ColumnFormatter(injector) {
|
|
552
|
+
var _this = _super.call(this) || this;
|
|
553
|
+
_this.injector = injector;
|
|
554
|
+
return _this;
|
|
555
|
+
}
|
|
556
|
+
ColumnFormatter.prototype.render = function (data, type, row, meta) {
|
|
557
|
+
//
|
|
558
|
+
};
|
|
559
|
+
return ColumnFormatter;
|
|
560
|
+
}(AdvancedColumnFormatter));
|
|
561
|
+
function forceCast(input) {
|
|
562
|
+
return input;
|
|
563
|
+
}
|
|
564
|
+
var AdvancedTableConfiguration = /** @class */ (function () {
|
|
565
|
+
function AdvancedTableConfiguration() {
|
|
566
|
+
}
|
|
567
|
+
AdvancedTableConfiguration.cast = function (input, clone) {
|
|
568
|
+
if (clone) {
|
|
569
|
+
return forceCast(JSON.parse(JSON.stringify(input)));
|
|
570
|
+
}
|
|
571
|
+
return forceCast(input);
|
|
572
|
+
};
|
|
573
|
+
return AdvancedTableConfiguration;
|
|
574
|
+
}());
|
|
575
|
+
function getRandomIdentifier() {
|
|
576
|
+
return (Number(String(Math.random()).slice(2))).toString(36);
|
|
577
|
+
}
|
|
578
|
+
var AdvancedTableComponent = /** @class */ (function () {
|
|
579
|
+
function AdvancedTableComponent(_context, _columnFormatters, _activatedRoute, _translateService, _injector, _advancedFilterValueProvider, _element, _template, _loading, _http) {
|
|
580
|
+
var _this = this;
|
|
581
|
+
this._context = _context;
|
|
582
|
+
this._columnFormatters = _columnFormatters;
|
|
583
|
+
this._activatedRoute = _activatedRoute;
|
|
584
|
+
this._translateService = _translateService;
|
|
585
|
+
this._injector = _injector;
|
|
586
|
+
this._advancedFilterValueProvider = _advancedFilterValueProvider;
|
|
587
|
+
this._element = _element;
|
|
588
|
+
this._template = _template;
|
|
589
|
+
this._loading = _loading;
|
|
590
|
+
this._http = _http;
|
|
591
|
+
this._firstLoad = true;
|
|
592
|
+
this._showFooter = true;
|
|
593
|
+
this._showPaging = false;
|
|
594
|
+
this._id = getRandomIdentifier();
|
|
595
|
+
this.smartSelect = false;
|
|
596
|
+
this.configChanges = new rxjs.BehaviorSubject(null);
|
|
597
|
+
this.height = 800;
|
|
598
|
+
this.showActions = true;
|
|
599
|
+
this.autoLoad = true;
|
|
600
|
+
this.load = new i0.EventEmitter();
|
|
601
|
+
this.init = new i0.EventEmitter();
|
|
602
|
+
this.reload = new i0.EventEmitter();
|
|
603
|
+
this.select = new i0.EventEmitter();
|
|
604
|
+
this.selectedItems = new i0.EventEmitter();
|
|
605
|
+
this.scrollable = true;
|
|
606
|
+
this.serverSide = true;
|
|
607
|
+
this.lengthMenu = [50, 100, 200, 500];
|
|
608
|
+
this.paging = true;
|
|
609
|
+
this.pageLength = 25;
|
|
610
|
+
this.scrollY = 800;
|
|
611
|
+
this.scrollX = true;
|
|
612
|
+
/**
|
|
613
|
+
* Enables row selection. The defaulr value is false
|
|
614
|
+
*/
|
|
615
|
+
this.selectable = false;
|
|
616
|
+
/**
|
|
617
|
+
* Enables or disable multiple selection. The default values is true.
|
|
618
|
+
*/
|
|
619
|
+
this.multipleSelect = true;
|
|
620
|
+
/**
|
|
621
|
+
* Enables custom selection and hides select column. The default value is false
|
|
622
|
+
*/
|
|
623
|
+
this.customSelect = false;
|
|
624
|
+
this.selected = [];
|
|
625
|
+
this.unselected = [];
|
|
626
|
+
// initialize translate pipe
|
|
627
|
+
this.translator = new core.TranslatePipe(this._translateService, new TableTranslationChangeDetector());
|
|
628
|
+
jQuery.fn.dataTable.ext.classes.sPageButton = 'btn';
|
|
629
|
+
jQuery.fn.dataTable.ext.classes.sPageButtonActive = 'btn btn-light';
|
|
630
|
+
this.reloadSubscription = this.reload.subscribe(function (data) {
|
|
631
|
+
_this.fetch();
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
Object.defineProperty(AdvancedTableComponent.prototype, "config", {
|
|
635
|
+
get: function () {
|
|
636
|
+
return this._config;
|
|
637
|
+
},
|
|
638
|
+
/**
|
|
639
|
+
* Gets or sets table configuration
|
|
640
|
+
*/
|
|
641
|
+
set: function (value) {
|
|
642
|
+
this._config = value;
|
|
643
|
+
// raise subscription
|
|
644
|
+
this.configChanges.next(this._config);
|
|
645
|
+
},
|
|
646
|
+
enumerable: true,
|
|
647
|
+
configurable: true
|
|
648
|
+
});
|
|
649
|
+
Object.defineProperty(AdvancedTableComponent.prototype, "showFooter", {
|
|
650
|
+
get: function () {
|
|
651
|
+
return this._showFooter;
|
|
652
|
+
},
|
|
653
|
+
/**
|
|
654
|
+
* Indicates whether table footer will be visible or not
|
|
655
|
+
*/
|
|
656
|
+
set: function (value) {
|
|
657
|
+
this._showFooter = value;
|
|
658
|
+
// show or hide footer
|
|
659
|
+
if (this._element && this._element.nativeElement) {
|
|
660
|
+
var element = this._element.nativeElement
|
|
661
|
+
.querySelector('.dataTables_info');
|
|
662
|
+
if (element == null) {
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
if (value) {
|
|
666
|
+
element.classList.remove('d-none');
|
|
667
|
+
}
|
|
668
|
+
else {
|
|
669
|
+
element.classList.add('d-none');
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
},
|
|
673
|
+
enumerable: true,
|
|
674
|
+
configurable: true
|
|
675
|
+
});
|
|
676
|
+
Object.defineProperty(AdvancedTableComponent.prototype, "showPaging", {
|
|
677
|
+
get: function () {
|
|
678
|
+
return this._showPaging;
|
|
679
|
+
},
|
|
680
|
+
/**
|
|
681
|
+
* Indicates whether paging information will be visible or not
|
|
682
|
+
*/
|
|
683
|
+
set: function (value) {
|
|
684
|
+
this._showPaging = value;
|
|
685
|
+
// show or hide footer
|
|
686
|
+
if (this._element && this._element.nativeElement) {
|
|
687
|
+
var element = this._element.nativeElement
|
|
688
|
+
.querySelector('.dataTables_paginate');
|
|
689
|
+
if (element == null) {
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
if (value) {
|
|
693
|
+
jQuery(element).show();
|
|
694
|
+
}
|
|
695
|
+
else {
|
|
696
|
+
jQuery(element).hide();
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
},
|
|
700
|
+
enumerable: true,
|
|
701
|
+
configurable: true
|
|
702
|
+
});
|
|
703
|
+
Object.defineProperty(AdvancedTableComponent.prototype, "query", {
|
|
704
|
+
get: function () {
|
|
705
|
+
return this._query;
|
|
706
|
+
},
|
|
707
|
+
/**
|
|
708
|
+
* Gets or sets an active query for this table
|
|
709
|
+
*/
|
|
710
|
+
set: function (value) {
|
|
711
|
+
this._query = value;
|
|
712
|
+
},
|
|
713
|
+
enumerable: true,
|
|
714
|
+
configurable: true
|
|
715
|
+
});
|
|
716
|
+
// simple search
|
|
717
|
+
AdvancedTableComponent.prototype.search = function (searchText) {
|
|
718
|
+
var _this = this;
|
|
719
|
+
this.query = this.query || this._context.model(this.config.model).asQueryable();
|
|
720
|
+
if (searchText && this.config.searchExpression) {
|
|
721
|
+
// validate search text in double quotes
|
|
722
|
+
if (/^"(.*?)"$/.test(searchText)) {
|
|
723
|
+
this.query.setParam('$filter', this._template.transform(this.config.searchExpression, {
|
|
724
|
+
text: searchText.replace(/^"|"$/g, '')
|
|
725
|
+
}));
|
|
726
|
+
}
|
|
727
|
+
else {
|
|
728
|
+
// try to split words
|
|
729
|
+
var words = searchText.split(' ');
|
|
730
|
+
// join words to a single filter
|
|
731
|
+
var filter = words.map(function (word) {
|
|
732
|
+
return _this._template.transform(_this.config.searchExpression, {
|
|
733
|
+
text: word
|
|
734
|
+
});
|
|
735
|
+
}).join(' and ');
|
|
736
|
+
// set filter
|
|
737
|
+
this.query.setParam('$filter', filter);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
else {
|
|
741
|
+
// clear filter
|
|
742
|
+
this.query.setParam('$filter', null);
|
|
743
|
+
}
|
|
744
|
+
this._firstLoad = false;
|
|
745
|
+
this.dataTable.draw();
|
|
746
|
+
};
|
|
747
|
+
AdvancedTableComponent.prototype.fetch = function (clearSelected) {
|
|
748
|
+
// if data table is null
|
|
749
|
+
if (this.dataTable == null) {
|
|
750
|
+
// initialize data table
|
|
751
|
+
return this.ngOnInit();
|
|
752
|
+
}
|
|
753
|
+
// clear selection if parameter is not declared or it's true
|
|
754
|
+
if (clearSelected == null || clearSelected === true) {
|
|
755
|
+
// set smart select to false
|
|
756
|
+
this.smartSelect = false;
|
|
757
|
+
// clear selected items
|
|
758
|
+
if (this.selected.length) {
|
|
759
|
+
this.selected.splice(0, this.selected.length);
|
|
760
|
+
}
|
|
761
|
+
// clear unselected items
|
|
762
|
+
if (this.unselected.length) {
|
|
763
|
+
this.unselected.splice(0, this.unselected.length);
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
// otherwise load data only
|
|
767
|
+
this.dataTable.draw();
|
|
768
|
+
};
|
|
769
|
+
AdvancedTableComponent.prototype.destroy = function () {
|
|
770
|
+
if (this.dataTable) {
|
|
771
|
+
this.dataTable.destroy();
|
|
772
|
+
this._firstLoad = true;
|
|
773
|
+
jQuery(this.table.nativeElement).empty();
|
|
774
|
+
this.dataTable = null;
|
|
775
|
+
// clear selected items
|
|
776
|
+
if (this.selected.length) {
|
|
777
|
+
this.selected.splice(0, this.selected.length);
|
|
778
|
+
}
|
|
779
|
+
// clear unselected items
|
|
780
|
+
if (this.unselected.length) {
|
|
781
|
+
this.unselected.splice(0, this.unselected.length);
|
|
782
|
+
}
|
|
783
|
+
// set smart select to false
|
|
784
|
+
this.smartSelect = false;
|
|
785
|
+
}
|
|
786
|
+
};
|
|
787
|
+
/**
|
|
788
|
+
* Selects the specified data row
|
|
789
|
+
*/
|
|
790
|
+
AdvancedTableComponent.prototype.selectRow = function (row, silent) {
|
|
791
|
+
if (row) {
|
|
792
|
+
// get row
|
|
793
|
+
var rowNode_1 = row.node();
|
|
794
|
+
// if multiple select is false
|
|
795
|
+
if (this.multipleSelect === false) {
|
|
796
|
+
if (this.customSelect === false) {
|
|
797
|
+
// enumerate row
|
|
798
|
+
this.dataTable.rows().nodes().each(function (node) {
|
|
799
|
+
if (node !== rowNode_1) {
|
|
800
|
+
jQuery(node).find(':checkbox').prop('checked', false);
|
|
801
|
+
}
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
else {
|
|
805
|
+
this.dataTable.rows('.selected').nodes().each(function (node) {
|
|
806
|
+
if (node !== rowNode_1) {
|
|
807
|
+
jQuery(node).removeClass('selected');
|
|
808
|
+
}
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
// clear selected
|
|
812
|
+
this.selected.splice(0, this.selected.length);
|
|
813
|
+
}
|
|
814
|
+
// if custom select mode is off
|
|
815
|
+
if (this.customSelect === false) {
|
|
816
|
+
jQuery(rowNode_1).find(':checkbox').prop('checked', true);
|
|
817
|
+
}
|
|
818
|
+
else {
|
|
819
|
+
// otherwise add class
|
|
820
|
+
jQuery(row.node()).addClass('selected');
|
|
821
|
+
}
|
|
822
|
+
// get row data
|
|
823
|
+
var key_1 = this.config.columns[0].property || this.config.columns[0].name;
|
|
824
|
+
var data_1 = row.data();
|
|
825
|
+
// search selected items
|
|
826
|
+
var findIndex = this.selected.findIndex(function (x) {
|
|
827
|
+
return x[key_1] === data_1[key_1];
|
|
828
|
+
});
|
|
829
|
+
if (findIndex >= 0) {
|
|
830
|
+
// remove previously selected row
|
|
831
|
+
this.selected.splice(findIndex, 1);
|
|
832
|
+
}
|
|
833
|
+
this.selected.push(data_1);
|
|
834
|
+
// validate unselected data
|
|
835
|
+
findIndex = this.unselected.findIndex(function (x) {
|
|
836
|
+
return x[key_1] === data_1[key_1];
|
|
837
|
+
});
|
|
838
|
+
if (findIndex >= 0) {
|
|
839
|
+
// remove previously selected row
|
|
840
|
+
this.unselected.splice(findIndex, 1);
|
|
841
|
+
}
|
|
842
|
+
if (silent) {
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
this.selectedItems.emit(this.selected);
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
|
+
/**
|
|
849
|
+
* Unselects the specified data row if it's selected
|
|
850
|
+
*/
|
|
851
|
+
AdvancedTableComponent.prototype.unSelectRow = function (row, silent) {
|
|
852
|
+
if (row) {
|
|
853
|
+
// if custom select mode is off
|
|
854
|
+
if (this.customSelect === false) {
|
|
855
|
+
jQuery(row.node()).find(':checkbox').prop('checked', false);
|
|
856
|
+
}
|
|
857
|
+
else {
|
|
858
|
+
// otherwise add class
|
|
859
|
+
jQuery(row.node()).removeClass('selected');
|
|
860
|
+
}
|
|
861
|
+
// get first column key
|
|
862
|
+
var key_2 = this.config.columns[0].property || this.config.columns[0].name;
|
|
863
|
+
var data = row.data();
|
|
864
|
+
var id_1 = data[key_2];
|
|
865
|
+
var findIndex = this.selected.findIndex(function (x) {
|
|
866
|
+
return x[key_2] === id_1;
|
|
867
|
+
});
|
|
868
|
+
if (findIndex >= 0) {
|
|
869
|
+
this.selected.splice(findIndex, 1);
|
|
870
|
+
if (this.smartSelect) {
|
|
871
|
+
// add this row to unselected rows
|
|
872
|
+
findIndex = this.unselected.findIndex(function (x) {
|
|
873
|
+
return x[key_2] === id_1;
|
|
874
|
+
});
|
|
875
|
+
if (findIndex < 0) {
|
|
876
|
+
this.unselected.push(data);
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
if (silent) {
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
this.selectedItems.emit(this.selected);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
};
|
|
886
|
+
AdvancedTableComponent.prototype.selectAny = function () {
|
|
887
|
+
var _this = this;
|
|
888
|
+
if (this.dataTable && this.selectable) {
|
|
889
|
+
// set smart select flag
|
|
890
|
+
this.smartSelect = true;
|
|
891
|
+
// select any row
|
|
892
|
+
this.dataTable.rows().every(function (index) {
|
|
893
|
+
var row = _this.dataTable.row(index);
|
|
894
|
+
_this.selectRow(row, true);
|
|
895
|
+
});
|
|
896
|
+
// emit selection event
|
|
897
|
+
this.selectedItems.emit(this.selected);
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
AdvancedTableComponent.prototype.selectNone = function () {
|
|
901
|
+
var _this = this;
|
|
902
|
+
if (this.dataTable && this.selectable) {
|
|
903
|
+
// set smart select flag
|
|
904
|
+
this.smartSelect = false;
|
|
905
|
+
this.unselected.splice(0, this.unselected.length);
|
|
906
|
+
// select any row
|
|
907
|
+
this.dataTable.rows().every(function (index) {
|
|
908
|
+
var row = _this.dataTable.row(index);
|
|
909
|
+
_this.unSelectRow(row, true);
|
|
910
|
+
});
|
|
911
|
+
this.selected.splice(0, this.selected.length);
|
|
912
|
+
// emit selection event
|
|
913
|
+
this.selectedItems.emit(this.selected);
|
|
914
|
+
}
|
|
915
|
+
};
|
|
916
|
+
AdvancedTableComponent.prototype.toggleSelectRow = function (row) {
|
|
917
|
+
if (row) {
|
|
918
|
+
var data = row.data();
|
|
919
|
+
// get first column key
|
|
920
|
+
var key_3 = this.config.columns[0].property || this.config.columns[0].name;
|
|
921
|
+
// get id
|
|
922
|
+
var id_2 = data[key_3];
|
|
923
|
+
// find if row is selected
|
|
924
|
+
var findIndex = this.selected.find(function (x) {
|
|
925
|
+
return x[key_3] === id_2;
|
|
926
|
+
});
|
|
927
|
+
// if row is selected
|
|
928
|
+
if (findIndex >= 0) {
|
|
929
|
+
// unselect
|
|
930
|
+
this.unSelectRow(row);
|
|
931
|
+
}
|
|
932
|
+
else {
|
|
933
|
+
this.selectRow(row);
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
// noinspection JSMethodCanBeStatic
|
|
938
|
+
/**
|
|
939
|
+
* Datatables column renderer for select checkbox
|
|
940
|
+
* @param data
|
|
941
|
+
* @param type
|
|
942
|
+
* @param row
|
|
943
|
+
* @param meta
|
|
944
|
+
* @private
|
|
945
|
+
*/
|
|
946
|
+
AdvancedTableComponent.prototype._renderSelect = function (data, type, row, meta) {
|
|
947
|
+
// get column
|
|
948
|
+
var column = meta.settings.aoColumns[meta.col];
|
|
949
|
+
// render template
|
|
950
|
+
return this._template.transform("<input class=\"checkbox checkbox-theme s-row\" type=\"checkbox\"\n id=\"s-" + this._id + "-" + meta.row + "\" data-id=\"" + data + "\" /><label for=\"s-" + this._id + "-" + meta.row + "\"> </label>", row);
|
|
951
|
+
};
|
|
952
|
+
AdvancedTableComponent.prototype.ngOnInit = function () {
|
|
953
|
+
var _this = this;
|
|
954
|
+
var self = this;
|
|
955
|
+
if (this.dataTable) {
|
|
956
|
+
this.destroy();
|
|
957
|
+
}
|
|
958
|
+
if (this.config) {
|
|
959
|
+
// parse properties
|
|
960
|
+
if (Object.prototype.hasOwnProperty.call(this.config, 'selectable')) {
|
|
961
|
+
this.selectable = this.config.selectable;
|
|
962
|
+
}
|
|
963
|
+
if (Object.prototype.hasOwnProperty.call(this.config, 'multipleSelect')) {
|
|
964
|
+
this.multipleSelect = this.config.multipleSelect;
|
|
965
|
+
}
|
|
966
|
+
// prepare configuration for columns
|
|
967
|
+
var tableColumns_1 = this.config.columns
|
|
968
|
+
// filter action link column
|
|
969
|
+
.filter(function (column) {
|
|
970
|
+
if (column.formatter && column.formatter === 'ActionLinkFormatter' && _this.showActions === false) {
|
|
971
|
+
return false;
|
|
972
|
+
}
|
|
973
|
+
return true;
|
|
974
|
+
}).map(function (column) {
|
|
975
|
+
// convert column to advance table column
|
|
976
|
+
return Object.assign(new ColumnFormatter(_this._injector), column);
|
|
977
|
+
}).map(function (column) {
|
|
978
|
+
var columnDefinition = {
|
|
979
|
+
data: column.property || column.name,
|
|
980
|
+
defaultContent: column.hasOwnProperty('defaultContent') ? column.defaultContent : '',
|
|
981
|
+
title: _this.translator.transform(column.title),
|
|
982
|
+
sortable: column.hasOwnProperty('sortable') ? column.sortable : true,
|
|
983
|
+
visible: column.hasOwnProperty('hidden') ? !column.hidden : true,
|
|
984
|
+
name: column.name
|
|
985
|
+
};
|
|
986
|
+
if (column.className) {
|
|
987
|
+
Object.assign(columnDefinition, {
|
|
988
|
+
className: column.className
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
else {
|
|
992
|
+
Object.assign(columnDefinition, {
|
|
993
|
+
className: ''
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
if (column.formatters) {
|
|
997
|
+
Object.assign(columnDefinition, {
|
|
998
|
+
render: function (data, type, row, meta) {
|
|
999
|
+
var result = data;
|
|
1000
|
+
column.formatters.forEach(function (columnFormatter) {
|
|
1001
|
+
var formatter = self._columnFormatters[columnFormatter.formatter];
|
|
1002
|
+
if (formatter && typeof formatter.render === 'function') {
|
|
1003
|
+
column.formatString = columnFormatter.formatString;
|
|
1004
|
+
column.formatOptions = columnFormatter.formatOptions;
|
|
1005
|
+
}
|
|
1006
|
+
result = formatter.render.bind(column)(result, type, row, meta);
|
|
1007
|
+
});
|
|
1008
|
+
delete column.formatString;
|
|
1009
|
+
delete column.formatOptions;
|
|
1010
|
+
return result;
|
|
1011
|
+
}
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
if (column.formatter) {
|
|
1015
|
+
var formatter = self._columnFormatters[column.formatter];
|
|
1016
|
+
if (formatter && typeof formatter.render === 'function') {
|
|
1017
|
+
Object.assign(columnDefinition, {
|
|
1018
|
+
render: formatter.render.bind(column)
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
return columnDefinition;
|
|
1023
|
+
});
|
|
1024
|
+
// get table element
|
|
1025
|
+
var tableElement_1 = jQuery(this.table.nativeElement);
|
|
1026
|
+
// allow selection
|
|
1027
|
+
if (this.selectable) {
|
|
1028
|
+
// get first column (as row primary key)
|
|
1029
|
+
// todo::allow row primary key configuration
|
|
1030
|
+
var firstColumn = this.config.columns[0];
|
|
1031
|
+
// add select column
|
|
1032
|
+
var selectColumnDefinition = {
|
|
1033
|
+
className: 'text-center pl-4 pr-0',
|
|
1034
|
+
data: firstColumn.property || firstColumn.name,
|
|
1035
|
+
defaultContent: '',
|
|
1036
|
+
title: '',
|
|
1037
|
+
sortable: false,
|
|
1038
|
+
visible: !this.customSelect,
|
|
1039
|
+
name: firstColumn.name,
|
|
1040
|
+
};
|
|
1041
|
+
// assign renderer
|
|
1042
|
+
Object.assign(selectColumnDefinition, {
|
|
1043
|
+
render: this._renderSelect.bind(this)
|
|
1044
|
+
});
|
|
1045
|
+
// and finally add column
|
|
1046
|
+
tableColumns_1.unshift(selectColumnDefinition);
|
|
1047
|
+
// user interface additions
|
|
1048
|
+
// handle page change event (a trick for firing draw.dt events)
|
|
1049
|
+
tableElement_1
|
|
1050
|
+
// for each page
|
|
1051
|
+
.on('page.dt', function ($event) {
|
|
1052
|
+
var info = _this.dataTable.page.info();
|
|
1053
|
+
})
|
|
1054
|
+
// handle draw events
|
|
1055
|
+
.on('draw.dt', function () {
|
|
1056
|
+
if (_this.customSelect) {
|
|
1057
|
+
// enable row selection event
|
|
1058
|
+
tableElement_1.find('tbody').on('click', 'tr', function () {
|
|
1059
|
+
// select row
|
|
1060
|
+
var row = self.dataTable.row(this);
|
|
1061
|
+
// add row
|
|
1062
|
+
self.select.emit(row);
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
1065
|
+
tableElement_1.find('input.s-row').on('click', _this.onSelectionChange.bind(_this));
|
|
1066
|
+
// make selection on current page
|
|
1067
|
+
var key = _this.config.columns[0].property;
|
|
1068
|
+
if (_this.selected.length > 0) {
|
|
1069
|
+
// enumerate selected items
|
|
1070
|
+
_this.selected.forEach(function (item) {
|
|
1071
|
+
// find row identifier
|
|
1072
|
+
var id = item[key];
|
|
1073
|
+
// if identifier is defined
|
|
1074
|
+
if (id != null) {
|
|
1075
|
+
// try to find check element with this identifier in attribute data-id
|
|
1076
|
+
tableElement_1.find("input[data-id='" + id + "']").prop('checked', true);
|
|
1077
|
+
}
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
if (_this.smartSelect) {
|
|
1081
|
+
// select rows that are not selected
|
|
1082
|
+
// and do not included in unselected collection
|
|
1083
|
+
tableElement_1.find('input[data-id]').each(function (index, element) {
|
|
1084
|
+
// get data id
|
|
1085
|
+
if (_this.unselected.findIndex(function (x) {
|
|
1086
|
+
// tslint:disable-next-line:triple-equals
|
|
1087
|
+
return x[key] == jQuery(element).attr('data-id');
|
|
1088
|
+
}) < 0) {
|
|
1089
|
+
_this.selectRow(_this.dataTable.row(index));
|
|
1090
|
+
}
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
else if (_this.selected.length === 0) {
|
|
1094
|
+
tableElement_1.find('input[data-id]').prop('checked', false);
|
|
1095
|
+
}
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
// initialize data table
|
|
1099
|
+
var settings = {
|
|
1100
|
+
// set length menu
|
|
1101
|
+
lengthMenu: [5, 10, 50, 100, 200, 500],
|
|
1102
|
+
// hide length menu
|
|
1103
|
+
lengthChange: false,
|
|
1104
|
+
// enable search but hide search box (css)
|
|
1105
|
+
searching: true,
|
|
1106
|
+
// enable data processing
|
|
1107
|
+
processing: true,
|
|
1108
|
+
// enable getting server side data
|
|
1109
|
+
serverSide: this.serverSide,
|
|
1110
|
+
// enumerate table columns
|
|
1111
|
+
columns: tableColumns_1,
|
|
1112
|
+
order: [],
|
|
1113
|
+
// set scroll x
|
|
1114
|
+
scrollX: this.scrollX,
|
|
1115
|
+
dom: 'Bfrtip',
|
|
1116
|
+
autoWidth: false,
|
|
1117
|
+
buttons: [
|
|
1118
|
+
{
|
|
1119
|
+
extend: 'excel',
|
|
1120
|
+
filename: this.config.title,
|
|
1121
|
+
className: 'd-none',
|
|
1122
|
+
exportOptions: {
|
|
1123
|
+
columns: 'th:not(:first-child)'
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
],
|
|
1127
|
+
// define server data callback
|
|
1128
|
+
fnServerData: function (sSource, aoData, fnCallback, oSettings) {
|
|
1129
|
+
// if method is invoked for the first time
|
|
1130
|
+
if (self._firstLoad) {
|
|
1131
|
+
// disabled first load flag
|
|
1132
|
+
self._firstLoad = false;
|
|
1133
|
+
// if auto load is disabled
|
|
1134
|
+
if (self.autoLoad === false) {
|
|
1135
|
+
var emptyDataSet = {
|
|
1136
|
+
recordsTotal: 0,
|
|
1137
|
+
recordsFiltered: 0,
|
|
1138
|
+
data: []
|
|
1139
|
+
};
|
|
1140
|
+
// emit empty data
|
|
1141
|
+
self.load.emit(emptyDataSet);
|
|
1142
|
+
// return empty data
|
|
1143
|
+
return fnCallback(emptyDataSet);
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
// get activated route params
|
|
1147
|
+
var queryParams = self._activatedRoute.snapshot.queryParams;
|
|
1148
|
+
// get columns
|
|
1149
|
+
var columns = aoData[1].value;
|
|
1150
|
+
// get order expression
|
|
1151
|
+
var order = aoData[2].value;
|
|
1152
|
+
// get skip records param
|
|
1153
|
+
var skip = aoData[3].value;
|
|
1154
|
+
// get page size param
|
|
1155
|
+
var top = aoData[4].value;
|
|
1156
|
+
// get search value
|
|
1157
|
+
var searchText = aoData[5].value;
|
|
1158
|
+
// get data queryable
|
|
1159
|
+
var q = self._query instanceof client.ClientDataQueryable ? self._query : self._context.model(self.config.model).asQueryable();
|
|
1160
|
+
// apply paging params
|
|
1161
|
+
if (top) {
|
|
1162
|
+
q.take(top).skip(skip);
|
|
1163
|
+
}
|
|
1164
|
+
// apply order params
|
|
1165
|
+
if (order && order.length) {
|
|
1166
|
+
// get order query expression
|
|
1167
|
+
var orderByStr = order.map(function (expr) {
|
|
1168
|
+
return tableColumns_1[expr.column].name + ' ' + expr.dir || 'asc';
|
|
1169
|
+
}).join(',');
|
|
1170
|
+
// set order
|
|
1171
|
+
q.setParam('$orderby', orderByStr);
|
|
1172
|
+
}
|
|
1173
|
+
// configure $select parameter
|
|
1174
|
+
var select = self.config.columns.filter(function (column) {
|
|
1175
|
+
if (column.virtual === true) {
|
|
1176
|
+
return false;
|
|
1177
|
+
}
|
|
1178
|
+
return true;
|
|
1179
|
+
}).map(function (column) {
|
|
1180
|
+
if (column.property) {
|
|
1181
|
+
return column.name + ' as ' + column.property;
|
|
1182
|
+
}
|
|
1183
|
+
else {
|
|
1184
|
+
return column.name;
|
|
1185
|
+
}
|
|
1186
|
+
});
|
|
1187
|
+
q.select.apply(q, select);
|
|
1188
|
+
// configure $filter
|
|
1189
|
+
if (queryParams.$filter && queryParams.$filter.length) {
|
|
1190
|
+
// set route filter
|
|
1191
|
+
var qParams = q.getParams();
|
|
1192
|
+
q.setParam('$filter', null);
|
|
1193
|
+
var expressions = [queryParams.$filter];
|
|
1194
|
+
if (qParams.$filter) {
|
|
1195
|
+
expressions.push('(' + qParams.$filter + ')');
|
|
1196
|
+
}
|
|
1197
|
+
q.filter(expressions.join(' and '));
|
|
1198
|
+
}
|
|
1199
|
+
// check if query parameters contain filter
|
|
1200
|
+
if (queryParams.$expand && queryParams.$expand.length) {
|
|
1201
|
+
// set route $expand
|
|
1202
|
+
q.setParam('$expand', queryParams.$expand);
|
|
1203
|
+
}
|
|
1204
|
+
if (!q.getParams()['$orderby'] && self.config && self.config.defaults && self.config.defaults.orderBy) {
|
|
1205
|
+
q.setParam('$orderby', self.config.defaults.orderBy);
|
|
1206
|
+
}
|
|
1207
|
+
// append default filter
|
|
1208
|
+
if (self.config && self.config.defaults && self.config.defaults.filter) {
|
|
1209
|
+
return self._advancedFilterValueProvider.asyncBuildFilter(self.config.defaults.filter).then(function (defaultFilterString) {
|
|
1210
|
+
if (defaultFilterString) {
|
|
1211
|
+
var qParams = q.getParams();
|
|
1212
|
+
q.setParam('$filter', null);
|
|
1213
|
+
var expressions = [defaultFilterString];
|
|
1214
|
+
if (qParams.$filter) {
|
|
1215
|
+
expressions.push('(' + qParams.$filter + ')');
|
|
1216
|
+
}
|
|
1217
|
+
q.filter(expressions.join(' and '));
|
|
1218
|
+
}
|
|
1219
|
+
self.lastQueryParams = q.getParams();
|
|
1220
|
+
q.getList().then(function (items) {
|
|
1221
|
+
var dataSet = {
|
|
1222
|
+
recordsTotal: items.total,
|
|
1223
|
+
recordsFiltered: items.total,
|
|
1224
|
+
data: items.value
|
|
1225
|
+
};
|
|
1226
|
+
if (items.total === 0) {
|
|
1227
|
+
self.resetEmptyTable();
|
|
1228
|
+
}
|
|
1229
|
+
// emit load event
|
|
1230
|
+
self.load.emit(dataSet);
|
|
1231
|
+
// return data
|
|
1232
|
+
return fnCallback(dataSet);
|
|
1233
|
+
});
|
|
1234
|
+
}).catch(function (err) {
|
|
1235
|
+
console.error('TABLES', err);
|
|
1236
|
+
});
|
|
1237
|
+
}
|
|
1238
|
+
self.lastQueryParams = q.getParams();
|
|
1239
|
+
q.getList().then(function (items) {
|
|
1240
|
+
var dataSet = {
|
|
1241
|
+
recordsTotal: items.total,
|
|
1242
|
+
recordsFiltered: items.total,
|
|
1243
|
+
data: items.value
|
|
1244
|
+
};
|
|
1245
|
+
if (items.total === 0) {
|
|
1246
|
+
self.resetEmptyTable();
|
|
1247
|
+
}
|
|
1248
|
+
// emit load event
|
|
1249
|
+
self.load.emit(dataSet);
|
|
1250
|
+
// return data
|
|
1251
|
+
return fnCallback(dataSet);
|
|
1252
|
+
}).catch(function (err) {
|
|
1253
|
+
console.error('TABLES', err);
|
|
1254
|
+
});
|
|
1255
|
+
},
|
|
1256
|
+
language: Object.assign({}, self.translator.transform('Tables.DataTable'), { emptyTable: ' ', processing: ' ' })
|
|
1257
|
+
};
|
|
1258
|
+
if (this.scrollable) {
|
|
1259
|
+
// set continuous scrolling
|
|
1260
|
+
Object.assign(settings, {
|
|
1261
|
+
scrollY: this.scrollY,
|
|
1262
|
+
scrollCollapse: false,
|
|
1263
|
+
scroller: {
|
|
1264
|
+
loadingIndicator: false,
|
|
1265
|
+
displayBuffer: 10
|
|
1266
|
+
},
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1269
|
+
else {
|
|
1270
|
+
Object.assign(settings, {
|
|
1271
|
+
paging: this.paging,
|
|
1272
|
+
pageLength: this.pageLength
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
if (this.selectable) ;
|
|
1276
|
+
// handle init.dt event and emit local event
|
|
1277
|
+
this.dataTable = tableElement_1.DataTable(settings);
|
|
1278
|
+
tableElement_1.on('init.dt', function () {
|
|
1279
|
+
if (_this.dataTable == null) {
|
|
1280
|
+
return;
|
|
1281
|
+
}
|
|
1282
|
+
// restore default empty table html
|
|
1283
|
+
// (due to ng async binding)
|
|
1284
|
+
_this.init.emit(_this.dataTable);
|
|
1285
|
+
});
|
|
1286
|
+
// show or hide footer
|
|
1287
|
+
if (!this.showFooter) {
|
|
1288
|
+
this._element.nativeElement
|
|
1289
|
+
.querySelector('.dataTables_info').classList.add('d-none');
|
|
1290
|
+
}
|
|
1291
|
+
// show or hide pager
|
|
1292
|
+
if (this.showPaging) {
|
|
1293
|
+
this.showPaging = true;
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
};
|
|
1297
|
+
Object.defineProperty(AdvancedTableComponent.prototype, "lastQuery", {
|
|
1298
|
+
get: function () {
|
|
1299
|
+
var _this = this;
|
|
1300
|
+
if (this.config == null) {
|
|
1301
|
+
return null;
|
|
1302
|
+
}
|
|
1303
|
+
if (this.lastQueryParams == null) {
|
|
1304
|
+
return null;
|
|
1305
|
+
}
|
|
1306
|
+
var q = this._context.model(this.config.model).asQueryable();
|
|
1307
|
+
Object.keys(this.lastQueryParams).forEach(function (key) {
|
|
1308
|
+
q.setParam(key, _this.lastQueryParams[key]);
|
|
1309
|
+
});
|
|
1310
|
+
// return query
|
|
1311
|
+
return q;
|
|
1312
|
+
},
|
|
1313
|
+
enumerable: true,
|
|
1314
|
+
configurable: true
|
|
1315
|
+
});
|
|
1316
|
+
/**
|
|
1317
|
+
* Fetches and updates a single row
|
|
1318
|
+
* @param find - Any object which is being converted to a query
|
|
1319
|
+
*/
|
|
1320
|
+
AdvancedTableComponent.prototype.fetchOne = function (find) {
|
|
1321
|
+
var _this = this;
|
|
1322
|
+
if (find == null) {
|
|
1323
|
+
return;
|
|
1324
|
+
}
|
|
1325
|
+
if (this.dataTable == null) {
|
|
1326
|
+
return;
|
|
1327
|
+
}
|
|
1328
|
+
if (this.lastQueryParams == null) {
|
|
1329
|
+
return;
|
|
1330
|
+
}
|
|
1331
|
+
// get rows
|
|
1332
|
+
var rows = Array.from(this.dataTable.rows().data());
|
|
1333
|
+
if (rows && rows.length) {
|
|
1334
|
+
// find result
|
|
1335
|
+
var findKeys_1 = Object.keys(find);
|
|
1336
|
+
if (findKeys_1.length === 0) {
|
|
1337
|
+
// do nothing
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
// find row index by searching each property
|
|
1341
|
+
var rowIndex_1 = rows.findIndex(function (row) {
|
|
1342
|
+
return findKeys_1.map(function (key) {
|
|
1343
|
+
return row[key] === find[key];
|
|
1344
|
+
}).filter(function (res) {
|
|
1345
|
+
return res === false;
|
|
1346
|
+
}).length === 0;
|
|
1347
|
+
});
|
|
1348
|
+
// if row has been found
|
|
1349
|
+
if (rowIndex_1 >= 0) {
|
|
1350
|
+
var query_1 = this._context.model(this.config.model).asQueryable();
|
|
1351
|
+
// select attributes
|
|
1352
|
+
query_1.setParam('$select', this.lastQueryParams.$select);
|
|
1353
|
+
// apply filter for row
|
|
1354
|
+
findKeys_1.forEach(function (key) {
|
|
1355
|
+
var column = _this.config.columns.find(function (col) {
|
|
1356
|
+
return col.property === key || col.name === key;
|
|
1357
|
+
});
|
|
1358
|
+
if (column) {
|
|
1359
|
+
// get property or name
|
|
1360
|
+
var property = column.property || column.name;
|
|
1361
|
+
query_1.and(property).equal(find[key]);
|
|
1362
|
+
}
|
|
1363
|
+
else {
|
|
1364
|
+
query_1.and(key).equal(find[key]);
|
|
1365
|
+
}
|
|
1366
|
+
});
|
|
1367
|
+
// and finally get item
|
|
1368
|
+
return query_1.getItem().then(function (item) {
|
|
1369
|
+
// if item exists
|
|
1370
|
+
var row = _this.dataTable.row(rowIndex_1);
|
|
1371
|
+
var checked = jQuery(row.node()).find(':checkbox').prop('checked');
|
|
1372
|
+
if (item) {
|
|
1373
|
+
// redraw row
|
|
1374
|
+
row.data(item);
|
|
1375
|
+
jQuery(row.node()).find(':checkbox').on('click', _this.onSelectionChange.bind(_this));
|
|
1376
|
+
// if row is already selected
|
|
1377
|
+
if (checked) {
|
|
1378
|
+
_this.selectRow(row, true);
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
return Promise.resolve();
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
return Promise.resolve();
|
|
1386
|
+
};
|
|
1387
|
+
AdvancedTableComponent.prototype.ngOnDestroy = function () {
|
|
1388
|
+
if (this.reloadSubscription) {
|
|
1389
|
+
this.reloadSubscription.unsubscribe();
|
|
1390
|
+
}
|
|
1391
|
+
};
|
|
1392
|
+
/**
|
|
1393
|
+
* Handle selection change
|
|
1394
|
+
* @param $event
|
|
1395
|
+
*/
|
|
1396
|
+
AdvancedTableComponent.prototype.onSelectionChange = function ($event) {
|
|
1397
|
+
var input = $event.target;
|
|
1398
|
+
// get row from id
|
|
1399
|
+
var rowIndex = parseInt(/-(\d+)$/g.exec(input.id)[1], 10);
|
|
1400
|
+
// get row
|
|
1401
|
+
var row = this.dataTable.row(rowIndex).data();
|
|
1402
|
+
// get row identifier
|
|
1403
|
+
if (row) {
|
|
1404
|
+
var key_4 = this.config.columns[0].property;
|
|
1405
|
+
var id_3 = row[key_4];
|
|
1406
|
+
var findItemIndex = this.selected.findIndex(function (item) {
|
|
1407
|
+
return item[key_4] === id_3;
|
|
1408
|
+
});
|
|
1409
|
+
if (input.checked) {
|
|
1410
|
+
if (findItemIndex < 0) {
|
|
1411
|
+
// add row to selected rows
|
|
1412
|
+
this.selected.push(row);
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
else {
|
|
1416
|
+
if (findItemIndex >= 0) {
|
|
1417
|
+
// remove selected item
|
|
1418
|
+
this.selected.splice(findItemIndex, 1);
|
|
1419
|
+
if (this.smartSelect) {
|
|
1420
|
+
// add row to unselected rows
|
|
1421
|
+
findItemIndex = this.unselected.findIndex(function (item) {
|
|
1422
|
+
return item[key_4] === id_3;
|
|
1423
|
+
});
|
|
1424
|
+
if (findItemIndex < 0) {
|
|
1425
|
+
this.unselected.push(row);
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
};
|
|
1432
|
+
AdvancedTableComponent.prototype.resetEmptyTable = function () {
|
|
1433
|
+
// this operation is important
|
|
1434
|
+
// due to ng data binding
|
|
1435
|
+
// empty table template has no translated text during ngOnInit()
|
|
1436
|
+
if (this.dataTable && this.dataTable.context[0]) {
|
|
1437
|
+
this.dataTable.context[0].oLanguage.sEmptyTable = this.emptyTable.nativeElement.innerHTML;
|
|
1438
|
+
}
|
|
1439
|
+
};
|
|
1440
|
+
AdvancedTableComponent.prototype.clearEmptyTable = function () {
|
|
1441
|
+
if (this.dataTable && this.dataTable.context[0]) {
|
|
1442
|
+
this.dataTable.context[0].oLanguage.sEmptyTable = '';
|
|
1443
|
+
}
|
|
1444
|
+
};
|
|
1445
|
+
AdvancedTableComponent.prototype.export = function () {
|
|
1446
|
+
var element = document.querySelector('.dt-buttons .buttons-excel');
|
|
1447
|
+
element.click();
|
|
1448
|
+
};
|
|
1449
|
+
AdvancedTableComponent.prototype.handleColumns = function (columnsToShow) {
|
|
1450
|
+
var table = this.dataTable;
|
|
1451
|
+
this.config.columns.slice(1).forEach(function (column, i) {
|
|
1452
|
+
if (!column.hidden) {
|
|
1453
|
+
if (columnsToShow.includes(column.name)) {
|
|
1454
|
+
// noinspection TypeScriptValidateJSTypes
|
|
1455
|
+
table.column(column.name + ':name').visible(true);
|
|
1456
|
+
}
|
|
1457
|
+
else {
|
|
1458
|
+
// noinspection TypeScriptValidateJSTypes
|
|
1459
|
+
table.column(column.name + ':name').visible(false);
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
});
|
|
1463
|
+
};
|
|
1464
|
+
AdvancedTableComponent.prototype.getConfig = function () {
|
|
1465
|
+
return this.config;
|
|
1466
|
+
};
|
|
1467
|
+
AdvancedTableComponent.prototype.ngOnChanges = function (changes) {
|
|
1468
|
+
var _this = this;
|
|
1469
|
+
if (Object.prototype.hasOwnProperty.call(changes, 'configSrc')) {
|
|
1470
|
+
if (changes.configSrc != null) {
|
|
1471
|
+
// load table configuration on change
|
|
1472
|
+
if (changes.configSrc.currentValue && (changes.configSrc.currentValue != changes.configSrc.previousValue)) {
|
|
1473
|
+
this._http.get(changes.configSrc.currentValue).toPromise().then(function (config) {
|
|
1474
|
+
// set configuration
|
|
1475
|
+
_this.config = config;
|
|
1476
|
+
// fetch and redraw
|
|
1477
|
+
_this.fetch();
|
|
1478
|
+
}).catch(function (err) {
|
|
1479
|
+
console.error('TABLES', 'An error occurred while loading table configuration.');
|
|
1480
|
+
console.error(err);
|
|
1481
|
+
});
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
};
|
|
1486
|
+
AdvancedTableComponent.decorators = [
|
|
1487
|
+
{ type: i0.Component, args: [{
|
|
1488
|
+
selector: 'app-advanced-table',
|
|
1489
|
+
template: "\n <table #table class=\"dataTable\">\n </table>\n <div #emptyTable class=\"d-none\">\n <div>\n <div class=\"mt-4\">\n <div class=\"icon-circle bg-gray-300 border-gray-100\"></div>\n </div>\n <div class=\"mt-4\">\n <h4 class=\"font-3xl text-dark\" [translate]=\"'Tables.EmptyTableTitle'\"></h4>\n <p class=\"font-lg text-dark\" [translate]=\"'Tables.EmptyTableMessage'\"></p>\n </div>\n </div>\n </div>\n ",
|
|
1490
|
+
encapsulation: i0.ViewEncapsulation.None,
|
|
1491
|
+
styles: ["table.dataTable thead .sorting{background-image:none}table.dataTable thead .sorting_asc{background-position:95% 60%;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAACXBIWXMAAAsSAAALEgHS3X78AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAEtJREFUKJFjYBgywAOKMQALFjE/BgaGTCibjYGBYRM+kz0ZGBh2MTAw8DAwMHAxMDBsY2BgCCBGMQzg1IRNMV5NuVAJXIALqmYwAgBBkAlPRCLcLwAAAABJRU5ErkJggg==)}table.dataTable thead .sorting_desc{background-position:95% 60%;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAACXBIWXMAAArzAAAK8wHvFRX1AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAFNJREFUKJHVzTEKgDAQRNGHZfBg2sSTeDMLKwXPYuVJbBKQQEyrH6bZ+cPyWWaElz4kR5cOJ1b0FXnBVRYjjmIUsGGqvX6OmnImYk+JLTkzpPyBGwrtCvfBe56nAAAAAElFTkSuQmCC)}table.dataTable thead th{color:#73818e;font-size:.75rem;font-weight:600;padding-top:16px;padding-bottom:4px;border-bottom:none;padding-left:8px}table.dataTable tbody tr:first-child td:first-child{border-radius:6px 0}table.dataTable tbody tr:first-child td:last-child{border-radius:0 6px}table.dataTable tbody tr{border-radius:6px}table.dataTable tbody tr td:first-child{border-left:1px solid #c2cfd6}table.dataTable tbody tr td:last-child{border-right:1px solid #c2cfd6}table.dataTable tbody tr td{padding-top:16px;padding-bottom:16px;border-top:1px solid #c2cfd6}table.dataTable tbody tr:last-child td:first-child{border-radius:0 0 0 6px}table.dataTable tbody tr:last-child td:last-child{border-radius:0 0 6px}table.dataTable tbody tr:last-child td{border-bottom:1px solid #c2cfd6}table.dataTable td.dataTables_empty{border:none!important}table.dataTable.no-footer{border-bottom:none}.dataTables_paginate .btn.previous{margin-right:8px}.dataTables_paginate .btn.next{margin-left:8px}.dataTables_info,.dataTables_paginate{margin-top:1rem}.dataTables_paginate span .btn{border-radius:1.5rem}.dataTables_filter{display:none}.dataTables_wrapper.no-footer .dataTables_scrollBody{border-bottom:0;overflow:auto}.dataTables_paginate{display:none}.dataTables_wrapper .dataTables_processing{background:0 0;top:-40%;color:#73818e}.text-decoration-line-through{text-decoration:line-through!important}tr.removed .checkbox+label{visibility:hidden}"]
|
|
1492
|
+
}] }
|
|
1493
|
+
];
|
|
1494
|
+
/** @nocollapse */
|
|
1495
|
+
AdvancedTableComponent.ctorParameters = function () {
|
|
1496
|
+
return [
|
|
1497
|
+
{ type: i1$1.AngularDataContext },
|
|
1498
|
+
{ type: undefined, decorators: [{ type: i0.Inject, args: [COLUMN_FORMATTERS,] }] },
|
|
1499
|
+
{ type: i1.ActivatedRoute },
|
|
1500
|
+
{ type: core.TranslateService },
|
|
1501
|
+
{ type: i0.Injector },
|
|
1502
|
+
{ type: AdvancedFilterValueProvider },
|
|
1503
|
+
{ type: i0.ElementRef },
|
|
1504
|
+
{ type: i2.TemplatePipe },
|
|
1505
|
+
{ type: i2.LoadingService },
|
|
1506
|
+
{ type: http.HttpClient }
|
|
1507
|
+
];
|
|
1508
|
+
};
|
|
1509
|
+
AdvancedTableComponent.propDecorators = {
|
|
1510
|
+
table: [{ type: i0.ViewChild, args: ['table',] }],
|
|
1511
|
+
emptyTable: [{ type: i0.ViewChild, args: ['emptyTable',] }],
|
|
1512
|
+
loadingTable: [{ type: i0.ViewChild, args: ['loadingTable',] }],
|
|
1513
|
+
height: [{ type: i0.Input }],
|
|
1514
|
+
showActions: [{ type: i0.Input }],
|
|
1515
|
+
autoLoad: [{ type: i0.Input }],
|
|
1516
|
+
load: [{ type: i0.Output, args: ['load',] }],
|
|
1517
|
+
init: [{ type: i0.Output, args: ['init',] }],
|
|
1518
|
+
reload: [{ type: i0.Input, args: ['reload',] }],
|
|
1519
|
+
select: [{ type: i0.Output, args: ['select',] }],
|
|
1520
|
+
selectedItems: [{ type: i0.Output, args: ['selectedItems',] }],
|
|
1521
|
+
scrollable: [{ type: i0.Input }],
|
|
1522
|
+
serverSide: [{ type: i0.Input }],
|
|
1523
|
+
lengthMenu: [{ type: i0.Input }],
|
|
1524
|
+
paging: [{ type: i0.Input }],
|
|
1525
|
+
pageLength: [{ type: i0.Input }],
|
|
1526
|
+
scrollY: [{ type: i0.Input }],
|
|
1527
|
+
scrollX: [{ type: i0.Input }],
|
|
1528
|
+
selectable: [{ type: i0.Input }],
|
|
1529
|
+
multipleSelect: [{ type: i0.Input }],
|
|
1530
|
+
customSelect: [{ type: i0.Input }],
|
|
1531
|
+
selected: [{ type: i0.Input }],
|
|
1532
|
+
configSrc: [{ type: i0.Input }],
|
|
1533
|
+
config: [{ type: i0.Input, args: ['config',] }],
|
|
1534
|
+
showFooter: [{ type: i0.Input, args: ['showFooter',] }],
|
|
1535
|
+
showPaging: [{ type: i0.Input, args: ['showPaging',] }],
|
|
1536
|
+
query: [{ type: i0.Input, args: ['query',] }]
|
|
1537
|
+
};
|
|
1538
|
+
return AdvancedTableComponent;
|
|
1539
|
+
}());
|
|
1540
|
+
|
|
1541
|
+
var AdvancedListComponent = /** @class */ (function () {
|
|
1542
|
+
function AdvancedListComponent(_context, _translateService, _activatedRoute, _errorService, _toastService, _modalService, _userActivityService) {
|
|
1543
|
+
this._context = _context;
|
|
1544
|
+
this._translateService = _translateService;
|
|
1545
|
+
this._activatedRoute = _activatedRoute;
|
|
1546
|
+
this._errorService = _errorService;
|
|
1547
|
+
this._toastService = _toastService;
|
|
1548
|
+
this._modalService = _modalService;
|
|
1549
|
+
this._userActivityService = _userActivityService;
|
|
1550
|
+
this.allowSaveOption = true;
|
|
1551
|
+
}
|
|
1552
|
+
AdvancedListComponent.prototype.ngOnDestroy = function () {
|
|
1553
|
+
if (this.dataSubscription) {
|
|
1554
|
+
this.dataSubscription.unsubscribe();
|
|
1555
|
+
}
|
|
1556
|
+
if (this.reloadSubscription) {
|
|
1557
|
+
this.reloadSubscription.unsubscribe();
|
|
1558
|
+
}
|
|
1559
|
+
if (this.subscription) {
|
|
1560
|
+
this.subscription.unsubscribe();
|
|
1561
|
+
}
|
|
1562
|
+
};
|
|
1563
|
+
AdvancedListComponent.prototype.ngOnInit = function () {
|
|
1564
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1565
|
+
var metadata_1, err_1;
|
|
1566
|
+
var _this = this;
|
|
1567
|
+
return __generator(this, function (_a) {
|
|
1568
|
+
switch (_a.label) {
|
|
1569
|
+
case 0:
|
|
1570
|
+
_a.trys.push([0, 2, , 3]);
|
|
1571
|
+
return [4 /*yield*/, this._context.getMetadata()];
|
|
1572
|
+
case 1:
|
|
1573
|
+
metadata_1 = _a.sent();
|
|
1574
|
+
// get route data
|
|
1575
|
+
this.dataSubscription = this._activatedRoute.data.subscribe(function (routeData) {
|
|
1576
|
+
// get entityType
|
|
1577
|
+
var re = new RegExp("^" + routeData.model + "$", 'ig');
|
|
1578
|
+
var entitySet = metadata_1.EntityContainer.EntitySet.find(function (x) {
|
|
1579
|
+
return re.test(x.Name);
|
|
1580
|
+
});
|
|
1581
|
+
// if entity type is null
|
|
1582
|
+
if (entitySet == null) {
|
|
1583
|
+
// navigate to error
|
|
1584
|
+
return _this._errorService.navigateToError(new client.ResponseError('EntitySet Not Found', 404));
|
|
1585
|
+
}
|
|
1586
|
+
// get entity type
|
|
1587
|
+
var entityType = metadata_1.EntityType.find(function (x) {
|
|
1588
|
+
return x.Name === entitySet.EntityType;
|
|
1589
|
+
});
|
|
1590
|
+
if (entityType == null) {
|
|
1591
|
+
return _this._errorService.navigateToError(new client.ResponseError('EntityType Not Found', 404));
|
|
1592
|
+
}
|
|
1593
|
+
if (routeData.searchConfiguration) {
|
|
1594
|
+
if (Object.prototype.hasOwnProperty.call(routeData.searchConfiguration, 'allowSave')) {
|
|
1595
|
+
_this.allowSaveOption = routeData.searchConfiguration.allowSave;
|
|
1596
|
+
}
|
|
1597
|
+
_this.searchConfiguration = routeData.searchConfiguration;
|
|
1598
|
+
}
|
|
1599
|
+
if (routeData.tableConfiguration) {
|
|
1600
|
+
_this.tableConfiguration = routeData.tableConfiguration;
|
|
1601
|
+
}
|
|
1602
|
+
if (routeData.description) {
|
|
1603
|
+
_this.description = _this._translateService.instant(routeData.description);
|
|
1604
|
+
}
|
|
1605
|
+
if (routeData.longDescription) {
|
|
1606
|
+
_this.longDescription = _this._translateService.instant(routeData.longDescription);
|
|
1607
|
+
}
|
|
1608
|
+
if (routeData.category) {
|
|
1609
|
+
_this.category = _this._translateService.instant(routeData.category);
|
|
1610
|
+
}
|
|
1611
|
+
// clone default configuration
|
|
1612
|
+
var defaultConfiguration = AdvancedTableConfiguration.cast(_this.tableConfiguration, true);
|
|
1613
|
+
// correct edit button link
|
|
1614
|
+
var column = defaultConfiguration.columns.find(function (col) {
|
|
1615
|
+
return col.formatter === 'ButtonFormatter' && col.formatString === '(modal:edit)';
|
|
1616
|
+
});
|
|
1617
|
+
if (column) {
|
|
1618
|
+
var url_1 = [];
|
|
1619
|
+
_this._activatedRoute.snapshot.pathFromRoot.forEach(function (route) {
|
|
1620
|
+
url_1.push.apply(url_1, route.url);
|
|
1621
|
+
});
|
|
1622
|
+
column.formatString = "#/" + url_1.join('/') + "/(modal:${id}/edit)";
|
|
1623
|
+
}
|
|
1624
|
+
// create list configuration by assigning list entity set
|
|
1625
|
+
_this.table.config = Object.assign({
|
|
1626
|
+
model: entitySet.Name
|
|
1627
|
+
}, defaultConfiguration);
|
|
1628
|
+
// fetch data
|
|
1629
|
+
_this.table.fetch(true);
|
|
1630
|
+
// do reload by using hidden fragment e.g. /classes#reload
|
|
1631
|
+
_this.reloadSubscription = _this._activatedRoute.fragment.subscribe(function (fragment) {
|
|
1632
|
+
if (fragment && fragment === 'reload') {
|
|
1633
|
+
_this._toastService.show(_this.description, _this._translateService.instant('Settings.OperationCompleted'));
|
|
1634
|
+
_this.table.fetch(true);
|
|
1635
|
+
}
|
|
1636
|
+
});
|
|
1637
|
+
// finally add user activity
|
|
1638
|
+
_this._userActivityService.setItem({
|
|
1639
|
+
category: _this.category,
|
|
1640
|
+
description: _this.description,
|
|
1641
|
+
url: window.location.hash.substring(1),
|
|
1642
|
+
dateCreated: new Date
|
|
1643
|
+
});
|
|
1644
|
+
});
|
|
1645
|
+
return [3 /*break*/, 3];
|
|
1646
|
+
case 2:
|
|
1647
|
+
err_1 = _a.sent();
|
|
1648
|
+
console.error(err_1);
|
|
1649
|
+
return [2 /*return*/, this._errorService.showError(err_1)];
|
|
1650
|
+
case 3: return [2 /*return*/];
|
|
1651
|
+
}
|
|
1652
|
+
});
|
|
1653
|
+
});
|
|
1654
|
+
};
|
|
1655
|
+
/**
|
|
1656
|
+
* Data load event handler of advanced table component
|
|
1657
|
+
* @param {AdvancedTableDataResult} data
|
|
1658
|
+
*/
|
|
1659
|
+
AdvancedListComponent.prototype.onDataLoad = function (data) {
|
|
1660
|
+
this.recordsTotal = data.recordsTotal;
|
|
1661
|
+
};
|
|
1662
|
+
/**
|
|
1663
|
+
* Remove selected items
|
|
1664
|
+
*/
|
|
1665
|
+
AdvancedListComponent.prototype.remove = function () {
|
|
1666
|
+
var _this = this;
|
|
1667
|
+
if (this.table && this.table.selected && this.table.selected.length) {
|
|
1668
|
+
// get items to remove
|
|
1669
|
+
var items_1 = this.table.selected;
|
|
1670
|
+
return this._modalService.showWarningDialog(this._translateService.instant('Tables.RemoveItemsTitle'), this._translateService.instant('Tables.RemoveItemsMessage'), i2.DIALOG_BUTTONS.OkCancel).then(function (result) {
|
|
1671
|
+
if (result === 'ok') {
|
|
1672
|
+
_this._context.model(_this.table.config.model).remove(items_1).then(function () {
|
|
1673
|
+
_this._toastService.show(_this.description + ':' + _this._translateService.instant('Tables.RemoveItemMessage.title'), _this._translateService.instant((items_1.length === 1 ?
|
|
1674
|
+
'Tables.RemoveItemMessage.one' : 'Tables.RemoveItemMessage.many'), { value: items_1.length }));
|
|
1675
|
+
_this.table.fetch(true);
|
|
1676
|
+
}).catch(function (err) {
|
|
1677
|
+
_this._errorService.showError(err, {
|
|
1678
|
+
continueLink: '.'
|
|
1679
|
+
});
|
|
1680
|
+
});
|
|
1681
|
+
}
|
|
1682
|
+
});
|
|
1683
|
+
}
|
|
1684
|
+
};
|
|
1685
|
+
AdvancedListComponent.decorators = [
|
|
1686
|
+
{ type: i0.Component, args: [{
|
|
1687
|
+
selector: 'app-advanced-list',
|
|
1688
|
+
template: "<div>\n <div class=\"row\" *ngIf=\"description\">\n <div class=\"col-auto\">\n <h2>{{description}}</h2>\n <p *ngIf=\"longDescription\">{{longDescription}}</p>\n </div>\n </div>\n <div class=\"row\" *ngIf=\"searchConfiguration\">\n <div class=\"col-12\" [ngVar]=\"{}\" #filter=\"ngVar\">\n <app-advanced-table-search #advancedSearch [(filter)]=\"filter.value\" [collapsed]=\"true\" [table]=\"table\" [allowSave]=\"allowSaveOption\">\n <advanced-search>\n <app-advanced-search-form [form]=\"searchConfiguration\" (filterChange)=\"advancedSearch.asyncAdvancedSearch()\" #search [(filter)]=\"filter.value\"></app-advanced-search-form>\n </advanced-search>\n </app-advanced-table-search>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-auto mt-4\">\n <div class=\"font-xl text-secondary\" *ngIf=\"recordsTotal > 1\">\n <span>{{recordsTotal}}</span><span> </span><span [translate]=\"'Tables.Items'\"></span>\n </div>\n <div class=\"font-xl text-secondary\" *ngIf=\"recordsTotal === 1\">\n <span>{{recordsTotal}}</span><span> </span><span [translate]=\"'Tables.Item'\"></span>\n </div>\n </div>\n <div class=\"pull-right ml-auto mr-3 mt-3\">\n <div class=\"font-lg btn-toolbar mt-3\">\n <a *ngIf=\"table && table.selected && table.selected.length\"\n class=\"text-danger text-decoration-none mr-2\" href=\"javascript:void(0)\" (click)=\"remove()\">\n <span>-</span><span> </span><span [translate]=\"'Tables.RemoveItem'\"></span>\n </a>\n <a class=\"text-indigo text-decoration-none\" [routerLink]=\"['.', { outlets:{ modal:'add'} }]\">\n <span>+</span><span> </span><span [translate]=\"'Tables.AddItem'\"></span>\n </a>\n </div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-12 mb-4\">\n <app-advanced-table [selectable]=\"true\" #table\n [autoLoad]=false\n [showFooter]=\"false\"\n (load)=\"onDataLoad($event)\" [height]=\"600\"></app-advanced-table>\n </div>\n </div>\n <router-modal></router-modal>\n</div>\n"
|
|
1689
|
+
}] }
|
|
1690
|
+
];
|
|
1691
|
+
/** @nocollapse */
|
|
1692
|
+
AdvancedListComponent.ctorParameters = function () {
|
|
1693
|
+
return [
|
|
1694
|
+
{ type: i1$1.AngularDataContext },
|
|
1695
|
+
{ type: core.TranslateService },
|
|
1696
|
+
{ type: i1.ActivatedRoute },
|
|
1697
|
+
{ type: i2.ErrorService },
|
|
1698
|
+
{ type: i2.ToastService },
|
|
1699
|
+
{ type: i2.ModalService },
|
|
1700
|
+
{ type: i2.UserActivityService }
|
|
1701
|
+
];
|
|
1702
|
+
};
|
|
1703
|
+
AdvancedListComponent.propDecorators = {
|
|
1704
|
+
entitySet: [{ type: i0.Input, args: ['entitySet',] }],
|
|
1705
|
+
category: [{ type: i0.Input, args: ['category',] }],
|
|
1706
|
+
description: [{ type: i0.Input, args: ['description',] }],
|
|
1707
|
+
longDescription: [{ type: i0.Input, args: ['longDescription',] }],
|
|
1708
|
+
tableConfiguration: [{ type: i0.Input, args: ['tableConfiguration',] }],
|
|
1709
|
+
searchConfiguration: [{ type: i0.Input, args: ['searchConfiguration',] }],
|
|
1710
|
+
table: [{ type: i0.ViewChild, args: ['table',] }],
|
|
1711
|
+
allowSaveOption: [{ type: i0.Input, args: ['allowSaveOption',] }]
|
|
1712
|
+
};
|
|
1713
|
+
return AdvancedListComponent;
|
|
1714
|
+
}());
|
|
1715
|
+
|
|
1716
|
+
var AdvancedRowActionComponent = /** @class */ (function (_super) {
|
|
1717
|
+
__extends(AdvancedRowActionComponent, _super);
|
|
1718
|
+
function AdvancedRowActionComponent(router, activatedRoute, _translateService, _context, _errorService, _modalService, _appEvent) {
|
|
1719
|
+
var _this = _super.call(this, router, activatedRoute) || this;
|
|
1720
|
+
_this._translateService = _translateService;
|
|
1721
|
+
_this._context = _context;
|
|
1722
|
+
_this._errorService = _errorService;
|
|
1723
|
+
_this._modalService = _modalService;
|
|
1724
|
+
_this._appEvent = _appEvent;
|
|
1725
|
+
_this.modalIcon = 'fas fa-project-diagram';
|
|
1726
|
+
_this.progressType = 'indigo';
|
|
1727
|
+
_this.errorMessage = 'Tables.Actions.CompletedWithErrors';
|
|
1728
|
+
_this.loading = false;
|
|
1729
|
+
_this.refresh = new i0.EventEmitter();
|
|
1730
|
+
// set modal size
|
|
1731
|
+
_this.modalClass = 'modal-lg';
|
|
1732
|
+
// set modal title
|
|
1733
|
+
_this.modalTitle = 'Tables.Actions.Label';
|
|
1734
|
+
// disable ok button
|
|
1735
|
+
_this.okButtonDisabled = false;
|
|
1736
|
+
// set button text
|
|
1737
|
+
_this.okButtonText = 'Tables.Actions.Start';
|
|
1738
|
+
return _this;
|
|
1739
|
+
}
|
|
1740
|
+
Object.defineProperty(AdvancedRowActionComponent.prototype, "form", {
|
|
1741
|
+
get: function () {
|
|
1742
|
+
return this.formComponent;
|
|
1743
|
+
},
|
|
1744
|
+
enumerable: true,
|
|
1745
|
+
configurable: true
|
|
1746
|
+
});
|
|
1747
|
+
AdvancedRowActionComponent.prototype.ngOnInit = function () {
|
|
1748
|
+
var _this = this;
|
|
1749
|
+
this.refreshSubscription = this.refresh.subscribe(function (value) {
|
|
1750
|
+
if (value && value.progress) {
|
|
1751
|
+
var progress = 0;
|
|
1752
|
+
if (value.progress < 0) {
|
|
1753
|
+
progress = 0;
|
|
1754
|
+
}
|
|
1755
|
+
else if (value.progress > 100) {
|
|
1756
|
+
progress = 100;
|
|
1757
|
+
}
|
|
1758
|
+
else {
|
|
1759
|
+
progress = value.progress;
|
|
1760
|
+
}
|
|
1761
|
+
_this.progressComponent.value = progress;
|
|
1762
|
+
}
|
|
1763
|
+
});
|
|
1764
|
+
};
|
|
1765
|
+
AdvancedRowActionComponent.prototype.ngAfterViewInit = function () {
|
|
1766
|
+
var _this = this;
|
|
1767
|
+
if (this.formComponent && this.formComponent.form) {
|
|
1768
|
+
this.okButtonDisabled = true;
|
|
1769
|
+
this.invalidSubscription = this.formComponent.form.change.subscribe(function (event) {
|
|
1770
|
+
if (Object.prototype.hasOwnProperty.call(event, "isValid") && (event.changed != null)) {
|
|
1771
|
+
_this.okButtonDisabled = !event.isValid;
|
|
1772
|
+
}
|
|
1773
|
+
});
|
|
1774
|
+
}
|
|
1775
|
+
};
|
|
1776
|
+
AdvancedRowActionComponent.prototype.ngOnDestroy = function () {
|
|
1777
|
+
if (this.refreshSubscription) {
|
|
1778
|
+
this.refreshSubscription.unsubscribe();
|
|
1779
|
+
}
|
|
1780
|
+
if (this.executeSubscription) {
|
|
1781
|
+
this.executeSubscription.unsubscribe();
|
|
1782
|
+
}
|
|
1783
|
+
if (this.invalidSubscription) {
|
|
1784
|
+
this.invalidSubscription.unsubscribe();
|
|
1785
|
+
}
|
|
1786
|
+
};
|
|
1787
|
+
AdvancedRowActionComponent.prototype.cancel = function () {
|
|
1788
|
+
if (this.loading) {
|
|
1789
|
+
return;
|
|
1790
|
+
}
|
|
1791
|
+
// close
|
|
1792
|
+
if (this._modalService.modalRef) {
|
|
1793
|
+
return this._modalService.modalRef.hide();
|
|
1794
|
+
}
|
|
1795
|
+
};
|
|
1796
|
+
AdvancedRowActionComponent.prototype.ok = function () {
|
|
1797
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1798
|
+
var _this = this;
|
|
1799
|
+
return __generator(this, function (_a) {
|
|
1800
|
+
try {
|
|
1801
|
+
this.loading = true;
|
|
1802
|
+
this.lastError = null;
|
|
1803
|
+
if (this.formComponent && this.formComponent.form &&
|
|
1804
|
+
this.formComponent.form.formio && this.formComponent.form.formio.data) {
|
|
1805
|
+
// set data
|
|
1806
|
+
this.data = this.formComponent.form.formio.data;
|
|
1807
|
+
}
|
|
1808
|
+
// do action
|
|
1809
|
+
this.execute.subscribe(function (result) {
|
|
1810
|
+
_this.loading = false;
|
|
1811
|
+
_this.refresh.emit({
|
|
1812
|
+
progress: 100
|
|
1813
|
+
});
|
|
1814
|
+
if (result && result.errors && result.errors > 0) {
|
|
1815
|
+
// show message for partial success
|
|
1816
|
+
if (result.errors === 1) {
|
|
1817
|
+
_this.lastError = new Error(_this._translateService.instant(_this.errorMessage + ".Description.One"));
|
|
1818
|
+
}
|
|
1819
|
+
else {
|
|
1820
|
+
_this.lastError = new Error(_this._translateService.instant(_this.errorMessage + ".Description.Many", result));
|
|
1821
|
+
}
|
|
1822
|
+
_this.refresh.emit({
|
|
1823
|
+
progress: 1
|
|
1824
|
+
});
|
|
1825
|
+
return;
|
|
1826
|
+
}
|
|
1827
|
+
if (_this._modalService.modalRef) {
|
|
1828
|
+
_this._modalService.modalRef.hide();
|
|
1829
|
+
}
|
|
1830
|
+
}, function (err) {
|
|
1831
|
+
_this.loading = false;
|
|
1832
|
+
_this.lastError = err;
|
|
1833
|
+
_this.refresh.emit({
|
|
1834
|
+
progress: 0
|
|
1835
|
+
});
|
|
1836
|
+
});
|
|
1837
|
+
}
|
|
1838
|
+
catch (err) {
|
|
1839
|
+
this.loading = false;
|
|
1840
|
+
this.lastError = err;
|
|
1841
|
+
}
|
|
1842
|
+
return [2 /*return*/];
|
|
1843
|
+
});
|
|
1844
|
+
});
|
|
1845
|
+
};
|
|
1846
|
+
AdvancedRowActionComponent.decorators = [
|
|
1847
|
+
{ type: i0.Component, args: [{
|
|
1848
|
+
selector: 'app-advanced-row-action',
|
|
1849
|
+
template: "<div>\n <div class=\"modal-header\" *ngIf=\"modalTitle\">\n <h5 class=\"modal-title\">{{modalTitle | translate}}</h5>\n <button (click)=\"cancel()\" [disabled]=\"loading\"\n type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Cancel\">\n <span aria-hidden=\"true\">×</span>\n </button>\n </div>\n <div class=\"modal-body pt-0 mt-2 pb-0\">\n <div class=\"row\" *ngIf=\"lastError\">\n <div class=\"col-12\">\n <div class=\"alert alert-warning\" role=\"alert\">\n <span>{{ 'Tables.Actions.CompletedWithErrors.Title' | translate }}</span><br>\n <small *ngIf=\"lastError.status >= 0\" [translate]=\"'E' + lastError.status + '.message'\"></small>\n <small *ngIf=\"lastError.status == null\">{{lastError.message}}</small>\n </div>\n </div>\n </div>\n <div class=\"row\" *ngIf=\"description\">\n <div class=\"col-12 mb-3\">\n <div class=\"text-justify\">\n {{description | translate}}\n </div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-12\">\n <div *ngIf=\"items && items.length > 1\" [translate]=\"'Tables.Actions.ActionMessage.Many'\" [translateParams]=\"items\"></div>\n <div *ngIf=\"items && items.length === 1\" [translate]=\"'Tables.Actions.ActionMessage.One'\"></div>\n <div class=\"font-weight-bold text-danger\" *ngIf=\"items && items.length <= 0\" [translate]=\"'Tables.Actions.ActionMessage.None'\"></div>\n <div class=\"pt-2 font-weight-bold text-danger\" *ngIf=\"additionalMessage && items && items.length <= 0\">{{additionalMessage}}</div>\n </div>\n </div>\n <div class=\"row pt-3\" *ngIf=\"formTemplate\">\n <div class=\"col-12 mb-3\">\n <div>\n <advanced-form-edit #formComponent [formName]=\"formTemplate\" [(data)]=\"data\"></advanced-form-edit>\n </div>\n </div>\n </div>\n\n <div class=\"row mt-3\">\n <div class=\"col-12\">\n <progressbar #progress [type]=\"progressType\" [max]=\"100\">\n </progressbar>\n </div>\n </div>\n </div>\n\n <div class=\"modal-footer justify-content-end\">\n <button [disabled]=\"okButtonDisabled || loading || (items && items.length === 0)\" (click)=\"ok()\"\n type=\"button\" [ngClass]=\"okButtonClass\">\n {{okButtonText | translate}}\n </button>\n <button [disabled]=\"cancelButtonDisabled || loading\"\n (click)=\"cancel()\" type=\"button\" [ngClass]=\"cancelButtonClass\" data-dismiss=\"modal\">\n {{cancelButtonText | translate}}\n </button>\n </div>\n</div>\n",
|
|
1850
|
+
encapsulation: i0.ViewEncapsulation.None,
|
|
1851
|
+
styles: ["\n .fa-1_5x {\n font-size: 1.5rem;\n }\n .form-control:disabled, .form-control[readonly] {\n background-color: inherit;\n }\n .form-check.checkbox {\n position: relative\n }\n "]
|
|
1852
|
+
}] }
|
|
1853
|
+
];
|
|
1854
|
+
/** @nocollapse */
|
|
1855
|
+
AdvancedRowActionComponent.ctorParameters = function () {
|
|
1856
|
+
return [
|
|
1857
|
+
{ type: i1.Router },
|
|
1858
|
+
{ type: i1.ActivatedRoute },
|
|
1859
|
+
{ type: core.TranslateService },
|
|
1860
|
+
{ type: i1$1.AngularDataContext },
|
|
1861
|
+
{ type: i2.ErrorService },
|
|
1862
|
+
{ type: i2.ModalService },
|
|
1863
|
+
{ type: i2.AppEventService }
|
|
1864
|
+
];
|
|
1865
|
+
};
|
|
1866
|
+
AdvancedRowActionComponent.propDecorators = {
|
|
1867
|
+
items: [{ type: i0.Input }],
|
|
1868
|
+
modalIcon: [{ type: i0.Input }],
|
|
1869
|
+
description: [{ type: i0.Input }],
|
|
1870
|
+
formTemplate: [{ type: i0.Input }],
|
|
1871
|
+
progressType: [{ type: i0.Input }],
|
|
1872
|
+
data: [{ type: i0.Output }],
|
|
1873
|
+
additionalMessage: [{ type: i0.Input }],
|
|
1874
|
+
errorMessage: [{ type: i0.Input }],
|
|
1875
|
+
progressComponent: [{ type: i0.ViewChild, args: ['progress',] }],
|
|
1876
|
+
formComponent: [{ type: i0.ViewChild, args: ['formComponent',] }],
|
|
1877
|
+
refresh: [{ type: i0.Input }],
|
|
1878
|
+
execute: [{ type: i0.Input }]
|
|
1879
|
+
};
|
|
1880
|
+
return AdvancedRowActionComponent;
|
|
1881
|
+
}(routing.RouterModalOkCancel));
|
|
1882
|
+
|
|
1883
|
+
var AdvancedTableSearchBaseComponent = /** @class */ (function () {
|
|
1884
|
+
function AdvancedTableSearchBaseComponent() {
|
|
1885
|
+
this.filterChange = new i0.EventEmitter();
|
|
1886
|
+
}
|
|
1887
|
+
Object.defineProperty(AdvancedTableSearchBaseComponent.prototype, "filter", {
|
|
1888
|
+
get: function () {
|
|
1889
|
+
return this._filter;
|
|
1890
|
+
},
|
|
1891
|
+
set: function (value) {
|
|
1892
|
+
this._filter = value;
|
|
1893
|
+
},
|
|
1894
|
+
enumerable: true,
|
|
1895
|
+
configurable: true
|
|
1896
|
+
});
|
|
1897
|
+
AdvancedTableSearchBaseComponent.prototype.onKeyEnter = function (event) {
|
|
1898
|
+
if (event.code === 'Enter') {
|
|
1899
|
+
this.filterChange.emit(this._filter);
|
|
1900
|
+
}
|
|
1901
|
+
};
|
|
1902
|
+
AdvancedTableSearchBaseComponent.propDecorators = {
|
|
1903
|
+
filterChange: [{ type: i0.Output }],
|
|
1904
|
+
filter: [{ type: i0.Input }]
|
|
1905
|
+
};
|
|
1906
|
+
return AdvancedTableSearchBaseComponent;
|
|
1907
|
+
}());
|
|
1908
|
+
|
|
1909
|
+
var AdvancedSearchFormComponent = /** @class */ (function (_super) {
|
|
1910
|
+
__extends(AdvancedSearchFormComponent, _super);
|
|
1911
|
+
function AdvancedSearchFormComponent(_context, _translateService, _activatedRoute, _http) {
|
|
1912
|
+
var _this = _super.call(this) || this;
|
|
1913
|
+
_this._context = _context;
|
|
1914
|
+
_this._translateService = _translateService;
|
|
1915
|
+
_this._activatedRoute = _activatedRoute;
|
|
1916
|
+
_this._http = _http;
|
|
1917
|
+
_this.form = {};
|
|
1918
|
+
_this.refreshForm = new i0.EventEmitter();
|
|
1919
|
+
_this.submission = { data: {} };
|
|
1920
|
+
_this.loading = true;
|
|
1921
|
+
return _this;
|
|
1922
|
+
}
|
|
1923
|
+
AdvancedSearchFormComponent.prototype.ngOnChanges = function (changes) {
|
|
1924
|
+
var _this = this;
|
|
1925
|
+
if (Object.prototype.hasOwnProperty.call(changes, 'form')) {
|
|
1926
|
+
if (changes.form != null) {
|
|
1927
|
+
if (changes.form.currentValue &&
|
|
1928
|
+
changes.form.currentValue != changes.form.previousValue) {
|
|
1929
|
+
this.ngOnInit();
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
if (Object.prototype.hasOwnProperty.call(changes, 'formSrc')) {
|
|
1934
|
+
if (changes.formSrc != null) {
|
|
1935
|
+
if (changes.formSrc.currentValue &&
|
|
1936
|
+
changes.formSrc.currentValue != changes.formSrc.previousValue) {
|
|
1937
|
+
this._http.get(changes.formSrc.currentValue).toPromise().then(function (form) {
|
|
1938
|
+
// set form
|
|
1939
|
+
_this.form = form;
|
|
1940
|
+
// and init
|
|
1941
|
+
_this.ngOnInit();
|
|
1942
|
+
}).catch(function (err) {
|
|
1943
|
+
console.error('An error occurred while loading search configuration');
|
|
1944
|
+
console.error(err);
|
|
1945
|
+
});
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
if (Object.prototype.hasOwnProperty.call(changes, 'filter')) {
|
|
1950
|
+
if (changes.filter != null) {
|
|
1951
|
+
this.submission.data = changes.filter.currentValue || {};
|
|
1952
|
+
this.refreshForm.emit({
|
|
1953
|
+
submission: this.submission
|
|
1954
|
+
});
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
};
|
|
1958
|
+
AdvancedSearchFormComponent.prototype.ngOnInit = function () {
|
|
1959
|
+
var _this = this;
|
|
1960
|
+
if (this.form) {
|
|
1961
|
+
new forms$1.ServiceUrlPreProcessor(this._context).parse(this.form);
|
|
1962
|
+
new forms$1.TranslatePreProcessor(this._translateService).parse(this.form);
|
|
1963
|
+
this.submission = {
|
|
1964
|
+
data: this.filter
|
|
1965
|
+
};
|
|
1966
|
+
this.refreshForm.emit({
|
|
1967
|
+
form: this.form
|
|
1968
|
+
});
|
|
1969
|
+
this.loading = false;
|
|
1970
|
+
this.filterSubscription = this.filterChange.subscribe(function (filter) {
|
|
1971
|
+
_this.submission.data = filter;
|
|
1972
|
+
_this.refreshForm.emit({
|
|
1973
|
+
submission: _this.submission
|
|
1974
|
+
});
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
};
|
|
1978
|
+
AdvancedSearchFormComponent.prototype.onChange = function (event) {
|
|
1979
|
+
var _this = this;
|
|
1980
|
+
Object.keys(this.formComponent.submission.data).forEach(function (key) {
|
|
1981
|
+
if (Object.prototype.hasOwnProperty.call(_this.formComponent.submission.data, key)) {
|
|
1982
|
+
var value = _this.formComponent.submission.data[key];
|
|
1983
|
+
// the filter with type is a string and is not empty
|
|
1984
|
+
var isEmptyString = typeof value === 'string' && value.length === 0;
|
|
1985
|
+
if (!isEmptyString) {
|
|
1986
|
+
Object.defineProperty(_this.filter, key, {
|
|
1987
|
+
configurable: true,
|
|
1988
|
+
enumerable: true,
|
|
1989
|
+
value: value
|
|
1990
|
+
});
|
|
1991
|
+
}
|
|
1992
|
+
else {
|
|
1993
|
+
delete _this.filter[key];
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
});
|
|
1997
|
+
};
|
|
1998
|
+
AdvancedSearchFormComponent.prototype.onFormLoad = function (form) {
|
|
1999
|
+
var currentLang = this._translateService.currentLang;
|
|
2000
|
+
this.formComponent.formio.i18next.options.resources[currentLang] = { translation: this._translateService.instant("Forms") };
|
|
2001
|
+
this.formComponent.formio.language = currentLang;
|
|
2002
|
+
};
|
|
2003
|
+
AdvancedSearchFormComponent.prototype.ngAfterViewInit = function () {
|
|
2004
|
+
//
|
|
2005
|
+
};
|
|
2006
|
+
AdvancedSearchFormComponent.prototype.ngOnDestroy = function () {
|
|
2007
|
+
if (this.filterSubscription) {
|
|
2008
|
+
this.filterSubscription.unsubscribe();
|
|
2009
|
+
}
|
|
2010
|
+
};
|
|
2011
|
+
AdvancedSearchFormComponent.decorators = [
|
|
2012
|
+
{ type: i0.Component, args: [{
|
|
2013
|
+
selector: 'app-advanced-search-form',
|
|
2014
|
+
template: "\n <div class=\"p-4\">\n <formio #formioComponent class=\"formio-search\" (keydown)=\"onKeyEnter($event)\" (change)=\"onChange($event)\" (formLoad)=\"onFormLoad($event)\"\n [refresh]=\"refreshForm\" [submission]=\"submission\" [form]=\"form\"></formio>\n </div>\n ",
|
|
2015
|
+
encapsulation: i0.ViewEncapsulation.None,
|
|
2016
|
+
styles: ["formio.formio-search .form-group{margin-bottom:0}formio.formio-search .form-group .col-form-label{font-size:90%;padding-top:4px;padding-bottom:4px}.choices__list.choices__list--single .choices__item:first-child.choices__item--selectable{width:85%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}"]
|
|
2017
|
+
}] }
|
|
2018
|
+
];
|
|
2019
|
+
/** @nocollapse */
|
|
2020
|
+
AdvancedSearchFormComponent.ctorParameters = function () {
|
|
2021
|
+
return [
|
|
2022
|
+
{ type: i1$1.AngularDataContext },
|
|
2023
|
+
{ type: core.TranslateService },
|
|
2024
|
+
{ type: i1.ActivatedRoute },
|
|
2025
|
+
{ type: http.HttpClient }
|
|
2026
|
+
];
|
|
2027
|
+
};
|
|
2028
|
+
AdvancedSearchFormComponent.propDecorators = {
|
|
2029
|
+
formComponent: [{ type: i0.ViewChild, args: ['formioComponent',] }],
|
|
2030
|
+
form: [{ type: i0.Input }],
|
|
2031
|
+
formSrc: [{ type: i0.Input }],
|
|
2032
|
+
refreshForm: [{ type: i0.Output }]
|
|
2033
|
+
};
|
|
2034
|
+
return AdvancedSearchFormComponent;
|
|
2035
|
+
}(AdvancedTableSearchBaseComponent));
|
|
2036
|
+
|
|
2037
|
+
var AdvancedTableConfigurationResolver = /** @class */ (function () {
|
|
2038
|
+
function AdvancedTableConfigurationResolver(_http) {
|
|
2039
|
+
this._http = _http;
|
|
2040
|
+
}
|
|
2041
|
+
AdvancedTableConfigurationResolver.prototype.resolve = function (route, state) {
|
|
2042
|
+
// get list
|
|
2043
|
+
var list = route.data.list || route.params.list;
|
|
2044
|
+
// get model
|
|
2045
|
+
var model = route.data.model || route.params.model;
|
|
2046
|
+
// get configuration
|
|
2047
|
+
return this._http.get("assets/lists/" + model + "/" + list + ".json").toPromise();
|
|
2048
|
+
};
|
|
2049
|
+
AdvancedTableConfigurationResolver.decorators = [
|
|
2050
|
+
{ type: i0.Injectable }
|
|
2051
|
+
];
|
|
2052
|
+
/** @nocollapse */
|
|
2053
|
+
AdvancedTableConfigurationResolver.ctorParameters = function () {
|
|
2054
|
+
return [
|
|
2055
|
+
{ type: http.HttpClient }
|
|
2056
|
+
];
|
|
2057
|
+
};
|
|
2058
|
+
return AdvancedTableConfigurationResolver;
|
|
2059
|
+
}());
|
|
2060
|
+
var AdvancedSearchConfigurationResolver = /** @class */ (function () {
|
|
2061
|
+
function AdvancedSearchConfigurationResolver(_http) {
|
|
2062
|
+
this._http = _http;
|
|
2063
|
+
}
|
|
2064
|
+
AdvancedSearchConfigurationResolver.prototype.resolve = function (route, state) {
|
|
2065
|
+
// get list
|
|
2066
|
+
var list = route.data.list || route.params.list;
|
|
2067
|
+
// get model
|
|
2068
|
+
var model = route.data.model || route.params.model;
|
|
2069
|
+
// get configuration
|
|
2070
|
+
return this._http.get("assets/lists/" + model + "/search." + list + ".json").toPromise();
|
|
2071
|
+
};
|
|
2072
|
+
AdvancedSearchConfigurationResolver.decorators = [
|
|
2073
|
+
{ type: i0.Injectable }
|
|
2074
|
+
];
|
|
2075
|
+
/** @nocollapse */
|
|
2076
|
+
AdvancedSearchConfigurationResolver.ctorParameters = function () {
|
|
2077
|
+
return [
|
|
2078
|
+
{ type: http.HttpClient }
|
|
2079
|
+
];
|
|
2080
|
+
};
|
|
2081
|
+
return AdvancedSearchConfigurationResolver;
|
|
2082
|
+
}());
|
|
2083
|
+
|
|
2084
|
+
var AdvancedTableSearchComponent = /** @class */ (function (_super) {
|
|
2085
|
+
__extends(AdvancedTableSearchComponent, _super);
|
|
2086
|
+
function AdvancedTableSearchComponent(_context, _activatedRoute, datePipe, _modalService, _userStorage, _translate, _advancedSearchValueProvider, _template, _router, _modal) {
|
|
2087
|
+
var _this = _super.call(this) || this;
|
|
2088
|
+
_this._context = _context;
|
|
2089
|
+
_this._activatedRoute = _activatedRoute;
|
|
2090
|
+
_this.datePipe = datePipe;
|
|
2091
|
+
_this._modalService = _modalService;
|
|
2092
|
+
_this._userStorage = _userStorage;
|
|
2093
|
+
_this._translate = _translate;
|
|
2094
|
+
_this._advancedSearchValueProvider = _advancedSearchValueProvider;
|
|
2095
|
+
_this._template = _template;
|
|
2096
|
+
_this._router = _router;
|
|
2097
|
+
_this._modal = _modal;
|
|
2098
|
+
_this.collapsed = true;
|
|
2099
|
+
_this.allowSave = true;
|
|
2100
|
+
_this.showMore = true;
|
|
2101
|
+
_this.mergeQueryParams = true;
|
|
2102
|
+
_this.viewChange = new i0.EventEmitter();
|
|
2103
|
+
_this.userSearchList = [];
|
|
2104
|
+
_this.selectedList = null;
|
|
2105
|
+
return _this;
|
|
2106
|
+
}
|
|
2107
|
+
Object.defineProperty(AdvancedTableSearchComponent.prototype, "text", {
|
|
2108
|
+
get: function () {
|
|
2109
|
+
if (this.searchText) {
|
|
2110
|
+
return this.searchText.nativeElement.value;
|
|
2111
|
+
}
|
|
2112
|
+
},
|
|
2113
|
+
set: function (value) {
|
|
2114
|
+
if (this.searchText) {
|
|
2115
|
+
this.searchText.nativeElement.value = value;
|
|
2116
|
+
}
|
|
2117
|
+
},
|
|
2118
|
+
enumerable: true,
|
|
2119
|
+
configurable: true
|
|
2120
|
+
});
|
|
2121
|
+
AdvancedTableSearchComponent.prototype.ngOnInit = function () {
|
|
2122
|
+
var _this = this;
|
|
2123
|
+
this.configChangesSubscription = this.table.configChanges.subscribe(function (config) {
|
|
2124
|
+
if (config == null) {
|
|
2125
|
+
return;
|
|
2126
|
+
}
|
|
2127
|
+
// load user searches
|
|
2128
|
+
_this.loadUserSearchList().then(function () {
|
|
2129
|
+
// if search component merges query params
|
|
2130
|
+
// (uses queryParams to apply filter)
|
|
2131
|
+
if (_this.mergeQueryParams) {
|
|
2132
|
+
_this.queryParamSubscription = _this._activatedRoute.queryParams.subscribe(function (queryParams) {
|
|
2133
|
+
_this.applyQueryParams(queryParams);
|
|
2134
|
+
});
|
|
2135
|
+
}
|
|
2136
|
+
});
|
|
2137
|
+
});
|
|
2138
|
+
};
|
|
2139
|
+
/**
|
|
2140
|
+
* Applies query given by the queryParams of the activated route
|
|
2141
|
+
* @param queryParams
|
|
2142
|
+
*/
|
|
2143
|
+
AdvancedTableSearchComponent.prototype.applyQueryParams = function (queryParams) {
|
|
2144
|
+
var _this = this;
|
|
2145
|
+
this.filter = {};
|
|
2146
|
+
if (Object.prototype.hasOwnProperty.call(queryParams, 'q')) {
|
|
2147
|
+
// set collapsed
|
|
2148
|
+
this.collapsed = true;
|
|
2149
|
+
// search text
|
|
2150
|
+
this.text = queryParams.q;
|
|
2151
|
+
return this.table.search(this.text);
|
|
2152
|
+
}
|
|
2153
|
+
else {
|
|
2154
|
+
this.text = '';
|
|
2155
|
+
}
|
|
2156
|
+
var filterParams = Object.assign({}, queryParams);
|
|
2157
|
+
if (Object.prototype.hasOwnProperty.call(queryParams, 's')) {
|
|
2158
|
+
// set collapsed
|
|
2159
|
+
this.collapsed = false;
|
|
2160
|
+
// find user search by name
|
|
2161
|
+
if (this.userSearchList) {
|
|
2162
|
+
this.selectedList = this.userSearchList.find(function (item) {
|
|
2163
|
+
return item.name === queryParams.s;
|
|
2164
|
+
});
|
|
2165
|
+
if (this.selectedList) {
|
|
2166
|
+
filterParams = this.selectedList.filter;
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
else {
|
|
2171
|
+
this.selectedList = null;
|
|
2172
|
+
}
|
|
2173
|
+
Object.keys(filterParams).filter(function (key) {
|
|
2174
|
+
// search criteria
|
|
2175
|
+
if (_this.table && _this.table.config && _this.table.config.criteria) {
|
|
2176
|
+
return _this.table.config.criteria.find(function (item) {
|
|
2177
|
+
return item.name === key;
|
|
2178
|
+
});
|
|
2179
|
+
}
|
|
2180
|
+
}).forEach(function (key) {
|
|
2181
|
+
var value = filterParams[key];
|
|
2182
|
+
if (client.TextUtils.isNumber(value)) {
|
|
2183
|
+
value = parseFloat(filterParams[key]);
|
|
2184
|
+
}
|
|
2185
|
+
if (_this.filter[key] !== value) {
|
|
2186
|
+
// set value
|
|
2187
|
+
Object.defineProperty(_this.filter, key, {
|
|
2188
|
+
configurable: true,
|
|
2189
|
+
enumerable: true,
|
|
2190
|
+
writable: true,
|
|
2191
|
+
value: value
|
|
2192
|
+
});
|
|
2193
|
+
}
|
|
2194
|
+
if (_this.filter[key] != null) {
|
|
2195
|
+
_this.collapsed = false;
|
|
2196
|
+
}
|
|
2197
|
+
});
|
|
2198
|
+
// call filterChange event to apply change to advanced search children
|
|
2199
|
+
this.filterChange.emit(this.filter);
|
|
2200
|
+
// apply query
|
|
2201
|
+
this.getQuery().then(function (query) {
|
|
2202
|
+
// if table query is null
|
|
2203
|
+
if (_this.table.query == null) {
|
|
2204
|
+
// set query
|
|
2205
|
+
_this.table.query = query;
|
|
2206
|
+
}
|
|
2207
|
+
else {
|
|
2208
|
+
if (query != null) {
|
|
2209
|
+
var params = query.getParams();
|
|
2210
|
+
// otherwise set filter params
|
|
2211
|
+
_this.table.query.setParam('$filter', params.$filter);
|
|
2212
|
+
}
|
|
2213
|
+
else {
|
|
2214
|
+
_this.table.query.setParam('$filter', null);
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
// and finally fetch data
|
|
2218
|
+
_this.table.fetch(true);
|
|
2219
|
+
});
|
|
2220
|
+
};
|
|
2221
|
+
AdvancedTableSearchComponent.prototype.ngOnDestroy = function () {
|
|
2222
|
+
if (this.queryParamSubscription) {
|
|
2223
|
+
this.queryParamSubscription.unsubscribe();
|
|
2224
|
+
}
|
|
2225
|
+
if (this.configChangesSubscription) {
|
|
2226
|
+
this.configChangesSubscription.unsubscribe();
|
|
2227
|
+
}
|
|
2228
|
+
};
|
|
2229
|
+
AdvancedTableSearchComponent.prototype.ngAfterViewInit = function () {
|
|
2230
|
+
};
|
|
2231
|
+
AdvancedTableSearchComponent.prototype.onSearchKeyDown = function (event) {
|
|
2232
|
+
if (this.table && event.keyCode === 13) {
|
|
2233
|
+
// get search text
|
|
2234
|
+
var searchText = event.target.value;
|
|
2235
|
+
// merge query params ?
|
|
2236
|
+
if (this.mergeQueryParams) {
|
|
2237
|
+
var queryParams_1 = {
|
|
2238
|
+
q: searchText
|
|
2239
|
+
};
|
|
2240
|
+
if (this.table.config && this.table.config.criteria) {
|
|
2241
|
+
this.table.config.criteria.forEach(function (item) {
|
|
2242
|
+
Object.defineProperty(queryParams_1, item.name, {
|
|
2243
|
+
configurable: true,
|
|
2244
|
+
enumerable: true,
|
|
2245
|
+
writable: true,
|
|
2246
|
+
value: null
|
|
2247
|
+
});
|
|
2248
|
+
});
|
|
2249
|
+
}
|
|
2250
|
+
// try to apply filter by appending query params
|
|
2251
|
+
return this._router.navigate([], {
|
|
2252
|
+
relativeTo: this._activatedRoute,
|
|
2253
|
+
queryParams: queryParams_1,
|
|
2254
|
+
queryParamsHandling: 'merge'
|
|
2255
|
+
});
|
|
2256
|
+
}
|
|
2257
|
+
// otherwise do search
|
|
2258
|
+
this.table.search(searchText);
|
|
2259
|
+
return false;
|
|
2260
|
+
}
|
|
2261
|
+
};
|
|
2262
|
+
AdvancedTableSearchComponent.prototype.transformDate = function (date) {
|
|
2263
|
+
date = this.datePipe.transform(date, 'MM/dd/yyyy'); // whatever format you need.
|
|
2264
|
+
return date;
|
|
2265
|
+
};
|
|
2266
|
+
AdvancedTableSearchComponent.prototype.convertToString = function (nameFilter) {
|
|
2267
|
+
var name = '';
|
|
2268
|
+
if (nameFilter != null) {
|
|
2269
|
+
name = nameFilter.toString();
|
|
2270
|
+
}
|
|
2271
|
+
return name;
|
|
2272
|
+
};
|
|
2273
|
+
// Load saved criteria searches user has stored before
|
|
2274
|
+
AdvancedTableSearchComponent.prototype.loadUserSearchList = function () {
|
|
2275
|
+
var _this = this;
|
|
2276
|
+
this.storageKey = 'tables/' + this.table.config.model + '/searches';
|
|
2277
|
+
return this._userStorage.getItem(this.storageKey).then(function (data) {
|
|
2278
|
+
var list = data.value || [];
|
|
2279
|
+
// if table configuration has pre-defined searches
|
|
2280
|
+
if (_this.table && _this.table.config.searches && _this.table.config.searches.length) {
|
|
2281
|
+
// add pre-defined lists
|
|
2282
|
+
list.push.apply(list, _this.table.config.searches.map(function (x) {
|
|
2283
|
+
x.readOnly = true; // as readonly
|
|
2284
|
+
x.name = _this._translate.instant(x.name);
|
|
2285
|
+
return x;
|
|
2286
|
+
}));
|
|
2287
|
+
}
|
|
2288
|
+
// set user search list
|
|
2289
|
+
_this.userSearchList = list;
|
|
2290
|
+
return Promise.resolve();
|
|
2291
|
+
}).catch(function (err) {
|
|
2292
|
+
// DO NOT THROW ERROR
|
|
2293
|
+
// todo: notify component for this error in order to disable some actions
|
|
2294
|
+
console.error('An error occurred while getting user search list');
|
|
2295
|
+
console.error(err);
|
|
2296
|
+
return Promise.resolve();
|
|
2297
|
+
});
|
|
2298
|
+
};
|
|
2299
|
+
AdvancedTableSearchComponent.prototype.onSelectUserSearch = function (event) {
|
|
2300
|
+
if (this.selectedList) {
|
|
2301
|
+
var listFound = this.searchInListByName(this.selectedList.name);
|
|
2302
|
+
if (listFound) {
|
|
2303
|
+
if (this.mergeQueryParams) {
|
|
2304
|
+
var queryParams_2 = { q: null, s: this.selectedList.name };
|
|
2305
|
+
// clear criteria if any
|
|
2306
|
+
this.table.config.criteria.forEach(function (item) {
|
|
2307
|
+
if (Object.prototype.hasOwnProperty.call(queryParams_2, item.name) === false) {
|
|
2308
|
+
// set null value
|
|
2309
|
+
Object.defineProperty(queryParams_2, item.name, {
|
|
2310
|
+
configurable: true,
|
|
2311
|
+
enumerable: true,
|
|
2312
|
+
writable: true,
|
|
2313
|
+
value: null
|
|
2314
|
+
});
|
|
2315
|
+
}
|
|
2316
|
+
});
|
|
2317
|
+
return this._router.navigate([], {
|
|
2318
|
+
relativeTo: this._activatedRoute,
|
|
2319
|
+
queryParams: queryParams_2,
|
|
2320
|
+
queryParamsHandling: 'merge'
|
|
2321
|
+
});
|
|
2322
|
+
}
|
|
2323
|
+
this.selectedList = listFound;
|
|
2324
|
+
this.filter = this.selectedList.filter;
|
|
2325
|
+
this.filterChange.emit(this.filter);
|
|
2326
|
+
return true;
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
else {
|
|
2330
|
+
return this._router.navigate([], {
|
|
2331
|
+
relativeTo: this._activatedRoute,
|
|
2332
|
+
queryParams: { s: null },
|
|
2333
|
+
queryParamsHandling: 'merge'
|
|
2334
|
+
});
|
|
2335
|
+
}
|
|
2336
|
+
return false;
|
|
2337
|
+
};
|
|
2338
|
+
AdvancedTableSearchComponent.prototype.searchInListByName = function (name) {
|
|
2339
|
+
if (Array.isArray(this.userSearchList)) {
|
|
2340
|
+
var listFound = this.userSearchList.find(function (x) { return x.name === name; });
|
|
2341
|
+
if (listFound) {
|
|
2342
|
+
return listFound;
|
|
2343
|
+
}
|
|
2344
|
+
else {
|
|
2345
|
+
return false;
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
};
|
|
2349
|
+
// Update list item contents with given content (Search by object name property)
|
|
2350
|
+
AdvancedTableSearchComponent.prototype.updateSavedSearchListItemByName = function (name, newItem) {
|
|
2351
|
+
var itemInList = this.userSearchList.find(function (x) { return x.name === name; });
|
|
2352
|
+
var index = this.userSearchList.indexOf(itemInList);
|
|
2353
|
+
this.userSearchList[index] = newItem;
|
|
2354
|
+
this.selectedList = this.userSearchList[index];
|
|
2355
|
+
};
|
|
2356
|
+
// Update list item contents with given content (Search by object)
|
|
2357
|
+
AdvancedTableSearchComponent.prototype.updateSavedSearchListItemByObject = function (itemInList, newItem) {
|
|
2358
|
+
var index = this.userSearchList.indexOf(itemInList);
|
|
2359
|
+
this.userSearchList[index] = newItem;
|
|
2360
|
+
this.selectedList = this.userSearchList[index];
|
|
2361
|
+
};
|
|
2362
|
+
// Delete list item from list
|
|
2363
|
+
AdvancedTableSearchComponent.prototype.deleteItemFromSavedSearchListByObject = function (itemInList) {
|
|
2364
|
+
this.userSearchList = this.userSearchList.filter(function (item) { return item !== itemInList; });
|
|
2365
|
+
this.selectedList = null;
|
|
2366
|
+
this.filter = {};
|
|
2367
|
+
this.advancedSearch(true);
|
|
2368
|
+
this.uploadListOnUserStorage();
|
|
2369
|
+
};
|
|
2370
|
+
// User chose to save its advanced form search criteria
|
|
2371
|
+
AdvancedTableSearchComponent.prototype.saveSearch = function (templateToLoad, newList) {
|
|
2372
|
+
if (newList === void 0) {
|
|
2373
|
+
newList = true;
|
|
2374
|
+
}
|
|
2375
|
+
if (this.table.config.model) {
|
|
2376
|
+
// Set the corresponding key to its list and show a confirmation modal window
|
|
2377
|
+
this.storageKey = "tables/" + this.table.config.model + "/searches";
|
|
2378
|
+
if (this.filter && Object.keys(this.filter).length) {
|
|
2379
|
+
// User wants to save an existing list from the dropdown
|
|
2380
|
+
if (!newList && this.selectedList) {
|
|
2381
|
+
var newItem = { 'name': this.selectedList.name, 'filter': __assign({}, this.filter) };
|
|
2382
|
+
this.updateSavedSearchListItemByObject(this.selectedList, newItem);
|
|
2383
|
+
this.uploadListOnUserStorage();
|
|
2384
|
+
// User wants to save a new list
|
|
2385
|
+
}
|
|
2386
|
+
else {
|
|
2387
|
+
this.modalRef = this._modalService.show(templateToLoad);
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
else {
|
|
2391
|
+
// User did not define any criteria
|
|
2392
|
+
this._modal.showWarningDialog(this._translate.instant('AdvancedSearch.Modal.Title'), this._translate.instant('AdvancedSearch.Modal.EmptyCriteriaList'), i2.DIALOG_BUTTONS.Ok);
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
else {
|
|
2396
|
+
this._modal.showWarningDialog(this._translate.instant('AdvancedSearch.Modal.Title'), this._translate.instant('AdvancedSearch.Modal.NoListDefined'), i2.DIALOG_BUTTONS.Ok);
|
|
2397
|
+
}
|
|
2398
|
+
};
|
|
2399
|
+
// User Accepted => Save list and Close modal
|
|
2400
|
+
AdvancedTableSearchComponent.prototype.confirmModal = function (saveFormName) {
|
|
2401
|
+
// name given and list name is unique
|
|
2402
|
+
if (saveFormName && !(this.searchInListByName(saveFormName))) {
|
|
2403
|
+
var newInsertedValue = { 'name': saveFormName, 'filter': __assign({}, this.filter) };
|
|
2404
|
+
if (this.userSearchList && this.userSearchList.length !== 0) {
|
|
2405
|
+
this.userSearchList.push(newInsertedValue);
|
|
2406
|
+
this.storageValue = this.userSearchList;
|
|
2407
|
+
this.selectedList = newInsertedValue;
|
|
2408
|
+
}
|
|
2409
|
+
else {
|
|
2410
|
+
this.storageValue = [newInsertedValue];
|
|
2411
|
+
this.userSearchList = this.storageValue;
|
|
2412
|
+
this.selectedList = newInsertedValue;
|
|
2413
|
+
}
|
|
2414
|
+
this.uploadListOnUserStorage();
|
|
2415
|
+
this.modalRef.hide();
|
|
2416
|
+
}
|
|
2417
|
+
else if (saveFormName && (this.searchInListByName(saveFormName))) {
|
|
2418
|
+
// User should insert a different name cause this one is already in use
|
|
2419
|
+
alert(this._translate.instant('AdvancedSearch.Modal.TitleOnListAlreadyCreated'));
|
|
2420
|
+
}
|
|
2421
|
+
else {
|
|
2422
|
+
// User did not insert any text
|
|
2423
|
+
alert(this._translate.instant('AdvancedSearch.Modal.TitleOnUserError'));
|
|
2424
|
+
}
|
|
2425
|
+
};
|
|
2426
|
+
// User declined => Close modal
|
|
2427
|
+
AdvancedTableSearchComponent.prototype.closeModal = function () {
|
|
2428
|
+
this.modalRef.hide();
|
|
2429
|
+
};
|
|
2430
|
+
// Upload user's criteria on User Storage
|
|
2431
|
+
AdvancedTableSearchComponent.prototype.uploadListOnUserStorage = function () {
|
|
2432
|
+
this._userStorage.setItem(this.storageKey, this.userSearchList.filter(function (x) {
|
|
2433
|
+
return !x.readOnly;
|
|
2434
|
+
}));
|
|
2435
|
+
};
|
|
2436
|
+
/**
|
|
2437
|
+
* @deprecated This method is going to be deprecated. Use search() method instead.
|
|
2438
|
+
* @param {*} event
|
|
2439
|
+
*/
|
|
2440
|
+
AdvancedTableSearchComponent.prototype.asyncAdvancedSearch = function (event) {
|
|
2441
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2442
|
+
var query, queryParams_3;
|
|
2443
|
+
return __generator(this, function (_a) {
|
|
2444
|
+
switch (_a.label) {
|
|
2445
|
+
case 0:
|
|
2446
|
+
if (!(this.table && this.table.config && Array.isArray(this.table.config.criteria)))
|
|
2447
|
+
return [3 /*break*/, 2];
|
|
2448
|
+
return [4 /*yield*/, this.getQuery()];
|
|
2449
|
+
case 1:
|
|
2450
|
+
query = _a.sent();
|
|
2451
|
+
if (this.mergeQueryParams) {
|
|
2452
|
+
this.selectedList = null;
|
|
2453
|
+
queryParams_3 = Object.assign({ q: null, s: null }, this.filter);
|
|
2454
|
+
// enumerate criteria
|
|
2455
|
+
this.table.config.criteria.forEach(function (item) {
|
|
2456
|
+
if (Object.prototype.hasOwnProperty.call(queryParams_3, item.name) === false) {
|
|
2457
|
+
// set null value
|
|
2458
|
+
Object.defineProperty(queryParams_3, item.name, {
|
|
2459
|
+
configurable: true,
|
|
2460
|
+
enumerable: true,
|
|
2461
|
+
writable: true,
|
|
2462
|
+
value: null
|
|
2463
|
+
});
|
|
2464
|
+
}
|
|
2465
|
+
});
|
|
2466
|
+
return [2 /*return*/, this._router.navigate([], {
|
|
2467
|
+
relativeTo: this._activatedRoute,
|
|
2468
|
+
queryParams: queryParams_3,
|
|
2469
|
+
queryParamsHandling: 'merge'
|
|
2470
|
+
})];
|
|
2471
|
+
}
|
|
2472
|
+
if (this.table.query) {
|
|
2473
|
+
this.table.query.setParam('$filter', query.getParams()['$filter']);
|
|
2474
|
+
}
|
|
2475
|
+
else {
|
|
2476
|
+
this.table.query = query;
|
|
2477
|
+
}
|
|
2478
|
+
this.table.fetch();
|
|
2479
|
+
_a.label = 2;
|
|
2480
|
+
case 2: return [2 /*return*/];
|
|
2481
|
+
}
|
|
2482
|
+
});
|
|
2483
|
+
});
|
|
2484
|
+
};
|
|
2485
|
+
AdvancedTableSearchComponent.prototype.search = function () {
|
|
2486
|
+
return this.asyncAdvancedSearch().then(function () {
|
|
2487
|
+
// do nothing
|
|
2488
|
+
});
|
|
2489
|
+
};
|
|
2490
|
+
AdvancedTableSearchComponent.prototype.getQuery = function () {
|
|
2491
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2492
|
+
var expressions_1, values_1, query;
|
|
2493
|
+
var _this = this;
|
|
2494
|
+
return __generator(this, function (_a) {
|
|
2495
|
+
switch (_a.label) {
|
|
2496
|
+
case 0:
|
|
2497
|
+
// on simple search return null
|
|
2498
|
+
if (this.collapsed) {
|
|
2499
|
+
return [2 /*return*/, null];
|
|
2500
|
+
}
|
|
2501
|
+
if (!(this.table && this.table.config && Array.isArray(this.table.config.criteria)))
|
|
2502
|
+
return [3 /*break*/, 2];
|
|
2503
|
+
expressions_1 = [];
|
|
2504
|
+
return [4 /*yield*/, this._advancedSearchValueProvider.getValues()];
|
|
2505
|
+
case 1:
|
|
2506
|
+
values_1 = _a.sent();
|
|
2507
|
+
this.table.config.criteria.forEach(function (x) {
|
|
2508
|
+
if (Object.prototype.hasOwnProperty.call(_this.filter, x.name)) {
|
|
2509
|
+
var nameFilter = _this.convertToString(_this.filter[x.name]);
|
|
2510
|
+
if (nameFilter.includes('GMT')) {
|
|
2511
|
+
var newDate = _this.transformDate(_this.filter[x.name]);
|
|
2512
|
+
expressions_1.push(_this._template.transform(x.filter, {
|
|
2513
|
+
value: newDate
|
|
2514
|
+
}));
|
|
2515
|
+
}
|
|
2516
|
+
else if (_this.filter[x.name] !== 'undefined') {
|
|
2517
|
+
expressions_1.push(_this._template.transform(x.filter, Object.assign({
|
|
2518
|
+
value: _this.filter[x.name]
|
|
2519
|
+
}, values_1)));
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
});
|
|
2523
|
+
query = void 0;
|
|
2524
|
+
if (expressions_1 || expressions_1.length) {
|
|
2525
|
+
// create client query
|
|
2526
|
+
query = this._context.model(this.table.config.model).asQueryable();
|
|
2527
|
+
query.setParam('filter', expressions_1.join(' and '));
|
|
2528
|
+
}
|
|
2529
|
+
else {
|
|
2530
|
+
query = this._context.model(this.table.config.model).asQueryable();
|
|
2531
|
+
}
|
|
2532
|
+
return [2 /*return*/, query];
|
|
2533
|
+
case 2: return [2 /*return*/];
|
|
2534
|
+
}
|
|
2535
|
+
});
|
|
2536
|
+
});
|
|
2537
|
+
};
|
|
2538
|
+
AdvancedTableSearchComponent.prototype.advancedSearch = function (event) {
|
|
2539
|
+
return this.asyncAdvancedSearch(event);
|
|
2540
|
+
};
|
|
2541
|
+
AdvancedTableSearchComponent.prototype.clear = function () {
|
|
2542
|
+
if (this.mergeQueryParams) {
|
|
2543
|
+
this.selectedList = null;
|
|
2544
|
+
var queryParams_4 = { q: null, s: null };
|
|
2545
|
+
// enumerate criteria
|
|
2546
|
+
this.table.config.criteria.forEach(function (item) {
|
|
2547
|
+
if (Object.prototype.hasOwnProperty.call(queryParams_4, item.name) === false) {
|
|
2548
|
+
// set null value
|
|
2549
|
+
Object.defineProperty(queryParams_4, item.name, {
|
|
2550
|
+
configurable: true,
|
|
2551
|
+
enumerable: true,
|
|
2552
|
+
writable: true,
|
|
2553
|
+
value: null
|
|
2554
|
+
});
|
|
2555
|
+
}
|
|
2556
|
+
});
|
|
2557
|
+
return this._router.navigate([], {
|
|
2558
|
+
relativeTo: this._activatedRoute,
|
|
2559
|
+
queryParams: queryParams_4,
|
|
2560
|
+
queryParamsHandling: 'merge'
|
|
2561
|
+
});
|
|
2562
|
+
}
|
|
2563
|
+
else {
|
|
2564
|
+
// clear filter
|
|
2565
|
+
this.filter = {};
|
|
2566
|
+
// clear list
|
|
2567
|
+
this.selectedList = null;
|
|
2568
|
+
// raise filter change event
|
|
2569
|
+
this.filterChange.emit(this.filter);
|
|
2570
|
+
}
|
|
2571
|
+
};
|
|
2572
|
+
Object.defineProperty(AdvancedTableSearchComponent.prototype, "viewState", {
|
|
2573
|
+
/**
|
|
2574
|
+
* Gets the view state of search control
|
|
2575
|
+
*/
|
|
2576
|
+
get: function () {
|
|
2577
|
+
return {
|
|
2578
|
+
advancedView: !this.collapsed
|
|
2579
|
+
};
|
|
2580
|
+
},
|
|
2581
|
+
enumerable: true,
|
|
2582
|
+
configurable: true
|
|
2583
|
+
});
|
|
2584
|
+
/**
|
|
2585
|
+
* Switches view between simple and advanced search
|
|
2586
|
+
*/
|
|
2587
|
+
AdvancedTableSearchComponent.prototype.toggleView = function () {
|
|
2588
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2589
|
+
return __generator(this, function (_a) {
|
|
2590
|
+
this.collapsed = !this.collapsed;
|
|
2591
|
+
// emit event for view status change
|
|
2592
|
+
this.viewChange.emit(this.viewState);
|
|
2593
|
+
return [2 /*return*/];
|
|
2594
|
+
});
|
|
2595
|
+
});
|
|
2596
|
+
};
|
|
2597
|
+
AdvancedTableSearchComponent.decorators = [
|
|
2598
|
+
{ type: i0.Component, args: [{
|
|
2599
|
+
selector: 'app-advanced-table-search',
|
|
2600
|
+
template: "<div class=\"s--list-navbar d-none d-sm-block\">\n\n <div id=\"collapse-header\" [ngClass]=\"{'show':collapsed}\" class=\"collapse multi-collapse\">\n <form class=\"form-inline p-3 col\">\n <div class=\"form-group col-7\" [ngClass]= \"{ 'col-12': !showMore }\">\n <label class=\"pr-3\" for=\"searchText\" [translate]=\"'Tables.Search'\"></label>\n <input (keydown)=\"onSearchKeyDown($event)\" spellcheck=\"false\" type=\"text\" id=\"searchText\" name=\"searchText\"\n class=\"form-control col text-left\" placeholder=\"{{ 'Tables.SearchPlaceholder' | translate }}\" #searchText>\n </div>\n <div *ngIf=\"showMore\" class=\"col-5 text-right text-secondary\" id=\"heading3\">\n <button class=\"d-inline-block btn btn-link collapsed float-right text-secondary text-decoration-none\"\n type=\"button\" (click)=\"toggleView();\">\n <span class=\"d-none d-sm-inline\" [translate]=\"'AdvancedSearch.More'\"></span>\n <i class=\"ml-2 pt-1 fa fa-chevron-down\"></i>\n </button>\n </div>\n </form>\n </div>\n\n <div id=\"collapse3\" [ngClass]=\"{'show':!collapsed}\" class=\"collapse multi-collapse\" aria-labelledby=\"heading3\">\n <div class=\"row\">\n <div class=\"col-sm-12\">\n <div id=\"advanced-form\">\n <ng-content select=\"advanced-search\"></ng-content>\n <hr class=\"mt-0 mb-0\" width=\"97%\">\n <div class=\"row\">\n <div class=\"col-sm-12\">\n <div class=\"form-inline pb-3 pt-3 pr-1 pl-1 col\">\n\n <div class=\"form-group col-4\">\n <div class=\"d-flex flex-row w-100\" *ngIf=\"allowSave\">\n <label class=\"pr-3 d-none\" [translate]=\"'AdvancedSearch.SavedSearches'\"></label>\n <select *ngIf=\"userSearchList\" class=\"custom-select text-secondary flex col-12\" (change)=\"onSelectUserSearch($event)\" [(ngModel)]=\"selectedList\">\n <option [ngValue]=\"null\" [translate]=\"'AdvancedSearch.Choose'\"></option>\n <option *ngFor=\"let item of userSearchList\" [ngValue]=\"item\">{{ item.name }}</option>\n </select>\n <select *ngIf=\"!userSearchList\" class=\"custom-select flex col-6\">\n <option [value]=\"null\" [translate]=\"'AdvancedSearch.Choose'\"></option>\n </select>\n </div>\n </div>\n\n <div class=\"col-3 d-flex flex-row w-100\">\n <div class=\"btn-group\" *ngIf=\"allowSave\" dropdown>\n <button type=\"button\" class=\"btn btn-sm btn-primary\" (click)=\"saveSearch(templateToUse, ( (selectedList && selectedList.readOnly) ? true : false ) )\" [translate]=\"'AdvancedSearch.SaveCurrentSearch'\"></button>\n <button type=\"button\" dropdownToggle class=\"btn btn-sm btn-primary dropdown-toggle dropdown-toggle-split\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\">\n <span class=\"sr-only\" [translate]=\"'AdvancedSearch.ToggleDropdown'\"></span>\n </button>\n\n <div class=\"dropdown-menu\" *dropdownMenu>\n <a [ngClass]=\"{'disabled': selectedList && selectedList.readOnly}\" class=\"dropdown-item\" (click)=\"saveSearch(templateToUse, false)\" [translate]=\"'AdvancedSearch.Save'\" href=\"javascript:void(0)\"></a>\n <a class=\"dropdown-item\" (click)=\"saveSearch(templateToUse)\" [translate]=\"'AdvancedSearch.SaveAs'\" href=\"javascript:void(0)\"></a>\n <div class=\"dropdown-divider\"></div>\n <a [ngClass]=\"{'disabled': selectedList && selectedList.readOnly}\" class=\"dropdown-item\" (click)=\"deleteItemFromSavedSearchListByObject(selectedList)\" [translate]=\"'AdvancedSearch.Delete'\" href=\"javascript:void(0)\"></a>\n </div>\n </div>\n </div>\n\n <div class=\"col-5 text-right text-secondary\">\n <button type=\"button\" class=\"btn btn-light text-secondary pl-2 pr-2 mr-2\" (click)=\"clear()\">\n <i class=\"fa fa-eraser\"></i>\n </button>\n <button type=\"button\" class=\"btn btn-success pl-4 pr-4 mr-2\" (click)=\"advancedSearch($event);\"\n [translate]=\"'Tables.Search'\"></button>\n <button class=\"d-inline-block btn btn-link collapsed float-right text-secondary text-decoration-none\"\n type=\"button\" (click)=\"toggleView();\">\n <span class=\"d-none d-sm-inline\" [translate]=\"'AdvancedSearch.Less'\"></span>\n <i class=\"ml-2 pt-1 fa fa-chevron-up\"></i>\n </button>\n </div>\n\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n\n <ng-template #templateToUse>\n <div class=\"modal-header\">\n <h4 class=\"modal-title pull-left\" [translate]=\"'AdvancedSearch.Modal.Title'\"></h4>\n <button type=\"button\" class=\"close pull-right\" aria-label=\"Close\" (click)=\"modalRef.hide()\">\n <span aria-hidden=\"true\">×</span>\n </button>\n </div>\n <div class=\"modal-body mt-0 mb-0 text-center\">\n <div>\n <p class=\"text-secondary text-left\" [translate]=\"'AdvancedSearch.Modal.Help'\"></p>\n </div>\n <form class=\"p-3 text-center\" #newListForm=\"ngForm\" >\n <div [ngVar]=\"{ name: ( selectedList?.name ? ( selectedList?.name + ' (1)' ) : null ) }\" #model=\"ngVar\">\n <input [(ngModel)]=\"model.value.name\" [required]=\"true\" id=\"newListName\" name=\"newListName\" type=\"text\" class=\"form-control\" placeholder=\"{{ 'AdvancedSearch.Modal.SaveNamePlaceholder' | translate }}\"/>\n <div class=\"btn-group mt-4\">\n <button [disabled]=\"newListForm.invalid\" type=\"button\" class=\"btn btn-primary\" (click)=\"confirmModal(model.value.name)\" [translate]=\"'AdvancedSearch.Modal.Accept'\"></button>\n <button type=\"button\" class=\"btn btn-gray-300 text-white\" (click)=\"closeModal()\" [translate]=\"'AdvancedSearch.Modal.Close'\"></button>\n </div>\n </div>\n </form>\n </div>\n </ng-template>\n\n</div>\n",
|
|
2601
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
2602
|
+
}] }
|
|
2603
|
+
];
|
|
2604
|
+
/** @nocollapse */
|
|
2605
|
+
AdvancedTableSearchComponent.ctorParameters = function () {
|
|
2606
|
+
return [
|
|
2607
|
+
{ type: i1$1.AngularDataContext },
|
|
2608
|
+
{ type: i1.ActivatedRoute },
|
|
2609
|
+
{ type: common.DatePipe },
|
|
2610
|
+
{ type: modal.BsModalService },
|
|
2611
|
+
{ type: i2.UserStorageService },
|
|
2612
|
+
{ type: core.TranslateService },
|
|
2613
|
+
{ type: AdvancedFilterValueProvider },
|
|
2614
|
+
{ type: i2.TemplatePipe },
|
|
2615
|
+
{ type: i1.Router },
|
|
2616
|
+
{ type: i2.ModalService }
|
|
2617
|
+
];
|
|
2618
|
+
};
|
|
2619
|
+
AdvancedTableSearchComponent.propDecorators = {
|
|
2620
|
+
table: [{ type: i0.Input }],
|
|
2621
|
+
collapsed: [{ type: i0.Input }],
|
|
2622
|
+
allowSave: [{ type: i0.Input }],
|
|
2623
|
+
showMore: [{ type: i0.Input }],
|
|
2624
|
+
mergeQueryParams: [{ type: i0.Input }],
|
|
2625
|
+
searchText: [{ type: i0.ViewChild, args: ['searchText',] }],
|
|
2626
|
+
viewChange: [{ type: i0.Output, args: ['viewChange',] }]
|
|
2627
|
+
};
|
|
2628
|
+
return AdvancedTableSearchComponent;
|
|
2629
|
+
}(AdvancedTableSearchBaseComponent));
|
|
2630
|
+
|
|
2631
|
+
var FORMATTERS = {
|
|
2632
|
+
ActionLinkFormatter: new ActionLinkFormatter(),
|
|
2633
|
+
ButtonFormatter: new ButtonFormatter(),
|
|
2634
|
+
DateTimeFormatter: new DateTimeFormatter(),
|
|
2635
|
+
LanguageFormatter: new LanguageFormatter(),
|
|
2636
|
+
LinkFormatter: new LinkFormatter(),
|
|
2637
|
+
NestedPropertyFormatter: new NestedPropertyFormatter(),
|
|
2638
|
+
NgClassFormatter: new NgClassFormatter(),
|
|
2639
|
+
SelectRowFormatter: new SelectRowFormatter(),
|
|
2640
|
+
TemplateFormatter: new TemplateFormatter(),
|
|
2641
|
+
TranslationFormatter: new TranslationFormatter(),
|
|
2642
|
+
TrueFalseFormatter: new TrueFalseFormatter()
|
|
2643
|
+
};
|
|
2644
|
+
|
|
2645
|
+
// important: export this const due to AOT compilation errors
|
|
2646
|
+
// see more https://angular.io/guide/aot-metadata-errors#only-initialized-variables
|
|
2647
|
+
var AdvancedTableModalBaseTemplate = "\n<div>\n <!-- search -->\n <div class=\"row mt-3\">\n <div class=\"col-12 col-lg-3\">\n <div class=\"input-group mb-3\">\n <input spellcheck=\"false\" type=\"text\"\n (keyup)=\"onKeyUp($event)\" [(ngModel)]=\"searchText\"\n class=\"form-control bg-gray-100 border-0\"\n placeholder=\"{{'Tables.SearchPlaceholder' | translate}}\" aria-label=\"Search\" aria-describedby=\"basic-addon2\">\n <div class=\"input-group-append\">\n <button class=\"btn btn-default bg-gray-100 border-0\" type=\"button\">\n <i class=\"fa fa-search text-secondary\"></i>\n </button>\n </div>\n </div>\n </div>\n <div #emptyTable class=\"d-none\">\n <div>\n <div class=\"mt-4\">\n <div class=\"icon-circle bg-gray-300 border-gray-100\"></div>\n </div>\n <div class=\"mt-4\">\n <h4 class=\"font-3xl text-dark\" [translate]=\"'Tables.EmptyTableTitle'\"></h4>\n <p class=\"font-lg text-dark\" [translate]=\"'Tables.EmptyTableMessage'\"></p>\n </div>\n\n </div>\n </div>\n <div class=\"col-12 col-lg-5\">\n <div class=\"btn-toolbar\">\n <button class=\"btn btn-gray-100\">\n <i class=\"fa fa-sliders-h pr-2 text-secondary\" aria-hidden=\"true\"></i>{{'Tables.Filters' | translate}}\n </button>\n <div #dropdownFilter class=\"dropdown ml-3\" dropdown>\n <button class=\"btn btn-gray-100 dropdown-toggle\"\n type=\"button\" id=\"dropdownDefaultFilters\"\n data-toggle=\"dropdown\" dropdownToggle>\n {{ this.defaultFilter.name | translate }}\n </button>\n <div class=\"dropdown-menu\" aria-labelledby=\"dropdownDefaultFilters\" *dropdownMenu>\n <a class=\"dropdown-item\" *ngFor=\"let filter of defaultFilters\" (click)=\"advancedSearch(filter.filter ? filter : '')\">\n {{ filter.name | translate }}\n </a>\n </div>\n </div>\n </div>\n </div>\n <div class=\"col text-lg-right mt-3 mt-lg-0\">\n <button [disabled]=\"true\" class=\"btn rounded-pill btn-outline-theme\">\n <span class=\"pr-2 font-lg\">+</span><span [translate]=\"'Tables.AddItem'\"></span>\n </button>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-12\" [ngClass]=\"{ 'component-loading': loading}\">\n <app-advanced-table #advancedTable (init)=\"onTableInit($event)\"\n (load)=\"onDataLoad($event)\"\n [selectable]=\"true\"\n [multipleSelect]=\"true\"\n [scrollX]=\"false\" [scrollY]=\"320\"\n [pageLength]=\"pageLength\"\n [scrollable]=\"false\" [showFooter]=\"false\"\n [showActions]=\"false\" [lengthMenu]=\"lengthMenu\"\n [config]=\"tableConfig\" [configSrc]=\"tableConfigSrc\"></app-advanced-table>\n </div>\n </div>\n <div class=\"row mt-3 table-custom-pager\">\n <div class=\"col-12 d-flex\" *ngIf=\"recordsTotal\">\n <div class=\"mt-2 ml-auto mr-3 text-secondary\" [translate]=\"'Tables.RecordsPerPage'\"></div>\n <div #dropdownLength class=\"dropdown mr-3\" dropdown>\n <button class=\"btn btn-gray-100 dropdown-toggle\"\n type=\"button\" id=\"dropdownPageSize\" data-toggle=\"dropdown\"\n dropdownToggle>\n {{pageLength}}\n </button>\n <div class=\"dropdown-menu\" aria-labelledby=\"dropdownPageSize\" *dropdownMenu>\n <button (click)=\"setLength(item)\"\n class=\"dropdown-item dropdown-item-theme\"\n type=\"button\" *ngFor=\"let item of lengthMenu\">{{item}}</button>\n </div>\n </div>\n <div class=\"mt-2 mr-2\" [translate]=\"'Tables.PageInfo'\" [translateParams]=\"pageInfo\"></div>\n <button [disabled]=\"pageInfo && pageInfo.page === 0\" class=\"btn text-nowrap\" (click)=\"firstPage()\">\n <i class=\"fa fa-chevron-left text-color-theme\"></i>\n <i class=\"fa fa-chevron-left text-color-theme\"></i>\n </button>\n <button [disabled]=\"pageInfo && pageInfo.page===0\" class=\"btn\" (click)=\"previousPage()\">\n <i class=\"fa fa-chevron-left text-color-theme\"></i>\n </button>\n <button [disabled]=\"pageInfo && pageInfo.page===pageInfo.pages-1\" class=\"btn\" (click)=\"nextPage()\">\n <i class=\"fa fa-chevron-right text-color-theme\"></i>\n </button>\n <button [disabled]=\"pageInfo && pageInfo.page===pageInfo.pages-1\" class=\"btn text-nowrap\" (click)=\"lastPage()\">\n <i class=\"fa fa-chevron-right text-color-theme\"></i>\n <i class=\"fa fa-chevron-right text-color-theme\"></i>\n </button>\n </div>\n </div>\n </div>\n";
|
|
2648
|
+
var AdvancedTableModalBaseComponent = /** @class */ (function (_super) {
|
|
2649
|
+
__extends(AdvancedTableModalBaseComponent, _super);
|
|
2650
|
+
function AdvancedTableModalBaseComponent(_router, _activatedRoute, _context, advancedFilterValueProvider, datePipe) {
|
|
2651
|
+
var _this = _super.call(this, _router, _activatedRoute) || this;
|
|
2652
|
+
_this._context = _context;
|
|
2653
|
+
_this.advancedFilterValueProvider = advancedFilterValueProvider;
|
|
2654
|
+
_this.datePipe = datePipe;
|
|
2655
|
+
_this.pageLength = 25;
|
|
2656
|
+
_this.lengthMenu = [5, 10, 25, 50, 100];
|
|
2657
|
+
_this.recordsTotal = 0;
|
|
2658
|
+
_this.loading = false;
|
|
2659
|
+
_this.recordsFiltered = 0;
|
|
2660
|
+
_this.defaultFilters = [AdvancedTableModalBaseComponent.DEFAULT_ALL_FILTER];
|
|
2661
|
+
_this.defaultFilter = AdvancedTableModalBaseComponent.DEFAULT_ALL_FILTER;
|
|
2662
|
+
_this.pageInfo = {
|
|
2663
|
+
serverSide: true
|
|
2664
|
+
};
|
|
2665
|
+
_this.modalClass = 'modal-xl modal-table';
|
|
2666
|
+
_this._template = new i2.TemplatePipe();
|
|
2667
|
+
return _this;
|
|
2668
|
+
}
|
|
2669
|
+
AdvancedTableModalBaseComponent.prototype.ngAfterViewInit = function () {
|
|
2670
|
+
//
|
|
2671
|
+
};
|
|
2672
|
+
AdvancedTableModalBaseComponent.prototype._getInputs = function (componentType) {
|
|
2673
|
+
var props = componentType.__prop__metadata__;
|
|
2674
|
+
var inputs = [];
|
|
2675
|
+
if (props == null) {
|
|
2676
|
+
return inputs;
|
|
2677
|
+
}
|
|
2678
|
+
Object.keys(props).forEach(function (prop) {
|
|
2679
|
+
var member = props[prop][0];
|
|
2680
|
+
if (member.ngMetadataName === 'Input') {
|
|
2681
|
+
inputs.push(prop);
|
|
2682
|
+
}
|
|
2683
|
+
});
|
|
2684
|
+
return inputs.sort();
|
|
2685
|
+
};
|
|
2686
|
+
AdvancedTableModalBaseComponent.prototype.hasInputs = function () {
|
|
2687
|
+
return [];
|
|
2688
|
+
};
|
|
2689
|
+
AdvancedTableModalBaseComponent.prototype.ngOnInit = function () {
|
|
2690
|
+
var _this = this;
|
|
2691
|
+
this.okButtonText = 'Tables.Apply';
|
|
2692
|
+
this.cancelButtonText = 'Tables.Cancel';
|
|
2693
|
+
// get route data
|
|
2694
|
+
this.subscription = this.activatedRoute.data.subscribe(function (data) {
|
|
2695
|
+
// set modal title if any
|
|
2696
|
+
if (data.title) {
|
|
2697
|
+
_this.modalTitle = data.title;
|
|
2698
|
+
}
|
|
2699
|
+
if (data.config) {
|
|
2700
|
+
_this.tableConfig = data.config;
|
|
2701
|
+
}
|
|
2702
|
+
if (_this.tableConfig) {
|
|
2703
|
+
_this.defaultFilters.push.apply(_this.defaultFilters, _this.tableConfig.searches);
|
|
2704
|
+
}
|
|
2705
|
+
// important: use hasInputs due to AOT compilation. Metadata properties cannot be used (e.g. @Input())
|
|
2706
|
+
// because there are empty during runtime
|
|
2707
|
+
// so we need to define manually input properties that are going to be bind through this process
|
|
2708
|
+
// bind all inputs
|
|
2709
|
+
var inputs = _this.hasInputs();
|
|
2710
|
+
inputs.forEach(function (input) {
|
|
2711
|
+
if (Object.prototype.hasOwnProperty.call(data, input)) {
|
|
2712
|
+
_this[input] = data[input];
|
|
2713
|
+
}
|
|
2714
|
+
});
|
|
2715
|
+
_this.configChangesSubscription = _this.advancedTable.configChanges.subscribe(function (config) {
|
|
2716
|
+
if (_this.tableConfig) {
|
|
2717
|
+
// reset default filter
|
|
2718
|
+
_this.defaultFilter = AdvancedTableModalBaseComponent.DEFAULT_ALL_FILTER;
|
|
2719
|
+
// init filter
|
|
2720
|
+
_this.defaultFilters = [AdvancedTableModalBaseComponent.DEFAULT_ALL_FILTER];
|
|
2721
|
+
// add extra filters
|
|
2722
|
+
_this.defaultFilters.push.apply(_this.defaultFilters, _this.tableConfig.searches);
|
|
2723
|
+
}
|
|
2724
|
+
});
|
|
2725
|
+
});
|
|
2726
|
+
};
|
|
2727
|
+
AdvancedTableModalBaseComponent.prototype.cancel = function () {
|
|
2728
|
+
return this.close();
|
|
2729
|
+
};
|
|
2730
|
+
AdvancedTableModalBaseComponent.prototype.ok = function () {
|
|
2731
|
+
return this.close();
|
|
2732
|
+
};
|
|
2733
|
+
AdvancedTableModalBaseComponent.prototype.ngOnDestroy = function () {
|
|
2734
|
+
if (this.subscription) {
|
|
2735
|
+
this.subscription.unsubscribe();
|
|
2736
|
+
}
|
|
2737
|
+
};
|
|
2738
|
+
AdvancedTableModalBaseComponent.prototype.onDataLoad = function (data) {
|
|
2739
|
+
this.recordsTotal = data.recordsTotal;
|
|
2740
|
+
this.recordsFiltered = data.recordsFiltered;
|
|
2741
|
+
// get first page info (because page is not going to be fired for first page)
|
|
2742
|
+
if (data.recordsTotal > 0 && this.pageInfo.recordsTotal === 0) {
|
|
2743
|
+
this.pageInfo.recordsTotal = data.recordsTotal;
|
|
2744
|
+
}
|
|
2745
|
+
};
|
|
2746
|
+
AdvancedTableModalBaseComponent.prototype.previousPage = function () {
|
|
2747
|
+
// go to next page
|
|
2748
|
+
// noinspection TypeScriptValidateJSTypes
|
|
2749
|
+
this.advancedTable.dataTable.page('previous').draw('page');
|
|
2750
|
+
};
|
|
2751
|
+
AdvancedTableModalBaseComponent.prototype.nextPage = function () {
|
|
2752
|
+
// go to next page
|
|
2753
|
+
// noinspection TypeScriptValidateJSTypes
|
|
2754
|
+
this.advancedTable.dataTable.page('next').draw('page');
|
|
2755
|
+
};
|
|
2756
|
+
AdvancedTableModalBaseComponent.prototype.onTableInit = function (dataTable) {
|
|
2757
|
+
var self = this;
|
|
2758
|
+
// get initial page info
|
|
2759
|
+
var initialPageInfo = dataTable.page.info();
|
|
2760
|
+
initialPageInfo.start += 1;
|
|
2761
|
+
self.pageInfo = initialPageInfo;
|
|
2762
|
+
// change emptyTableMessage
|
|
2763
|
+
dataTable.context[0].oLanguage.sEmptyTable = this.emptyTable.nativeElement.innerHTML;
|
|
2764
|
+
// bind page change event
|
|
2765
|
+
dataTable.on('page.dt', function () {
|
|
2766
|
+
var pageInfo = dataTable.page.info();
|
|
2767
|
+
pageInfo.start += 1;
|
|
2768
|
+
self.pageInfo = pageInfo;
|
|
2769
|
+
});
|
|
2770
|
+
// bind draw change event
|
|
2771
|
+
dataTable.on('draw.dt', function () {
|
|
2772
|
+
// for future use
|
|
2773
|
+
self.loading = false;
|
|
2774
|
+
var pageInfo = dataTable.page.info();
|
|
2775
|
+
pageInfo.start += 1;
|
|
2776
|
+
self.pageInfo = pageInfo;
|
|
2777
|
+
});
|
|
2778
|
+
};
|
|
2779
|
+
AdvancedTableModalBaseComponent.prototype.firstPage = function () {
|
|
2780
|
+
// go to first page
|
|
2781
|
+
// noinspection TypeScriptValidateJSTypes
|
|
2782
|
+
this.advancedTable.dataTable.page('first').draw('page');
|
|
2783
|
+
};
|
|
2784
|
+
AdvancedTableModalBaseComponent.prototype.lastPage = function () {
|
|
2785
|
+
// go to last page
|
|
2786
|
+
// noinspection TypeScriptValidateJSTypes
|
|
2787
|
+
this.advancedTable.dataTable.page('last').draw('page');
|
|
2788
|
+
};
|
|
2789
|
+
AdvancedTableModalBaseComponent.prototype.setLength = function (value) {
|
|
2790
|
+
this.pageLength = value;
|
|
2791
|
+
this.advancedTable.dataTable.page.len(value).draw();
|
|
2792
|
+
};
|
|
2793
|
+
AdvancedTableModalBaseComponent.prototype.onKeyUp = function (event) {
|
|
2794
|
+
if (event.code === 'Enter') {
|
|
2795
|
+
// loading
|
|
2796
|
+
this.loading = true;
|
|
2797
|
+
this.advancedTable.search(event.target.value);
|
|
2798
|
+
}
|
|
2799
|
+
};
|
|
2800
|
+
/**
|
|
2801
|
+
*
|
|
2802
|
+
* Reads the modal table and returns a list of filters to use in the table
|
|
2803
|
+
* query.
|
|
2804
|
+
*
|
|
2805
|
+
* @param tableConfig {object} The table configuration from json file
|
|
2806
|
+
* @param defaultFilterValues {object} A list of default filters
|
|
2807
|
+
* @param {object} searchItem The searchItem to use
|
|
2808
|
+
*
|
|
2809
|
+
*/
|
|
2810
|
+
AdvancedTableModalBaseComponent.prototype.getFilters = function (tableConfig, defaultFilterValues, searchItem) {
|
|
2811
|
+
if (defaultFilterValues === void 0) {
|
|
2812
|
+
defaultFilterValues = {};
|
|
2813
|
+
}
|
|
2814
|
+
// Do nothing in absence of configuration.
|
|
2815
|
+
if (!tableConfig || !Array.isArray(tableConfig.criteria)) {
|
|
2816
|
+
console.warn('No table configuration available', this.tableConfig);
|
|
2817
|
+
return [];
|
|
2818
|
+
}
|
|
2819
|
+
var matchedCriterion = tableConfig.criteria.find(function (criterion) {
|
|
2820
|
+
return Object.prototype.hasOwnProperty.call(searchItem.filter, criterion.name);
|
|
2821
|
+
});
|
|
2822
|
+
if (!matchedCriterion) {
|
|
2823
|
+
return [];
|
|
2824
|
+
}
|
|
2825
|
+
var criterionSafeName = matchedCriterion.name !== null
|
|
2826
|
+
? matchedCriterion.name.toString()
|
|
2827
|
+
: '';
|
|
2828
|
+
var applicableFilter;
|
|
2829
|
+
// Raw dates should be transformed to a specific format
|
|
2830
|
+
if (criterionSafeName.includes('GMT')) {
|
|
2831
|
+
var newDate = this.datePipe.transform(criterionSafeName, 'MM/dd/yyyy');
|
|
2832
|
+
applicableFilter = this._template.transform(matchedCriterion.filter, {
|
|
2833
|
+
value: newDate
|
|
2834
|
+
});
|
|
2835
|
+
}
|
|
2836
|
+
else if (criterionSafeName !== 'undefined') {
|
|
2837
|
+
applicableFilter = (this._template.transform(matchedCriterion.filter, Object.assign({
|
|
2838
|
+
value: matchedCriterion.filter
|
|
2839
|
+
}, defaultFilterValues)));
|
|
2840
|
+
}
|
|
2841
|
+
else {
|
|
2842
|
+
applicableFilter = '';
|
|
2843
|
+
}
|
|
2844
|
+
return [applicableFilter];
|
|
2845
|
+
};
|
|
2846
|
+
/**
|
|
2847
|
+
*
|
|
2848
|
+
* Runs a filter against the modal table
|
|
2849
|
+
*
|
|
2850
|
+
* @param {object} filter The filter to use in the search
|
|
2851
|
+
*
|
|
2852
|
+
*/
|
|
2853
|
+
AdvancedTableModalBaseComponent.prototype.advancedSearch = function (filter) {
|
|
2854
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2855
|
+
var defaultFilterValues, err_1, expressions, predefinedCriteria, query;
|
|
2856
|
+
return __generator(this, function (_a) {
|
|
2857
|
+
switch (_a.label) {
|
|
2858
|
+
case 0:
|
|
2859
|
+
// Do nothing in absence of configuration.
|
|
2860
|
+
if (!this.tableConfig && !Array.isArray(this.tableConfig.criteria)) {
|
|
2861
|
+
console.warn('No table configuration available', this.tableConfig);
|
|
2862
|
+
return [2 /*return*/];
|
|
2863
|
+
}
|
|
2864
|
+
_a.label = 1;
|
|
2865
|
+
case 1:
|
|
2866
|
+
_a.trys.push([1, 3, , 4]);
|
|
2867
|
+
return [4 /*yield*/, this.advancedFilterValueProvider.getValues()];
|
|
2868
|
+
case 2:
|
|
2869
|
+
defaultFilterValues = _a.sent();
|
|
2870
|
+
return [3 /*break*/, 4];
|
|
2871
|
+
case 3:
|
|
2872
|
+
err_1 = _a.sent();
|
|
2873
|
+
defaultFilterValues = {};
|
|
2874
|
+
return [3 /*break*/, 4];
|
|
2875
|
+
case 4:
|
|
2876
|
+
expressions = [];
|
|
2877
|
+
if (filter) {
|
|
2878
|
+
this.defaultFilter = filter;
|
|
2879
|
+
predefinedCriteria = this.getFilters(this.tableConfig, defaultFilterValues, filter);
|
|
2880
|
+
}
|
|
2881
|
+
else {
|
|
2882
|
+
// Empty a falsy filter resets the results
|
|
2883
|
+
this.defaultFilter = AdvancedTableModalBaseComponent.DEFAULT_ALL_FILTER;
|
|
2884
|
+
}
|
|
2885
|
+
// search filter is applied separately, there is no need to add here.
|
|
2886
|
+
expressions.push(predefinedCriteria);
|
|
2887
|
+
query = this._context.model(this.advancedTable.config.model).asQueryable();
|
|
2888
|
+
query.setParam('filter', expressions.join(' and ')).prepare();
|
|
2889
|
+
this.advancedTable.query = query;
|
|
2890
|
+
this.advancedTable.fetch();
|
|
2891
|
+
return [2 /*return*/];
|
|
2892
|
+
}
|
|
2893
|
+
});
|
|
2894
|
+
});
|
|
2895
|
+
};
|
|
2896
|
+
AdvancedTableModalBaseComponent.DEFAULT_ALL_FILTER = {
|
|
2897
|
+
name: 'Tables.All',
|
|
2898
|
+
filter: null
|
|
2899
|
+
};
|
|
2900
|
+
AdvancedTableModalBaseComponent.decorators = [
|
|
2901
|
+
{ type: i0.Component, args: [{
|
|
2902
|
+
selector: 'app-advanced-table-modal',
|
|
2903
|
+
template: AdvancedTableModalBaseTemplate,
|
|
2904
|
+
styles: ["\n\n "]
|
|
2905
|
+
}] }
|
|
2906
|
+
];
|
|
2907
|
+
/** @nocollapse */
|
|
2908
|
+
AdvancedTableModalBaseComponent.ctorParameters = function () {
|
|
2909
|
+
return [
|
|
2910
|
+
{ type: i1.Router },
|
|
2911
|
+
{ type: i1.ActivatedRoute },
|
|
2912
|
+
{ type: i1$1.AngularDataContext },
|
|
2913
|
+
{ type: AdvancedFilterValueProvider },
|
|
2914
|
+
{ type: common.DatePipe }
|
|
2915
|
+
];
|
|
2916
|
+
};
|
|
2917
|
+
AdvancedTableModalBaseComponent.propDecorators = {
|
|
2918
|
+
advancedTable: [{ type: i0.ViewChild, args: ['advancedTable',] }],
|
|
2919
|
+
emptyTable: [{ type: i0.ViewChild, args: ['emptyTable',] }],
|
|
2920
|
+
dropdownFilter: [{ type: i0.ViewChild, args: ['dropdownFilter',] }],
|
|
2921
|
+
dropdownLength: [{ type: i0.ViewChild, args: ['dropdownLength',] }],
|
|
2922
|
+
tableConfig: [{ type: i0.Input, args: ['tableConfig',] }],
|
|
2923
|
+
tableConfigSrc: [{ type: i0.Input, args: ['tableConfigSrc',] }],
|
|
2924
|
+
pageLength: [{ type: i0.Input, args: ['pageLength',] }],
|
|
2925
|
+
searchText: [{ type: i0.Input, args: ['searchText',] }],
|
|
2926
|
+
lengthMenu: [{ type: i0.Input, args: ['lengthMenu',] }],
|
|
2927
|
+
defaultFilter: [{ type: i0.Input, args: ['defaultFilter',] }]
|
|
2928
|
+
};
|
|
2929
|
+
return AdvancedTableModalBaseComponent;
|
|
2930
|
+
}(routing.RouterModalOkCancel));
|
|
2931
|
+
|
|
2932
|
+
var AdvancedSelectComponent = /** @class */ (function (_super) {
|
|
2933
|
+
__extends(AdvancedSelectComponent, _super);
|
|
2934
|
+
function AdvancedSelectComponent(router, activatedRoute, context, advancedFilterValueProvider, datePipe, _modalRef) {
|
|
2935
|
+
var _this = _super.call(this, router, activatedRoute, context, advancedFilterValueProvider, datePipe) || this;
|
|
2936
|
+
_this._modalRef = _modalRef;
|
|
2937
|
+
_this.dismiss = new i0.EventEmitter();
|
|
2938
|
+
return _this;
|
|
2939
|
+
}
|
|
2940
|
+
AdvancedSelectComponent.prototype.ok = function () {
|
|
2941
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2942
|
+
return __generator(this, function (_a) {
|
|
2943
|
+
this._modalRef.hide();
|
|
2944
|
+
this.dismiss.emit('ok');
|
|
2945
|
+
return [2 /*return*/];
|
|
2946
|
+
});
|
|
2947
|
+
});
|
|
2948
|
+
};
|
|
2949
|
+
AdvancedSelectComponent.prototype.cancel = function () {
|
|
2950
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2951
|
+
return __generator(this, function (_a) {
|
|
2952
|
+
this._modalRef.hide();
|
|
2953
|
+
this.dismiss.emit('cancel');
|
|
2954
|
+
return [2 /*return*/];
|
|
2955
|
+
});
|
|
2956
|
+
});
|
|
2957
|
+
};
|
|
2958
|
+
AdvancedSelectComponent.decorators = [
|
|
2959
|
+
{ type: i0.Component, args: [{
|
|
2960
|
+
selector: 'app-advanced-select',
|
|
2961
|
+
template: "<div class=\"modal-header\" *ngIf=\"modalTitle\">\n <h5 class=\"modal-title\">{{modalTitle | translate}}</h5>\n <button [disabled]=\"cancelButtonDisabled\" (click)=\"cancel()\" type=\"button\" class=\"close\" data-dismiss=\"modal\"\n aria-label=\"Cancel\">\n <span aria-hidden=\"true\">×</span>\n </button>\n</div>\n<div class=\"modal-body\">\n <div>\n <!-- search -->\n <div class=\"row mt-3\">\n <div class=\"col-12 col-lg-3\">\n <div class=\"input-group mb-3\">\n <input spellcheck=\"false\" type=\"text\" (keyup)=\"onKeyUp($event)\" [(ngModel)]=\"searchText\"\n class=\"form-control bg-gray-100 border-0\" placeholder=\"{{'Tables.SearchPlaceholder' | translate}}\"\n aria-label=\"Search\" aria-describedby=\"basic-addon2\">\n <div class=\"input-group-append\">\n <button class=\"btn btn-default bg-gray-100 border-0\" type=\"button\">\n <i class=\"fa fa-search text-secondary\"></i>\n </button>\n </div>\n </div>\n </div>\n <div #emptyTable class=\"d-none\">\n <div>\n <div class=\"mt-4\">\n <div class=\"icon-circle bg-gray-300 border-gray-100\"></div>\n </div>\n <div class=\"mt-4\">\n <h4 class=\"font-3xl text-dark\" [translate]=\"'Tables.EmptyTableTitle'\"></h4>\n <p class=\"font-lg text-dark\" [translate]=\"'Tables.EmptyTableMessage'\"></p>\n </div>\n\n </div>\n </div>\n <div class=\"col-12 col-lg-5\">\n <div class=\"btn-toolbar\">\n <button class=\"btn btn-gray-100\">\n <i class=\"fa fa-sliders-h pr-2 text-secondary\" aria-hidden=\"true\"></i>{{'Tables.Filters' | translate}}\n </button>\n <div class=\"dropdown ml-3\" dropdown>\n <button dropdownToggle class=\"btn btn-gray-100 dropdown-toggle\" type=\"button\" id=\"dropdownDefaultFilters\"\n data-toggle=\"dropdown\">\n {{ this.defaultFilter.name | translate }}\n </button>\n <div class=\"dropdown-menu\" aria-labelledby=\"dropdownDefaultFilters\" *dropdownMenu>\n <a class=\"dropdown-item\" *ngFor=\"let filter of defaultFilters\"\n (click)=\"advancedSearch(filter.filter ? filter : '')\">\n {{ filter.name | translate }}\n </a>\n </div>\n </div>\n </div>\n </div>\n <div class=\"col text-lg-right mt-3 mt-lg-0\">\n <button [disabled]=\"true\" class=\"btn rounded-pill btn-outline-theme\">\n <span class=\"pr-2 font-lg\">+</span><span [translate]=\"'Tables.AddItem'\"></span>\n </button>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-12\" [ngClass]=\"{ 'component-loading': loading}\">\n <app-advanced-table #advancedTable (init)=\"onTableInit($event)\" (load)=\"onDataLoad($event)\"\n [selectable]=\"true\" [multipleSelect]=\"true\" [scrollX]=\"false\" [scrollY]=\"320\" [pageLength]=\"pageLength\"\n [scrollable]=\"false\" [showFooter]=\"false\" [showActions]=\"false\" [lengthMenu]=\"lengthMenu\"\n [config]=\"tableConfig\" [configSrc]=\"tableConfigSrc\"></app-advanced-table>\n </div>\n </div>\n <div class=\"row mt-3 table-custom-pager\">\n <div class=\"col-12 d-flex\" *ngIf=\"recordsTotal\">\n <div class=\"mt-2 ml-auto mr-3 text-secondary\" [translate]=\"'Tables.RecordsPerPage'\"></div>\n <div class=\"dropdown mr-3\" dropdown>\n <button dropdownToggle class=\"btn btn-gray-100 dropdown-toggle\" type=\"button\" id=\"dropdownPageSize\"\n data-toggle=\"dropdown\">\n {{pageLength}}\n </button>\n <div class=\"dropdown-menu\" aria-labelledby=\"dropdownPageSize\" *dropdownMenu>\n <button (click)=\"setLength(item)\" class=\"dropdown-item dropdown-item-theme\" type=\"button\"\n *ngFor=\"let item of lengthMenu\">{{item}}</button>\n </div>\n </div>\n <div class=\"mt-2 mr-2\" [translate]=\"'Tables.PageInfo'\" [translateParams]=\"pageInfo\"></div>\n <button [disabled]=\"pageInfo && pageInfo.page === 0\" class=\"btn text-nowrap\" (click)=\"firstPage()\">\n <i class=\"fa fa-chevron-left text-color-theme\"></i>\n <i class=\"fa fa-chevron-left text-color-theme\"></i>\n </button>\n <button [disabled]=\"pageInfo && pageInfo.page===0\" class=\"btn\" (click)=\"previousPage()\">\n <i class=\"fa fa-chevron-left text-color-theme\"></i>\n </button>\n <button [disabled]=\"pageInfo && pageInfo.page===pageInfo.pages-1\" class=\"btn\" (click)=\"nextPage()\">\n <i class=\"fa fa-chevron-right text-color-theme\"></i>\n </button>\n <button [disabled]=\"pageInfo && pageInfo.page===pageInfo.pages-1\" class=\"btn text-nowrap\"\n (click)=\"lastPage()\">\n <i class=\"fa fa-chevron-right text-color-theme\"></i>\n <i class=\"fa fa-chevron-right text-color-theme\"></i>\n </button>\n </div>\n </div>\n </div>\n</div>\n<div class=\"modal-footer justify-content-end\">\n <button [disabled]=\"okButtonDisabled\" (click)=\"ok()\" type=\"button\" [ngClass]=\"okButtonClass\">\n {{okButtonText | translate}}\n </button>\n <button [disabled]=\"cancelButtonDisabled\" (click)=\"cancel()\" type=\"button\" [ngClass]=\"cancelButtonClass\"\n data-dismiss=\"modal\">\n {{ cancelButtonText | translate}}\n </button>\n</div>\n",
|
|
2962
|
+
encapsulation: i0.ViewEncapsulation.None,
|
|
2963
|
+
styles: ["\n .modal-table .dataTables_wrapper {\n height: 50vh;\n overflow-y: auto;\n }\n "]
|
|
2964
|
+
}] }
|
|
2965
|
+
];
|
|
2966
|
+
/** @nocollapse */
|
|
2967
|
+
AdvancedSelectComponent.ctorParameters = function () {
|
|
2968
|
+
return [
|
|
2969
|
+
{ type: i1.Router },
|
|
2970
|
+
{ type: i1.ActivatedRoute },
|
|
2971
|
+
{ type: i1$1.AngularDataContext },
|
|
2972
|
+
{ type: AdvancedFilterValueProvider },
|
|
2973
|
+
{ type: common.DatePipe },
|
|
2974
|
+
{ type: modal.BsModalRef }
|
|
2975
|
+
];
|
|
2976
|
+
};
|
|
2977
|
+
return AdvancedSelectComponent;
|
|
2978
|
+
}(AdvancedTableModalBaseComponent));
|
|
2979
|
+
|
|
2980
|
+
var AdvancedSelectService = /** @class */ (function () {
|
|
2981
|
+
function AdvancedSelectService(_modal) {
|
|
2982
|
+
this._modal = _modal;
|
|
2983
|
+
//
|
|
2984
|
+
}
|
|
2985
|
+
AdvancedSelectService.prototype.select = function (initialState) {
|
|
2986
|
+
var _this = this;
|
|
2987
|
+
return new Promise(function (resolve, reject) {
|
|
2988
|
+
try {
|
|
2989
|
+
var modalRef = _this._modal.openModalComponent(AdvancedSelectComponent, {
|
|
2990
|
+
class: 'modal-xl modal-table',
|
|
2991
|
+
ignoreBackdropClick: true,
|
|
2992
|
+
animated: true,
|
|
2993
|
+
initialState: initialState
|
|
2994
|
+
});
|
|
2995
|
+
var componentRef_1 = modalRef.content;
|
|
2996
|
+
componentRef_1.dismiss.subscribe(function (result) {
|
|
2997
|
+
return resolve({
|
|
2998
|
+
result: result,
|
|
2999
|
+
items: componentRef_1.advancedTable.selected
|
|
3000
|
+
});
|
|
3001
|
+
});
|
|
3002
|
+
}
|
|
3003
|
+
catch (err) {
|
|
3004
|
+
return reject(err);
|
|
3005
|
+
}
|
|
3006
|
+
});
|
|
3007
|
+
};
|
|
3008
|
+
AdvancedSelectService.decorators = [
|
|
3009
|
+
{ type: i0.Injectable }
|
|
3010
|
+
];
|
|
3011
|
+
/** @nocollapse */
|
|
3012
|
+
AdvancedSelectService.ctorParameters = function () {
|
|
3013
|
+
return [
|
|
3014
|
+
{ type: i2.ModalService }
|
|
3015
|
+
];
|
|
3016
|
+
};
|
|
3017
|
+
return AdvancedSelectService;
|
|
3018
|
+
}());
|
|
3019
|
+
|
|
3020
|
+
var ActivatedTableService = /** @class */ (function () {
|
|
3021
|
+
function ActivatedTableService(_router, _activatedRoute) {
|
|
3022
|
+
var _this = this;
|
|
3023
|
+
this._router = _router;
|
|
3024
|
+
this._activatedRoute = _activatedRoute;
|
|
3025
|
+
_router.events.forEach(function (event) {
|
|
3026
|
+
if (event instanceof i1.NavigationStart) {
|
|
3027
|
+
if (_this._activeTable) {
|
|
3028
|
+
_this._activeTable = null;
|
|
3029
|
+
}
|
|
3030
|
+
}
|
|
3031
|
+
});
|
|
3032
|
+
}
|
|
3033
|
+
Object.defineProperty(ActivatedTableService.prototype, "activeTable", {
|
|
3034
|
+
get: function () {
|
|
3035
|
+
return this._activeTable;
|
|
3036
|
+
},
|
|
3037
|
+
set: function (tableComponent) {
|
|
3038
|
+
this._activeTable = tableComponent;
|
|
3039
|
+
},
|
|
3040
|
+
enumerable: true,
|
|
3041
|
+
configurable: true
|
|
3042
|
+
});
|
|
3043
|
+
ActivatedTableService.decorators = [
|
|
3044
|
+
{ type: i0.Injectable, args: [{
|
|
3045
|
+
providedIn: 'root'
|
|
3046
|
+
},] }
|
|
3047
|
+
];
|
|
3048
|
+
/** @nocollapse */
|
|
3049
|
+
ActivatedTableService.ctorParameters = function () {
|
|
3050
|
+
return [
|
|
3051
|
+
{ type: i1.Router },
|
|
3052
|
+
{ type: i1.ActivatedRoute }
|
|
3053
|
+
];
|
|
3054
|
+
};
|
|
3055
|
+
ActivatedTableService.ngInjectableDef = i0.defineInjectable({ factory: function ActivatedTableService_Factory() { return new ActivatedTableService(i0.inject(i1.Router), i0.inject(i1.ActivatedRoute)); }, token: ActivatedTableService, providedIn: "root" });
|
|
3056
|
+
return ActivatedTableService;
|
|
3057
|
+
}());
|
|
3058
|
+
|
|
3059
|
+
var MAX_EXPORT_ITEMS = 500;
|
|
3060
|
+
var BtnExpDirective = /** @class */ (function () {
|
|
3061
|
+
function BtnExpDirective(_activatedTable, _context, _config, _translate, _loadingService, _errorService) {
|
|
3062
|
+
this._activatedTable = _activatedTable;
|
|
3063
|
+
this._context = _context;
|
|
3064
|
+
this._config = _config;
|
|
3065
|
+
this._translate = _translate;
|
|
3066
|
+
this._loadingService = _loadingService;
|
|
3067
|
+
this._errorService = _errorService;
|
|
3068
|
+
}
|
|
3069
|
+
BtnExpDirective.prototype.clickEvent = function (event) {
|
|
3070
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3071
|
+
var lastQuery, tableConfig, serviceHeaders, queryModel, query, queryParams, maxExportItems, url;
|
|
3072
|
+
return __generator(this, function (_a) {
|
|
3073
|
+
event.preventDefault();
|
|
3074
|
+
event.stopPropagation();
|
|
3075
|
+
if (this._activatedTable.activeTable) {
|
|
3076
|
+
lastQuery = this._activatedTable.activeTable.lastQuery;
|
|
3077
|
+
tableConfig = this._activatedTable.activeTable.config;
|
|
3078
|
+
serviceHeaders = this._context.getService().getHeaders();
|
|
3079
|
+
queryModel = lastQuery.getModel();
|
|
3080
|
+
query = this._context.model(queryModel).asQueryable();
|
|
3081
|
+
queryParams = lastQuery.getParams();
|
|
3082
|
+
query = this.constructQuery(query, queryParams, tableConfig, serviceHeaders);
|
|
3083
|
+
maxExportItems = 1000;
|
|
3084
|
+
if (maxExportItems && typeof maxExportItems === 'number' && maxExportItems > 0) {
|
|
3085
|
+
query.skip(0).take(maxExportItems);
|
|
3086
|
+
}
|
|
3087
|
+
else {
|
|
3088
|
+
query.skip(0).take(MAX_EXPORT_ITEMS);
|
|
3089
|
+
}
|
|
3090
|
+
url = this.constructURL(query);
|
|
3091
|
+
this.downloadFile(url, query.getService().getHeaders(), query.getModel());
|
|
3092
|
+
}
|
|
3093
|
+
return [2 /*return*/];
|
|
3094
|
+
});
|
|
3095
|
+
});
|
|
3096
|
+
};
|
|
3097
|
+
/**
|
|
3098
|
+
* Sets the parameters to the query based on
|
|
3099
|
+
* the active filters of the activated table
|
|
3100
|
+
* @param {ClientDataQueryable} query
|
|
3101
|
+
* @param params: The filters of the last query of the activated table
|
|
3102
|
+
* @return ClientDataQueryable
|
|
3103
|
+
*/
|
|
3104
|
+
BtnExpDirective.prototype.setParams = function (query, params) {
|
|
3105
|
+
if (params && typeof params === 'object') {
|
|
3106
|
+
Object.keys(params).forEach(function (key) {
|
|
3107
|
+
query.setParam(key, params[key]);
|
|
3108
|
+
});
|
|
3109
|
+
}
|
|
3110
|
+
return query;
|
|
3111
|
+
};
|
|
3112
|
+
/**
|
|
3113
|
+
* Sets the headers to the query based on
|
|
3114
|
+
* the default headers of the DataContext
|
|
3115
|
+
* and appending the accept header to get
|
|
3116
|
+
* an xlsx file from the API
|
|
3117
|
+
* @param {ClientDataQueryable} query
|
|
3118
|
+
* @param {Headers} headers: The headers to append to the query
|
|
3119
|
+
* @return ClientDataQueryable
|
|
3120
|
+
*/
|
|
3121
|
+
BtnExpDirective.prototype.setHeaders = function (query, headers) {
|
|
3122
|
+
Object.keys(headers).forEach(function (key) {
|
|
3123
|
+
if (headers.hasOwnProperty(key)) {
|
|
3124
|
+
query.getService().setHeader(key, headers[key]);
|
|
3125
|
+
}
|
|
3126
|
+
});
|
|
3127
|
+
// sets a header to accept xlsx files
|
|
3128
|
+
query.getService().setHeader('Accept', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
3129
|
+
return query;
|
|
3130
|
+
};
|
|
3131
|
+
/**
|
|
3132
|
+
* Constructs the select parameter of the
|
|
3133
|
+
* ClientDataQuery by replacing the target name
|
|
3134
|
+
* of the field based on the localized translation
|
|
3135
|
+
* of that property on the advanced tabled
|
|
3136
|
+
* @param {ClientDataQueryable} query
|
|
3137
|
+
* @param tableConfig: The configuration of the activated table
|
|
3138
|
+
* @return ClientDataQueryable
|
|
3139
|
+
*/
|
|
3140
|
+
BtnExpDirective.prototype.constructQueryParam = function (query, tableConfig) {
|
|
3141
|
+
var _this = this;
|
|
3142
|
+
var selectQuery = query.getParams().$select;
|
|
3143
|
+
var selectQueryArray = selectQuery.split(',');
|
|
3144
|
+
selectQueryArray = selectQueryArray.map(function (select) {
|
|
3145
|
+
var e_1, _a, e_2, _b;
|
|
3146
|
+
var words = select.split(' ');
|
|
3147
|
+
if (words.length === 3) {
|
|
3148
|
+
if (tableConfig && tableConfig.columns) {
|
|
3149
|
+
try {
|
|
3150
|
+
for (var _c = __values(tableConfig.columns), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
3151
|
+
var column = _d.value;
|
|
3152
|
+
if (column.property === words[2] && column.title) {
|
|
3153
|
+
words[2] = "\"" + _this._translate.instant(column.title) + "\"";
|
|
3154
|
+
}
|
|
3155
|
+
else if (column.property === words[2]) {
|
|
3156
|
+
words[2] = "\"" + _this._translate.instant(words[2]) + "\"";
|
|
3157
|
+
}
|
|
3158
|
+
}
|
|
3159
|
+
}
|
|
3160
|
+
catch (e_1_1) {
|
|
3161
|
+
e_1 = { error: e_1_1 };
|
|
3162
|
+
}
|
|
3163
|
+
finally {
|
|
3164
|
+
try {
|
|
3165
|
+
if (_d && !_d.done && (_a = _c.return))
|
|
3166
|
+
_a.call(_c);
|
|
3167
|
+
}
|
|
3168
|
+
finally {
|
|
3169
|
+
if (e_1)
|
|
3170
|
+
throw e_1.error;
|
|
3171
|
+
}
|
|
3172
|
+
}
|
|
3173
|
+
}
|
|
3174
|
+
}
|
|
3175
|
+
if (words.length === 1) {
|
|
3176
|
+
if (tableConfig && tableConfig.columns) {
|
|
3177
|
+
try {
|
|
3178
|
+
for (var _e = __values(tableConfig.columns), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
3179
|
+
var column = _f.value;
|
|
3180
|
+
if (column.name === words[0] && column.title) {
|
|
3181
|
+
words[0] = words[0] + " as \"" + _this._translate.instant(column.title) + "\"";
|
|
3182
|
+
break;
|
|
3183
|
+
}
|
|
3184
|
+
else if (column.name === words[0] && column.property) {
|
|
3185
|
+
words[0] = words[0] + " as \"" + _this._translate.instant(column.property) + "\"";
|
|
3186
|
+
break;
|
|
3187
|
+
}
|
|
3188
|
+
else if (words[0] === column.name && words[0] === "id" && column.hidden) {
|
|
3189
|
+
break;
|
|
3190
|
+
}
|
|
3191
|
+
else if (words[0] == column.name || words[0] === column.property) {
|
|
3192
|
+
words[0] = words[0] + " as \"" + _this._translate.instant(words[0]) + "\"";
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3196
|
+
catch (e_2_1) {
|
|
3197
|
+
e_2 = { error: e_2_1 };
|
|
3198
|
+
}
|
|
3199
|
+
finally {
|
|
3200
|
+
try {
|
|
3201
|
+
if (_f && !_f.done && (_b = _e.return))
|
|
3202
|
+
_b.call(_e);
|
|
3203
|
+
}
|
|
3204
|
+
finally {
|
|
3205
|
+
if (e_2)
|
|
3206
|
+
throw e_2.error;
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3210
|
+
return words[0];
|
|
3211
|
+
}
|
|
3212
|
+
return words.join(' ');
|
|
3213
|
+
});
|
|
3214
|
+
selectQuery = selectQueryArray.join(',');
|
|
3215
|
+
query.setParam('$select', selectQuery);
|
|
3216
|
+
return query;
|
|
3217
|
+
};
|
|
3218
|
+
/**
|
|
3219
|
+
* Constructs the fetch URL based the query parameters
|
|
3220
|
+
* @param {ClientDataQueryable} query
|
|
3221
|
+
* @return String
|
|
3222
|
+
*/
|
|
3223
|
+
BtnExpDirective.prototype.constructURL = function (query) {
|
|
3224
|
+
var baseURL = query.getService().getBase();
|
|
3225
|
+
var url = baseURL.endsWith('/') ? (baseURL + query.getModel() + '?') : (baseURL + '/' + query.getModel() + '?');
|
|
3226
|
+
Object.keys(query.getParams()).forEach(function (key, index) {
|
|
3227
|
+
if (index === 0) {
|
|
3228
|
+
url += key + '=' + query.getParams()[key];
|
|
3229
|
+
}
|
|
3230
|
+
else {
|
|
3231
|
+
url += '&' + key + '=' + query.getParams()[key];
|
|
3232
|
+
}
|
|
3233
|
+
});
|
|
3234
|
+
return url;
|
|
3235
|
+
};
|
|
3236
|
+
/**
|
|
3237
|
+
* Constructs the query by setting the parameters of the
|
|
3238
|
+
* advanced table's active filters, sets the necessary headers
|
|
3239
|
+
* and build the select parameter of the query
|
|
3240
|
+
* @param {ClientDataQueryable} query
|
|
3241
|
+
* @param params: The filters of the last query of the activated table
|
|
3242
|
+
* @param tableConfig: The configuration of the activated table
|
|
3243
|
+
* @param {Headers} headers: The headers to append to the query
|
|
3244
|
+
* @return ClientDataQueryable
|
|
3245
|
+
*/
|
|
3246
|
+
BtnExpDirective.prototype.constructQuery = function (query, params, tableConfig, headers) {
|
|
3247
|
+
var _query = this.setParams(query, params);
|
|
3248
|
+
_query = this.setHeaders(_query, headers);
|
|
3249
|
+
_query = this.constructQueryParam(_query, tableConfig);
|
|
3250
|
+
return _query;
|
|
3251
|
+
};
|
|
3252
|
+
/**
|
|
3253
|
+
* Fetches and saves the xlsx file
|
|
3254
|
+
* @param {String} url
|
|
3255
|
+
* @param {Headers} serviceHeaders: The headers to append to the query
|
|
3256
|
+
* @param modelName: The model name of the advanced table
|
|
3257
|
+
*/
|
|
3258
|
+
BtnExpDirective.prototype.downloadFile = function (url, serviceHeaders, modelName) {
|
|
3259
|
+
var _this = this;
|
|
3260
|
+
this._loadingService.showLoading();
|
|
3261
|
+
fetch(encodeURI(url), {
|
|
3262
|
+
headers: serviceHeaders,
|
|
3263
|
+
credentials: 'include'
|
|
3264
|
+
}).then(function (response) {
|
|
3265
|
+
if (response && !response.ok) {
|
|
3266
|
+
throw new client.ResponseError(response.statusText, response.status);
|
|
3267
|
+
}
|
|
3268
|
+
return response.blob();
|
|
3269
|
+
}).then(function (blob) {
|
|
3270
|
+
var objectUrl = window.URL.createObjectURL(blob);
|
|
3271
|
+
var a = document.createElement('a');
|
|
3272
|
+
document.body.appendChild(a);
|
|
3273
|
+
a.setAttribute('style', 'display: none');
|
|
3274
|
+
a.href = objectUrl;
|
|
3275
|
+
var downloadName = modelName + ".xlsx";
|
|
3276
|
+
a.download = downloadName;
|
|
3277
|
+
// this adds support for IE and MS Edge (up to version 44.19041)
|
|
3278
|
+
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
|
|
3279
|
+
window.navigator.msSaveOrOpenBlob(blob, downloadName);
|
|
3280
|
+
}
|
|
3281
|
+
else {
|
|
3282
|
+
// for all other browsers
|
|
3283
|
+
a.click();
|
|
3284
|
+
}
|
|
3285
|
+
window.URL.revokeObjectURL(objectUrl);
|
|
3286
|
+
a.remove();
|
|
3287
|
+
_this._loadingService.hideLoading();
|
|
3288
|
+
}).catch(function (err) {
|
|
3289
|
+
_this._loadingService.hideLoading();
|
|
3290
|
+
_this._errorService.showError(err, {
|
|
3291
|
+
continueLink: '.'
|
|
3292
|
+
});
|
|
3293
|
+
});
|
|
3294
|
+
};
|
|
3295
|
+
BtnExpDirective.decorators = [
|
|
3296
|
+
{ type: i0.Directive, args: [{
|
|
3297
|
+
selector: '.universis-btn-export'
|
|
3298
|
+
},] }
|
|
3299
|
+
];
|
|
3300
|
+
/** @nocollapse */
|
|
3301
|
+
BtnExpDirective.ctorParameters = function () {
|
|
3302
|
+
return [
|
|
3303
|
+
{ type: ActivatedTableService },
|
|
3304
|
+
{ type: i1$1.AngularDataContext },
|
|
3305
|
+
{ type: i2.ConfigurationService },
|
|
3306
|
+
{ type: core.TranslateService },
|
|
3307
|
+
{ type: i2.LoadingService },
|
|
3308
|
+
{ type: i2.ErrorService }
|
|
3309
|
+
];
|
|
3310
|
+
};
|
|
3311
|
+
BtnExpDirective.propDecorators = {
|
|
3312
|
+
clickEvent: [{ type: i0.HostListener, args: ['click', ['$event'],] }]
|
|
3313
|
+
};
|
|
3314
|
+
return BtnExpDirective;
|
|
3315
|
+
}());
|
|
3316
|
+
|
|
3317
|
+
var AdvancedTableSettingsComponent = /** @class */ (function () {
|
|
3318
|
+
function AdvancedTableSettingsComponent(_context, _activatedRoute, elRef, modalService, userStorage, formBuilder, _activatedTable) {
|
|
3319
|
+
this._context = _context;
|
|
3320
|
+
this._activatedRoute = _activatedRoute;
|
|
3321
|
+
this.elRef = elRef;
|
|
3322
|
+
this.modalService = modalService;
|
|
3323
|
+
this.userStorage = userStorage;
|
|
3324
|
+
this.formBuilder = formBuilder;
|
|
3325
|
+
this._activatedTable = _activatedTable;
|
|
3326
|
+
this.params = this._activatedRoute.params;
|
|
3327
|
+
this.columns = [];
|
|
3328
|
+
}
|
|
3329
|
+
AdvancedTableSettingsComponent.prototype.ngOnInit = function () {
|
|
3330
|
+
};
|
|
3331
|
+
AdvancedTableSettingsComponent.prototype.ngAfterViewInit = function () {
|
|
3332
|
+
var _this = this;
|
|
3333
|
+
this.activeTableConfig = this._activatedTable.activeTable.getConfig();
|
|
3334
|
+
this.storageKey = 'registrar/settings/' + this.activeTableConfig.title + '/table/columns';
|
|
3335
|
+
this.form = this.formBuilder.group({ columns: new forms.FormArray([], this.minSelectedColumns(1)) });
|
|
3336
|
+
this.userStorage.getItem(this.storageKey).then(function (data) {
|
|
3337
|
+
if (data) {
|
|
3338
|
+
_this.savedTableSettings = data.value;
|
|
3339
|
+
if (_this.savedTableSettings) {
|
|
3340
|
+
if (_this._activatedTable.activeTable) {
|
|
3341
|
+
_this._activatedTable.activeTable.handleColumns(_this.savedTableSettings);
|
|
3342
|
+
}
|
|
3343
|
+
}
|
|
3344
|
+
_this.addCheckboxes();
|
|
3345
|
+
}
|
|
3346
|
+
});
|
|
3347
|
+
};
|
|
3348
|
+
AdvancedTableSettingsComponent.prototype.addCheckboxes = function () {
|
|
3349
|
+
var _this = this;
|
|
3350
|
+
this.tableColumns = this.activeTableConfig.columns.slice(1);
|
|
3351
|
+
this.tableColumns.forEach(function (column, i) {
|
|
3352
|
+
if (!column.hidden) {
|
|
3353
|
+
var control = {
|
|
3354
|
+
id: column.name,
|
|
3355
|
+
name: column.title
|
|
3356
|
+
};
|
|
3357
|
+
_this.columns.push(control);
|
|
3358
|
+
}
|
|
3359
|
+
});
|
|
3360
|
+
if (this.savedTableSettings) {
|
|
3361
|
+
this.columns.forEach(function (column, i) {
|
|
3362
|
+
column.check = false;
|
|
3363
|
+
column.check = _this.savedTableSettings.includes(column.id);
|
|
3364
|
+
});
|
|
3365
|
+
this.columns.map(function (column, i) {
|
|
3366
|
+
var control = new forms.FormControl(column.check);
|
|
3367
|
+
_this.form.controls.columns.push(control);
|
|
3368
|
+
});
|
|
3369
|
+
}
|
|
3370
|
+
};
|
|
3371
|
+
AdvancedTableSettingsComponent.prototype.openTableSettings = function (table_settings_modal) {
|
|
3372
|
+
this.modalRef = this.modalService.show(table_settings_modal);
|
|
3373
|
+
};
|
|
3374
|
+
AdvancedTableSettingsComponent.prototype.saveTableSettings = function () {
|
|
3375
|
+
var _this = this;
|
|
3376
|
+
var selectedColumnsIds = this.form.value.columns
|
|
3377
|
+
.map(function (v, i) { return v ? _this.columns[i].id : null; })
|
|
3378
|
+
.filter(function (v) { return v !== null; });
|
|
3379
|
+
this.userStorage.setItem(this.storageKey, selectedColumnsIds);
|
|
3380
|
+
if (this._activatedTable.activeTable) {
|
|
3381
|
+
this._activatedTable.activeTable.handleColumns(selectedColumnsIds);
|
|
3382
|
+
}
|
|
3383
|
+
this.modalRef.hide();
|
|
3384
|
+
};
|
|
3385
|
+
AdvancedTableSettingsComponent.prototype.dismiss = function () {
|
|
3386
|
+
this.modalRef.hide();
|
|
3387
|
+
};
|
|
3388
|
+
AdvancedTableSettingsComponent.prototype.minSelectedColumns = function (min) {
|
|
3389
|
+
if (min === void 0) {
|
|
3390
|
+
min = 1;
|
|
3391
|
+
}
|
|
3392
|
+
var validator = function (formArray) {
|
|
3393
|
+
var totalSelected = formArray.controls
|
|
3394
|
+
.map(function (control) { return control.value; })
|
|
3395
|
+
.reduce(function (prev, next) { return next ? prev + next : prev; }, 0);
|
|
3396
|
+
return totalSelected >= min ? null : { required: true };
|
|
3397
|
+
};
|
|
3398
|
+
return validator;
|
|
3399
|
+
};
|
|
3400
|
+
AdvancedTableSettingsComponent.decorators = [
|
|
3401
|
+
{ type: i0.Component, args: [{
|
|
3402
|
+
selector: 'app-advanced-table-settings',
|
|
3403
|
+
template: "<i class=\"fa fa-edit fa-lg advanced-table-settings\" (click)=\"openTableSettings(modal_settings_template)\"></i>\r\n<ng-template #modal_settings_template>\r\n <div class=\"modal-header\">\r\n <h3 class=\"modal-title\" [translate]=\"'Tables.ColumnDisplay'\"></h3>\r\n <button type=\"button\" class=\"close pull-right\" aria-label=\"Close\" (click)=\"dismiss()\">\r\n <span aria-hidden=\"true\">×</span>\r\n </button>\r\n </div>\r\n\r\n <form class=\"form-group p-3 text-left\" [formGroup]=\"form\" (ngSubmit)=\"saveTableSettings()\">\r\n <div class=\"modal-body\">\r\n <p [translate]=\"'Tables.ColumnDisplayInfo'\"></p>\r\n <!-- <div *ngFor=\"let column of form.controls.columns.controls; let i = index\">\r\n <div formArrayName=\"columns\">\r\n <input class=\"checkbox checkbox-primary\" type=\"checkbox\" [formControlName]=\"i\" id=\"checkbox{{i}}\">\r\n <label for=\"checkbox{{i}}\">\r\n {{columns[i].name | translate}}\r\n </label>\r\n </div>\r\n </div> -->\r\n </div>\r\n <div class=\"modal-footer\">\r\n <button type=\"button\" class=\"btn btn-light\" (click)=\"dismiss()\" [translate]=\"'Tables.Cancel'\"> </button>\r\n <button type=\"submit\" class=\"btn btn-success\" [translate]=\"'Tables.Save'\"></button>\r\n </div>\r\n </form>\r\n</ng-template>\r\n",
|
|
3404
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
3405
|
+
}] }
|
|
3406
|
+
];
|
|
3407
|
+
/** @nocollapse */
|
|
3408
|
+
AdvancedTableSettingsComponent.ctorParameters = function () {
|
|
3409
|
+
return [
|
|
3410
|
+
{ type: i1$1.AngularDataContext },
|
|
3411
|
+
{ type: i1.ActivatedRoute },
|
|
3412
|
+
{ type: i0.ElementRef },
|
|
3413
|
+
{ type: modal.BsModalService },
|
|
3414
|
+
{ type: i2.UserStorageService },
|
|
3415
|
+
{ type: forms.FormBuilder },
|
|
3416
|
+
{ type: ActivatedTableService }
|
|
3417
|
+
];
|
|
3418
|
+
};
|
|
3419
|
+
AdvancedTableSettingsComponent.propDecorators = {
|
|
3420
|
+
table: [{ type: i0.Input }],
|
|
3421
|
+
modal_settings_template: [{ type: i0.ViewChild, args: ['modal_settings_template',] }]
|
|
3422
|
+
};
|
|
3423
|
+
return AdvancedTableSettingsComponent;
|
|
3424
|
+
}());
|
|
3425
|
+
|
|
3426
|
+
var TABLES_EL = {
|
|
3427
|
+
"Tables": {
|
|
3428
|
+
"Export": "Εξαγωγή",
|
|
3429
|
+
"More": "Περισσότερα",
|
|
3430
|
+
"Search": "Αναζήτηση",
|
|
3431
|
+
"SearchPlaceholder": "Αναζήτηση...",
|
|
3432
|
+
"GroupBy": "Ομαδοποίηση ανά",
|
|
3433
|
+
"DataTable": {
|
|
3434
|
+
"paginate": {
|
|
3435
|
+
"first": "Πρώτη σελίδα",
|
|
3436
|
+
"last": "Τελεταία σελίδα",
|
|
3437
|
+
"next": "Επόμενη",
|
|
3438
|
+
"previous": "Προηγούμενη"
|
|
3439
|
+
},
|
|
3440
|
+
"info": "Εμφάνιση _START_ έως _END_ από _TOTAL_ εγγραφές",
|
|
3441
|
+
"infoEmpty": "Δεν βρέθηκαν εγγραφές",
|
|
3442
|
+
"loading": "Εμφάνιση δεδομένων...",
|
|
3443
|
+
"processing": "Παραλαβή δεδομένων...",
|
|
3444
|
+
"emptyTable": "Δεν βρέθηκαν αποτελέσματα."
|
|
3445
|
+
},
|
|
3446
|
+
"ColumnDisplay": "Επιλογή Εμφάνισης στηλών",
|
|
3447
|
+
"ColumnDisplayInfo": "Επιλέξτε τις στήλες που θέλετε να εμφανίζονται.",
|
|
3448
|
+
"Save": "Εφαρμογή",
|
|
3449
|
+
"Apply": "Εφαρμογή",
|
|
3450
|
+
"Cancel": "Ακύρωση",
|
|
3451
|
+
"RecordsPerPage": "Εγγραφές ανά σελίδα",
|
|
3452
|
+
"PageInfo": "{{start}}-{{end}} από {{recordsTotal}}",
|
|
3453
|
+
"SearchListPlaceholder": "Αναζητήστε στη λίστα...",
|
|
3454
|
+
"Filters": "Φίλτρα",
|
|
3455
|
+
"All": "Όλα",
|
|
3456
|
+
"AddItem": "Προσθήκη στοιχείου",
|
|
3457
|
+
"EmptyTableTitle": "Δεν βρέθηκαν αποτελέσματα.",
|
|
3458
|
+
"EmptyTableMessage": "Προσπαθήστε να χρησιμοποιήσετε άλλες λέξεις κλειδιά.",
|
|
3459
|
+
"RemoveItem": "Διαγραφή στοιχείου",
|
|
3460
|
+
"Items": "στοιχεία",
|
|
3461
|
+
"Item": "στοιχείο",
|
|
3462
|
+
"AddItemMessage": {
|
|
3463
|
+
"title": "Προσθήκη στοιχείων",
|
|
3464
|
+
"one": "Ένα νέο στοιχείο προστέθηκε με επιτυχία.",
|
|
3465
|
+
"many": "{{value}} νέα στοιχεία προστέθηκαν με επιτυχία."
|
|
3466
|
+
},
|
|
3467
|
+
"RemoveItemMessage": {
|
|
3468
|
+
"title": "Αφαίρεση στοιχείων",
|
|
3469
|
+
"one": "Ένα στοιχείο αφαιρέθηκε με επιτυχία.",
|
|
3470
|
+
"many": "{{value}} στοιχεία αφαιρέθηκαν με επιτυχία."
|
|
3471
|
+
},
|
|
3472
|
+
"RemoveItemsTitle": "Διαγραφή στοιχείου",
|
|
3473
|
+
"RemoveItemsMessage": "Πρόκειται να διαγράψετε ένα ή περισσότερα στοιχεία. Θέλετε να προχωρήσετε?",
|
|
3474
|
+
"SelectAll": "Επιλογή όλων",
|
|
3475
|
+
"ClearSelection": "Αναίρεση επιλογής",
|
|
3476
|
+
"Actions": {
|
|
3477
|
+
"Label": "Επεξεργασία",
|
|
3478
|
+
"Start": "Έναρξη",
|
|
3479
|
+
"ActionMessage": {
|
|
3480
|
+
"None": "Δεν έχετε επιλέξει κανένα στοιχείο που να ακολουθεί τις προϋποθέσεις της ενέργειας.",
|
|
3481
|
+
"One": "Έχετε επιλέξει ένα στοιχείο που ακολουθεί τις προϋποθέσεις της ενέργειας. Πατήστε το πλήκτρο Έναρξη για να ξεκινήσει η διαδικασία.",
|
|
3482
|
+
"Many": "Έχετε επιλέξει {{length}} στοιχεία που ακολουθούν τις προϋποθέσεις της ενέργειας. Πατήστε το πλήκτρο Έναρξη για να ξεκινήσει η διαδικασία."
|
|
3483
|
+
},
|
|
3484
|
+
"CompletedWithErrors": {
|
|
3485
|
+
"Title": "Η διαδικασία ολοκληρώθηκε με σφάλματα.",
|
|
3486
|
+
"Description": {
|
|
3487
|
+
"One": "Ένα στοιχείο δεν ανανεώθηκε λόγω ενός σφάλματος που συνέβη κατά την εκτέλεση της διαδικασίας.",
|
|
3488
|
+
"Many": "{{errors}} στοιχεία δεν ανανεώθηκαν λόγω ενός σφάλματος που συνέβη κατά την εκτέλεση της διαδικασίας."
|
|
3489
|
+
}
|
|
3490
|
+
},
|
|
3491
|
+
"CompletedWithSuccess": {
|
|
3492
|
+
"Title": "Η διαδικασία ολοκληρώθηκε με επιτυχία."
|
|
3493
|
+
}
|
|
3494
|
+
}
|
|
3495
|
+
},
|
|
3496
|
+
"TrueFalse": {
|
|
3497
|
+
"long": {
|
|
3498
|
+
"Yes": "Ναι",
|
|
3499
|
+
"No": "Όχι"
|
|
3500
|
+
}
|
|
3501
|
+
},
|
|
3502
|
+
"AdvancedSearch": {
|
|
3503
|
+
"Choose": "<Επιλέξτε μια αναζήτηση>",
|
|
3504
|
+
"ChooseDate": "Επιλογή ημερομηνίας",
|
|
3505
|
+
"SavedSearches": "Αποθηκευμένες αναζητήσεις",
|
|
3506
|
+
"ToggleDropdown": "Εμφάνιση λίστας",
|
|
3507
|
+
"SaveCurrentSearch": "Αποθήκευση αναζήτησης",
|
|
3508
|
+
"SaveAs": "Αποθήκευση ως",
|
|
3509
|
+
"Save": "Αποθήκευση",
|
|
3510
|
+
"Delete": "Διαγραφή",
|
|
3511
|
+
"More": "Περισσότερα",
|
|
3512
|
+
"Less": "Λιγότερα",
|
|
3513
|
+
"Modal": {
|
|
3514
|
+
"Title": "Αποθήκευση κριτηρίων αναζήτησης",
|
|
3515
|
+
"Help": "Ορίστε έναν τίτλο για τα επιλεγμένα κριτήρια αναζήτησης. Αυτός ο τίτλος θα σας βοηθήσει να τα χρησιμοποιήσετε ξανά στο μέλλον.",
|
|
3516
|
+
"TitleOnUserError": "Παρακαλώ εισάγετε έναν τίτλο",
|
|
3517
|
+
"TitleOnListAlreadyCreated": "Το όνομα αυτό χρησιμοποιείται ήδη. Διαλέξτε ένα διαφορετικό.",
|
|
3518
|
+
"NoListDefined": "Δεν έχει οριστεί το σημείο αποθήκευσης της λίστας",
|
|
3519
|
+
"EmptyCriteriaList": "Δεν έχετε καθορίσει κανένα κριτήριο για αποθήκευση",
|
|
3520
|
+
"SaveNameLabel": "Ονομασία λίστας",
|
|
3521
|
+
"SaveNamePlaceholder": "Εισάγετε έναν τίτλο",
|
|
3522
|
+
"Accept": "Αποθήκευση",
|
|
3523
|
+
"Decline": "Απόρριψη",
|
|
3524
|
+
"Close": "Κλείσιμο"
|
|
3525
|
+
}
|
|
3526
|
+
}
|
|
3527
|
+
};
|
|
3528
|
+
|
|
3529
|
+
var TABLES_EN = {
|
|
3530
|
+
"Tables": {
|
|
3531
|
+
"Export": "Export",
|
|
3532
|
+
"More": "More",
|
|
3533
|
+
"Search": "Search",
|
|
3534
|
+
"SearchPlaceholder": "Search...",
|
|
3535
|
+
"GroupBy": "Group by",
|
|
3536
|
+
"DataTable": {
|
|
3537
|
+
"paginate": {
|
|
3538
|
+
"first": "First",
|
|
3539
|
+
"last": "Last",
|
|
3540
|
+
"next": "Next",
|
|
3541
|
+
"previous": "Previous"
|
|
3542
|
+
},
|
|
3543
|
+
"info": "Showing _START_ to _END_ of _TOTAL_ entries",
|
|
3544
|
+
"infoEmpty": "Showing 0 to 0 of 0 entries",
|
|
3545
|
+
"processing": "Processing data...",
|
|
3546
|
+
"emptyTable": "There are no matching records."
|
|
3547
|
+
},
|
|
3548
|
+
"ColumnDisplay": "Column Display",
|
|
3549
|
+
"ColumnDisplayInfo": "Επιλέξτε τις στήλες που θέλετε να εμφανίζονται.",
|
|
3550
|
+
"Save": "Save",
|
|
3551
|
+
"Apply": "Apply",
|
|
3552
|
+
"Cancel": "Cancel",
|
|
3553
|
+
"RecordsPerPage": "Items per page",
|
|
3554
|
+
"PageInfo": "{{start}}-{{end}} of {{recordsTotal}}",
|
|
3555
|
+
"SearchListPlaceHolder": "Search in list...",
|
|
3556
|
+
"Filters": "Filters",
|
|
3557
|
+
"All": "All",
|
|
3558
|
+
"AddItem": "Add item",
|
|
3559
|
+
"EmptyTableTitle": "There are no matching records.",
|
|
3560
|
+
"EmptyTableMessage": "Please try to use other keywords or search parameters.",
|
|
3561
|
+
"RemoveItem": "Remove item",
|
|
3562
|
+
"Items": "items",
|
|
3563
|
+
"Item": "item",
|
|
3564
|
+
"AddItemMessage": {
|
|
3565
|
+
"title": "Add item",
|
|
3566
|
+
"one": "A new item has been added successfully.",
|
|
3567
|
+
"many": "{{value}} new items have been added successfully."
|
|
3568
|
+
},
|
|
3569
|
+
"RemoveItemMessage": {
|
|
3570
|
+
"title": "Remove items",
|
|
3571
|
+
"one": "An item has been successfully removed.",
|
|
3572
|
+
"many": "{{value}} items have been successfully removed."
|
|
3573
|
+
},
|
|
3574
|
+
"RemoveItemsTitle": "Remove items",
|
|
3575
|
+
"RemoveItemsMessage": "You are going to remove one or more instructor courses. Do you want to proceed?",
|
|
3576
|
+
"SelectAll": "Select all",
|
|
3577
|
+
"ClearSelection": "Clear selection",
|
|
3578
|
+
"Actions": {
|
|
3579
|
+
"Label": "Edit",
|
|
3580
|
+
"Start": "Start",
|
|
3581
|
+
"ActionMessage": {
|
|
3582
|
+
"None": "There is no selected item that meets action requirements.",
|
|
3583
|
+
"One": "You have selected one item that meets action requirements.",
|
|
3584
|
+
"Many": "You have selected {{length}} items that meet action requirements."
|
|
3585
|
+
},
|
|
3586
|
+
"CompletedWithErrors": {
|
|
3587
|
+
"Title": "The operation was completed with errors.",
|
|
3588
|
+
"Description": {
|
|
3589
|
+
"One": "One item has not been updated due to an error occurred while executing process.",
|
|
3590
|
+
"Many": "{{errors}} items have not been updated due to an error occurred while executing process."
|
|
3591
|
+
}
|
|
3592
|
+
},
|
|
3593
|
+
"CompletedWithSuccess": {
|
|
3594
|
+
"Title": "The operation was completed successfully."
|
|
3595
|
+
}
|
|
3596
|
+
}
|
|
3597
|
+
},
|
|
3598
|
+
"TrueFalse": {
|
|
3599
|
+
"long": {
|
|
3600
|
+
"Yes": "Yes",
|
|
3601
|
+
"No": "No"
|
|
3602
|
+
}
|
|
3603
|
+
},
|
|
3604
|
+
"AdvancedSearch": {
|
|
3605
|
+
"Choose": "<Select a saved search>",
|
|
3606
|
+
"ChooseDate": "Choose date",
|
|
3607
|
+
"SavedSearches": "Saved searches",
|
|
3608
|
+
"ToggleDropdown": "Toggle Dropdown",
|
|
3609
|
+
"SaveCurrentSearch": "Save search",
|
|
3610
|
+
"SaveAs": "Save as...",
|
|
3611
|
+
"Save": "Save",
|
|
3612
|
+
"Delete": "Remove",
|
|
3613
|
+
"More": "More",
|
|
3614
|
+
"Less": "Less",
|
|
3615
|
+
"Modal": {
|
|
3616
|
+
"Title": "Save current search criteria",
|
|
3617
|
+
"Help": "Please add a title for the given search criteria. This title will help you to use those criteria again in the future.",
|
|
3618
|
+
"TitleOnUserError": "Please use a valid name for your list",
|
|
3619
|
+
"TitleOnListAlreadyCreated": "Name already in use. Please choose a different one",
|
|
3620
|
+
"NoListDefined": "Cannot define user storage key.",
|
|
3621
|
+
"EmptyCriteriaList": "Please define search criteria before save.",
|
|
3622
|
+
"SaveNameLabel": "List name",
|
|
3623
|
+
"SaveNamePlaceholder": "Type a title here...",
|
|
3624
|
+
"Accept": "Save",
|
|
3625
|
+
"Decline": "Decline",
|
|
3626
|
+
"Close": "Close"
|
|
3627
|
+
}
|
|
3628
|
+
}
|
|
3629
|
+
};
|
|
3630
|
+
|
|
3631
|
+
var SimpleHeaderToolsComponent = /** @class */ (function () {
|
|
3632
|
+
function SimpleHeaderToolsComponent() {
|
|
3633
|
+
}
|
|
3634
|
+
SimpleHeaderToolsComponent.decorators = [
|
|
3635
|
+
{ type: i0.Component, args: [{
|
|
3636
|
+
selector: 'table-simple-header-tools',
|
|
3637
|
+
template: "\n <ng-content></ng-content>\n "
|
|
3638
|
+
}] }
|
|
3639
|
+
];
|
|
3640
|
+
return SimpleHeaderToolsComponent;
|
|
3641
|
+
}());
|
|
3642
|
+
var TableSimpleHeaderComponent = /** @class */ (function () {
|
|
3643
|
+
function TableSimpleHeaderComponent() {
|
|
3644
|
+
}
|
|
3645
|
+
TableSimpleHeaderComponent.prototype.ngOnChanges = function (changes) {
|
|
3646
|
+
var _this = this;
|
|
3647
|
+
if (changes.table) {
|
|
3648
|
+
if (changes.table.currentValue == null) {
|
|
3649
|
+
if (this.dataLoadSubscription) {
|
|
3650
|
+
this.dataLoadSubscription.unsubscribe();
|
|
3651
|
+
return;
|
|
3652
|
+
}
|
|
3653
|
+
}
|
|
3654
|
+
if (changes.table.currentValue != changes.table.previousValue) {
|
|
3655
|
+
this.dataLoadSubscription = changes.table.currentValue.load.subscribe(function (data) {
|
|
3656
|
+
_this.recordsTotal = data.recordsTotal;
|
|
3657
|
+
});
|
|
3658
|
+
}
|
|
3659
|
+
}
|
|
3660
|
+
};
|
|
3661
|
+
TableSimpleHeaderComponent.prototype.ngOnDestroy = function () {
|
|
3662
|
+
if (this.dataLoadSubscription) {
|
|
3663
|
+
this.dataLoadSubscription.unsubscribe();
|
|
3664
|
+
}
|
|
3665
|
+
};
|
|
3666
|
+
TableSimpleHeaderComponent.prototype.ngOnInit = function () {
|
|
3667
|
+
//
|
|
3668
|
+
};
|
|
3669
|
+
TableSimpleHeaderComponent.decorators = [
|
|
3670
|
+
{ type: i0.Component, args: [{
|
|
3671
|
+
selector: 'app-table-simple-header',
|
|
3672
|
+
template: "<div class=\"row\">\n <div class=\"col-auto mt-4\">\n <div class=\"font-xl text-secondary\" *ngIf=\"recordsTotal === 0\">\n <span> </span>\n </div>\n <div class=\"font-xl text-secondary\" *ngIf=\"recordsTotal > 1\">\n <span>{{recordsTotal}}</span><span> </span><span [translate]=\"'Tables.Items'\"></span>\n </div>\n <div class=\"font-xl text-secondary\" *ngIf=\"recordsTotal === 1\">\n <span>{{recordsTotal}}</span><span> </span><span [translate]=\"'Tables.Item'\"></span>\n </div>\n </div>\n <div class=\"pull-right ml-auto mr-3 mt-3\">\n <div class=\"font-lg btn-toolbar mt-2\">\n <ng-content select=\"table-simple-header-tools\"></ng-content>\n </div>\n </div>\n</div>\n\n"
|
|
3673
|
+
}] }
|
|
3674
|
+
];
|
|
3675
|
+
/** @nocollapse */
|
|
3676
|
+
TableSimpleHeaderComponent.ctorParameters = function () { return []; };
|
|
3677
|
+
TableSimpleHeaderComponent.propDecorators = {
|
|
3678
|
+
table: [{ type: i0.Input }]
|
|
3679
|
+
};
|
|
3680
|
+
return TableSimpleHeaderComponent;
|
|
3681
|
+
}());
|
|
3682
|
+
|
|
3683
|
+
var AdvancedTableNotNullError = /** @class */ (function (_super) {
|
|
3684
|
+
__extends(AdvancedTableNotNullError, _super);
|
|
3685
|
+
function AdvancedTableNotNullError() {
|
|
3686
|
+
return _super.call(this, 'Advanced table component cannot be empty at this context.') || this;
|
|
3687
|
+
}
|
|
3688
|
+
return AdvancedTableNotNullError;
|
|
3689
|
+
}(Error));
|
|
3690
|
+
var AdvancedTableEditorDirective = /** @class */ (function () {
|
|
3691
|
+
function AdvancedTableEditorDirective(table) {
|
|
3692
|
+
this.table = table;
|
|
3693
|
+
this.dirty = false;
|
|
3694
|
+
this.dirtyChange = new i0.EventEmitter(false);
|
|
3695
|
+
//
|
|
3696
|
+
}
|
|
3697
|
+
/**
|
|
3698
|
+
* Add rows to table and mark them as added rows
|
|
3699
|
+
*/
|
|
3700
|
+
AdvancedTableEditorDirective.prototype.add = function () {
|
|
3701
|
+
var addItems = [];
|
|
3702
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3703
|
+
addItems[_i] = arguments[_i];
|
|
3704
|
+
}
|
|
3705
|
+
if (this.table == null) {
|
|
3706
|
+
throw new AdvancedTableNotNullError();
|
|
3707
|
+
}
|
|
3708
|
+
// decorate items
|
|
3709
|
+
var key = this.table.config.columns[0].property || this.table.config.columns[0].name;
|
|
3710
|
+
for (var index = 0; index < addItems.length; index++) {
|
|
3711
|
+
var element = addItems[index];
|
|
3712
|
+
var tr = this.table.dataTable.rows(':has(input[data-id="' + element[key] + '"])').nodes().to$();
|
|
3713
|
+
if (tr.hasClass('removed')) {
|
|
3714
|
+
tr.toggleClass('removed text-gray-400 text-decoration-line-through');
|
|
3715
|
+
}
|
|
3716
|
+
else {
|
|
3717
|
+
this.table.dataTable.rows.add([element]);
|
|
3718
|
+
tr = this.table.dataTable.rows(':has(input[data-id="' + element[key] + '"])').nodes().to$();
|
|
3719
|
+
tr.toggleClass('added font-weight-bold text-success');
|
|
3720
|
+
}
|
|
3721
|
+
}
|
|
3722
|
+
this.table.dataTable.draw();
|
|
3723
|
+
// find removed
|
|
3724
|
+
var removedLength = this.table.dataTable.rows('.removed')[0].length;
|
|
3725
|
+
// find added
|
|
3726
|
+
var addedLength = this.table.dataTable.rows('.added')[0].length;
|
|
3727
|
+
// and emit event
|
|
3728
|
+
var items = this.table.dataTable.rows().data();
|
|
3729
|
+
this.table.load.emit({
|
|
3730
|
+
data: items,
|
|
3731
|
+
recordsFiltered: items.length - removedLength,
|
|
3732
|
+
recordsTotal: items.length - removedLength
|
|
3733
|
+
});
|
|
3734
|
+
this.dirty = (removedLength > 0 || addedLength > 0);
|
|
3735
|
+
this.dirtyChange.emit(this.dirty);
|
|
3736
|
+
};
|
|
3737
|
+
/**
|
|
3738
|
+
* Marks rows as removed rows
|
|
3739
|
+
*/
|
|
3740
|
+
AdvancedTableEditorDirective.prototype.remove = function () {
|
|
3741
|
+
var removeItems = [];
|
|
3742
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3743
|
+
removeItems[_i] = arguments[_i];
|
|
3744
|
+
}
|
|
3745
|
+
if (this.table == null) {
|
|
3746
|
+
throw new AdvancedTableNotNullError();
|
|
3747
|
+
}
|
|
3748
|
+
// get key
|
|
3749
|
+
var key = this.table.config.columns[0].property || this.table.config.columns[0].name;
|
|
3750
|
+
var _loop_1 = function (index) {
|
|
3751
|
+
var element = removeItems[index];
|
|
3752
|
+
var tr = this_1.table.dataTable.rows(':has(input[data-id="' + element[key] + '"])').nodes().to$();
|
|
3753
|
+
// if row is marked as added
|
|
3754
|
+
if (tr.hasClass('added')) {
|
|
3755
|
+
// remove this dirty row
|
|
3756
|
+
this_1.table.dataTable.rows(tr).remove();
|
|
3757
|
+
}
|
|
3758
|
+
else {
|
|
3759
|
+
// otherwise unmarked row
|
|
3760
|
+
tr.toggleClass('removed text-gray-400 text-decoration-line-through');
|
|
3761
|
+
}
|
|
3762
|
+
// check if item is selected
|
|
3763
|
+
var selectedIndex = this_1.table.selected.findIndex(function (item) {
|
|
3764
|
+
return item[key] === element[key];
|
|
3765
|
+
});
|
|
3766
|
+
// and remove it from selected collection
|
|
3767
|
+
if (selectedIndex >= 0) {
|
|
3768
|
+
this_1.table.selected.splice(selectedIndex, 1);
|
|
3769
|
+
}
|
|
3770
|
+
};
|
|
3771
|
+
var this_1 = this;
|
|
3772
|
+
// loop items
|
|
3773
|
+
for (var index = 0; index < removeItems.length; index++) {
|
|
3774
|
+
_loop_1(index);
|
|
3775
|
+
}
|
|
3776
|
+
// re-draw table
|
|
3777
|
+
this.table.dataTable.draw();
|
|
3778
|
+
// get number of table items
|
|
3779
|
+
var items = this.table.dataTable.rows().data();
|
|
3780
|
+
// get number of removed items
|
|
3781
|
+
var removedLength = this.table.dataTable.rows('.removed')[0].length;
|
|
3782
|
+
// get number of added items
|
|
3783
|
+
var addedLength = this.table.dataTable.rows('.added')[0].length;
|
|
3784
|
+
// refresh
|
|
3785
|
+
this.table.load.emit({
|
|
3786
|
+
data: items,
|
|
3787
|
+
recordsFiltered: items.length - removedLength,
|
|
3788
|
+
recordsTotal: items.length - removedLength
|
|
3789
|
+
});
|
|
3790
|
+
this.dirty = (removedLength > 0 || addedLength > 0);
|
|
3791
|
+
this.dirtyChange.emit(this.dirty);
|
|
3792
|
+
};
|
|
3793
|
+
AdvancedTableEditorDirective.prototype.set = function (items) {
|
|
3794
|
+
if (this.table == null) {
|
|
3795
|
+
throw new AdvancedTableNotNullError();
|
|
3796
|
+
}
|
|
3797
|
+
// clear rows
|
|
3798
|
+
this.table.selected = [];
|
|
3799
|
+
this.table.dataTable.clear();
|
|
3800
|
+
// set items
|
|
3801
|
+
this.table.dataTable.rows.add(items).draw();
|
|
3802
|
+
this.table.load.emit({
|
|
3803
|
+
data: items,
|
|
3804
|
+
recordsFiltered: items.length,
|
|
3805
|
+
recordsTotal: items.length
|
|
3806
|
+
});
|
|
3807
|
+
};
|
|
3808
|
+
/**
|
|
3809
|
+
* Undo changes
|
|
3810
|
+
*/
|
|
3811
|
+
AdvancedTableEditorDirective.prototype.undo = function () {
|
|
3812
|
+
if (this.table == null) {
|
|
3813
|
+
throw new AdvancedTableNotNullError();
|
|
3814
|
+
}
|
|
3815
|
+
// reset removed rows
|
|
3816
|
+
this.table.dataTable.rows('.removed').nodes().to$().toggleClass('removed text-gray-400 text-decoration-line-through');
|
|
3817
|
+
// remove added rows
|
|
3818
|
+
this.table.dataTable.rows('.added').remove();
|
|
3819
|
+
// clear selected items
|
|
3820
|
+
this.table.selected = [];
|
|
3821
|
+
var items = this.table.dataTable.rows().data();
|
|
3822
|
+
this.table.dataTable.draw();
|
|
3823
|
+
this.table.load.emit({
|
|
3824
|
+
data: items,
|
|
3825
|
+
recordsFiltered: items.length,
|
|
3826
|
+
recordsTotal: items.length
|
|
3827
|
+
});
|
|
3828
|
+
this.dirty = false;
|
|
3829
|
+
this.dirtyChange.emit(this.dirty);
|
|
3830
|
+
};
|
|
3831
|
+
AdvancedTableEditorDirective.prototype.rows = function () {
|
|
3832
|
+
if (this.table == null) {
|
|
3833
|
+
throw new AdvancedTableNotNullError();
|
|
3834
|
+
}
|
|
3835
|
+
return Array.from(this.table.dataTable.rows(':not(.removed)').data());
|
|
3836
|
+
};
|
|
3837
|
+
AdvancedTableEditorDirective.decorators = [
|
|
3838
|
+
{ type: i0.Directive, args: [{
|
|
3839
|
+
selector: '[tableEditor]'
|
|
3840
|
+
},] }
|
|
3841
|
+
];
|
|
3842
|
+
/** @nocollapse */
|
|
3843
|
+
AdvancedTableEditorDirective.ctorParameters = function () {
|
|
3844
|
+
return [
|
|
3845
|
+
{ type: AdvancedTableComponent }
|
|
3846
|
+
];
|
|
3847
|
+
};
|
|
3848
|
+
AdvancedTableEditorDirective.propDecorators = {
|
|
3849
|
+
dirtyChange: [{ type: i0.Output }]
|
|
3850
|
+
};
|
|
3851
|
+
return AdvancedTableEditorDirective;
|
|
3852
|
+
}());
|
|
3853
|
+
|
|
3854
|
+
var AdvancedAggregatorService = /** @class */ (function () {
|
|
3855
|
+
function AdvancedAggregatorService(_context, _template) {
|
|
3856
|
+
this._context = _context;
|
|
3857
|
+
this._template = _template;
|
|
3858
|
+
}
|
|
3859
|
+
/**
|
|
3860
|
+
*
|
|
3861
|
+
* Formats and executes the data query
|
|
3862
|
+
*
|
|
3863
|
+
* @param {string} model The target model
|
|
3864
|
+
* @param {object} fixedParams Pairs of parameters to always be applied
|
|
3865
|
+
* @param {string} queryStatement The default query to use for fetching the data (e.g. expands etc)
|
|
3866
|
+
* @param {Array<string>} filters A list of filter expressions to append at the query
|
|
3867
|
+
* @param {string} searchTemplate The template to use for searching expressions
|
|
3868
|
+
* @param {string} searchValue The value of the user search
|
|
3869
|
+
*
|
|
3870
|
+
* @returns {Promise<any>} The response of the query execution
|
|
3871
|
+
*/
|
|
3872
|
+
AdvancedAggregatorService.prototype.fetchData = function (model, fixedParams, queryStatement, filters, searchTemplate, searchValue) {
|
|
3873
|
+
if (queryStatement === void 0) {
|
|
3874
|
+
queryStatement = '';
|
|
3875
|
+
}
|
|
3876
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3877
|
+
var e_1, _a, query, filterExpressions, _b, _c, param, evaluatedSearch, words;
|
|
3878
|
+
var _this = this;
|
|
3879
|
+
return __generator(this, function (_d) {
|
|
3880
|
+
query = this._context.model(model).asQueryable();
|
|
3881
|
+
if (!fixedParams || typeof fixedParams !== 'object') {
|
|
3882
|
+
fixedParams = {};
|
|
3883
|
+
}
|
|
3884
|
+
filterExpressions = [];
|
|
3885
|
+
if (fixedParams) {
|
|
3886
|
+
try {
|
|
3887
|
+
for (_b = __values(Object.keys(fixedParams)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
3888
|
+
param = _c.value;
|
|
3889
|
+
filterExpressions.push(param + " eq " + fixedParams[param]);
|
|
3890
|
+
}
|
|
3891
|
+
}
|
|
3892
|
+
catch (e_1_1) {
|
|
3893
|
+
e_1 = { error: e_1_1 };
|
|
3894
|
+
}
|
|
3895
|
+
finally {
|
|
3896
|
+
try {
|
|
3897
|
+
if (_c && !_c.done && (_a = _b.return))
|
|
3898
|
+
_a.call(_b);
|
|
3899
|
+
}
|
|
3900
|
+
finally {
|
|
3901
|
+
if (e_1)
|
|
3902
|
+
throw e_1.error;
|
|
3903
|
+
}
|
|
3904
|
+
}
|
|
3905
|
+
}
|
|
3906
|
+
if (filters && Array.isArray(filters)) {
|
|
3907
|
+
filterExpressions = __spread(filterExpressions, filters);
|
|
3908
|
+
}
|
|
3909
|
+
if (searchTemplate && searchValue) {
|
|
3910
|
+
evaluatedSearch = void 0;
|
|
3911
|
+
if (/^"(.*?)"$/.test(searchValue)) { // validate search text in double quotes
|
|
3912
|
+
evaluatedSearch = this._template.transform(searchTemplate, __assign({}, fixedParams, { text: searchValue.replace(/^"|"$/g, '') }));
|
|
3913
|
+
}
|
|
3914
|
+
else {
|
|
3915
|
+
words = searchValue.split(' ');
|
|
3916
|
+
// join words to a single filter
|
|
3917
|
+
evaluatedSearch = words.map(function (word) {
|
|
3918
|
+
return _this._template.transform(searchTemplate, __assign({}, fixedParams, { text: word }));
|
|
3919
|
+
}).join(' and ');
|
|
3920
|
+
}
|
|
3921
|
+
filterExpressions.push(evaluatedSearch);
|
|
3922
|
+
}
|
|
3923
|
+
query.setParam('$filter', filterExpressions.join(' and '));
|
|
3924
|
+
return [2 /*return*/, query.expand(queryStatement).take(-1).getItems()];
|
|
3925
|
+
});
|
|
3926
|
+
});
|
|
3927
|
+
};
|
|
3928
|
+
/**
|
|
3929
|
+
*
|
|
3930
|
+
* Formats the received data to use flat keys
|
|
3931
|
+
*
|
|
3932
|
+
* @param config The applied configuration
|
|
3933
|
+
* @param data The raw data
|
|
3934
|
+
*
|
|
3935
|
+
* @returns {Array<any>} The flat-key object list
|
|
3936
|
+
*
|
|
3937
|
+
*/
|
|
3938
|
+
AdvancedAggregatorService.prototype.formatData = function (config, data) {
|
|
3939
|
+
try {
|
|
3940
|
+
return data.map(function (entry) {
|
|
3941
|
+
var entryObject = {};
|
|
3942
|
+
for (var i = 0; i < config.columns.length; i++) {
|
|
3943
|
+
var keys = config.columns[i].name.split('/');
|
|
3944
|
+
var helperObject = entry[keys[0]];
|
|
3945
|
+
if (helperObject && keys.length > 1) {
|
|
3946
|
+
for (var i_1 = 1; i_1 < keys.length; i_1++) {
|
|
3947
|
+
if (helperObject === undefined || helperObject === null) {
|
|
3948
|
+
break;
|
|
3949
|
+
}
|
|
3950
|
+
else {
|
|
3951
|
+
helperObject = helperObject[keys[i_1]] !== undefined && helperObject[keys[i_1]] !== null
|
|
3952
|
+
? helperObject[keys[i_1]]
|
|
3953
|
+
: undefined;
|
|
3954
|
+
}
|
|
3955
|
+
}
|
|
3956
|
+
}
|
|
3957
|
+
entryObject[config.columns[i].name] = helperObject;
|
|
3958
|
+
}
|
|
3959
|
+
if (entry.subitems) {
|
|
3960
|
+
entryObject.subitems = entry.subitems;
|
|
3961
|
+
}
|
|
3962
|
+
return entryObject;
|
|
3963
|
+
});
|
|
3964
|
+
}
|
|
3965
|
+
catch (err) {
|
|
3966
|
+
console.error(err);
|
|
3967
|
+
}
|
|
3968
|
+
};
|
|
3969
|
+
AdvancedAggregatorService.decorators = [
|
|
3970
|
+
{ type: i0.Injectable, args: [{
|
|
3971
|
+
providedIn: 'root'
|
|
3972
|
+
},] }
|
|
3973
|
+
];
|
|
3974
|
+
/** @nocollapse */
|
|
3975
|
+
AdvancedAggregatorService.ctorParameters = function () {
|
|
3976
|
+
return [
|
|
3977
|
+
{ type: i1$1.AngularDataContext },
|
|
3978
|
+
{ type: i2.TemplatePipe }
|
|
3979
|
+
];
|
|
3980
|
+
};
|
|
3981
|
+
AdvancedAggregatorService.ngInjectableDef = i0.defineInjectable({ factory: function AdvancedAggregatorService_Factory() { return new AdvancedAggregatorService(i0.inject(i1$1.AngularDataContext), i0.inject(i2.TemplatePipe)); }, token: AdvancedAggregatorService, providedIn: "root" });
|
|
3982
|
+
return AdvancedAggregatorService;
|
|
3983
|
+
}());
|
|
3984
|
+
|
|
3985
|
+
/**
|
|
3986
|
+
*
|
|
3987
|
+
* @class AdvancedAggregatorComponent
|
|
3988
|
+
* @classdesc An advanced list with the capability of aggregate data based on configurable filters
|
|
3989
|
+
*
|
|
3990
|
+
*/
|
|
3991
|
+
var AdvancedAggregatorComponent = /** @class */ (function () {
|
|
3992
|
+
function AdvancedAggregatorComponent(_changeDetector, _advancedAggregatorService, _loadingService) {
|
|
3993
|
+
this._changeDetector = _changeDetector;
|
|
3994
|
+
this._advancedAggregatorService = _advancedAggregatorService;
|
|
3995
|
+
this._loadingService = _loadingService;
|
|
3996
|
+
this.groups = [];
|
|
3997
|
+
this.eventHandler = new i0.EventEmitter();
|
|
3998
|
+
}
|
|
3999
|
+
Object.defineProperty(AdvancedAggregatorComponent.prototype, "config", {
|
|
4000
|
+
get: function () {
|
|
4001
|
+
return this._config;
|
|
4002
|
+
},
|
|
4003
|
+
set: function (value) {
|
|
4004
|
+
this._config = value;
|
|
4005
|
+
},
|
|
4006
|
+
enumerable: true,
|
|
4007
|
+
configurable: true
|
|
4008
|
+
});
|
|
4009
|
+
Object.defineProperty(AdvancedAggregatorComponent.prototype, "aggregators", {
|
|
4010
|
+
get: function () {
|
|
4011
|
+
return this._aggregators;
|
|
4012
|
+
},
|
|
4013
|
+
set: function (value) {
|
|
4014
|
+
this._aggregators = value;
|
|
4015
|
+
},
|
|
4016
|
+
enumerable: true,
|
|
4017
|
+
configurable: true
|
|
4018
|
+
});
|
|
4019
|
+
Object.defineProperty(AdvancedAggregatorComponent.prototype, "postProcessors", {
|
|
4020
|
+
get: function () {
|
|
4021
|
+
return this._postProcessors;
|
|
4022
|
+
},
|
|
4023
|
+
set: function (value) {
|
|
4024
|
+
this._postProcessors = value;
|
|
4025
|
+
},
|
|
4026
|
+
enumerable: true,
|
|
4027
|
+
configurable: true
|
|
4028
|
+
});
|
|
4029
|
+
AdvancedAggregatorComponent.prototype.ngOnInit = function () {
|
|
4030
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4031
|
+
var _this = this;
|
|
4032
|
+
return __generator(this, function (_a) {
|
|
4033
|
+
this.selectedGroups$.subscribe(function (data) {
|
|
4034
|
+
_this.groups = data;
|
|
4035
|
+
_this._changeDetector.markForCheck();
|
|
4036
|
+
});
|
|
4037
|
+
this.filters$.subscribe(function (filters) {
|
|
4038
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
4039
|
+
var err_1;
|
|
4040
|
+
return __generator(this, function (_a) {
|
|
4041
|
+
switch (_a.label) {
|
|
4042
|
+
case 0:
|
|
4043
|
+
_a.trys.push([0, 2, , 3]);
|
|
4044
|
+
return [4 /*yield*/, this.fetch(filters)];
|
|
4045
|
+
case 1:
|
|
4046
|
+
_a.sent();
|
|
4047
|
+
return [3 /*break*/, 3];
|
|
4048
|
+
case 2:
|
|
4049
|
+
err_1 = _a.sent();
|
|
4050
|
+
console.error(err_1);
|
|
4051
|
+
return [3 /*break*/, 3];
|
|
4052
|
+
case 3: return [2 /*return*/];
|
|
4053
|
+
}
|
|
4054
|
+
});
|
|
4055
|
+
});
|
|
4056
|
+
});
|
|
4057
|
+
return [2 /*return*/];
|
|
4058
|
+
});
|
|
4059
|
+
});
|
|
4060
|
+
};
|
|
4061
|
+
AdvancedAggregatorComponent.prototype.ngOnDestroy = function () {
|
|
4062
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4063
|
+
return __generator(this, function (_a) {
|
|
4064
|
+
this.selectedGroups$.unsubscribe();
|
|
4065
|
+
this.filters$.unsubscribe();
|
|
4066
|
+
return [2 /*return*/];
|
|
4067
|
+
});
|
|
4068
|
+
});
|
|
4069
|
+
};
|
|
4070
|
+
/**
|
|
4071
|
+
*
|
|
4072
|
+
* Retrieves the data
|
|
4073
|
+
*
|
|
4074
|
+
*/
|
|
4075
|
+
AdvancedAggregatorComponent.prototype.fetch = function (filters) {
|
|
4076
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4077
|
+
var data, i, err_2;
|
|
4078
|
+
return __generator(this, function (_a) {
|
|
4079
|
+
switch (_a.label) {
|
|
4080
|
+
case 0:
|
|
4081
|
+
_a.trys.push([0, 6, 7, 8]);
|
|
4082
|
+
this._loadingService.showLoading();
|
|
4083
|
+
return [4 /*yield*/, this._advancedAggregatorService.fetchData(this.config.model, this.params, this.config.query, filters.filters, this.searchExpression, filters.text)];
|
|
4084
|
+
case 1:
|
|
4085
|
+
data = _a.sent();
|
|
4086
|
+
if (!(this.postProcessors && Object.keys(this.postProcessors).length > 0 && this.config.postProcessors && this.config.postProcessors.length > 0))
|
|
4087
|
+
return [3 /*break*/, 5];
|
|
4088
|
+
i = 0;
|
|
4089
|
+
_a.label = 2;
|
|
4090
|
+
case 2:
|
|
4091
|
+
if (!(i < this.config.postProcessors.length))
|
|
4092
|
+
return [3 /*break*/, 5];
|
|
4093
|
+
return [4 /*yield*/, this.postProcessors[this.config.postProcessors[i].name](data)];
|
|
4094
|
+
case 3:
|
|
4095
|
+
data = _a.sent();
|
|
4096
|
+
_a.label = 4;
|
|
4097
|
+
case 4:
|
|
4098
|
+
i++;
|
|
4099
|
+
return [3 /*break*/, 2];
|
|
4100
|
+
case 5:
|
|
4101
|
+
this.body = this._advancedAggregatorService.formatData(this.config, data);
|
|
4102
|
+
this._changeDetector.markForCheck();
|
|
4103
|
+
return [3 /*break*/, 8];
|
|
4104
|
+
case 6:
|
|
4105
|
+
err_2 = _a.sent();
|
|
4106
|
+
console.error(err_2);
|
|
4107
|
+
return [3 /*break*/, 8];
|
|
4108
|
+
case 7:
|
|
4109
|
+
this._loadingService.hideLoading();
|
|
4110
|
+
return [7 /*endfinally*/];
|
|
4111
|
+
case 8: return [2 /*return*/];
|
|
4112
|
+
}
|
|
4113
|
+
});
|
|
4114
|
+
});
|
|
4115
|
+
};
|
|
4116
|
+
/**
|
|
4117
|
+
*
|
|
4118
|
+
* Triggers the event handler event
|
|
4119
|
+
*
|
|
4120
|
+
* @param {*} event The event data
|
|
4121
|
+
*
|
|
4122
|
+
*/
|
|
4123
|
+
AdvancedAggregatorComponent.prototype.onActionEvent = function (event) {
|
|
4124
|
+
this.eventHandler.emit(event);
|
|
4125
|
+
};
|
|
4126
|
+
AdvancedAggregatorComponent.decorators = [
|
|
4127
|
+
{ type: i0.Component, args: [{
|
|
4128
|
+
selector: 'app-advanced-aggregator',
|
|
4129
|
+
template: "<ng-container *ngIf=\"config && body\">\n <div class=\"w-100 text-center\" *ngIf=\"body && body.length === 0\">\n <div>\n <div class=\"mt-4\">\n <div class=\"icon-circle bg-gray-300 border-gray-100\"></div>\n </div>\n <div class=\"mt-4\">\n <h4 class=\"font-3xl text-dark\" [translate]=\"'Tables.EmptyTableTitle'\"></h4>\n <p class=\"font-lg text-dark\" [translate]=\"'Tables.EmptyTableMessage'\"></p>\n </div>\n </div>\n </div>\n <ng-container *ngIf=\"groups.length === 0\">\n <div class=\"row mt-4\">\n <app-advanced-aggregator-list [body]=\"body\" [config]=\"config\" (clickEvent)=\"onActionEvent($event)\" class=\"col-12\">\n </app-advanced-aggregator-list>\n <div *ngIf=\"config.aggregators && config.aggregators.length > 0\"\n class=\"footer-text text-dark font-weight-normal text-right font-sm mt-3 mr-2 w-100\">\n <div *ngFor=\"let aggregator of config.aggregators\">\n <span *ngIf=\"aggregator.label\"> {{ aggregator.label | translate }} </span>:\n <span class=\"font-weight-bold\"> {{ body | callAggregator: aggregators: aggregator.name }}\n </span>\n </div>\n </div>\n </div>\n </ng-container>\n <ng-container *ngIf=\"groups.length === 1\">\n <ng-container *ngFor=\"let group of body | groupBy: groups[0].name | keyvalue\">\n <div class=\"row mt-4\">\n <h4 class=\"col text-secondary\"> {{ groups[0].title | aggregatorListTitle: group.key }} </h4>\n <app-advanced-aggregator-list [body]=\"group.value\" [config]=\"config\" (clickEvent)=\"onActionEvent($event)\"\n class=\"col-12\">\n </app-advanced-aggregator-list>\n </div>\n\n <!-- Footer for the group -->\n <div *ngIf=\"config.aggregators && config.aggregators.length > 0\"\n class=\"footer-text text-dark font-weight-normal text-right font-sm mt-3 mr-2 w-100\">\n <div *ngFor=\"let aggregator of config.aggregators\">\n <span *ngIf=\"aggregator.label\"> {{ aggregator.label | translate }} </span>:\n <span class=\"font-weight-bold\"> {{ group.value | callAggregator: aggregators: aggregator.name }} </span>\n </div>\n </div>\n </ng-container>\n </ng-container>\n <ng-container *ngIf=\"groups.length > 1\">\n <ng-container *ngFor=\"let group of body | groupBy: groups[0].name | keyvalue\">\n <div class=\"row mt-4\">\n <h4 class=\"col text-secondary\"> {{ groups[0].title | aggregatorListTitle: group.key }} </h4>\n <div *ngFor=\"let subgroup of group.value | groupBy: groups[1].name | keyvalue\" class=\"col-12 ml-4 pl-4\">\n <div class=\"row mt-4\">\n <h6 class=\"col-12 text-secondary\"> {{ groups[1].title | aggregatorListTitle: subgroup.key }} </h6>\n <app-advanced-aggregator-list [body]=\"subgroup.value\" [config]=\"config\" (clickEvent)=\"onActionEvent($event)\"\n class=\"col-12\">\n </app-advanced-aggregator-list>\n </div>\n\n <!-- Footer for each subgroup -->\n <div *ngIf=\"config.aggregators && config.aggregators.length > 0\"\n class=\"footer-text text-dark font-weight-normal text-right font-sm mt-3 mr-2 w-100\">\n <div *ngFor=\"let aggregator of config.aggregators\">\n <span *ngIf=\"aggregator.label\"> {{ aggregator.label | translate }} </span>:\n <span class=\"font-weight-bold\"> {{ subgroup.value | callAggregator: aggregators: aggregator.name }}\n </span>\n </div>\n </div>\n </div>\n </div>\n </ng-container>\n </ng-container>\n</ng-container>",
|
|
4130
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
4131
|
+
}] }
|
|
4132
|
+
];
|
|
4133
|
+
/** @nocollapse */
|
|
4134
|
+
AdvancedAggregatorComponent.ctorParameters = function () {
|
|
4135
|
+
return [
|
|
4136
|
+
{ type: i0.ChangeDetectorRef },
|
|
4137
|
+
{ type: AdvancedAggregatorService },
|
|
4138
|
+
{ type: i2.LoadingService }
|
|
4139
|
+
];
|
|
4140
|
+
};
|
|
4141
|
+
AdvancedAggregatorComponent.propDecorators = {
|
|
4142
|
+
config: [{ type: i0.Input, args: ['config',] }],
|
|
4143
|
+
aggregators: [{ type: i0.Input, args: ['aggregators',] }],
|
|
4144
|
+
postProcessors: [{ type: i0.Input, args: ['postProcessors',] }],
|
|
4145
|
+
params: [{ type: i0.Input, args: ['params',] }],
|
|
4146
|
+
selectedGroups$: [{ type: i0.Input, args: ['selectedGroups',] }],
|
|
4147
|
+
filters$: [{ type: i0.Input, args: ['filters',] }],
|
|
4148
|
+
searchExpression: [{ type: i0.Input, args: ['searchExpression',] }],
|
|
4149
|
+
eventHandler: [{ type: i0.Output }]
|
|
4150
|
+
};
|
|
4151
|
+
return AdvancedAggregatorComponent;
|
|
4152
|
+
}());
|
|
4153
|
+
|
|
4154
|
+
var Lengths;
|
|
4155
|
+
(function (Lengths) {
|
|
4156
|
+
Lengths["XL"] = "xl";
|
|
4157
|
+
Lengths["LG"] = "lg";
|
|
4158
|
+
Lengths["MD"] = "md";
|
|
4159
|
+
Lengths["SM"] = "sm";
|
|
4160
|
+
Lengths["XS"] = "xs";
|
|
4161
|
+
})(Lengths || (Lengths = {}));
|
|
4162
|
+
var AdvancedAggregatorListComponent = /** @class */ (function () {
|
|
4163
|
+
function AdvancedAggregatorListComponent(_template) {
|
|
4164
|
+
this._template = _template;
|
|
4165
|
+
this.clickEvent = new i0.EventEmitter();
|
|
4166
|
+
}
|
|
4167
|
+
AdvancedAggregatorListComponent.prototype.ngOnInit = function () {
|
|
4168
|
+
var _this = this;
|
|
4169
|
+
this.config.columns.forEach(function (x) {
|
|
4170
|
+
x.length = Object.values(Lengths).includes(x.length) ? _this._template.transform("sis--list-group-item_" + x.length + "_column", x) :
|
|
4171
|
+
!x.length ? 'sis--list-group-item_sm_column' : x.length;
|
|
4172
|
+
});
|
|
4173
|
+
};
|
|
4174
|
+
/**
|
|
4175
|
+
*
|
|
4176
|
+
* Triggers the output event emitter
|
|
4177
|
+
*
|
|
4178
|
+
* @param type The type of the event as it's declared in the configuration
|
|
4179
|
+
* @param item The value of the current item
|
|
4180
|
+
* }
|
|
4181
|
+
*/
|
|
4182
|
+
AdvancedAggregatorListComponent.prototype.callCallback = function (type, data) {
|
|
4183
|
+
this.clickEvent.emit({
|
|
4184
|
+
type: type,
|
|
4185
|
+
data: data
|
|
4186
|
+
});
|
|
4187
|
+
};
|
|
4188
|
+
AdvancedAggregatorListComponent.decorators = [
|
|
4189
|
+
{ type: i0.Component, args: [{
|
|
4190
|
+
selector: 'app-advanced-aggregator-list',
|
|
4191
|
+
template: "<div id=\"group-list\" class=\"flex-column\" *ngIf=\"config && config.columns\">\n <ul class=\"sis--list-group sis--list-group-header\">\n <li class=\"sis--list-group-item text-wrap\">\n <div class=\"d-flex justify-content-center align-items-center\" *ngIf=\"body && body.length > 0\">\n <div *ngIf=\"config.actions && config.actions.length > 0\" class=\"sis--list-group-item_sm_column\"></div>\n <div *ngFor=\"let column of config.columns; let i = index\" class=\"text-left\"\n [class]=\"config.columns[i].length\"\n [translate]=\"config.columns[i].type === 'action' ? '' : column.title\" [ngClass]=\"{\n 'd-none': config.columns[i].hidden\n }\"></div>\n </div>\n </li>\n </ul>\n\n <!-- The list of entries -->\n <ul class=\"sis--list-group sis--list-group-body\" *ngIf=\"body && body.length > 0\">\n <li class=\"sis--list-group-item text-wrap\" *ngFor=\"let entry of body | orderBy: config.orderBy\">\n <div class=\"d-flex justify-content-center align-items-center list-color\">\n <!-- The list of actions -->\n <div *ngIf=\"config.actions && config.actions.length > 0\" class=\"sis--list-group-item_sm_column text-left pr-0\">\n <button *ngFor=\"let action of config.actions\" (click)=\"callCallback(action.identifier, entry)\"\n [title]=\"(action.title ? action.title : '') | translate \" class=\"btn btn-default px-0\">\n <i [class]=\"'fas text-indigo ml-2 ' + 'fa-' + action.icon\"></i>\n </button>\n </div>\n <!-- The list of data -->\n <div *ngFor=\"let column of config.columns; let i=index\" [class]=\"config.columns[i].length\" class=\"text-left\"\n [ngClass]=\"{\n 'text-truncate': config.columns[i].hasOwnProperty('truncate') && config.columns[i].truncate,\n 'd-none': config.columns[i].hidden,\n 'd-md-block': !config.columns[i].hidden\n }\"\n [title]=\"config.columns[i].hasOwnProperty('truncate') && config.columns[i].truncate ? entry[column.name] : ''\">\n <span class=\"text-secondary\"\n *ngIf=\"!config.columns[i].hasOwnProperty('type') || (config.columns[i].hasOwnProperty('type') && config.columns[i].type === 'text')\"\n [ngClass]=\"{\n 'font-xs': config.columns[i].variant !== 'primary',\n 'text-body': config.columns[i].variant === 'primary',\n 'text-success': config.columns[i].variant === 'redGreen' && config.columns[i].hasOwnProperty('condition') && entry[config.columns[i].condition],\n 'text-danger': config.columns[i].variant === 'redGreen' && config.columns[i].hasOwnProperty('condition') && !entry[config.columns[i].condition],\n 'font-lg': config.columns[i].variant === 'redGreen' && entry[column.name] && entry[column.name].length > 3,\n 'font-2xl': config.columns[i].variant === 'redGreen' && entry[column.name] && entry[column.name].length <= 3\n }\">\n {{entry[column.name] || '-'}}\n </span>\n\n <span *ngIf=\"config.columns[i].type === 'boolean'\">\n <i class=\"fa font-lg\" [ngClass]=\"{\n 'fa-check text-success': entry[column.name].toString() === config.columns[i].trueValue,\n 'fa-times text-danger': entry[column.name].toString() !== config.columns[i].trueValue && config.columns[i].variant !== 'checkOrDash'\n }\"></i>\n <span\n *ngIf=\"entry[column.name].toString() !== config.columns[i].trueValue && config.columns[i].variant === 'checkOrDash'\"\n class=\"text-secondary font-xs\">-</span>\n </span>\n </div>\n </div>\n <ul *ngIf=\"entry && entry.subitems\">\n <li *ngFor=\"let subitem of entry.subitems\" class=\"d-flex justify-content-center align-items-center list-color\">\n <div class=\"text-left\"></div>\n <div *ngFor=\"let column of config.columns; let i=index\" [class]=\"config.column[i].length\" class=\"text-left\"\n [ngClass]=\"{\n 'text-truncate': config.columns[i].hasOwnProperty('truncate') && config.columns[i].truncate,\n 'd-none': config.columns[i].hidden,\n 'd-md-block': !config.columns[i].hidden\n }\"\n [title]=\"config.columns[i].hasOwnProperty('truncate') && config.columns[i].truncate ? entry[column.name] : ''\">\n <span class=\"text-secondary\"\n *ngIf=\"!config.columns[i].hasOwnProperty('type') || (config.columns[i].hasOwnProperty('type') && config.columns[i].type === 'text')\"\n [ngClass]=\"{\n 'font-xs': config.columns[i].variant !== 'primary',\n 'text-body': config.columns[i].variant === 'primary',\n 'text-success': config.columns[i].variant === 'redGreen' && config.columns[i].hasOwnProperty('condition') && subitem[config.columns[i].condition],\n 'text-danger': config.columns[i].variant === 'redGreen' && config.columns[i].hasOwnProperty('condition') && !subitem[config.columns[i].condition],\n 'font-lg': config.columns[i].variant === 'redGreen' && subitem[column.name] && subitem[column.name].length > 3,\n 'font-2xl': config.columns[i].variant === 'redGreen' && subitem[column.name] && subitem[column.name].length <= 3\n }\">\n {{subitem[column.name] || '-'}}\n </span>\n </div>\n </li>\n </ul>\n </li>\n </ul>\n</div>\n"
|
|
4192
|
+
}] }
|
|
4193
|
+
];
|
|
4194
|
+
/** @nocollapse */
|
|
4195
|
+
AdvancedAggregatorListComponent.ctorParameters = function () {
|
|
4196
|
+
return [
|
|
4197
|
+
{ type: i2.TemplatePipe }
|
|
4198
|
+
];
|
|
4199
|
+
};
|
|
4200
|
+
AdvancedAggregatorListComponent.propDecorators = {
|
|
4201
|
+
config: [{ type: i0.Input }],
|
|
4202
|
+
body: [{ type: i0.Input }],
|
|
4203
|
+
clickEvent: [{ type: i0.Output }]
|
|
4204
|
+
};
|
|
4205
|
+
return AdvancedAggregatorListComponent;
|
|
4206
|
+
}());
|
|
4207
|
+
|
|
4208
|
+
/**
|
|
4209
|
+
*
|
|
4210
|
+
* @class AdvancedAggregatorPipe
|
|
4211
|
+
* @classdesc Given a list of items runs a user defined function against that list
|
|
4212
|
+
*
|
|
4213
|
+
*/
|
|
4214
|
+
var AdvancedAggregatorPipe = /** @class */ (function () {
|
|
4215
|
+
function AdvancedAggregatorPipe() {
|
|
4216
|
+
}
|
|
4217
|
+
/**
|
|
4218
|
+
*
|
|
4219
|
+
* @override
|
|
4220
|
+
*
|
|
4221
|
+
* @param items The list of items to run the aggregator against
|
|
4222
|
+
* @param functionPool The functions that are available from the list caller
|
|
4223
|
+
* @param functionName The name of the function to be called
|
|
4224
|
+
*
|
|
4225
|
+
* @returns {string} The value to show at the UI
|
|
4226
|
+
*
|
|
4227
|
+
*/
|
|
4228
|
+
AdvancedAggregatorPipe.prototype.transform = function (items, functionPool, functionName) {
|
|
4229
|
+
if (Array.isArray(items) && functionName && functionName in functionPool) {
|
|
4230
|
+
return functionPool[functionName](items);
|
|
4231
|
+
}
|
|
4232
|
+
else {
|
|
4233
|
+
return '-';
|
|
4234
|
+
}
|
|
4235
|
+
};
|
|
4236
|
+
AdvancedAggregatorPipe.decorators = [
|
|
4237
|
+
{ type: i0.Pipe, args: [{
|
|
4238
|
+
name: 'callAggregator'
|
|
4239
|
+
},] }
|
|
4240
|
+
];
|
|
4241
|
+
return AdvancedAggregatorPipe;
|
|
4242
|
+
}());
|
|
4243
|
+
|
|
4244
|
+
/**
|
|
4245
|
+
*
|
|
4246
|
+
* @class ParseTitlePipe
|
|
4247
|
+
* @classdesc Given a title of an aggregator list, translates and evaluates the parameter if any
|
|
4248
|
+
*
|
|
4249
|
+
*/
|
|
4250
|
+
var ParseTitlePipe = /** @class */ (function () {
|
|
4251
|
+
function ParseTitlePipe(_translateService) {
|
|
4252
|
+
this._translateService = _translateService;
|
|
4253
|
+
}
|
|
4254
|
+
/**
|
|
4255
|
+
*
|
|
4256
|
+
* @override
|
|
4257
|
+
*
|
|
4258
|
+
* @param {string} title The title of the list
|
|
4259
|
+
* @param {string} key The current list key that is being used
|
|
4260
|
+
*
|
|
4261
|
+
*/
|
|
4262
|
+
ParseTitlePipe.prototype.transform = function (title, key) {
|
|
4263
|
+
var _this = this;
|
|
4264
|
+
if (!title) {
|
|
4265
|
+
return '';
|
|
4266
|
+
}
|
|
4267
|
+
else {
|
|
4268
|
+
if (key === undefined || key === null || key === 'undefined' || key === 'null') {
|
|
4269
|
+
key = this._translateService.instant('Tables.NotDefined');
|
|
4270
|
+
}
|
|
4271
|
+
return title.split(' ')
|
|
4272
|
+
.map(function (part) { return _this._translateService.instant(part); })
|
|
4273
|
+
.map(function (part) { return part.replace('${param}', key); })
|
|
4274
|
+
.join(' ');
|
|
4275
|
+
}
|
|
4276
|
+
};
|
|
4277
|
+
ParseTitlePipe.decorators = [
|
|
4278
|
+
{ type: i0.Pipe, args: [{
|
|
4279
|
+
name: 'aggregatorListTitle'
|
|
4280
|
+
},] }
|
|
4281
|
+
];
|
|
4282
|
+
/** @nocollapse */
|
|
4283
|
+
ParseTitlePipe.ctorParameters = function () {
|
|
4284
|
+
return [
|
|
4285
|
+
{ type: core.TranslateService }
|
|
4286
|
+
];
|
|
4287
|
+
};
|
|
4288
|
+
return ParseTitlePipe;
|
|
4289
|
+
}());
|
|
4290
|
+
|
|
4291
|
+
var AddItemsComponent = /** @class */ (function (_super) {
|
|
4292
|
+
__extends(AddItemsComponent, _super);
|
|
4293
|
+
function AddItemsComponent(router, activatedRoute, _errorService, _modalService, _appEvent, _toastService, _loadingService, _translateService, _context) {
|
|
4294
|
+
var _this = _super.call(this, router, activatedRoute) || this;
|
|
4295
|
+
_this._errorService = _errorService;
|
|
4296
|
+
_this._modalService = _modalService;
|
|
4297
|
+
_this._appEvent = _appEvent;
|
|
4298
|
+
_this._toastService = _toastService;
|
|
4299
|
+
_this._loadingService = _loadingService;
|
|
4300
|
+
_this._translateService = _translateService;
|
|
4301
|
+
_this._context = _context;
|
|
4302
|
+
_this.loading = false;
|
|
4303
|
+
_this.items = [];
|
|
4304
|
+
_this.messages = [];
|
|
4305
|
+
// set modal size
|
|
4306
|
+
_this.modalClass = 'modal-lg';
|
|
4307
|
+
_this.okButtonDisabled = true;
|
|
4308
|
+
return _this;
|
|
4309
|
+
}
|
|
4310
|
+
AddItemsComponent.prototype.ngOnInit = function () {
|
|
4311
|
+
var _this = this;
|
|
4312
|
+
this.selectedSubscription = this.selectComponent.advancedTable.selectedItems.subscribe(function (items) {
|
|
4313
|
+
if (_this.formName == null) {
|
|
4314
|
+
_this.okButtonDisabled = items.length === 0;
|
|
4315
|
+
}
|
|
4316
|
+
});
|
|
4317
|
+
if (this.formName != null) {
|
|
4318
|
+
this.formChangeSubscription = this.formComponent.form.change.subscribe(function (event) {
|
|
4319
|
+
if (Object.prototype.hasOwnProperty.call(event, 'isValid')) {
|
|
4320
|
+
// enable or disable button based on form status
|
|
4321
|
+
_this.okButtonDisabled = (!event.isValid);
|
|
4322
|
+
}
|
|
4323
|
+
});
|
|
4324
|
+
}
|
|
4325
|
+
if (this.target) {
|
|
4326
|
+
var target = this.target;
|
|
4327
|
+
}
|
|
4328
|
+
};
|
|
4329
|
+
AddItemsComponent.prototype.cancel = function () {
|
|
4330
|
+
this.clearMessages();
|
|
4331
|
+
if (this.loading) {
|
|
4332
|
+
return;
|
|
4333
|
+
}
|
|
4334
|
+
// close
|
|
4335
|
+
if (this._modalService.modalRef) {
|
|
4336
|
+
return this._modalService.modalRef.hide();
|
|
4337
|
+
}
|
|
4338
|
+
};
|
|
4339
|
+
AddItemsComponent.prototype.ngOnDestroy = function () {
|
|
4340
|
+
if (this.formLoadSubscription) {
|
|
4341
|
+
this.formLoadSubscription.unsubscribe();
|
|
4342
|
+
}
|
|
4343
|
+
if (this.formChangeSubscription) {
|
|
4344
|
+
this.formChangeSubscription.unsubscribe();
|
|
4345
|
+
}
|
|
4346
|
+
if (this.selectedSubscription) {
|
|
4347
|
+
this.selectedSubscription.unsubscribe();
|
|
4348
|
+
}
|
|
4349
|
+
};
|
|
4350
|
+
Object.defineProperty(AddItemsComponent.prototype, "formData", {
|
|
4351
|
+
get: function () {
|
|
4352
|
+
if (this.formComponent === null) {
|
|
4353
|
+
return null;
|
|
4354
|
+
}
|
|
4355
|
+
return this.formComponent.form.formio.data;
|
|
4356
|
+
},
|
|
4357
|
+
enumerable: true,
|
|
4358
|
+
configurable: true
|
|
4359
|
+
});
|
|
4360
|
+
AddItemsComponent.prototype.ok = function () {
|
|
4361
|
+
var _this = this;
|
|
4362
|
+
try {
|
|
4363
|
+
this.clearMessages();
|
|
4364
|
+
return new Promise(function (resolve, reject) {
|
|
4365
|
+
_this.loading = false;
|
|
4366
|
+
_this.lastError = null;
|
|
4367
|
+
// set courses
|
|
4368
|
+
_this.items = _this.selectComponent.advancedTable.selected;
|
|
4369
|
+
// execute add
|
|
4370
|
+
_this.executeSubscription = _this.execute.subscribe(function (result) {
|
|
4371
|
+
_this.loading = false;
|
|
4372
|
+
if (_this.executeSubscription) {
|
|
4373
|
+
_this.executeSubscription.unsubscribe();
|
|
4374
|
+
}
|
|
4375
|
+
// close modal
|
|
4376
|
+
if (_this._modalService.modalRef) {
|
|
4377
|
+
_this._modalService.modalRef.hide();
|
|
4378
|
+
}
|
|
4379
|
+
return resolve();
|
|
4380
|
+
}, function (err) {
|
|
4381
|
+
_this.loading = false;
|
|
4382
|
+
// ensure that loading is hidden
|
|
4383
|
+
_this._loadingService.hideLoading();
|
|
4384
|
+
// set last error
|
|
4385
|
+
_this.lastError = err;
|
|
4386
|
+
return resolve();
|
|
4387
|
+
});
|
|
4388
|
+
});
|
|
4389
|
+
}
|
|
4390
|
+
catch (err) {
|
|
4391
|
+
this.loading = false;
|
|
4392
|
+
this._loadingService.hideLoading();
|
|
4393
|
+
this.lastError = err;
|
|
4394
|
+
}
|
|
4395
|
+
};
|
|
4396
|
+
AddItemsComponent.prototype.onChange = function ($event) { };
|
|
4397
|
+
AddItemsComponent.prototype.clearMessages = function () {
|
|
4398
|
+
this.messages = [];
|
|
4399
|
+
};
|
|
4400
|
+
AddItemsComponent.prototype.onFilterChange = function (event) { };
|
|
4401
|
+
AddItemsComponent.decorators = [
|
|
4402
|
+
{ type: i0.Component, args: [{
|
|
4403
|
+
selector: 'app-add-items',
|
|
4404
|
+
template: "<div>\n <div class=\"modal-header\" *ngIf=\"modalTitle\">\n <h5 class=\"modal-title\">{{modalTitle | translate}}</h5>\n <button (click)=\"cancel()\" [disabled]=\"loading\"\n type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Cancel\">\n <span aria-hidden=\"true\">×</span>\n </button>\n </div>\n <div class=\"modal-body pt-0\">\n <div class=\"row\" *ngIf=\"lastError\">\n <div class=\"alert alert-danger col-12\" role=\"alert\">\n <span [translate]=\"'E' + (lastError.statusCode || 500) + '.title'\"></span><br>\n <small *ngIf=\"lastError.statusCode >= 0\" [translate]=\"'E' + (lastError.statusCode || 500) + '.message'\"></small>\n <small *ngIf=\"lastError.statusCode == null\">{{lastError.message}}</small>\n </div>\n </div>\n <div class=\"row d-none\" *ngIf=\"items\">\n <div class=\"col-12\">\n <p [translate]=\"'StudyPrograms.AddCoursesHelp'\" [translateParams]=\"items\" ></p>\n </div>\n </div>\n <div class=\"row mt-3\">\n <div class=\"col-12\">\n <ng-container>\n <ul style=\"margin-left: -24px\" class=\"nav nav-tabs mb-1\" id=\"myTab\" role=\"tablist\">\n <li class=\"nav-item\" *ngIf=\"tableConfiguration\">\n <a class=\"nav-link active\" id=\"courses-tab\" data-toggle=\"tab\" href=\"#courses\" role=\"tab\" aria-controls=\"home\" aria-selected=\"true\" [translate]=\"'AddItems.SelectCourses'\" ></a>\n </li>\n <li class=\"nav-item\" *ngIf=\"formName\">\n <a class=\"nav-link\" [ngClass]=\"{ 'disabled': !(selectComponent.advancedTable.selected && selectComponent.advancedTable.selected.length) }\" id=\"attributes-tab\" data-toggle=\"tab\" href=\"#attributes\" role=\"tab\" aria-controls=\"profile\" aria-selected=\"false\" [translate]=\"'AddItems.EditAttributes'\"></a>\n </li>\n <li class=\"nav-item\" *ngIf=\"messages && messages.length > 0\">\n <a class=\"nav-link\" id=\"messages-tab\" data-toggle=\"tab\" href=\"#messages\" role=\"tab\" aria-controls=\"profile\" aria-selected=\"false\" [translate]=\"'AddItems.Messages'\"></a>\n </li>\n </ul>\n <div class=\"tab-content border-0\" id=\"myTabContent\">\n <div class=\"tab-pane fade show active\" id=\"courses\" role=\"tabpanel\" aria-labelledby=\"home-tab\">\n <app-advanced-table-modal #selectComponent (filter)=\"onFilterChange($event)\" [tableConfig]=\"tableConfiguration\"></app-advanced-table-modal>\n </div>\n <div class=\"tab-pane fade\" id=\"attributes\" role=\"tabpanel\" aria-labelledby=\"profile-tab\"\n [ngClass]=\"{'invisible':(formName == null)}\">\n<!-- <advanced-form-edit #formComponent [formName]=\"formName\" ></advanced-form-edit>-->\n </div>\n <div class=\"tab-pane fade\" id=\"messages\" role=\"tabpanel\" aria-labelledby=\"profile-tab\"\n [ngClass]=\"{'invisible':(messages == null)}\">\n <ul *ngIf=\"messages && messages.length>0\" class=\"sis--list-group sis--list-group-header\">\n <li class=\"sis--list-group-item\">\n <div class=\"d-flex justify-content-center align-items-center\">\n <div class=\"sis--list-group-item_lg_column\" [translate]=\"'AddItems.Messages'\"></div>\n </div>\n </li>\n </ul>\n <ul class=\"sis--list-group sis--list-group-body\">\n <li *ngFor=\"let message of messages\" class=\"sis--list-group-item\">\n <div class=\"d-flex justify-content-center align-items-center list-color\">\n <div class=\"sis--list-group-item_lg_column\">{{ message?.message }}</div>\n </div>\n </li>\n </ul>\n <div *ngIf=\"messages && messages.length>0\">\n <button [disabled]=\"loading\" (click)=\"clearMessages()\" type=\"button\" class=\"btn btn-indigo mt-3\">\n {{'Clear' | translate}}\n </button>\n </div>\n </div>\n </div>\n </ng-container>\n </div>\n </div>\n </div>\n <div class=\"modal-footer justify-content-end\">\n <button [disabled]=\"okButtonDisabled || loading || !(selectComponent.advancedTable.selected && selectComponent.advancedTable.selected.length) \" (click)=\"ok()\"\n type=\"button\" [ngClass]=\"okButtonClass\">\n {{'OK' | translate}}\n </button>\n <button [disabled]=\"cancelButtonDisabled || loading\"\n (click)=\"cancel()\" type=\"button\" [ngClass]=\"cancelButtonClass\" data-dismiss=\"modal\">\n {{'Cancel' | translate}}\n </button>\n </div>\n</div>\n"
|
|
4405
|
+
}] }
|
|
4406
|
+
];
|
|
4407
|
+
/** @nocollapse */
|
|
4408
|
+
AddItemsComponent.ctorParameters = function () {
|
|
4409
|
+
return [
|
|
4410
|
+
{ type: i1.Router },
|
|
4411
|
+
{ type: i1.ActivatedRoute },
|
|
4412
|
+
{ type: i2.ErrorService },
|
|
4413
|
+
{ type: i2.ModalService },
|
|
4414
|
+
{ type: i2.AppEventService },
|
|
4415
|
+
{ type: i2.ToastService },
|
|
4416
|
+
{ type: i2.LoadingService },
|
|
4417
|
+
{ type: core.TranslateService },
|
|
4418
|
+
{ type: i1$1.AngularDataContext }
|
|
4419
|
+
];
|
|
4420
|
+
};
|
|
4421
|
+
AddItemsComponent.propDecorators = {
|
|
4422
|
+
execute: [{ type: i0.Input }],
|
|
4423
|
+
items: [{ type: i0.Input }],
|
|
4424
|
+
target: [{ type: i0.Input }],
|
|
4425
|
+
tableConfiguration: [{ type: i0.Input }],
|
|
4426
|
+
formName: [{ type: i0.Input }],
|
|
4427
|
+
messages: [{ type: i0.Input }],
|
|
4428
|
+
formComponent: [{ type: i0.ViewChild, args: ['formComponent',] }],
|
|
4429
|
+
selectComponent: [{ type: i0.ViewChild, args: ['selectComponent',] }]
|
|
4430
|
+
};
|
|
4431
|
+
return AddItemsComponent;
|
|
4432
|
+
}(routing.RouterModalOkCancel));
|
|
4433
|
+
|
|
4434
|
+
var ɵ0 = FORMATTERS;
|
|
4435
|
+
var TablesModule = /** @class */ (function () {
|
|
4436
|
+
function TablesModule(_translateService) {
|
|
4437
|
+
this._translateService = _translateService;
|
|
4438
|
+
this.ngOnInit().catch(function (err) {
|
|
4439
|
+
console.error('An error occurred while loading tables module');
|
|
4440
|
+
console.error(err);
|
|
4441
|
+
});
|
|
4442
|
+
}
|
|
4443
|
+
TablesModule.prototype.ngOnInit = function () {
|
|
4444
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4445
|
+
return __generator(this, function (_a) {
|
|
4446
|
+
this._translateService.setTranslation('en', TABLES_EN, true);
|
|
4447
|
+
this._translateService.setTranslation('el', TABLES_EL, true);
|
|
4448
|
+
return [2 /*return*/];
|
|
4449
|
+
});
|
|
4450
|
+
});
|
|
4451
|
+
};
|
|
4452
|
+
TablesModule.decorators = [
|
|
4453
|
+
{ type: i0.NgModule, args: [{
|
|
4454
|
+
imports: [
|
|
4455
|
+
common.CommonModule,
|
|
4456
|
+
i2.SharedModule,
|
|
4457
|
+
core.TranslateModule,
|
|
4458
|
+
forms.FormsModule,
|
|
4459
|
+
forms.ReactiveFormsModule,
|
|
4460
|
+
i1.RouterModule,
|
|
4461
|
+
routing.RouterModalModule,
|
|
4462
|
+
angularFormio.FormioModule,
|
|
4463
|
+
forms$1.AdvancedFormsModule,
|
|
4464
|
+
i2.SharedModule,
|
|
4465
|
+
modal.ModalModule,
|
|
4466
|
+
dropdown.BsDropdownModule,
|
|
4467
|
+
progressbar.ProgressbarModule,
|
|
4468
|
+
ngxPipes.NgPipesModule
|
|
4469
|
+
],
|
|
4470
|
+
providers: [common.DatePipe, i2.TemplatePipe,
|
|
4471
|
+
{
|
|
4472
|
+
provide: COLUMN_FORMATTERS,
|
|
4473
|
+
useValue: ɵ0
|
|
4474
|
+
},
|
|
4475
|
+
AdvancedTableConfigurationResolver,
|
|
4476
|
+
AdvancedSearchConfigurationResolver,
|
|
4477
|
+
AdvancedSelectService,
|
|
4478
|
+
AdvancedAggregatorService,
|
|
4479
|
+
ngxPipes.GroupByPipe
|
|
4480
|
+
],
|
|
4481
|
+
declarations: [
|
|
4482
|
+
AdvancedTableComponent,
|
|
4483
|
+
AdvancedTableSearchComponent,
|
|
4484
|
+
BtnExpDirective,
|
|
4485
|
+
AdvancedTableSettingsComponent,
|
|
4486
|
+
AdvancedTableModalBaseComponent,
|
|
4487
|
+
AdvancedSearchFormComponent,
|
|
4488
|
+
AdvancedListComponent,
|
|
4489
|
+
AdvancedRowActionComponent,
|
|
4490
|
+
TableSimpleHeaderComponent,
|
|
4491
|
+
SimpleHeaderToolsComponent,
|
|
4492
|
+
AdvancedSelectComponent,
|
|
4493
|
+
AdvancedTableEditorDirective,
|
|
4494
|
+
AdvancedAggregatorComponent,
|
|
4495
|
+
AdvancedAggregatorListComponent,
|
|
4496
|
+
AdvancedAggregatorPipe,
|
|
4497
|
+
ParseTitlePipe,
|
|
4498
|
+
AddItemsComponent
|
|
4499
|
+
],
|
|
4500
|
+
exports: [
|
|
4501
|
+
AdvancedTableComponent,
|
|
4502
|
+
AdvancedTableSearchComponent,
|
|
4503
|
+
BtnExpDirective,
|
|
4504
|
+
AdvancedTableSettingsComponent,
|
|
4505
|
+
AdvancedSearchFormComponent,
|
|
4506
|
+
AdvancedListComponent,
|
|
4507
|
+
AdvancedRowActionComponent,
|
|
4508
|
+
TableSimpleHeaderComponent,
|
|
4509
|
+
SimpleHeaderToolsComponent,
|
|
4510
|
+
AdvancedSelectComponent,
|
|
4511
|
+
AdvancedTableEditorDirective,
|
|
4512
|
+
AdvancedAggregatorComponent,
|
|
4513
|
+
AdvancedAggregatorListComponent,
|
|
4514
|
+
AddItemsComponent
|
|
4515
|
+
],
|
|
4516
|
+
entryComponents: [
|
|
4517
|
+
AdvancedTableModalBaseComponent,
|
|
4518
|
+
AdvancedTableSettingsComponent,
|
|
4519
|
+
AdvancedRowActionComponent,
|
|
4520
|
+
AdvancedSelectComponent,
|
|
4521
|
+
AddItemsComponent
|
|
4522
|
+
],
|
|
4523
|
+
schemas: [i0.CUSTOM_ELEMENTS_SCHEMA]
|
|
4524
|
+
},] }
|
|
4525
|
+
];
|
|
4526
|
+
/** @nocollapse */
|
|
4527
|
+
TablesModule.ctorParameters = function () {
|
|
4528
|
+
return [
|
|
4529
|
+
{ type: core.TranslateService }
|
|
4530
|
+
];
|
|
4531
|
+
};
|
|
4532
|
+
return TablesModule;
|
|
4533
|
+
}());
|
|
4534
|
+
|
|
4535
|
+
/*
|
|
4536
|
+
* Public API Surface of tables
|
|
4537
|
+
*/
|
|
4538
|
+
|
|
4539
|
+
/**
|
|
4540
|
+
* Generated bundle index. Do not edit.
|
|
4541
|
+
*/
|
|
4542
|
+
|
|
4543
|
+
exports.ɵb = AdvancedFilterValueProvider;
|
|
4544
|
+
exports.ɵa = AdvancedTableSearchBaseComponent;
|
|
4545
|
+
exports.ɵe = AdvancedTableSettingsComponent;
|
|
4546
|
+
exports.ɵf = SimpleHeaderToolsComponent;
|
|
4547
|
+
exports.ɵg = TableSimpleHeaderComponent;
|
|
4548
|
+
exports.ɵd = BtnExpDirective;
|
|
4549
|
+
exports.ɵh = AdvancedAggregatorPipe;
|
|
4550
|
+
exports.ɵi = ParseTitlePipe;
|
|
4551
|
+
exports.ɵc = AdvancedAggregatorService;
|
|
4552
|
+
exports.AdvancedListComponent = AdvancedListComponent;
|
|
4553
|
+
exports.AdvancedRowActionComponent = AdvancedRowActionComponent;
|
|
4554
|
+
exports.AdvancedSearchFormComponent = AdvancedSearchFormComponent;
|
|
4555
|
+
exports.AdvancedTableConfigurationResolver = AdvancedTableConfigurationResolver;
|
|
4556
|
+
exports.AdvancedSearchConfigurationResolver = AdvancedSearchConfigurationResolver;
|
|
4557
|
+
exports.AdvancedColumnFormatter = AdvancedColumnFormatter;
|
|
4558
|
+
exports.NestedPropertyFormatter = NestedPropertyFormatter;
|
|
4559
|
+
exports.ButtonFormatter = ButtonFormatter;
|
|
4560
|
+
exports.LinkFormatter = LinkFormatter;
|
|
4561
|
+
exports.ActionLinkFormatter = ActionLinkFormatter;
|
|
4562
|
+
exports.SelectRowFormatter = SelectRowFormatter;
|
|
4563
|
+
exports.TemplateFormatter = TemplateFormatter;
|
|
4564
|
+
exports.TrueFalseFormatter = TrueFalseFormatter;
|
|
4565
|
+
exports.TranslationFormatter = TranslationFormatter;
|
|
4566
|
+
exports.DateTimeFormatter = DateTimeFormatter;
|
|
4567
|
+
exports.NgClassFormatter = NgClassFormatter;
|
|
4568
|
+
exports.LanguageFormatter = LanguageFormatter;
|
|
4569
|
+
exports.COLUMN_FORMATTERS = COLUMN_FORMATTERS;
|
|
4570
|
+
exports.AdvancedTableConfiguration = AdvancedTableConfiguration;
|
|
4571
|
+
exports.AdvancedTableComponent = AdvancedTableComponent;
|
|
4572
|
+
exports.AdvancedTableSearchComponent = AdvancedTableSearchComponent;
|
|
4573
|
+
exports.FORMATTERS = FORMATTERS;
|
|
4574
|
+
exports.AdvancedTableModalBaseTemplate = AdvancedTableModalBaseTemplate;
|
|
4575
|
+
exports.AdvancedTableModalBaseComponent = AdvancedTableModalBaseComponent;
|
|
4576
|
+
exports.AdvancedSelectComponent = AdvancedSelectComponent;
|
|
4577
|
+
exports.AdvancedSelectService = AdvancedSelectService;
|
|
4578
|
+
exports.TablesModule = TablesModule;
|
|
4579
|
+
exports.ɵ0 = ɵ0;
|
|
4580
|
+
exports.ActivatedTableService = ActivatedTableService;
|
|
4581
|
+
exports.AdvancedTableNotNullError = AdvancedTableNotNullError;
|
|
4582
|
+
exports.AdvancedTableEditorDirective = AdvancedTableEditorDirective;
|
|
4583
|
+
exports.AdvancedAggregatorComponent = AdvancedAggregatorComponent;
|
|
4584
|
+
exports.AdvancedAggregatorListComponent = AdvancedAggregatorListComponent;
|
|
4585
|
+
exports.AddItemsComponent = AddItemsComponent;
|
|
4586
|
+
|
|
4587
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4588
|
+
|
|
4589
|
+
})));
|
|
4590
|
+
|
|
4591
|
+
//# sourceMappingURL=universis-ngx-tables.umd.js.map
|