@universis/ngx-tables 0.6.6 → 0.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/universis-ngx-tables.umd.js +79 -74
- package/bundles/universis-ngx-tables.umd.js.map +1 -1
- package/bundles/universis-ngx-tables.umd.min.js +1 -1
- package/bundles/universis-ngx-tables.umd.min.js.map +1 -1
- package/esm2015/lib/components/advanced-table/advanced-table.component.js +17 -1
- package/esm2015/lib/components/advanced-table/advanced-table.formatters.interface.js +3 -3
- package/esm2015/lib/components/advanced-table/advanced-table.formatters.js +44 -72
- package/esm5/lib/components/advanced-table/advanced-table.component.js +17 -1
- package/esm5/lib/components/advanced-table/advanced-table.formatters.interface.js +3 -3
- package/esm5/lib/components/advanced-table/advanced-table.formatters.js +52 -69
- package/fesm2015/universis-ngx-tables.js +60 -71
- package/fesm2015/universis-ngx-tables.js.map +1 -1
- package/fesm5/universis-ngx-tables.js +68 -68
- package/fesm5/universis-ngx-tables.js.map +1 -1
- package/lib/components/advanced-table/advanced-table.formatters.d.ts +8 -2
- package/package.json +1 -1
- package/universis-ngx-tables.metadata.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getNativeName } from 'iso-639-1/build';
|
|
2
|
+
import { Dropdown } from 'bootstrap';
|
|
2
3
|
import * as jQuery_ from 'jquery';
|
|
3
4
|
import 'datatables.net';
|
|
4
5
|
import { template, at } from 'lodash';
|
|
@@ -26,6 +27,16 @@ import { GroupByPipe, NgPipesModule } from 'ngx-pipes';
|
|
|
26
27
|
var AdvancedColumnFormatter = /** @class */ (function () {
|
|
27
28
|
function AdvancedColumnFormatter() {
|
|
28
29
|
}
|
|
30
|
+
AdvancedColumnFormatter.template = function (expr) {
|
|
31
|
+
var result = AdvancedColumnFormatter.templateCache.get(expr);
|
|
32
|
+
if (typeof result === 'function') {
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
result = template(expr);
|
|
36
|
+
AdvancedColumnFormatter.templateCache.set(expr, result);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
AdvancedColumnFormatter.templateCache = new Map();
|
|
29
40
|
return AdvancedColumnFormatter;
|
|
30
41
|
}());
|
|
31
42
|
var NestedPropertyFormatter = /** @class */ (function (_super) {
|
|
@@ -76,7 +87,7 @@ var ButtonFormatter = /** @class */ (function (_super) {
|
|
|
76
87
|
var router = this.injector.get(Router);
|
|
77
88
|
var commands = this.formatOptions.commands.map(function (command) {
|
|
78
89
|
if (typeof command === 'string') {
|
|
79
|
-
return
|
|
90
|
+
return AdvancedColumnFormatter.template(command)(row);
|
|
80
91
|
}
|
|
81
92
|
if (command.outlets) {
|
|
82
93
|
var commandOutlets_1 = {};
|
|
@@ -89,7 +100,7 @@ var ButtonFormatter = /** @class */ (function (_super) {
|
|
|
89
100
|
configurable: true,
|
|
90
101
|
writable: true,
|
|
91
102
|
value: outlet.map(function (x) {
|
|
92
|
-
return
|
|
103
|
+
return AdvancedColumnFormatter.template(x)(row);
|
|
93
104
|
}),
|
|
94
105
|
});
|
|
95
106
|
}
|
|
@@ -113,7 +124,7 @@ var ButtonFormatter = /** @class */ (function (_super) {
|
|
|
113
124
|
var replaceUrl = true;
|
|
114
125
|
if (this.formatOptions.navigationExtras && this.formatOptions.navigationExtras.queryParams) {
|
|
115
126
|
Object.keys(this.formatOptions.navigationExtras.queryParams).map(function (key) {
|
|
116
|
-
queryParams_1[key] =
|
|
127
|
+
queryParams_1[key] = AdvancedColumnFormatter.template(_this.formatOptions.navigationExtras.queryParams[key])(row);
|
|
117
128
|
});
|
|
118
129
|
}
|
|
119
130
|
if (this.formatOptions.navigationExtras && typeof this.formatOptions.navigationExtras.replaceUrl !== 'undefined') {
|
|
@@ -132,7 +143,7 @@ var ButtonFormatter = /** @class */ (function (_super) {
|
|
|
132
143
|
return "<a class=\"" + formatOptions.buttonClass + "\" title=\"" + buttonTitle + "\" href=\"#" + routerLink + "\">" + buttonText + "</a>";
|
|
133
144
|
}
|
|
134
145
|
// and return button
|
|
135
|
-
var href =
|
|
146
|
+
var href = AdvancedColumnFormatter.template(this.formatString)(row);
|
|
136
147
|
return "<a class=\"" + formatOptions.buttonClass + "\" title=\"" + buttonTitle + "\" href=\"" + href + "\">" + buttonText + "</a>";
|
|
137
148
|
};
|
|
138
149
|
return ButtonFormatter;
|
|
@@ -146,17 +157,7 @@ var LinkFormatter = /** @class */ (function (_super) {
|
|
|
146
157
|
// get column
|
|
147
158
|
var column = meta.settings.aoColumns[meta.col];
|
|
148
159
|
if (column && column.data) {
|
|
149
|
-
|
|
150
|
-
if (Object.prototype.hasOwnProperty.call(column, 'linkTemplate')) {
|
|
151
|
-
templateFunc = column.linkTemplate;
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
templateFunc = template(this.formatString);
|
|
155
|
-
Object.assign(column, {
|
|
156
|
-
linkTemplate: templateFunc,
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
return "<a href=\"" + (templateFunc(row)) + "\">" + data + "</a>";
|
|
160
|
+
return "<a href=\"" + (AdvancedColumnFormatter.template(this.formatString)(row)) + "\">" + data + "</a>";
|
|
160
161
|
}
|
|
161
162
|
return data;
|
|
162
163
|
};
|
|
@@ -169,32 +170,44 @@ var ActionLinkFormatter = /** @class */ (function (_super) {
|
|
|
169
170
|
}
|
|
170
171
|
ActionLinkFormatter.prototype.render = function (data, type, row, meta) {
|
|
171
172
|
var _this = this;
|
|
173
|
+
var e_1, _a;
|
|
172
174
|
// get column
|
|
173
175
|
var column = meta.settings.aoColumns[meta.col];
|
|
174
176
|
if (column && column.data) {
|
|
175
|
-
|
|
176
|
-
var
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
177
|
+
var actions = this.actions || [];
|
|
178
|
+
var index = 1;
|
|
179
|
+
try {
|
|
180
|
+
for (var actions_1 = __values(actions), actions_1_1 = actions_1.next(); !actions_1_1.done; actions_1_1 = actions_1.next()) {
|
|
181
|
+
var action = actions_1_1.value;
|
|
182
|
+
Object.assign(action, {
|
|
183
|
+
name: action.name || "action" + index,
|
|
183
184
|
});
|
|
184
|
-
|
|
185
|
-
return x;
|
|
186
|
-
}
|
|
185
|
+
index += 1;
|
|
187
186
|
}
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
}
|
|
188
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
189
|
+
finally {
|
|
190
|
+
try {
|
|
191
|
+
if (actions_1_1 && !actions_1_1.done && (_a = actions_1.return)) _a.call(actions_1);
|
|
190
192
|
}
|
|
191
|
-
|
|
193
|
+
finally { if (e_1) throw e_1.error; }
|
|
194
|
+
}
|
|
192
195
|
// return the dropdown menu with 3 dots
|
|
193
|
-
return
|
|
194
|
-
.
|
|
196
|
+
return "<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 " + actions.map(function (x) {
|
|
197
|
+
if (x.type === 'divider') {
|
|
198
|
+
return "<div class=\"dropdown-divider\"></div>";
|
|
199
|
+
}
|
|
200
|
+
return "<a data-name='" + x.name + "' class=\"dropdown-item\" href=\"" + AdvancedColumnFormatter.template(x.href)(row) + "\">\n " + _this.injector.get(TranslateService).instant(x.title) + "\n </a>";
|
|
201
|
+
})
|
|
202
|
+
.join('') + "\n </div>\n </div>";
|
|
195
203
|
}
|
|
196
204
|
return data;
|
|
197
205
|
};
|
|
206
|
+
ActionLinkFormatter.prototype.afterRender = function (cell, cellData, rowData, rowIndex, colIndex) {
|
|
207
|
+
// assign bootstrap dropdown
|
|
208
|
+
// tslint:disable-next-line: no-unused-expression
|
|
209
|
+
new Dropdown(cell);
|
|
210
|
+
};
|
|
198
211
|
return ActionLinkFormatter;
|
|
199
212
|
}(AdvancedColumnFormatter));
|
|
200
213
|
var SelectRowFormatter = /** @class */ (function (_super) {
|
|
@@ -207,7 +220,7 @@ var SelectRowFormatter = /** @class */ (function (_super) {
|
|
|
207
220
|
var column = meta.settings.aoColumns[meta.col];
|
|
208
221
|
if (column && column.data) {
|
|
209
222
|
var _tpl = "<input class=\"checkbox checkbox-theme\" type=\"checkbox\"\n id=\"s-" + meta.row + "\" /><label for=\"s-" + meta.row + "\"> </label>";
|
|
210
|
-
return
|
|
223
|
+
return AdvancedColumnFormatter.template(_tpl)(row);
|
|
211
224
|
}
|
|
212
225
|
return data;
|
|
213
226
|
};
|
|
@@ -222,16 +235,7 @@ var TemplateFormatter = /** @class */ (function (_super) {
|
|
|
222
235
|
// get column
|
|
223
236
|
var column = meta.settings.aoColumns[meta.col];
|
|
224
237
|
if (column && column.data) {
|
|
225
|
-
|
|
226
|
-
if (Object.prototype.hasOwnProperty.call(column, 'templateTemplate')) {
|
|
227
|
-
templateFunc = column.templateTemplate;
|
|
228
|
-
return templateFunc(row);
|
|
229
|
-
}
|
|
230
|
-
templateFunc = template(this.formatString);
|
|
231
|
-
Object.assign(column, {
|
|
232
|
-
templateTemplate: templateFunc,
|
|
233
|
-
});
|
|
234
|
-
return templateFunc(row);
|
|
238
|
+
return AdvancedColumnFormatter.template(this.formatString)(row);
|
|
235
239
|
}
|
|
236
240
|
return data;
|
|
237
241
|
};
|
|
@@ -257,16 +261,7 @@ var TranslationFormatter = /** @class */ (function (_super) {
|
|
|
257
261
|
// get column
|
|
258
262
|
var column = meta.settings.aoColumns[meta.col];
|
|
259
263
|
if (column && data != null) {
|
|
260
|
-
|
|
261
|
-
// in order to call consecutively for each row
|
|
262
|
-
var translateTemplate = column.translateTemplate;
|
|
263
|
-
if (typeof translateTemplate !== 'function') {
|
|
264
|
-
translateTemplate = template(this.formatString);
|
|
265
|
-
Object.assign(column, {
|
|
266
|
-
translateTemplate: translateTemplate,
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
return this.injector.get(TranslateService).instant(translateTemplate({
|
|
264
|
+
return this.injector.get(TranslateService).instant(AdvancedColumnFormatter.template(this.formatString)({
|
|
270
265
|
value: data,
|
|
271
266
|
}));
|
|
272
267
|
}
|
|
@@ -299,7 +294,7 @@ var NgClassFormatter = /** @class */ (function (_super) {
|
|
|
299
294
|
return _super.call(this) || this;
|
|
300
295
|
}
|
|
301
296
|
NgClassFormatter.prototype.render = function (data, type, row, meta) {
|
|
302
|
-
var
|
|
297
|
+
var e_2, _a;
|
|
303
298
|
// get column
|
|
304
299
|
var column = meta.settings.aoColumns[meta.col];
|
|
305
300
|
if (column && column.data) {
|
|
@@ -308,21 +303,10 @@ var NgClassFormatter = /** @class */ (function (_super) {
|
|
|
308
303
|
var ngClass = this.formatOptions.ngClass;
|
|
309
304
|
// check condition for each key
|
|
310
305
|
column.ngClassTemplates = column.ngClassTemplates || {};
|
|
311
|
-
var templateFunc = void 0;
|
|
312
306
|
try {
|
|
313
307
|
for (var _b = __values(Object.keys(ngClass)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
314
308
|
var key = _c.value;
|
|
315
|
-
|
|
316
|
-
if (typeof templateFunc !== 'function') {
|
|
317
|
-
templateFunc = template(ngClass[key]);
|
|
318
|
-
Object.defineProperty(column.ngClassTemplates, key, {
|
|
319
|
-
configurable: true,
|
|
320
|
-
enumerable: true,
|
|
321
|
-
writable: true,
|
|
322
|
-
value: templateFunc,
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
var result = templateFunc(row);
|
|
309
|
+
var result = AdvancedColumnFormatter.template(ngClass[key])(row);
|
|
326
310
|
var fn = new Function("return " + result + ";");
|
|
327
311
|
// if condition returns true add class
|
|
328
312
|
if (fn() === true) {
|
|
@@ -330,12 +314,12 @@ var NgClassFormatter = /** @class */ (function (_super) {
|
|
|
330
314
|
}
|
|
331
315
|
}
|
|
332
316
|
}
|
|
333
|
-
catch (
|
|
317
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
334
318
|
finally {
|
|
335
319
|
try {
|
|
336
320
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
337
321
|
}
|
|
338
|
-
finally { if (
|
|
322
|
+
finally { if (e_2) throw e_2.error; }
|
|
339
323
|
}
|
|
340
324
|
}
|
|
341
325
|
return data;
|
|
@@ -933,6 +917,22 @@ var AdvancedTableComponent = /** @class */ (function () {
|
|
|
933
917
|
return result;
|
|
934
918
|
},
|
|
935
919
|
});
|
|
920
|
+
// check if column formatters export createdCell event
|
|
921
|
+
var items_1 = column.formatters.filter(function (columnFormatter) {
|
|
922
|
+
return typeof columnFormatter.afterRender === 'function';
|
|
923
|
+
});
|
|
924
|
+
if (items_1.length > 0) {
|
|
925
|
+
Object.assign(columnDefinition, {
|
|
926
|
+
afterRender: function (cell, cellData, rowData, rowIndex, colIndex) {
|
|
927
|
+
items_1.forEach(function (columnFormatter) {
|
|
928
|
+
var formatter = self._columnFormatters[columnFormatter.formatter];
|
|
929
|
+
if (formatter && typeof formatter.afterRender === 'function') {
|
|
930
|
+
formatter.afterRender.bind(column)(cell, cellData, rowData, rowIndex, colIndex);
|
|
931
|
+
}
|
|
932
|
+
});
|
|
933
|
+
},
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
936
|
}
|
|
937
937
|
if (column.formatter) {
|
|
938
938
|
var formatter = self._columnFormatters[column.formatter];
|
|
@@ -3563,7 +3563,7 @@ var FORMATTERS = {
|
|
|
3563
3563
|
SelectRowFormatter: new SelectRowFormatter(),
|
|
3564
3564
|
TemplateFormatter: new TemplateFormatter(),
|
|
3565
3565
|
TranslationFormatter: new TranslationFormatter(),
|
|
3566
|
-
TrueFalseFormatter: new TrueFalseFormatter()
|
|
3566
|
+
TrueFalseFormatter: new TrueFalseFormatter(),
|
|
3567
3567
|
};
|
|
3568
3568
|
|
|
3569
3569
|
var SimpleHeaderToolsComponent = /** @class */ (function () {
|