1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400 | 1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
20534×
1×
5×
4×
5×
5×
8×
8×
8×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
84×
6×
6×
3×
1×
1×
1×
1×
1×
1×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-data"], function (require, exports, ej2_base_1, ej2_data_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var BASE_DOC_URL = 'https://ej2.syncfusion.com/documentation/grid';
var DOC_URL = 'https://ej2.syncfusion.com/documentation/';
var WARNING = '[EJ2Grid.Warning]';
var ERROR = '[EJ2Grid.Error]';
var INFO = '[EJ2Grid.Info]';
var Logger = (function () {
function Logger(parent) {
this.parent = parent;
this.parent.on('initial-end', this.patchadaptor, this);
}
Logger.prototype.getModuleName = function () {
return 'logger';
};
Logger.prototype.log = function (types, args) {
if (!(types instanceof Array)) {
types = [types];
}
var type = types;
for (var i = 0; i < type.length; i++) {
var item = exports.detailLists[type[parseInt(i.toString(), 10)]];
var cOp = item.check(args, this.parent);
Iif (cOp.success) {
console[item.logType](item.generateMessage(args, this.parent, cOp.options));
}
}
};
Logger.prototype.patchadaptor = function () {
var adaptor = this.parent.getDataModule().dataManager.adaptor;
var original = adaptor.beforeSend;
Iif (original) {
adaptor.beforeSend = function (dm, request, settings) {
original.call(adaptor, dm, request, settings);
};
}
};
Logger.prototype.destroy = function () {
Eif (this.parent.isDestroyed) {
return;
}
this.parent.off('initial-end', this.patchadaptor);
};
return Logger;
}());
exports.Logger = Logger;
exports.detailLists = {
module_missing: {
type: 'module_missing',
logType: 'warn',
check: function (args, parent) {
var injected = parent.getInjectedModules().map(function (m) { return m.prototype.getModuleName(); });
var modules = parent.requiredModules().map(function (m) { return m.member; })
.filter(function (name) { return injected.indexOf(name) === -1; });
return { success: modules.filter(function (m) { return m !== 'resize'; }).length > 0, options: modules };
},
generateMessage: function (args, parent, modules) {
modules = modules.filter(function (m) { return m !== 'resize'; })
.reduce(function (prev, cur) { return prev + ("* " + cur + "\n"); }, '');
return WARNING + ': MODULES MISSING\n' + 'The following modules are not injected:.\n' +
("" + modules) +
("Refer to " + BASE_DOC_URL + "/module.html for documentation on importing feature modules.");
}
},
promise_enabled: {
type: 'promise_enabled',
logType: 'error',
check: function () {
return { success: typeof Promise === 'undefined' };
},
generateMessage: function () {
return ERROR + ': PROMISE UNDEFINED\n' +
'Promise object is not present in the global environment,' +
'please use polyfil to support Promise object in your environment.\n' +
("Refer to " + DOC_URL + "/base/browser.html?#required-polyfills for more information.");
}
},
primary_column_missing: {
type: 'primary_column_missing',
logType: 'warn',
check: function (args, parent) {
return { success: parent.enableColumnVirtualization
? parent.getPrimaryKeyFieldNames().length === 0
: parent.getColumns().filter(function (column) { return column.isPrimaryKey; }).length === 0 };
},
generateMessage: function () {
return WARNING + ': PRIMARY KEY MISSING\n' + 'Editing is enabled but primary key column is not specified.\n' +
("Refer to " + BASE_DOC_URL + "/api-column.html?#isprimarykey for documentation on providing primary key columns.");
}
},
selection_key_missing: {
type: 'selection_key_missing',
logType: 'warn',
check: function (args, parent) {
return { success: parent.selectionSettings.persistSelection &&
parent.getColumns().filter(function (column) { return column.isPrimaryKey; }).length === 0 };
},
generateMessage: function () {
return WARNING + ': PRIMARY KEY MISSING\n' +
'selectionSettings.persistSelection property is enabled. It requires one primary key column to persist selection.\n' +
("Refer to " + BASE_DOC_URL + "/api-column.html?#isprimarykey for documentation on providing primary key columns.");
}
},
actionfailure: {
type: 'actionfailure',
logType: 'error',
check: function () {
return { success: true };
},
generateMessage: function (args, parent) {
var message = '';
var formatError = formatErrorHandler(args, parent);
var ajaxError = ajaxErrorHandler(args, parent);
if (ajaxError !== '') {
message = ajaxError;
}
else if (formatError !== '') {
message = formatError;
}
else {
message = args.error;
}
return WARNING + ': ' + message;
}
},
locale_missing: {
type: 'locale_missing',
logType: 'warn',
check: function (args, parent) {
var lObj = ej2_data_1.DataUtil.getObject("locale." + parent.locale + ".grid", ej2_base_1.L10n);
return { success: parent.locale !== 'en-US' && ej2_base_1.isNullOrUndefined(lObj) };
},
generateMessage: function (args, parent) {
return WARNING + ': LOCALE CONFIG MISSING\n' + ("Locale configuration for '" + parent.locale + "' is not provided.\n") +
("Refer to " + BASE_DOC_URL + "/globalization-and-localization.html?#localization \n for documentation on setting locale configuration.");
}
},
limitation: {
type: 'limitation',
logType: 'warn',
check: function (args, parent) {
var name = args;
var opt;
switch (name) {
case 'freeze':
opt = {
success: !ej2_base_1.isUndefined(parent.detailTemplate) || !ej2_base_1.isUndefined(parent.childGrid),
options: { name: 'freeze' }
};
break;
case 'virtualization':
opt = {
success: !ej2_base_1.isUndefined(parent.detailTemplate) || !ej2_base_1.isUndefined(parent.childGrid),
options: { name: 'virtualization' }
};
break;
default:
opt = { success: false };
break;
}
return opt;
},
generateMessage: function (args, parent, options) {
var name = options.name;
var opt;
switch (name) {
case 'freeze':
opt = 'Frozen rows and columns do not support the following features:\n' +
'* Details Template\n' +
'* Hierarchy Grid\n';
break;
case 'virtualization':
opt = 'Virtualization does not support the following features.\n' +
'* Details Template.\n' +
'* Hierarchy Grid.\n';
break;
default:
opt = '';
break;
}
return WARNING + (": " + name.toUpperCase() + " LIMITATIONS\n") + opt;
}
},
check_datasource_columns: {
type: 'check_datasource_columns',
logType: 'warn',
check: function (args, parent) {
return { success: !(parent.columns.length ||
(parent.dataSource instanceof ej2_data_1.DataManager) ||
(!ej2_base_1.isNullOrUndefined(parent.dataSource) && parent.dataSource.length)) };
},
generateMessage: function () {
return WARNING + ': GRID CONFIG MISSING\n' + 'dataSource and columns are not provided in the grid. ' +
'At least one of either must be provided for grid configuration.\n' +
("Refer to " + BASE_DOC_URL + "/columns.html for documentation on configuring the grid data and columns.");
}
},
virtual_height: {
type: 'virtual_height',
logType: 'error',
check: function (args, parent) {
return { success: ej2_base_1.isNullOrUndefined(parent.height) || parent.height === 'auto' };
},
generateMessage: function () {
return ERROR + ': GRID HEIGHT MISSING \n' + 'height property is required to use virtualization.\n' +
("Refer to " + BASE_DOC_URL + "/virtual.html for documentation on configuring the virtual grid.");
}
},
grid_remote_edit: {
type: 'grid_remote_edit',
logType: 'error',
check: function (args) {
return { success: Array.isArray(args) || Array.isArray(args.result) };
},
generateMessage: function () {
return ERROR + ': RETRUN VALUE MISSING \n' +
'Remote service returns invalid data. \n' +
("Refer to " + BASE_DOC_URL + "/edit.html for documentation on configuring editing with remote data.");
}
},
grid_sort_comparer: {
type: 'grid_sort_comparer',
logType: 'warn',
check: function (args, parent) {
return { success: parent.getDataModule().isRemote() };
},
generateMessage: function () {
return WARNING + ': SORT COMPARER NOT WORKING \n' + 'Sort comparer will not work with remote data.' +
("Refer to " + BASE_DOC_URL + "/sorting/#custom-sort-comparer for documentation on using the sort comparer.");
}
},
resize_min_max: {
type: 'resize_min_max',
logType: 'info',
check: function (args) {
return { success: (args.column.minWidth && args.column.minWidth >= args.width) ||
(args.column.maxWidth && args.column.maxWidth <= args.width) };
},
generateMessage: function () {
return INFO + ': RESIZING COLUMN REACHED MIN OR MAX \n' + 'The column resizing width is at its min or max.';
}
},
action_disabled_column: {
type: 'action_disabled_column',
logType: 'info',
check: function (args) {
var success = true;
var fn;
switch (args.moduleName) {
case 'reorder':
if (ej2_base_1.isNullOrUndefined(args.destColumn)) {
fn = "reordering action is disabled for the " + args.column.headerText + " column";
}
else {
fn = "reordering action is disabled for the " + (args.column.allowReordering ?
args.destColumn.headerText : args.column.headerText) + " column";
}
break;
case 'group':
fn = "grouping action is disabled for the " + args.columnName + " column.";
break;
case 'filter':
fn = "filtering action is disabled for the " + args.columnName + " column.";
break;
case 'sort':
fn = "sorting action is disabled for the " + args.columnName + " column.";
break;
}
return { success: success, options: { fn: fn } };
},
generateMessage: function (args, parent, options) {
return INFO + (": ACTION DISABLED \n " + options.fn);
}
},
exporting_begin: {
type: 'exporting_begin',
logType: 'info',
check: function (args) {
return { success: true, options: { args: args } };
},
generateMessage: function (args, parent, options) {
return INFO + (": EXPORTING INPROGRESS \n Grid " + options.args + "ing is in progress");
}
},
exporting_complete: {
type: 'exporting_complete',
logType: 'info',
check: function (args) {
return { success: true, options: { args: args } };
},
generateMessage: function (args, parent, options) {
return INFO + (": EXPORTING COMPLETED \n Grid " + options.args + "ing is complete");
}
},
foreign_key_failure: {
type: 'foreign_key_failure',
logType: 'error',
check: function () {
return { success: true };
},
generateMessage: function () {
return ERROR + ': FOREIGNKEY CONFIG \n Grid foreign key column needs a valid data source/service.' +
("Refer to " + BASE_DOC_URL + "/columns/#foreign-key-column for documentation on configuring foreign key columns.");
}
},
initial_action: {
type: 'initial_action',
logType: 'error',
check: function (args) {
var success = true;
var fn;
switch (args.moduleName) {
case 'group':
fn = "The " + args.columnName + " column is not available in the grid's column model." +
'Please provide a valid field name to group the column';
break;
case 'filter':
fn = "The " + args.columnName + " column is not available in the grid's column model." +
'Please provide a valid field name to filter the column.';
break;
case 'sort':
fn = "The " + args.columnName + " column is not available in the grid's column model." +
'Please provide a valid field name to sort the column.';
break;
}
return { success: success, options: { fn: fn } };
},
generateMessage: function (args, parent, options) {
return ERROR + (": INITIAL ACTION FAILURE \n " + options.fn);
}
},
frozen_rows_columns: {
type: 'frozen_rows_columns',
logType: 'error',
check: function (args, parent) {
return { success: parent.getColumns().length <= parent.frozenColumns
|| (parent.currentViewData.length && parent.frozenRows >= parent.currentViewData.length) };
},
generateMessage: function (args, parent) {
return ERROR + (": OUT OF RANGE ERROR-\n " + (parent.getColumns().length <= parent.frozenColumns ? 'FROZEN COLUMNS,' : '')) +
((parent.frozenRows >= parent.currentViewData.length ? 'FROZEN ROWS' : '') + " invalid");
}
},
column_type_missing: {
type: 'column_type_missing',
logType: 'error',
check: function (args) {
return { success: ej2_base_1.isNullOrUndefined(args.column.type), options: args.column.headerText };
},
generateMessage: function (args, parent, options) {
return ERROR + (": COLUMN TYPE MISSING-\n " + options + " column type was invalid or not defined.") +
("Please go through below help link: " + DOC_URL + "/grid/columns/#column-type");
}
},
datasource_syntax_mismatch: {
type: 'datasource_syntax_mismatch',
logType: 'warn',
check: function (args) {
return { success: args.dataState.dataSource && !(args.dataState.dataSource instanceof ej2_data_1.DataManager ||
'result' in args.dataState.dataSource || args.dataState.dataSource instanceof Array) &&
!(ej2_base_1.isNullOrUndefined(args.dataState.dataStateChange)) };
},
generateMessage: function () {
return WARNING + ': DATASOURCE SYNTAX WARNING\n' +
'DataSource should be in the form of {result: Object[], count: number}' +
'when dataStateChangeEvent used';
}
}
};
var formatErrorHandler = function (args) {
var error = args.error;
if (error.indexOf && error.indexOf('Format options') !== 0) {
return '';
}
return 'INVALID FORMAT\n' +
'For more information, refer to the following documentation links:\n' +
("Number format: " + DOC_URL + "/common/internationalization#supported-format-string\n") +
("Date format: " + DOC_URL + "/common/internationalization#manipulating-datetime\n") +
("Message: " + error);
};
var ajaxErrorHandler = function (args) {
var error = ej2_data_1.DataUtil.getObject('error.error', args);
if (ej2_base_1.isNullOrUndefined(error)) {
return '';
}
var jsonResult = '';
try {
jsonResult = JSON.parse(error.responseText);
}
catch (_a) {
jsonResult = '';
}
return 'XMLHTTPREQUEST FAILED\n' +
("Url: " + error.responseURL + "\n") +
("Status: " + error.status + " - " + error.statusText + "\n") +
("" + (jsonResult !== '' ? 'Message: ' + jsonResult : ''));
};
});
|