@progress/telerik-jquery-report-viewer 31.26.812 → 32.26.1110
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/README.md +2 -0
- package/dist/cjs/commandSet.js +24 -1
- package/dist/cjs/exportDialog.js +1101 -0
- package/dist/cjs/history.js +19 -1
- package/dist/cjs/mainMenu.js +9 -3
- package/dist/cjs/notificationService.js +4 -0
- package/dist/cjs/parameters.js +20 -15
- package/dist/cjs/reportViewer.js +35 -5
- package/dist/cjs/search.js +4 -3
- package/dist/cjs/sendEmail.js +3 -2
- package/dist/cjs/sideMenu.js +9 -2
- package/dist/cjs/sr.js +40 -1
- package/dist/cjs/template-cache.js +18 -1
- package/dist/cjs/toolbar/page-number-input.js +2 -1
- package/dist/cjs/toolbar.js +28 -7
- package/dist/cjs/utils.js +32 -0
- package/dist/js/telerikReportViewer.js +4631 -2808
- package/dist/js/telerikReportViewer.kendo.js +15452 -36624
- package/dist/js/telerikReportViewer.kendo.min.js +87 -43
- package/dist/js/telerikReportViewer.min.js +3 -1
- package/dist/js/telerikReportViewer.stringResources.js +257 -1
- package/dist/styles/telerikReportViewer.css +5 -3
- package/dist/styles/telerikReportViewer.min.css +5 -3
- package/dist/templates/telerikReportViewerTemplate.html +143 -105
- package/package.json +2 -3
- package/dist/font/ReportingIcons-20.2.26.812.ttf +0 -0
- package/dist/font/font-icons.css +0 -4155
- package/dist/font/font-icons.min.css +0 -10
- package/dist/font/reporting-icons.ttf +0 -0
|
@@ -0,0 +1,1101 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var RCV = require('@progress/telerik-common-report-viewer');
|
|
6
|
+
var stringResources = require('./stringResources.js');
|
|
7
|
+
var binder = require('./binder.js');
|
|
8
|
+
var command = require('./command.js');
|
|
9
|
+
var utils = require('./utils.js');
|
|
10
|
+
|
|
11
|
+
const PAGE_SELECTION_FIELD = "__trvPageSelection";
|
|
12
|
+
const PAGE_RANGE_FIELD = "__trvPageRange";
|
|
13
|
+
const SUBGROUP_FIELD_PREFIX = "__trvSubgroup_";
|
|
14
|
+
const SUBGROUP_HEADER_PREFIX = "__trvSubgroupHeader_";
|
|
15
|
+
const CONFIRM_FIELD_PREFIX = "__trvConfirm_";
|
|
16
|
+
const PRESET_FIELD_PREFIX = "__trvPreset_";
|
|
17
|
+
const REQUIRED_RULE = "trvrequired";
|
|
18
|
+
const CONFIRM_RULE = "trvconfirm";
|
|
19
|
+
const PAGE_RANGE_RULE = "trvpagerange";
|
|
20
|
+
const DIFFER_RULE = "trvdiffer";
|
|
21
|
+
function replaceStringResources($dialog) {
|
|
22
|
+
if (!$dialog) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const labels = $dialog.find(".trv-replace-string");
|
|
26
|
+
if (labels.length) {
|
|
27
|
+
Array.from(labels).forEach((element) => {
|
|
28
|
+
const $element = $(element);
|
|
29
|
+
const stringResource = stringResources.stringResources[$element.text()];
|
|
30
|
+
if (stringResource) {
|
|
31
|
+
$element.text(stringResource);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const ariaLabels = $dialog.find("[aria-label]").add($dialog);
|
|
36
|
+
if (ariaLabels.length) {
|
|
37
|
+
Array.from(ariaLabels).forEach((element) => {
|
|
38
|
+
const $element = $(element);
|
|
39
|
+
const stringResource = stringResources.stringResources[$element.attr("aria-label")];
|
|
40
|
+
if (stringResource) {
|
|
41
|
+
$element.attr("aria-label", stringResource);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function isSameValue(value, other) {
|
|
47
|
+
return String(value ?? "").toLowerCase() === String(other ?? "").toLowerCase();
|
|
48
|
+
}
|
|
49
|
+
function createEditorInput(container, options, type) {
|
|
50
|
+
return $("<input />").attr({
|
|
51
|
+
id: options.field,
|
|
52
|
+
name: options.field,
|
|
53
|
+
type,
|
|
54
|
+
"data-bind": `${type === "checkbox" ? "checked" : "value"}:${options.field}`
|
|
55
|
+
}).appendTo(container);
|
|
56
|
+
}
|
|
57
|
+
function createPasswordEditor(container, options) {
|
|
58
|
+
createEditorInput(container, options, "password").attr("autocomplete", "new-password").kendoTextBox({
|
|
59
|
+
placeholder: options.editorOptions.placeholder,
|
|
60
|
+
enable: options.editorOptions.enabled
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function createSwitchEditor(container, options) {
|
|
64
|
+
container.closest(".k-form-field").addClass("trv-export-switch-field");
|
|
65
|
+
createEditorInput(container, options, "checkbox").kendoSwitch({
|
|
66
|
+
enabled: options.editorOptions.enabled,
|
|
67
|
+
messages: {
|
|
68
|
+
checked: stringResources.stringResources.exportDialogSwitchOnLabel,
|
|
69
|
+
unchecked: stringResources.stringResources.exportDialogSwitchOffLabel
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function createDropDownEditor(container, options) {
|
|
74
|
+
createEditorInput(container, options, "text").kendoDropDownList({
|
|
75
|
+
dataSource: options.editorOptions.dataSource,
|
|
76
|
+
dataTextField: "text",
|
|
77
|
+
dataValueField: "value",
|
|
78
|
+
valuePrimitive: true,
|
|
79
|
+
enable: options.editorOptions.enabled
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function createRadioGroupEditor(container, options) {
|
|
83
|
+
const groupName = `${options.field}-${kendo.guid()}`;
|
|
84
|
+
const radios = [];
|
|
85
|
+
const $group = $('<div class="trv-export-radio-group" role="radiogroup"></div>').attr("aria-labelledby", `${options.field}-form-label`).appendTo(container);
|
|
86
|
+
container.closest(".k-form-field").addClass("trv-export-radio-field");
|
|
87
|
+
options.editorOptions.dataSource.forEach((item, index) => {
|
|
88
|
+
const option = $('<label class="trv-export-radio-option"></label>').appendTo($group);
|
|
89
|
+
const input = $('<input type="radio" />').attr({
|
|
90
|
+
id: kendo.guid(),
|
|
91
|
+
name: groupName,
|
|
92
|
+
[kendo.attr("skip")]: true
|
|
93
|
+
}).appendTo(option).kendoRadioButton({
|
|
94
|
+
checked: isSameValue(options.model.get(options.field), item.value),
|
|
95
|
+
enabled: options.editorOptions.enabled
|
|
96
|
+
});
|
|
97
|
+
$("<span></span>").text(item.text).appendTo(option);
|
|
98
|
+
input.on("change", () => options.model.set(options.field, item.value));
|
|
99
|
+
radios.push({ input, value: item.value });
|
|
100
|
+
});
|
|
101
|
+
options.model.bind("change", (event) => {
|
|
102
|
+
if (event.field === options.field) {
|
|
103
|
+
radios.forEach((radio) => radio.input.prop("checked", isSameValue(options.model.get(options.field), radio.value)));
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function createSubgroupHeaderEditor(container, options) {
|
|
108
|
+
container.closest(".k-form-field").addClass("trv-export-subgroup-header");
|
|
109
|
+
$('<div class="k-form-label trv-export-subgroup-title" role="heading" aria-level="4"></div>').text(options.editorOptions.text).appendTo(container);
|
|
110
|
+
}
|
|
111
|
+
function createInfoIcon(description) {
|
|
112
|
+
return $('<span class="trv-export-setting-info" tabindex="0" role="img"></span>').attr({
|
|
113
|
+
"aria-label": description,
|
|
114
|
+
"data-description": description
|
|
115
|
+
}).append(kendo.ui.icon({ icon: "info-circle", size: "small" })).on("click", (event) => event.preventDefault());
|
|
116
|
+
}
|
|
117
|
+
function appendInfoIcon($label, description) {
|
|
118
|
+
let $text = $label.children(".trv-export-setting-label-text");
|
|
119
|
+
if (!$text.length) {
|
|
120
|
+
$text = $('<span class="trv-export-setting-label-text"></span>').attr("id", kendo.guid());
|
|
121
|
+
$label.contents().filter((index, node) => node.nodeType === Node.TEXT_NODE).wrapAll($text);
|
|
122
|
+
$text = $label.children(".trv-export-setting-label-text");
|
|
123
|
+
}
|
|
124
|
+
$label.append(createInfoIcon(description));
|
|
125
|
+
if ($label.hasClass("trv-export-subgroup-title")) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const $field = $label.closest(".k-form-field");
|
|
129
|
+
const $widgets = $field.find('[role="combobox"], [role="switch"], [role="radiogroup"], [role="spinbutton"]');
|
|
130
|
+
const $inputs = $field.find('input:not([type="hidden"]):not([type="radio"])').filter((index, element) => $(element).closest('[role="combobox"], [role="switch"], [role="spinbutton"]').length === 0);
|
|
131
|
+
$widgets.add($inputs).attr("aria-labelledby", $text.attr("id"));
|
|
132
|
+
}
|
|
133
|
+
function createCheckBoxEditor(container, options) {
|
|
134
|
+
container.closest(".k-form-field").addClass("trv-export-boolean-field");
|
|
135
|
+
createEditorInput(container, options, "checkbox").kendoCheckBox({
|
|
136
|
+
enabled: options.editorOptions.enabled
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function createNumericEditor(container, options) {
|
|
140
|
+
createEditorInput(container, options, "text").kendoNumericTextBox({
|
|
141
|
+
format: "n0",
|
|
142
|
+
decimals: 0,
|
|
143
|
+
min: options.editorOptions.min ?? 0,
|
|
144
|
+
max: options.editorOptions.max ?? null,
|
|
145
|
+
step: 1,
|
|
146
|
+
autoAdjust: true,
|
|
147
|
+
enable: options.editorOptions.enabled
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function createTextEditor(container, options) {
|
|
151
|
+
createEditorInput(container, options, "text").kendoTextBox({
|
|
152
|
+
placeholder: options.editorOptions.placeholder || stringResources.stringResources.exportDialogTextPlaceholder,
|
|
153
|
+
enable: options.editorOptions.enabled
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
function createPageRangeEditor(container, options) {
|
|
157
|
+
container.closest(".k-form-field").addClass("trv-export-page-range");
|
|
158
|
+
createEditorInput(container, options, "text").attr("aria-label", options.editorOptions.ariaLabel).kendoTextBox({
|
|
159
|
+
placeholder: options.editorOptions.placeholder,
|
|
160
|
+
enable: options.editorOptions.enabled
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function createCustomValueEditor(container, options) {
|
|
164
|
+
container.closest(".k-form-field").addClass("trv-export-custom-value");
|
|
165
|
+
if (options.editorOptions.numeric) {
|
|
166
|
+
createNumericEditor(container, options);
|
|
167
|
+
container.find("input").attr("aria-label", options.editorOptions.ariaLabel);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
createEditorInput(container, options, "text").attr("aria-label", options.editorOptions.ariaLabel).kendoTextBox({
|
|
171
|
+
placeholder: options.editorOptions.placeholder,
|
|
172
|
+
enable: options.editorOptions.enabled
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function createPageSelectionEditor(container, options) {
|
|
176
|
+
const optionName = `${options.field}-${kendo.guid()}`;
|
|
177
|
+
container.closest(".k-form-field").addClass("trv-export-page-selection");
|
|
178
|
+
[
|
|
179
|
+
{ selected: false, text: options.editorOptions.allPagesLabel },
|
|
180
|
+
{ selected: true, text: options.editorOptions.pageRangeLabel }
|
|
181
|
+
].forEach((pageOption) => {
|
|
182
|
+
const inputId = kendo.guid();
|
|
183
|
+
const option = $('<label class="trv-export-page-option"></label>').appendTo(container);
|
|
184
|
+
const input = $('<input type="radio" />').attr({
|
|
185
|
+
id: inputId,
|
|
186
|
+
name: optionName,
|
|
187
|
+
[kendo.attr("skip")]: true
|
|
188
|
+
}).appendTo(option).kendoRadioButton({ checked: pageOption.selected === options.editorOptions.pageRangeSelected });
|
|
189
|
+
$("<span></span>").text(pageOption.text).appendTo(option);
|
|
190
|
+
input.on("change", () => options.editorOptions.change(pageOption.selected, options.model));
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
class ExportDialog {
|
|
194
|
+
// #region fields
|
|
195
|
+
// #endregion
|
|
196
|
+
// #region constructor
|
|
197
|
+
constructor(element, options, viewerOptions) {
|
|
198
|
+
this.options = options;
|
|
199
|
+
this.viewerOptions = viewerOptions;
|
|
200
|
+
this.element = element;
|
|
201
|
+
this.$element = $(element);
|
|
202
|
+
this.controller = options.controller;
|
|
203
|
+
this.notificationService = options.notificationService;
|
|
204
|
+
this.exportSettingsStore = options.exportSettingsStore;
|
|
205
|
+
this.initialized = false;
|
|
206
|
+
this.dialogVisible = false;
|
|
207
|
+
this.format = "";
|
|
208
|
+
this.formats = [];
|
|
209
|
+
this.pendingValues = {};
|
|
210
|
+
this.initialValues = {};
|
|
211
|
+
this.formatDrawer = void 0;
|
|
212
|
+
this.settingsForm = void 0;
|
|
213
|
+
this.currentValues = void 0;
|
|
214
|
+
this.pagingSettingNames = [];
|
|
215
|
+
this.pageRangeSelected = false;
|
|
216
|
+
this.settingsLayout = [];
|
|
217
|
+
this.subgroupFields = [];
|
|
218
|
+
this.confirmFields = [];
|
|
219
|
+
this.presetFields = [];
|
|
220
|
+
this.windowLocation = void 0;
|
|
221
|
+
if (!this.controller) {
|
|
222
|
+
throw "No controller (telerikReporting.ReportViewerController) has been specified.";
|
|
223
|
+
}
|
|
224
|
+
if (!this.notificationService) {
|
|
225
|
+
throw "No notificationService (telerikReporting.NotificationService) has been specified.";
|
|
226
|
+
}
|
|
227
|
+
this.init();
|
|
228
|
+
}
|
|
229
|
+
// #endregion
|
|
230
|
+
// #region methods
|
|
231
|
+
init() {
|
|
232
|
+
if (this.initialized) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
replaceStringResources(this.$element);
|
|
236
|
+
this.$settingsContainer = this.$element.find(".trv-export-dialog-settings");
|
|
237
|
+
this.$noSettingsMessage = this.$element.find(".trv-export-dialog-no-settings");
|
|
238
|
+
this.$formatSelector = this.$element.find(".trv-export-dialog-formats");
|
|
239
|
+
this._initDialog();
|
|
240
|
+
this._attachCommands();
|
|
241
|
+
this._attachEvents();
|
|
242
|
+
this.initialized = true;
|
|
243
|
+
}
|
|
244
|
+
_initDialog() {
|
|
245
|
+
this.phoneViewport = this.isPhoneViewport();
|
|
246
|
+
this.kendoExportDialog = new kendo.ui.Window(this.element, {
|
|
247
|
+
title: stringResources.stringResources.exportDialogTitle,
|
|
248
|
+
visible: false,
|
|
249
|
+
draggable: !this.phoneViewport,
|
|
250
|
+
resizable: true,
|
|
251
|
+
modal: true,
|
|
252
|
+
close: () => {
|
|
253
|
+
this.storeDialogPosition();
|
|
254
|
+
},
|
|
255
|
+
open: () => {
|
|
256
|
+
this.updateDialogViewport();
|
|
257
|
+
this.adjustDialogPosition();
|
|
258
|
+
},
|
|
259
|
+
resize: () => {
|
|
260
|
+
kendo.resize(this.$element, true);
|
|
261
|
+
},
|
|
262
|
+
deactivate: () => {
|
|
263
|
+
this.notificationService.setExportDialogVisible({ visible: false });
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
this.kendoExportDialog.element.removeClass("trv-export-dialog k-hidden");
|
|
267
|
+
this.kendoExportDialog.wrapper.addClass("trv-export-dialog");
|
|
268
|
+
const $title = this.kendoExportDialog.wrapper.find(".k-window-title");
|
|
269
|
+
const titleId = $title.attr("id") || kendo.guid();
|
|
270
|
+
$title.attr("id", titleId).prepend(utils.renderExportOptionsIcon());
|
|
271
|
+
this.kendoExportDialog.wrapper.attr({
|
|
272
|
+
role: "dialog",
|
|
273
|
+
"aria-modal": "true",
|
|
274
|
+
"aria-labelledby": titleId
|
|
275
|
+
});
|
|
276
|
+
this.$element.find(".trv-export-dialog-reset").kendoButton({
|
|
277
|
+
icon: "arrow-rotate-cw",
|
|
278
|
+
size: "small",
|
|
279
|
+
rounded: "medium",
|
|
280
|
+
fillMode: "outline",
|
|
281
|
+
themeColor: "base"
|
|
282
|
+
});
|
|
283
|
+
this.$element.find(".trv-export-dialog-documentation").attr("title", stringResources.stringResources.exportDialogDocumentationLabel).prepend(kendo.ui.icon({ icon: "hyperlink-open" }));
|
|
284
|
+
this.$element.find('[data-command="telerik_ReportViewer_exportDialog_Close"]').kendoButton({
|
|
285
|
+
fillMode: "outline",
|
|
286
|
+
themeColor: "base"
|
|
287
|
+
});
|
|
288
|
+
this.$element.find('[data-command="telerik_ReportViewer_exportDialog_Save"]').kendoButton({
|
|
289
|
+
fillMode: "solid",
|
|
290
|
+
themeColor: "primary"
|
|
291
|
+
});
|
|
292
|
+
this.$settingsContainer.kendoTooltip({
|
|
293
|
+
filter: ".trv-export-setting-info",
|
|
294
|
+
showOn: "mouseenter focus",
|
|
295
|
+
position: "top",
|
|
296
|
+
content: (event) => $('<span class="trv-export-setting-tooltip-text"></span>').text(event.target.attr("data-description") || "")[0].outerHTML
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
_attachCommands() {
|
|
300
|
+
this.optionsCommandSet = {
|
|
301
|
+
"exportDialog_Close": new command.Command(() => {
|
|
302
|
+
this.close();
|
|
303
|
+
}),
|
|
304
|
+
"exportDialog_Save": new command.Command(() => {
|
|
305
|
+
this.save();
|
|
306
|
+
}),
|
|
307
|
+
"exportDialog_Reset": new command.Command(() => {
|
|
308
|
+
this.reset();
|
|
309
|
+
})
|
|
310
|
+
};
|
|
311
|
+
binder.Binder.attachCommands(this.$element.find(".trv-export-dialog-layout"), this.optionsCommandSet, this.viewerOptions);
|
|
312
|
+
}
|
|
313
|
+
_attachEvents() {
|
|
314
|
+
this.controller.on("beginLoadReport", this.close.bind(this)).on("viewModeChanged", this.close.bind(this));
|
|
315
|
+
this.notificationService.setExportDialogVisible((event, args) => {
|
|
316
|
+
if (args && args.visible === true) {
|
|
317
|
+
this.open(args.format);
|
|
318
|
+
} else {
|
|
319
|
+
this.close();
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
$(window).on("resize", () => {
|
|
323
|
+
if (this.kendoExportDialog && this.kendoExportDialog.options.visible) {
|
|
324
|
+
if (!this.phoneViewport) {
|
|
325
|
+
this.storeDialogPosition();
|
|
326
|
+
}
|
|
327
|
+
this.updateDialogViewport();
|
|
328
|
+
this.adjustDialogPosition();
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
isPhoneViewport() {
|
|
333
|
+
return $(window).innerWidth() <= 767;
|
|
334
|
+
}
|
|
335
|
+
updateDialogViewport() {
|
|
336
|
+
const phone = this.isPhoneViewport();
|
|
337
|
+
if (phone !== this.phoneViewport) {
|
|
338
|
+
this.phoneViewport = phone;
|
|
339
|
+
this.kendoExportDialog.setOptions({ draggable: !phone });
|
|
340
|
+
}
|
|
341
|
+
this.updateFormatDrawerForViewport();
|
|
342
|
+
kendo.resize(this.$element, true);
|
|
343
|
+
}
|
|
344
|
+
open() {
|
|
345
|
+
this.dialogVisible = false;
|
|
346
|
+
const formatsPromise = this.controller.getDocumentFormats();
|
|
347
|
+
Promise.resolve(formatsPromise).then((formats) => {
|
|
348
|
+
if (!RCV.hasExportSettings(formats)) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
this.dialogVisible = true;
|
|
352
|
+
this.pendingValues = {};
|
|
353
|
+
this.initialValues = {};
|
|
354
|
+
this.formats = formats || [];
|
|
355
|
+
this.buildFormatDrawer();
|
|
356
|
+
this.kendoExportDialog.open();
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
close() {
|
|
360
|
+
this.dialogVisible = false;
|
|
361
|
+
this.pendingValues = {};
|
|
362
|
+
this.initialValues = {};
|
|
363
|
+
this.destroySettingsForm();
|
|
364
|
+
if (this.kendoExportDialog && this.kendoExportDialog.options.visible) {
|
|
365
|
+
this.kendoExportDialog.close();
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
buildFormatDrawer() {
|
|
369
|
+
const selectedFormat = this.formats.some((item) => item.name === this.format) ? this.format : this.formats[0]?.name;
|
|
370
|
+
const drawerItems = this.formats.map((format) => ({
|
|
371
|
+
format: format.name,
|
|
372
|
+
text: RCV.getExportFormatName(format, stringResources.stringResources),
|
|
373
|
+
selected: format.name === selectedFormat,
|
|
374
|
+
miniTemplate: () => {
|
|
375
|
+
const icon = utils.renderExportFormatIcon(format.name) || `<span aria-hidden="true">${kendo.htmlEncode(format.name.slice(0, 3))}</span>`;
|
|
376
|
+
return `<li data-role="drawer-item">${icon}</li>`;
|
|
377
|
+
}
|
|
378
|
+
}));
|
|
379
|
+
if (this.formatDrawer) {
|
|
380
|
+
this.formatDrawer.setOptions({ items: drawerItems });
|
|
381
|
+
} else {
|
|
382
|
+
this.formatDrawer = this.$formatSelector.kendoDrawer({
|
|
383
|
+
items: drawerItems,
|
|
384
|
+
mode: "push",
|
|
385
|
+
position: "left",
|
|
386
|
+
width: 240,
|
|
387
|
+
mini: { width: 48 },
|
|
388
|
+
expanded: !this.isPhoneViewport(),
|
|
389
|
+
autoCollapse: false,
|
|
390
|
+
swipeToOpen: false,
|
|
391
|
+
navigatable: true,
|
|
392
|
+
itemClick: (event) => {
|
|
393
|
+
if (!event.dataItem?.format || event.dataItem.format === this.format) {
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
if (!this.validateSettingsForm()) {
|
|
397
|
+
this.selectDrawerFormat(this.format);
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
this.showFormat(event.dataItem.format);
|
|
401
|
+
}
|
|
402
|
+
}).data("kendoDrawer");
|
|
403
|
+
}
|
|
404
|
+
this.updateFormatDrawerForViewport();
|
|
405
|
+
this.renderFormatDrawerIcons();
|
|
406
|
+
this.showFormat(selectedFormat);
|
|
407
|
+
}
|
|
408
|
+
updateFormatDrawerForViewport() {
|
|
409
|
+
if (!this.formatDrawer) {
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
if (this.isPhoneViewport() && this.formatDrawer.visible) {
|
|
413
|
+
this.formatDrawer.hide();
|
|
414
|
+
} else if (!this.isPhoneViewport() && !this.formatDrawer.visible) {
|
|
415
|
+
this.formatDrawer.show();
|
|
416
|
+
}
|
|
417
|
+
if (this.formatDrawer.visible) {
|
|
418
|
+
this.renderFormatDrawerIcons();
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
renderFormatDrawerIcons() {
|
|
422
|
+
if (!this.formatDrawer.visible) {
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
const drawerElements = this.formatDrawer.drawerItemsWrapper.find('[data-role="drawer-item"]');
|
|
426
|
+
drawerElements.each((index, element) => {
|
|
427
|
+
const format = this.formats[index];
|
|
428
|
+
const icon = utils.renderExportFormatIcon(format?.name);
|
|
429
|
+
const $element = $(element);
|
|
430
|
+
$element.find(".k-item-text").attr("title", RCV.getExportFormatName(format, stringResources.stringResources));
|
|
431
|
+
if (icon && !$element.find(".trv-export-format-icon").length) {
|
|
432
|
+
$element.prepend(icon);
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
showFormat(format) {
|
|
437
|
+
this.capturePendingValues();
|
|
438
|
+
this.format = format;
|
|
439
|
+
const extension = this.formats.find((item) => item.name === format);
|
|
440
|
+
this.$element.find(".trv-export-dialog-format-name").text(
|
|
441
|
+
`${RCV.getExportFormatName(extension, stringResources.stringResources) || format || ""}${stringResources.stringResources.exportDialogSettingsSuffix}`
|
|
442
|
+
);
|
|
443
|
+
this.$element.find(".trv-export-dialog-reset").attr("title", stringResources.stringResources.ariaLabelExportDialogReset);
|
|
444
|
+
this.$element.find(".trv-export-dialog-documentation").attr("href", RCV.getExportDocumentationUrl(format));
|
|
445
|
+
this.buildSettingsForm(extension);
|
|
446
|
+
}
|
|
447
|
+
buildSettingsForm(extension) {
|
|
448
|
+
this.destroySettingsForm();
|
|
449
|
+
const settings = extension?.settings || [];
|
|
450
|
+
if (settings.length === 0) {
|
|
451
|
+
this.$noSettingsMessage.removeClass("k-hidden");
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
this.$noSettingsMessage.addClass("k-hidden");
|
|
455
|
+
if (!kendo.ui.Form) {
|
|
456
|
+
console.error("The Kendo UI Form widget is not available. Export settings cannot be displayed.");
|
|
457
|
+
this.$noSettingsMessage.removeClass("k-hidden");
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
const formData = {};
|
|
461
|
+
settings.forEach((setting) => {
|
|
462
|
+
formData[setting.name] = this.getInitialValue(setting);
|
|
463
|
+
});
|
|
464
|
+
const layout = RCV.createExportSettingsLayout(extension);
|
|
465
|
+
this.settingsLayout = layout;
|
|
466
|
+
this.initSubgroupFields(layout, formData);
|
|
467
|
+
this.initConfirmFields(settings, formData);
|
|
468
|
+
this.initPresetFields(settings, formData);
|
|
469
|
+
this.pageRangeSelected = RCV.formatExportPageRange(formData.StartPage, formData.EndPage) !== "";
|
|
470
|
+
if (!Object.prototype.hasOwnProperty.call(this.initialValues, this.format)) {
|
|
471
|
+
this.initialValues[this.format] = { ...formData };
|
|
472
|
+
}
|
|
473
|
+
this.currentValues = { ...formData };
|
|
474
|
+
this.presetFields.forEach((entry) => {
|
|
475
|
+
formData[entry.field] = entry.key;
|
|
476
|
+
});
|
|
477
|
+
formData[PAGE_SELECTION_FIELD] = this.pageRangeSelected;
|
|
478
|
+
formData[PAGE_RANGE_FIELD] = RCV.formatExportPageRange(formData.StartPage, formData.EndPage);
|
|
479
|
+
this.subgroupFields.filter((entry) => entry.headerField).forEach((entry) => {
|
|
480
|
+
formData[entry.headerField] = null;
|
|
481
|
+
});
|
|
482
|
+
const formElement = $('<div class="trv-export-settings-form"></div>').appendTo(this.$settingsContainer.empty());
|
|
483
|
+
const items = layout.map((group) => ({
|
|
484
|
+
type: "group",
|
|
485
|
+
label: RCV.getExportGroupLabel(group, this.format, stringResources.stringResources),
|
|
486
|
+
layout: "grid",
|
|
487
|
+
grid: { cols: 1, gutter: 12 },
|
|
488
|
+
items: this.createGroupItems(group)
|
|
489
|
+
}));
|
|
490
|
+
this.settingsForm = formElement.kendoForm({
|
|
491
|
+
formData: { ...formData },
|
|
492
|
+
items,
|
|
493
|
+
renderButtons: false,
|
|
494
|
+
focusFirst: false,
|
|
495
|
+
validatable: {
|
|
496
|
+
validateOnBlur: true,
|
|
497
|
+
validationSummary: false
|
|
498
|
+
},
|
|
499
|
+
change: (event) => this.onFormChange(event)
|
|
500
|
+
}).data("kendoForm");
|
|
501
|
+
this.renderSettingInfoIcons(settings);
|
|
502
|
+
this.updateFieldVisibility();
|
|
503
|
+
}
|
|
504
|
+
getInitialValue(setting) {
|
|
505
|
+
if (this.hasPendingValue(setting.name)) {
|
|
506
|
+
return this.pendingValues[this.format][setting.name];
|
|
507
|
+
}
|
|
508
|
+
const savedValue = this.exportSettingsStore ? this.exportSettingsStore.getValue(this.format, setting) : setting.value;
|
|
509
|
+
return savedValue ?? this.getDefaultValue(setting.type);
|
|
510
|
+
}
|
|
511
|
+
hasPendingValue(name) {
|
|
512
|
+
const pendingValues = this.pendingValues[this.format];
|
|
513
|
+
return Boolean(pendingValues) && Object.prototype.hasOwnProperty.call(pendingValues, name);
|
|
514
|
+
}
|
|
515
|
+
initSubgroupFields(layout, formData) {
|
|
516
|
+
layout.forEach((group) => {
|
|
517
|
+
group.subgroups.forEach((subgroup) => {
|
|
518
|
+
const index = this.subgroupFields.length;
|
|
519
|
+
const entry = { layout: subgroup, field: void 0, headerField: void 0, locked: false };
|
|
520
|
+
if (subgroup.hasSwitch) {
|
|
521
|
+
entry.field = `${SUBGROUP_FIELD_PREFIX}${index}`;
|
|
522
|
+
entry.locked = RCV.isExportSubgroupLocked(subgroup, formData);
|
|
523
|
+
formData[entry.field] = entry.locked || (this.hasPendingValue(entry.field) ? this.pendingValues[this.format][entry.field] === true : RCV.isExportSubgroupOn(subgroup, formData));
|
|
524
|
+
} else if (!this.usesSubgroupLabel(subgroup)) {
|
|
525
|
+
entry.headerField = `${SUBGROUP_HEADER_PREFIX}${index}`;
|
|
526
|
+
}
|
|
527
|
+
this.subgroupFields.push(entry);
|
|
528
|
+
});
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
initConfirmFields(settings, formData) {
|
|
532
|
+
settings.filter((setting) => RCV.isExportConfirmedPasswordSetting(setting)).forEach((setting) => {
|
|
533
|
+
const confirmField = `${CONFIRM_FIELD_PREFIX}${setting.name}`;
|
|
534
|
+
formData[confirmField] = this.hasPendingValue(confirmField) ? this.pendingValues[this.format][confirmField] : formData[setting.name];
|
|
535
|
+
this.confirmFields.push({ field: confirmField, setting });
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
// Settings whose values cannot be bound directly to a dropdown get a preset field; a custom or unlisted current value gets its own item.
|
|
539
|
+
initPresetFields(settings, formData) {
|
|
540
|
+
settings.forEach((setting) => {
|
|
541
|
+
const presets = RCV.createExportSettingPresets(setting, formData[setting.name], this.format, stringResources.stringResources);
|
|
542
|
+
if (presets) {
|
|
543
|
+
this.presetFields.push({ setting, field: `${PRESET_FIELD_PREFIX}${setting.name}`, ...presets });
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
// The editor of a setting is bound to its own field when the setting is edited through a preset.
|
|
548
|
+
getSettingFieldName(setting) {
|
|
549
|
+
return this.presetFields.find((entry) => entry.setting === setting)?.field ?? setting.name;
|
|
550
|
+
}
|
|
551
|
+
getPresetDataSource(presetField) {
|
|
552
|
+
const items = presetField.items.map((item) => ({ text: item.text, value: item.key }));
|
|
553
|
+
if (presetField.allowCustom) {
|
|
554
|
+
items.push({ text: stringResources.stringResources.exportDialogCustomOption, value: RCV.EXPORT_CUSTOM_PRESET_KEY });
|
|
555
|
+
}
|
|
556
|
+
return items;
|
|
557
|
+
}
|
|
558
|
+
// An empty preset value means that the setting is not sent, so the renderer uses its own default.
|
|
559
|
+
applyPresetKey(presetField, key) {
|
|
560
|
+
const value = RCV.getExportPresetValue(presetField.setting, presetField, key);
|
|
561
|
+
if (value !== void 0) {
|
|
562
|
+
this.getFormModel().set(presetField.setting.name, value);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
onPresetChange(presetField, key) {
|
|
566
|
+
presetField.key = key;
|
|
567
|
+
this.applyPresetKey(presetField, key);
|
|
568
|
+
this.updateFieldVisibility();
|
|
569
|
+
const $custom = this.getFieldInput(presetField.setting.name);
|
|
570
|
+
if (key === RCV.EXPORT_CUSTOM_PRESET_KEY) {
|
|
571
|
+
$custom.trigger("focus");
|
|
572
|
+
} else if ($custom.length > 0) {
|
|
573
|
+
this.settingsForm.validator.validateInput($custom);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
// Turning a switch on selects the first preset of settings without a value, so the switch is never on with nothing chosen.
|
|
577
|
+
selectDefaultPresets(subgroupField) {
|
|
578
|
+
this.presetFields.filter((entry) => subgroupField.layout.settings.includes(entry.setting)).forEach((entry) => {
|
|
579
|
+
if (!RCV.hasExportSettingValue(this.getFormModel().get(entry.setting.name))) {
|
|
580
|
+
this.getFormModel().set(entry.field, entry.items[0].key);
|
|
581
|
+
this.onPresetChange(entry, entry.items[0].key);
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
usesSubgroupLabel(subgroup) {
|
|
586
|
+
return RCV.usesExportSubgroupLabel(subgroup, this.format, stringResources.stringResources);
|
|
587
|
+
}
|
|
588
|
+
createGroupItems(group) {
|
|
589
|
+
let settings = group.settings;
|
|
590
|
+
const items = [];
|
|
591
|
+
if (group.name === "Paging") {
|
|
592
|
+
const pagingSettings = settings.filter((setting) => RCV.EXPORT_PAGING_SETTINGS.includes(setting.name));
|
|
593
|
+
if (pagingSettings.length > 0) {
|
|
594
|
+
this.pagingSettingNames = pagingSettings.map((setting) => setting.name);
|
|
595
|
+
settings = settings.filter((setting) => !RCV.EXPORT_PAGING_SETTINGS.includes(setting.name));
|
|
596
|
+
items.push(
|
|
597
|
+
this.createPageSelectionFormItem(this.pageRangeSelected),
|
|
598
|
+
this.createPageRangeFormItem(pagingSettings)
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
settings.forEach((setting) => this.pushSettingItems(items, setting));
|
|
603
|
+
group.subgroups.forEach((subgroup) => {
|
|
604
|
+
const entry = this.subgroupFields.find((candidate) => candidate.layout === subgroup);
|
|
605
|
+
if (entry.field) {
|
|
606
|
+
items.push(this.createSubgroupSwitchItem(entry));
|
|
607
|
+
} else if (entry.headerField) {
|
|
608
|
+
items.push(this.createSubgroupHeaderItem(entry));
|
|
609
|
+
}
|
|
610
|
+
subgroup.settings.forEach((setting) => {
|
|
611
|
+
const label = this.usesSubgroupLabel(subgroup) ? this.getSubgroupLabel(subgroup) : void 0;
|
|
612
|
+
this.pushSettingItems(items, setting, label);
|
|
613
|
+
});
|
|
614
|
+
});
|
|
615
|
+
return items;
|
|
616
|
+
}
|
|
617
|
+
pushSettingItems(items, setting, label) {
|
|
618
|
+
const item = this.createFormItem(setting);
|
|
619
|
+
if (label) {
|
|
620
|
+
item.label = label;
|
|
621
|
+
}
|
|
622
|
+
items.push(item);
|
|
623
|
+
const presetField = this.presetFields.find((entry) => entry.setting === setting);
|
|
624
|
+
if (presetField?.allowCustom) {
|
|
625
|
+
items.push(this.createCustomValueFormItem(setting));
|
|
626
|
+
}
|
|
627
|
+
const confirmField = this.confirmFields.find((entry) => entry.setting === setting);
|
|
628
|
+
if (confirmField) {
|
|
629
|
+
items.push(this.createConfirmFormItem(confirmField));
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
onFormChange(event) {
|
|
633
|
+
if (event.field === PAGE_SELECTION_FIELD || !this.currentValues) {
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
if (event.field === PAGE_RANGE_FIELD) {
|
|
637
|
+
this.applyPageRange(event.value);
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
const presetField = this.presetFields.find((entry) => entry.field === event.field);
|
|
641
|
+
if (presetField) {
|
|
642
|
+
if (presetField.key !== event.value) {
|
|
643
|
+
this.onPresetChange(presetField, event.value);
|
|
644
|
+
}
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
647
|
+
this.currentValues[event.field] = event.value;
|
|
648
|
+
this.updateSameValueSettings(event.field, event.value);
|
|
649
|
+
this.updateFieldVisibility();
|
|
650
|
+
this.revalidateDifferingSetting(event.field);
|
|
651
|
+
const subgroupField = this.subgroupFields.find((entry) => entry.field && entry.field === event.field);
|
|
652
|
+
if (subgroupField && event.value === false) {
|
|
653
|
+
this.clearSubgroupSettings(subgroupField);
|
|
654
|
+
} else if (subgroupField) {
|
|
655
|
+
this.selectDefaultPresets(subgroupField);
|
|
656
|
+
}
|
|
657
|
+
const confirmField = this.confirmFields.find((entry) => entry.setting.name === event.field);
|
|
658
|
+
if (confirmField) {
|
|
659
|
+
this.revalidateConfirmField(confirmField);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
// Settings that are not displayed because they take the value of the changed setting.
|
|
663
|
+
updateSameValueSettings(name, value) {
|
|
664
|
+
const settings = this.formats.find((item) => item.name === this.format)?.settings || [];
|
|
665
|
+
RCV.getExportSameValueSettings(name, settings).forEach((setting) => this.getFormModel().set(setting.name, value));
|
|
666
|
+
}
|
|
667
|
+
// Turning off a subgroup switch clears its settings, so hidden values are not applied on export.
|
|
668
|
+
clearSubgroupSettings(subgroupField) {
|
|
669
|
+
const model = this.getFormModel();
|
|
670
|
+
subgroupField.layout.settings.forEach((setting) => {
|
|
671
|
+
if (!setting.readOnly) {
|
|
672
|
+
model.set(setting.name, this.getDefaultValue(setting.type));
|
|
673
|
+
}
|
|
674
|
+
});
|
|
675
|
+
this.confirmFields.filter((entry) => subgroupField.layout.settings.includes(entry.setting)).forEach((entry) => model.set(entry.field, ""));
|
|
676
|
+
}
|
|
677
|
+
// Re-checks a confirmation the user already typed, because changing the password does not validate it.
|
|
678
|
+
revalidateConfirmField(confirmField) {
|
|
679
|
+
const $input = this.getFieldInput(confirmField.field);
|
|
680
|
+
if ($input.val() || $input.hasClass("k-invalid")) {
|
|
681
|
+
this.settingsForm.validator.validateInput($input);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
validateSettingsForm() {
|
|
685
|
+
if (!this.settingsForm || this.settingsForm.validate()) {
|
|
686
|
+
return true;
|
|
687
|
+
}
|
|
688
|
+
this.$settingsContainer.find(".k-invalid").first().trigger("focus");
|
|
689
|
+
return false;
|
|
690
|
+
}
|
|
691
|
+
getValidationRules() {
|
|
692
|
+
return {
|
|
693
|
+
[REQUIRED_RULE]: (input) => this.validateRequired(input),
|
|
694
|
+
[CONFIRM_RULE]: (input) => this.validateConfirmation(input),
|
|
695
|
+
[PAGE_RANGE_RULE]: (input) => this.validatePageRange(input),
|
|
696
|
+
[DIFFER_RULE]: (input) => this.validateDifferingValue(input)
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
// Re-checks the setting that must differ from the changed one, because changing a value does not validate the other.
|
|
700
|
+
revalidateDifferingSetting(name) {
|
|
701
|
+
const partner = this.getExportSetting(name)?.mustDifferFrom;
|
|
702
|
+
if (!partner) {
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
const $input = this.getFieldInput(partner);
|
|
706
|
+
if ($input.length > 0 && this.isFieldShown(partner) && ($input.val() || $input.hasClass("k-invalid"))) {
|
|
707
|
+
this.settingsForm.validator.validateInput($input);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
validateDifferingValue(input) {
|
|
711
|
+
const setting = this.getExportSetting(input.attr("name"));
|
|
712
|
+
const other = setting?.mustDifferFrom ? this.getExportSetting(setting.mustDifferFrom) : void 0;
|
|
713
|
+
if (!other || !this.isFieldShown(setting.name) || !input.val() || input.val() !== String(this.getFormModel().get(other.name) ?? "")) {
|
|
714
|
+
return true;
|
|
715
|
+
}
|
|
716
|
+
input.attr(
|
|
717
|
+
kendo.attr(`${DIFFER_RULE}-msg`),
|
|
718
|
+
kendo.format(stringResources.stringResources.exportDialogMustDiffer, this.getSettingLabel(setting), this.getSettingLabel(other))
|
|
719
|
+
);
|
|
720
|
+
return false;
|
|
721
|
+
}
|
|
722
|
+
getExportSetting(name) {
|
|
723
|
+
return this.formats.find((item) => item.name === this.format)?.settings.find((candidate) => candidate.name === name);
|
|
724
|
+
}
|
|
725
|
+
validatePageRange(input) {
|
|
726
|
+
if (input.attr("name") !== PAGE_RANGE_FIELD || !this.isFieldShown(PAGE_RANGE_FIELD) || RCV.parseExportPageRange(input.val())) {
|
|
727
|
+
return true;
|
|
728
|
+
}
|
|
729
|
+
input.attr(kendo.attr(`${PAGE_RANGE_RULE}-msg`), stringResources.stringResources.exportDialogPageRangeInvalid);
|
|
730
|
+
return false;
|
|
731
|
+
}
|
|
732
|
+
// Invalid text keeps the last valid pages; validation blocks saving until the text is fixed.
|
|
733
|
+
applyPageRange(text) {
|
|
734
|
+
const range = RCV.parseExportPageRange(text);
|
|
735
|
+
if (!range) {
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
const model = this.getFormModel();
|
|
739
|
+
if (this.pagingSettingNames.includes("StartPage")) {
|
|
740
|
+
model.set("StartPage", range.start);
|
|
741
|
+
}
|
|
742
|
+
if (this.pagingSettingNames.includes("EndPage")) {
|
|
743
|
+
model.set("EndPage", range.end);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
validateRequired(input) {
|
|
747
|
+
const name = input.attr("name");
|
|
748
|
+
const setting = this.getExportSetting(name);
|
|
749
|
+
if (!setting || !(setting.required || setting.allowCustom) || !this.isFieldShown(name) || input.val() !== "") {
|
|
750
|
+
return true;
|
|
751
|
+
}
|
|
752
|
+
input.attr(kendo.attr(`${REQUIRED_RULE}-msg`), RCV.isExportPasswordSetting(name) ? stringResources.stringResources.exportDialogPasswordRequired : this.getSettingText(setting, "RequiredMessage") || stringResources.stringResources.exportDialogValueRequired);
|
|
753
|
+
return false;
|
|
754
|
+
}
|
|
755
|
+
validateConfirmation(input) {
|
|
756
|
+
const name = input.attr("name");
|
|
757
|
+
const confirmField = this.confirmFields.find((entry) => entry.field === name);
|
|
758
|
+
if (!confirmField || !this.isFieldShown(name)) {
|
|
759
|
+
return true;
|
|
760
|
+
}
|
|
761
|
+
const password = this.getFormModel().get(confirmField.setting.name) || "";
|
|
762
|
+
if ((input.val() || "") === password) {
|
|
763
|
+
return true;
|
|
764
|
+
}
|
|
765
|
+
input.attr(kendo.attr(`${CONFIRM_RULE}-msg`), stringResources.stringResources.exportDialogPasswordMismatch);
|
|
766
|
+
return false;
|
|
767
|
+
}
|
|
768
|
+
isFieldShown(name) {
|
|
769
|
+
const $field = this.getFormField(name);
|
|
770
|
+
return $field.length > 0 && !$field.hasClass("k-hidden");
|
|
771
|
+
}
|
|
772
|
+
getFormModel() {
|
|
773
|
+
return this.settingsForm.editable.options.model;
|
|
774
|
+
}
|
|
775
|
+
getFormField(name) {
|
|
776
|
+
return this.$settingsContainer.find("[data-container-for]").filter((index, element) => element.getAttribute("data-container-for") === name).closest(".k-form-field");
|
|
777
|
+
}
|
|
778
|
+
getFieldInput(name) {
|
|
779
|
+
return this.$settingsContainer.find("input").filter((index, element) => element.getAttribute("name") === name);
|
|
780
|
+
}
|
|
781
|
+
updateFieldVisibility() {
|
|
782
|
+
if (!this.settingsForm || !this.currentValues) {
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
const values = this.currentValues;
|
|
786
|
+
const visibleSettings = /* @__PURE__ */ new Set();
|
|
787
|
+
const isSettingVisible = (setting) => RCV.isExportSettingVisible(setting, values) && (!this.pagingSettingNames.includes(setting.name) || this.pageRangeSelected);
|
|
788
|
+
const setSettingVisible = (setting, visible) => {
|
|
789
|
+
if (visible) {
|
|
790
|
+
visibleSettings.add(setting);
|
|
791
|
+
}
|
|
792
|
+
this.getFormField(this.getSettingFieldName(setting)).toggleClass("k-hidden", !visible);
|
|
793
|
+
const presetField = this.presetFields.find((entry) => entry.setting === setting);
|
|
794
|
+
if (presetField?.allowCustom) {
|
|
795
|
+
this.getFormField(setting.name).toggleClass("k-hidden", !visible || presetField.key !== RCV.EXPORT_CUSTOM_PRESET_KEY);
|
|
796
|
+
}
|
|
797
|
+
};
|
|
798
|
+
this.settingsLayout.forEach((group) => {
|
|
799
|
+
group.settings.forEach((setting) => setSettingVisible(setting, isSettingVisible(setting)));
|
|
800
|
+
group.subgroups.forEach((subgroup) => {
|
|
801
|
+
const entry = this.subgroupFields.find((candidate) => candidate.layout === subgroup);
|
|
802
|
+
const switchOn = !entry.field || values[entry.field] === true;
|
|
803
|
+
let anyVisible = false;
|
|
804
|
+
subgroup.settings.forEach((setting) => {
|
|
805
|
+
const visible = switchOn && isSettingVisible(setting);
|
|
806
|
+
anyVisible = anyVisible || visible;
|
|
807
|
+
setSettingVisible(setting, visible);
|
|
808
|
+
});
|
|
809
|
+
if (entry.field) {
|
|
810
|
+
this.getFormField(entry.field).toggleClass("k-hidden", !subgroup.settings.some(isSettingVisible));
|
|
811
|
+
} else if (entry.headerField) {
|
|
812
|
+
this.getFormField(entry.headerField).toggleClass("k-hidden", !anyVisible);
|
|
813
|
+
}
|
|
814
|
+
});
|
|
815
|
+
});
|
|
816
|
+
this.confirmFields.forEach((entry) => {
|
|
817
|
+
this.getFormField(entry.field).toggleClass("k-hidden", !visibleSettings.has(entry.setting));
|
|
818
|
+
});
|
|
819
|
+
this.getFormField(PAGE_RANGE_FIELD).toggleClass("k-hidden", !this.pageRangeSelected);
|
|
820
|
+
this.$settingsContainer.find(".k-form-fieldset").each((index, element) => {
|
|
821
|
+
const $fieldset = $(element);
|
|
822
|
+
$fieldset.toggleClass("k-hidden", $fieldset.find(".k-form-field").not(".k-hidden").length === 0);
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
selectDrawerFormat(format) {
|
|
826
|
+
const index = this.formats.findIndex((item) => item.name === format);
|
|
827
|
+
this.formatDrawer?.drawerItemsWrapper.find('[data-role="drawer-item"]').removeClass("k-selected").eq(index).addClass("k-selected");
|
|
828
|
+
}
|
|
829
|
+
renderSettingInfoIcons(settings) {
|
|
830
|
+
const describedSubgroups = this.subgroupFields.map((entry) => ({ entry, description: RCV.getExportSubgroupDescription(entry.layout, this.format, stringResources.stringResources) })).filter((item) => item.description);
|
|
831
|
+
settings.forEach((setting) => {
|
|
832
|
+
const description = this.getSettingText(setting, "Description") || setting.description;
|
|
833
|
+
if (!description || describedSubgroups.some((item) => item.entry.layout.settings.includes(setting))) {
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
const switchField = this.subgroupFields.find((entry) => entry.field && entry.layout.settings.length === 1 && entry.layout.settings[0] === setting);
|
|
837
|
+
const fieldName = switchField ? switchField.field : this.getSettingFieldName(setting);
|
|
838
|
+
this.findFieldLabel(fieldName).each((index, label) => appendInfoIcon($(label), description));
|
|
839
|
+
});
|
|
840
|
+
describedSubgroups.forEach(({ entry, description }) => {
|
|
841
|
+
const label = entry.field ? this.findFieldLabel(entry.field) : this.getFormField(entry.headerField).find(".trv-export-subgroup-title");
|
|
842
|
+
label.each((index, element) => appendInfoIcon($(element), description));
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
findFieldLabel(fieldName) {
|
|
846
|
+
return this.$settingsContainer.find(".k-form-label").filter((index, element) => element.htmlFor === fieldName);
|
|
847
|
+
}
|
|
848
|
+
createPageSelectionFormItem(pageRangeSelected) {
|
|
849
|
+
return {
|
|
850
|
+
field: PAGE_SELECTION_FIELD,
|
|
851
|
+
label: stringResources.stringResources.exportDialogPagesLabel,
|
|
852
|
+
editor: createPageSelectionEditor,
|
|
853
|
+
editorOptions: {
|
|
854
|
+
pageRangeSelected,
|
|
855
|
+
allPagesLabel: stringResources.stringResources.exportDialogAllPagesLabel,
|
|
856
|
+
pageRangeLabel: stringResources.stringResources.exportDialogPageRangeLabel,
|
|
857
|
+
change: (selected, model) => this.onPageSelectionChange(selected, model)
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
createPageRangeFormItem(pagingSettings) {
|
|
862
|
+
return {
|
|
863
|
+
field: PAGE_RANGE_FIELD,
|
|
864
|
+
label: "",
|
|
865
|
+
editor: createPageRangeEditor,
|
|
866
|
+
editorOptions: {
|
|
867
|
+
enabled: !pagingSettings.some((setting) => setting.readOnly),
|
|
868
|
+
placeholder: stringResources.stringResources.exportDialogPageRangePlaceholder,
|
|
869
|
+
ariaLabel: stringResources.stringResources.exportDialogPageRangeLabel
|
|
870
|
+
},
|
|
871
|
+
validation: this.getValidationRules()
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
onPageSelectionChange(pageRangeSelected, model) {
|
|
875
|
+
model.set(PAGE_SELECTION_FIELD, pageRangeSelected);
|
|
876
|
+
if (pageRangeSelected) {
|
|
877
|
+
this.applyPageRange(model.get(PAGE_RANGE_FIELD));
|
|
878
|
+
} else {
|
|
879
|
+
this.pagingSettingNames.forEach((name) => model.set(name, 0));
|
|
880
|
+
}
|
|
881
|
+
this.pageRangeSelected = pageRangeSelected;
|
|
882
|
+
this.updateFieldVisibility();
|
|
883
|
+
if (!pageRangeSelected) {
|
|
884
|
+
this.settingsForm.validator.validateInput(this.getFieldInput(PAGE_RANGE_FIELD));
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
createSubgroupSwitchItem(subgroupField) {
|
|
888
|
+
return {
|
|
889
|
+
field: subgroupField.field,
|
|
890
|
+
label: this.getSubgroupLabel(subgroupField.layout),
|
|
891
|
+
editor: createSwitchEditor,
|
|
892
|
+
editorOptions: {
|
|
893
|
+
enabled: !subgroupField.locked
|
|
894
|
+
}
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
createSubgroupHeaderItem(subgroupField) {
|
|
898
|
+
return {
|
|
899
|
+
field: subgroupField.headerField,
|
|
900
|
+
label: "",
|
|
901
|
+
editor: createSubgroupHeaderEditor,
|
|
902
|
+
editorOptions: {
|
|
903
|
+
text: this.getSubgroupLabel(subgroupField.layout)
|
|
904
|
+
}
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
createConfirmFormItem(confirmField) {
|
|
908
|
+
return {
|
|
909
|
+
field: confirmField.field,
|
|
910
|
+
label: stringResources.stringResources.exportDialogConfirmPasswordLabel,
|
|
911
|
+
editor: createPasswordEditor,
|
|
912
|
+
editorOptions: {
|
|
913
|
+
enabled: true,
|
|
914
|
+
placeholder: stringResources.stringResources.exportDialogConfirmPasswordPlaceholder
|
|
915
|
+
},
|
|
916
|
+
validation: this.getValidationRules()
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
createCustomValueFormItem(setting) {
|
|
920
|
+
return {
|
|
921
|
+
field: setting.name,
|
|
922
|
+
label: this.getSettingText(setting, "CustomLabel") || "",
|
|
923
|
+
editor: createCustomValueEditor,
|
|
924
|
+
editorOptions: {
|
|
925
|
+
enabled: !setting.readOnly,
|
|
926
|
+
numeric: setting.type === "number",
|
|
927
|
+
min: RCV.getExportSettingRange(setting)?.min,
|
|
928
|
+
max: RCV.getExportSettingRange(setting)?.max,
|
|
929
|
+
placeholder: this.getSettingText(setting, "Placeholder") || stringResources.stringResources.exportDialogTextPlaceholder,
|
|
930
|
+
ariaLabel: this.getSettingLabel(setting)
|
|
931
|
+
},
|
|
932
|
+
validation: this.getValidationRules()
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
createFormItem(setting) {
|
|
936
|
+
const presetField = this.presetFields.find((entry) => entry.setting === setting);
|
|
937
|
+
const placeholder = this.getSettingText(setting, "Placeholder");
|
|
938
|
+
const hint = this.getSettingText(setting, "Hint");
|
|
939
|
+
const item = {
|
|
940
|
+
field: this.getSettingFieldName(setting),
|
|
941
|
+
label: this.getSettingLabel(setting),
|
|
942
|
+
editorOptions: {
|
|
943
|
+
enabled: !setting.readOnly,
|
|
944
|
+
placeholder: placeholder || void 0
|
|
945
|
+
}
|
|
946
|
+
};
|
|
947
|
+
if (hint) {
|
|
948
|
+
item.hint = hint;
|
|
949
|
+
}
|
|
950
|
+
if (setting.required) {
|
|
951
|
+
item.validation = this.getValidationRules();
|
|
952
|
+
}
|
|
953
|
+
const options = this.getSettingOptions(setting);
|
|
954
|
+
if (presetField) {
|
|
955
|
+
item.editor = createDropDownEditor;
|
|
956
|
+
item.editorOptions.dataSource = this.getPresetDataSource(presetField);
|
|
957
|
+
} else if (RCV.isExportPasswordSetting(setting.name)) {
|
|
958
|
+
item.editor = createPasswordEditor;
|
|
959
|
+
item.editorOptions.placeholder = placeholder || stringResources.stringResources.exportDialogPasswordPlaceholder;
|
|
960
|
+
} else if (options && options.length === 2) {
|
|
961
|
+
item.editor = createRadioGroupEditor;
|
|
962
|
+
item.editorOptions.dataSource = options;
|
|
963
|
+
} else if (options) {
|
|
964
|
+
item.editor = createDropDownEditor;
|
|
965
|
+
item.editorOptions.dataSource = options;
|
|
966
|
+
} else {
|
|
967
|
+
switch (setting.type) {
|
|
968
|
+
case "boolean":
|
|
969
|
+
item.editor = setting.useSwitch ? createSwitchEditor : createCheckBoxEditor;
|
|
970
|
+
break;
|
|
971
|
+
case "number":
|
|
972
|
+
item.editor = createNumericEditor;
|
|
973
|
+
item.editorOptions.min = RCV.getExportSettingRange(setting)?.min;
|
|
974
|
+
item.editorOptions.max = RCV.getExportSettingRange(setting)?.max;
|
|
975
|
+
break;
|
|
976
|
+
default:
|
|
977
|
+
item.editor = createTextEditor;
|
|
978
|
+
break;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
return item;
|
|
982
|
+
}
|
|
983
|
+
capturePendingValues() {
|
|
984
|
+
if (this.currentValues && this.format) {
|
|
985
|
+
this.pendingValues[this.format] = { ...this.currentValues };
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
reset() {
|
|
989
|
+
if (!this.format || !this.exportSettingsStore?.resetValues(this.format)) {
|
|
990
|
+
return;
|
|
991
|
+
}
|
|
992
|
+
delete this.pendingValues[this.format];
|
|
993
|
+
delete this.initialValues[this.format];
|
|
994
|
+
const extension = this.formats.find((item) => item.name === this.format);
|
|
995
|
+
this.buildSettingsForm(extension);
|
|
996
|
+
}
|
|
997
|
+
save() {
|
|
998
|
+
if (!this.validateSettingsForm()) {
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
this.capturePendingValues();
|
|
1002
|
+
let saved = true;
|
|
1003
|
+
this.formats.forEach((extension) => {
|
|
1004
|
+
const values = this.pendingValues[extension.name];
|
|
1005
|
+
if (values && this.exportSettingsStore) {
|
|
1006
|
+
const initialValues = this.initialValues[extension.name] || {};
|
|
1007
|
+
const changedValues = {};
|
|
1008
|
+
Object.keys(values).forEach((name) => {
|
|
1009
|
+
if (values[name] !== initialValues[name]) {
|
|
1010
|
+
changedValues[name] = values[name];
|
|
1011
|
+
}
|
|
1012
|
+
});
|
|
1013
|
+
saved = this.exportSettingsStore.saveValues(
|
|
1014
|
+
extension.name,
|
|
1015
|
+
extension.settings || [],
|
|
1016
|
+
changedValues
|
|
1017
|
+
) && saved;
|
|
1018
|
+
if (saved) {
|
|
1019
|
+
this.initialValues[extension.name] = { ...values };
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
});
|
|
1023
|
+
if (saved) {
|
|
1024
|
+
this.close();
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
getDefaultValue(settingType) {
|
|
1028
|
+
switch (settingType) {
|
|
1029
|
+
case "boolean":
|
|
1030
|
+
return false;
|
|
1031
|
+
case "number":
|
|
1032
|
+
return null;
|
|
1033
|
+
default:
|
|
1034
|
+
return "";
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
getSettingLabel(setting) {
|
|
1038
|
+
return RCV.getExportSettingLabel(setting, this.format, stringResources.stringResources);
|
|
1039
|
+
}
|
|
1040
|
+
getSettingText(setting, kind) {
|
|
1041
|
+
return RCV.getExportSettingText(setting, kind, this.format, stringResources.stringResources);
|
|
1042
|
+
}
|
|
1043
|
+
getSettingOptions(setting) {
|
|
1044
|
+
return RCV.getExportSettingOptions(setting, this.format, stringResources.stringResources);
|
|
1045
|
+
}
|
|
1046
|
+
getSubgroupLabel(subgroup) {
|
|
1047
|
+
return RCV.getExportSubgroupLabel(subgroup, this.format, stringResources.stringResources);
|
|
1048
|
+
}
|
|
1049
|
+
destroySettingsForm() {
|
|
1050
|
+
if (this.settingsForm) {
|
|
1051
|
+
this.settingsForm.destroy();
|
|
1052
|
+
this.settingsForm = void 0;
|
|
1053
|
+
}
|
|
1054
|
+
this.currentValues = void 0;
|
|
1055
|
+
this.pagingSettingNames = [];
|
|
1056
|
+
this.pageRangeSelected = false;
|
|
1057
|
+
this.settingsLayout = [];
|
|
1058
|
+
this.subgroupFields = [];
|
|
1059
|
+
this.confirmFields = [];
|
|
1060
|
+
this.presetFields = [];
|
|
1061
|
+
if (this.$settingsContainer) {
|
|
1062
|
+
this.$settingsContainer.empty();
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
storeDialogPosition() {
|
|
1066
|
+
if (this.phoneViewport) {
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
const kendoWindow = this.kendoExportDialog.element.parent(".k-window");
|
|
1070
|
+
this.windowLocation = kendoWindow.offset();
|
|
1071
|
+
}
|
|
1072
|
+
adjustDialogPosition() {
|
|
1073
|
+
if (this.phoneViewport) {
|
|
1074
|
+
return;
|
|
1075
|
+
}
|
|
1076
|
+
const windowWidth = $(window).innerWidth();
|
|
1077
|
+
const windowHeight = $(window).innerHeight();
|
|
1078
|
+
const width = this.kendoExportDialog.wrapper.outerWidth(true);
|
|
1079
|
+
const height = this.kendoExportDialog.wrapper.outerHeight(true);
|
|
1080
|
+
const padding = 10;
|
|
1081
|
+
if (!this.windowLocation) {
|
|
1082
|
+
this.kendoExportDialog.center();
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
let left = this.windowLocation.left;
|
|
1086
|
+
let top = this.windowLocation.top;
|
|
1087
|
+
const right = left + width;
|
|
1088
|
+
const bottom = top + height;
|
|
1089
|
+
if (right > windowWidth - padding) {
|
|
1090
|
+
left = Math.max(padding, windowWidth - width - padding);
|
|
1091
|
+
this.kendoExportDialog.setOptions({ position: { left } });
|
|
1092
|
+
}
|
|
1093
|
+
if (bottom > windowHeight - padding) {
|
|
1094
|
+
top = Math.max(padding, windowHeight - height - padding);
|
|
1095
|
+
this.kendoExportDialog.setOptions({ position: { top } });
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
// #endregion
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
exports.ExportDialog = ExportDialog;
|