@sankhyalabs/sankhyablocks 2.6.0 → 2.8.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.
Files changed (55) hide show
  1. package/dist/cjs/AuthorizationConfig-79ffae4b.js +7 -0
  2. package/dist/cjs/{SnkMessageBuilder-09b25b0a.js → SnkMessageBuilder-248b5105.js} +7 -0
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  5. package/dist/cjs/snk-application.cjs.entry.js +24 -2
  6. package/dist/cjs/snk-configurator_3.cjs.entry.js +6 -38
  7. package/dist/cjs/{snk-data-exporter_9.cjs.entry.js → snk-data-exporter_8.cjs.entry.js} +83 -155
  8. package/dist/cjs/snk-data-unit.cjs.entry.js +1 -1
  9. package/dist/cjs/snk-exporter-email-sender.cjs.entry.js +129 -0
  10. package/dist/collection/components/snk-application/snk-application.js +30 -0
  11. package/dist/collection/components/snk-data-exporter/exporter-email-sender/email-info-step.js +3 -2
  12. package/dist/collection/components/snk-data-exporter/exporter-email-sender/options-step.js +1 -1
  13. package/dist/collection/components/snk-data-exporter/exporter-email-sender/snk-exporter-email-sender.js +29 -6
  14. package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +49 -31
  15. package/dist/collection/components/snk-grid/snk-grid.js +1 -43
  16. package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +9 -1
  17. package/dist/collection/lib/http/data-fetcher/fetchers/fetchDataExporter/permission-export-pdf.js +7 -0
  18. package/dist/collection/lib/message/resources/snk-data-exporter.msg.js +7 -0
  19. package/dist/components/SnkMessageBuilder.js +7 -0
  20. package/dist/components/snk-application2.js +25 -2
  21. package/dist/components/snk-data-exporter2.js +58 -17
  22. package/dist/components/snk-exporter-email-sender2.js +18 -13
  23. package/dist/components/snk-form2.js +10 -4
  24. package/dist/components/snk-grid2.js +3 -35
  25. package/dist/components/snk-taskbar2.js +8 -2
  26. package/dist/esm/AuthorizationConfig-dcbd207a.js +7 -0
  27. package/dist/esm/{SnkMessageBuilder-47db5d75.js → SnkMessageBuilder-4a060599.js} +7 -0
  28. package/dist/esm/loader.js +1 -1
  29. package/dist/esm/sankhyablocks.js +1 -1
  30. package/dist/esm/snk-application.entry.js +24 -2
  31. package/dist/esm/snk-configurator_3.entry.js +2 -34
  32. package/dist/esm/{snk-data-exporter_9.entry.js → snk-data-exporter_8.entry.js} +64 -135
  33. package/dist/esm/snk-data-unit.entry.js +1 -1
  34. package/dist/esm/snk-exporter-email-sender.entry.js +125 -0
  35. package/dist/sankhyablocks/{p-d96bf6a7.entry.js → p-3480f2fa.entry.js} +1 -1
  36. package/dist/sankhyablocks/{p-02d430a7.entry.js → p-43eff4d3.entry.js} +12 -5
  37. package/dist/sankhyablocks/p-48d7ba04.entry.js +1 -0
  38. package/dist/sankhyablocks/p-97347faf.entry.js +1 -0
  39. package/dist/sankhyablocks/p-dc36cfbf.js +1 -0
  40. package/dist/sankhyablocks/p-f5246cd6.entry.js +1 -0
  41. package/dist/sankhyablocks/{p-1d7a0daf.js → p-f624979d.js} +1 -1
  42. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  43. package/dist/types/components/snk-application/snk-application.d.ts +4 -0
  44. package/dist/types/components/snk-data-exporter/data/export-config.d.ts +1 -1
  45. package/dist/types/components/snk-data-exporter/exporter-email-sender/email-info-step.d.ts +2 -2
  46. package/dist/types/components/snk-data-exporter/snk-data-exporter.d.ts +5 -5
  47. package/dist/types/components.d.ts +5 -8
  48. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IFetchDataExporterParams.d.ts +5 -1
  49. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/permission-export-pdf.d.ts +1 -0
  50. package/package.json +2 -2
  51. package/dist/cjs/data-exporter-option-417da37a.js +0 -19
  52. package/dist/esm/data-exporter-option-006307dd.js +0 -19
  53. package/dist/sankhyablocks/p-04581d0c.entry.js +0 -1
  54. package/dist/sankhyablocks/p-50c8bcb7.entry.js +0 -1
  55. package/dist/sankhyablocks/p-719e570a.js +0 -1
@@ -4,17 +4,29 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-2cd6f753.js');
6
6
  const core = require('@sankhyalabs/core');
7
- const dataExporterOption = require('./data-exporter-option-417da37a.js');
7
+ const utils = require('@sankhyalabs/ezui/dist/collection/utils');
8
8
  const ConfigStorage = require('./ConfigStorage-91953f29.js');
9
9
  const filterItemType_enum = require('./filter-item-type.enum-3daf58d3.js');
10
10
  const ezModalContainer = require('@sankhyalabs/ezui/dist/collection/components/ez-modal-container');
11
11
  const DataType = require('@sankhyalabs/core/dist/dataunit/metadata/DataType');
12
- const utils = require('@sankhyalabs/ezui/dist/collection/utils');
13
12
  const constants = require('./constants-a47a5190.js');
13
+ const AuthorizationConfig = require('./AuthorizationConfig-79ffae4b.js');
14
14
  const taskbarElements = require('./taskbar-elements-bbb89cdb.js');
15
15
  require('./_commonjsHelpers-537d719a.js');
16
16
  require('./index-696b5c3b.js');
17
17
 
18
+ var DataExporterOption;
19
+ (function (DataExporterOption) {
20
+ DataExporterOption["EXPORT_TO_PDF"] = "exportToPDF";
21
+ DataExporterOption["EXPORT_TO_XLS"] = "exportToXLS";
22
+ DataExporterOption["EXPORT_CURRENT_PAGE"] = "exportCurrentPage";
23
+ DataExporterOption["EXPORT_PAGE_TO_PDF"] = "exportPageToPDF";
24
+ DataExporterOption["EXPORT_PAGE_TO_XLS"] = "exportPageToXLS";
25
+ DataExporterOption["EXPORT_BY_EMAIL"] = "exportToEmail";
26
+ DataExporterOption["EXPORT_PDF_TO_EMAIL"] = "exportPDFToEmail";
27
+ DataExporterOption["EXPORT_XLS_TO_EMAIL"] = "exportXLSToEmail";
28
+ })(DataExporterOption || (DataExporterOption = {}));
29
+
18
30
  var __rest = (undefined && undefined.__rest) || function (s, e) {
19
31
  var t = {};
20
32
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -63,10 +75,10 @@ class ItemBuilder {
63
75
  */
64
76
  setExportOption(option, items) {
65
77
  const groupName = this.getExportGroupName();
66
- if (option === dataExporterOption.DataExporterOption.EXPORT_TO_PDF) {
78
+ if (option === DataExporterOption.EXPORT_TO_PDF) {
67
79
  items.push(this.getExportToPDF(groupName));
68
80
  }
69
- if (option === dataExporterOption.DataExporterOption.EXPORT_TO_XLS) {
81
+ if (option === DataExporterOption.EXPORT_TO_XLS) {
70
82
  items.push(this.getExportToXLS(groupName));
71
83
  }
72
84
  this.setExportCurrentPage(option, items);
@@ -79,23 +91,23 @@ class ItemBuilder {
79
91
  */
80
92
  setExportCurrentPage(option, items) {
81
93
  var _a;
82
- const pageOptions = [dataExporterOption.DataExporterOption.EXPORT_PAGE_TO_PDF, dataExporterOption.DataExporterOption.EXPORT_PAGE_TO_XLS];
83
- if (option === dataExporterOption.DataExporterOption.EXPORT_CURRENT_PAGE) {
94
+ const pageOptions = [DataExporterOption.EXPORT_PAGE_TO_PDF, DataExporterOption.EXPORT_PAGE_TO_XLS];
95
+ if (option === DataExporterOption.EXPORT_CURRENT_PAGE) {
84
96
  items.push(this.getCurrentPage());
85
97
  }
86
98
  if (pageOptions.includes(option)) {
87
- let item = items.find((item) => item.id === dataExporterOption.DataExporterOption.EXPORT_CURRENT_PAGE);
99
+ let item = items.find((item) => item.id === DataExporterOption.EXPORT_CURRENT_PAGE);
88
100
  if (item == undefined) {
89
101
  items.push(this.getCurrentPage());
90
- item = items.find((item) => item.id === dataExporterOption.DataExporterOption.EXPORT_CURRENT_PAGE);
102
+ item = items.find((item) => item.id === DataExporterOption.EXPORT_CURRENT_PAGE);
91
103
  }
92
104
  if (!((_a = item === null || item === void 0 ? void 0 : item.children) === null || _a === void 0 ? void 0 : _a.length)) {
93
105
  item.children = [];
94
106
  }
95
- if (option === dataExporterOption.DataExporterOption.EXPORT_PAGE_TO_PDF) {
107
+ if (option === DataExporterOption.EXPORT_PAGE_TO_PDF) {
96
108
  item.children.push(this.getExportPageToPDF());
97
109
  }
98
- if (option === dataExporterOption.DataExporterOption.EXPORT_PAGE_TO_XLS) {
110
+ if (option === DataExporterOption.EXPORT_PAGE_TO_XLS) {
99
111
  item.children.push(this.getExportPageToXLS());
100
112
  }
101
113
  }
@@ -106,7 +118,7 @@ class ItemBuilder {
106
118
  * @param items - Array que será alimentado com as opções permitidas.
107
119
  */
108
120
  setExportByEmail(option, items) {
109
- if (option === dataExporterOption.DataExporterOption.EXPORT_BY_EMAIL) {
121
+ if (option === DataExporterOption.EXPORT_BY_EMAIL) {
110
122
  items.push(this.getExportByEmail());
111
123
  }
112
124
  }
@@ -117,7 +129,7 @@ class ItemBuilder {
117
129
  */
118
130
  getExportToPDF(groupName) {
119
131
  return {
120
- id: dataExporterOption.DataExporterOption.EXPORT_TO_PDF,
132
+ id: DataExporterOption.EXPORT_TO_PDF,
121
133
  label: "PDF (.pdf)",
122
134
  group: groupName
123
135
  };
@@ -129,7 +141,7 @@ class ItemBuilder {
129
141
  */
130
142
  getExportToXLS(groupName) {
131
143
  return {
132
- id: dataExporterOption.DataExporterOption.EXPORT_TO_XLS,
144
+ id: DataExporterOption.EXPORT_TO_XLS,
133
145
  label: `${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`,
134
146
  group: groupName
135
147
  };
@@ -140,7 +152,7 @@ class ItemBuilder {
140
152
  */
141
153
  getCurrentPage() {
142
154
  return {
143
- id: dataExporterOption.DataExporterOption.EXPORT_CURRENT_PAGE,
155
+ id: DataExporterOption.EXPORT_CURRENT_PAGE,
144
156
  label: this._getMessage("snkDataExporter.label.currentPage"),
145
157
  group: this._getMessage("snkDataExporter.group.custom")
146
158
  };
@@ -151,7 +163,7 @@ class ItemBuilder {
151
163
  */
152
164
  getExportPageToPDF() {
153
165
  return {
154
- id: dataExporterOption.DataExporterOption.EXPORT_PAGE_TO_PDF,
166
+ id: DataExporterOption.EXPORT_PAGE_TO_PDF,
155
167
  label: "PDF (.pdf)"
156
168
  };
157
169
  }
@@ -161,7 +173,7 @@ class ItemBuilder {
161
173
  */
162
174
  getExportPageToXLS() {
163
175
  return {
164
- id: dataExporterOption.DataExporterOption.EXPORT_PAGE_TO_XLS,
176
+ id: DataExporterOption.EXPORT_PAGE_TO_XLS,
165
177
  label: `${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`
166
178
  };
167
179
  }
@@ -171,7 +183,7 @@ class ItemBuilder {
171
183
  */
172
184
  getExportByEmail() {
173
185
  return {
174
- id: dataExporterOption.DataExporterOption.EXPORT_BY_EMAIL,
186
+ id: DataExporterOption.EXPORT_BY_EMAIL,
175
187
  label: `${this._getMessage("snkDataExporter.label.sendByEmail")}...`
176
188
  };
177
189
  }
@@ -195,21 +207,46 @@ const snkDataExporterCss = ".sc-snk-data-exporter-h{--snk-data-exporter--z-index
195
207
  const SnkDataExporter = class {
196
208
  constructor(hostRef) {
197
209
  index.registerInstance(this, hostRef);
198
- this.ezClickDataExporter = index.createEvent(this, "ezClickDataExporter", 7);
199
210
  this._items = [];
200
211
  this._selectedNumber = 0;
201
212
  this._showDropdown = false;
202
213
  this._releasedToExport = [
203
- dataExporterOption.DataExporterOption.EXPORT_TO_PDF,
204
- dataExporterOption.DataExporterOption.EXPORT_BY_EMAIL,
205
- dataExporterOption.DataExporterOption.EXPORT_PDF_TO_EMAIL,
206
- dataExporterOption.DataExporterOption.EXPORT_XLS_TO_EMAIL
214
+ DataExporterOption.EXPORT_TO_PDF,
215
+ DataExporterOption.EXPORT_BY_EMAIL,
216
+ DataExporterOption.EXPORT_PDF_TO_EMAIL,
217
+ DataExporterOption.EXPORT_XLS_TO_EMAIL
207
218
  ];
208
219
  /**
209
220
  * Provedor das informações para exportação dos dados.
210
221
  */
211
222
  this.provider = null;
212
223
  }
224
+ async exportByEmail() {
225
+ const selectedRows = this._selectedNumber;
226
+ const config = {
227
+ type: selectedRows > 0 ? "selection" : "all",
228
+ selectedRows,
229
+ email: {
230
+ attachments: [
231
+ { name: this._appLabel }
232
+ ]
233
+ }
234
+ };
235
+ this._snkEmailSender.open(config)
236
+ .then(({ format, email: { to, subject, message } }) => {
237
+ const methodName = this.getFormatExporter(format);
238
+ this.resolveExporter({ methodName, to, subject, message, fileName: this._appLabel, titleGrid: this._appLabel }, () => {
239
+ this._snkEmailSender.close();
240
+ utils.ApplicationUtils.info(this.getMessage("snkDataExporter.message.emailSuccess"), { iconName: "check" });
241
+ });
242
+ });
243
+ }
244
+ getFormatExporter(format) {
245
+ if (format === "xlsx") {
246
+ return DataExporterOption.EXPORT_XLS_TO_EMAIL;
247
+ }
248
+ return DataExporterOption.EXPORT_PDF_TO_EMAIL;
249
+ }
213
250
  /**
214
251
  * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
215
252
  * através de um pequeno modulo na estrutura da aplicação:
@@ -246,24 +283,32 @@ const SnkDataExporter = class {
246
283
  controlDropdown() {
247
284
  this._showDropdown = !this._showDropdown;
248
285
  }
286
+ resolveExporter(resolveProps, callbackResolver) {
287
+ if (this.provider == undefined) {
288
+ return;
289
+ }
290
+ const filters = this.provider.getFilters();
291
+ const columns = this.provider.getColumnsMetadata();
292
+ const sort = this.provider.getOrders();
293
+ const resourceURI = this.provider.getResourceURI();
294
+ fetchDataExporter(Object.assign({ filters,
295
+ columns,
296
+ sort,
297
+ resourceURI }, resolveProps))
298
+ .then((result) => callbackResolver(result))
299
+ .catch(() => utils.ApplicationUtils.error(this.getMessage("snkDataExporter.title.error"), this.getMessage("snkDataExporter.message.exportError")));
300
+ }
249
301
  async processExporter(evt) {
250
302
  const item = evt === null || evt === void 0 ? void 0 : evt.detail;
251
303
  if (!this._releasedToExport.includes(item === null || item === void 0 ? void 0 : item.id)) {
252
304
  return;
253
305
  }
254
- if (item.id !== dataExporterOption.DataExporterOption.EXPORT_BY_EMAIL) {
255
- if (this.provider == undefined) {
256
- return;
257
- }
258
- const filters = this.provider.getFilters();
259
- const columns = this.provider.getColumnsMetadata();
260
- const sort = this.provider.getOrders();
261
- const resourceURI = this.provider.getResourceURI();
262
- fetchDataExporter({ filters, columns, sort, resourceURI, methodName: item.id })
263
- .then((response) => fileViewer(Object.assign(Object.assign({}, response), { fileType: "PDF" })))
264
- .catch(err => console.log(err));
306
+ if (item.id === DataExporterOption.EXPORT_BY_EMAIL) {
307
+ this.exportByEmail();
308
+ }
309
+ else {
310
+ this.resolveExporter({ methodName: item.id, fileName: this._appLabel, titleGrid: this._appLabel }, (response) => (fileViewer(Object.assign(Object.assign({}, response), { fileType: "PDF" }))));
265
311
  }
266
- this.ezClickDataExporter.emit(item);
267
312
  this._showDropdown = false;
268
313
  }
269
314
  getItems() {
@@ -282,6 +327,7 @@ const SnkDataExporter = class {
282
327
  }
283
328
  componentWillLoad() {
284
329
  this._application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
330
+ this._application.getAppLabel().then(result => this._appLabel = result);
285
331
  this.loadDropdown();
286
332
  this.setEvents();
287
333
  }
@@ -304,129 +350,12 @@ const SnkDataExporter = class {
304
350
  render() {
305
351
  return (index.h(index.Host, null, index.h("div", { class: "snk-data-exporter" }, index.h("ez-button", Object.assign({ ref: (ref) => this._ezButton = ref, iconName: "file-download", size: "small", mode: "icon", onClick: () => this.controlDropdown() }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${core.ElementIDUtils.getInternalIDInfo("button")}` })), this._showDropdown &&
306
352
  index.h("ez-dropdown", Object.assign({ ref: (ref) => this._ezDropdown = ref, items: this._items, onEzClick: (evt) => this.processExporter(evt) }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${core.ElementIDUtils.getInternalIDInfo("dropdown")}` }))), this._showDropdown &&
307
- index.h("div", Object.assign({ class: "ez-scrim ez-scrim-light" }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${core.ElementIDUtils.getInternalIDInfo("ezScrim")}` }))));
353
+ index.h("div", Object.assign({ class: "ez-scrim ez-scrim-light" }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${core.ElementIDUtils.getInternalIDInfo("ezScrim")}` })), index.h("snk-exporter-email-sender", { ref: ref => this._snkEmailSender = ref, getMessage: (key, params) => this.getMessage(key, params) })));
308
354
  }
309
355
  get _element() { return index.getElement(this); }
310
356
  };
311
357
  SnkDataExporter.style = snkDataExporterCss;
312
358
 
313
- const EmailInfoStep = ({ getMessage, changeInfo, data }) => {
314
- return index.h("div", null,
315
- index.h("ez-text-input", Object.assign({ label: `${getMessage("snkExporter.emailSenderInfoStep_sendTo")} (obrigatório) *`, required: true, value: data === null || data === void 0 ? void 0 : data.to, onEzChange: evt => changeInfo("to", evt.detail) }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${core.ElementIDUtils.getInternalIDInfo("sendTo")}` })),
316
- index.h("ez-text-input", Object.assign({ label: `${getMessage("snkExporter.emailSenderInfoStep_subject")} (obrigatório) *`, required: true, value: data === null || data === void 0 ? void 0 : data.subject, onEzChange: evt => changeInfo("subject", evt.detail) }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${core.ElementIDUtils.getInternalIDInfo("subject")}` })),
317
- index.h("ez-text-area", Object.assign({ label: getMessage("snkExporter.emailSenderInfoStep_message"), value: data === null || data === void 0 ? void 0 : data.message, onEzChange: evt => changeInfo("message", evt.detail) }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${core.ElementIDUtils.getInternalIDInfo("message")}` })),
318
- ((data === null || data === void 0 ? void 0 : data.attachments) || [])
319
- .map((file, index$1) => index.h("ez-file-item", Object.assign({ class: "ez-padding-bottom--large", fileName: file.name, fileSize: file.size, canRemove: false }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${core.ElementIDUtils.getInternalIDInfo("fileItem_") + (index$1 + 1)}` }))));
320
- };
321
-
322
- const OptionsStep = ({ getMessage, changeInfo, data }) => {
323
- const selectionCount = (data === null || data === void 0 ? void 0 : data.selectedRows) || 0;
324
- const formatOptions = [
325
- { label: getMessage("snkExporter.emailSenderOptStep_formatPDF"), value: "pdf" },
326
- { label: getMessage("snkExporter.emailSenderOptStep_formatXLSX"), value: "xlsx" }
327
- ];
328
- const typeOptions = [
329
- { label: getMessage("snkExporter.emailSenderOptStep_allData"), value: "all" },
330
- { label: getMessage("snkExporter.emailSenderOptStep_currentPage"), value: "page" },
331
- ];
332
- if (selectionCount > 0) {
333
- const label = getMessage(selectionCount > 1 ? "snkExporter.emailSenderOptStep_someRecords" : "snkExporter.emailSenderOptStep_oneRecord", { SELECTION_COUNT: selectionCount });
334
- typeOptions.push({
335
- label,
336
- value: "selection"
337
- });
338
- }
339
- return index.h("div", null,
340
- index.h("ez-radio-button", Object.assign({ class: "ez-margin-bottom--large" }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${core.ElementIDUtils.getInternalIDInfo("formato")}` }, { label: getMessage("snkExporter.emailSenderOptStep_lblFormat"), direction: "horizontal", value: (data === null || data === void 0 ? void 0 : data.format) || "pdf", onEzChange: evt => changeInfo("format", evt.detail), options: formatOptions })),
341
- index.h("ez-radio-button", Object.assign({ class: "ez-margin-bottom--large" }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${core.ElementIDUtils.getInternalIDInfo("type")}` }, { label: getMessage("snkExporter.emailSenderOptStep_export"), value: (data === null || data === void 0 ? void 0 : data.type) || "all", onEzChange: evt => changeInfo("type", evt.detail), options: typeOptions })));
342
- };
343
-
344
- const SnkExporterEmailSender = class {
345
- constructor(hostRef) {
346
- index.registerInstance(this, hostRef);
347
- this._stepInfo = [
348
- {
349
- subTitle: "snkExporter.emailSenderOptStep_subtitle",
350
- firstButton: "snkExporter.emailSenderCancelButton",
351
- secondButton: "snkExporter.emailSenderNextButton",
352
- firstButtonAction: () => this.close(),
353
- secondButtonAction: () => this.changeStep(1)
354
- },
355
- {
356
- subTitle: "snkExporter.emailSenderInfoStep_subtitle",
357
- firstButton: "snkExporter.emailSenderBackButton",
358
- secondButton: "snkExporter.emailSenderSendButton",
359
- firstButtonAction: () => this.changeStep(0),
360
- secondButtonAction: () => this.send(),
361
- secondButtonEnabledTester: () => this.isFilled(),
362
- secondButtonClass: "ez-button--primary"
363
- }
364
- ];
365
- this._opened = false;
366
- this._currentStep = 0;
367
- }
368
- open(config) {
369
- this._config = config;
370
- this._opened = true;
371
- this.changeStep(0);
372
- return new Promise(accept => {
373
- this._promiseResolver = accept;
374
- });
375
- }
376
- getStepMessage(key) {
377
- const stepInfo = this._stepInfo[this._currentStep] || {};
378
- return this.getMessage(stepInfo[key]);
379
- }
380
- executeButtonAction(first) {
381
- const stepInfo = this._stepInfo[this._currentStep] || {};
382
- stepInfo[first ? "firstButtonAction" : "secondButtonAction"]();
383
- }
384
- checkButtonEnabled(first) {
385
- const stepInfo = this._stepInfo[this._currentStep] || {};
386
- const testFunction = stepInfo[first ? "firstButtonEnabledTester" : "secondButtonEnabledTester"];
387
- if (testFunction) {
388
- return testFunction();
389
- }
390
- return true;
391
- }
392
- changeStep(index) {
393
- this._currentStep = index;
394
- if (this._viewStack) {
395
- this._viewStack.show(this._currentStep);
396
- }
397
- }
398
- send() {
399
- const { format, type, email } = this._config;
400
- this._promiseResolver({ format, type, email, report: undefined });
401
- }
402
- close() {
403
- this._opened = false;
404
- }
405
- isFilled() {
406
- var _a, _b;
407
- return ((_a = this._config.email) === null || _a === void 0 ? void 0 : _a.to) && ((_b = this._config.email) === null || _b === void 0 ? void 0 : _b.subject) ? true : false;
408
- }
409
- updateEmailInfo(field, value) {
410
- this._config = Object.assign(Object.assign({}, this._config), { email: Object.assign(Object.assign({}, this._config.email), { [field]: value }) });
411
- }
412
- updateConfigInfo(field, value) {
413
- this._config = Object.assign(Object.assign({}, this._config), { [field]: value });
414
- }
415
- getSecondButtonClass() {
416
- const stepInfo = this._stepInfo[this._currentStep] || {};
417
- return stepInfo["secondButtonClass"] || "ez-button--secondary";
418
- }
419
- render() {
420
- var _a;
421
- core.ElementIDUtils.addIDInfoIfNotExists(this._element, 'snkExporterEmailSender');
422
- return (index.h("ez-popup", { useHeader: false, size: "x-small", heightMode: "auto", opened: this._opened }, index.h("ez-modal-container", { onEzModalAction: evt => {
423
- if (evt.detail === "CLOSE")
424
- this.close();
425
- }, modalTitle: this.getMessage("snkExporter.emailSenderTitle"), modalSubTitle: this.getStepMessage("subTitle") }, index.h("ez-view-stack", { ref: ref => this._viewStack = ref }, index.h("stack-item", null, index.h(OptionsStep, { getMessage: this.getMessage, data: this._config, changeInfo: (field, value) => this.updateConfigInfo(field, value) })), index.h("stack-item", null, index.h(EmailInfoStep, { getMessage: this.getMessage, data: (_a = this._config) === null || _a === void 0 ? void 0 : _a.email, changeInfo: (field, value) => this.updateEmailInfo(field, value) }))), index.h("div", { class: "ez-col ez-col--sd-12 ez-flex--justify-end ez-margin-vertical--small" }, index.h("ez-button", Object.assign({ class: "ez-button--tertiary ez-padding-right--medium", label: this.getStepMessage("firstButton"), onClick: () => this.executeButtonAction(true), enabled: this.checkButtonEnabled(true) }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${core.ElementIDUtils.getInternalIDInfo("firstButton")}` })), index.h("ez-button", Object.assign({ class: this.getSecondButtonClass(), label: this.getStepMessage("secondButton"), onClick: () => this.executeButtonAction(false), enabled: this.checkButtonEnabled(false) }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${core.ElementIDUtils.getInternalIDInfo("secondButton")}` }))))));
426
- }
427
- get _element() { return index.getElement(this); }
428
- };
429
-
430
359
  const buildFilter = (item) => {
431
360
  switch (item.type) {
432
361
  case filterItemType_enum.FilterItemType.DEFAULT_FILTER:
@@ -1835,8 +1764,8 @@ const SnkTaskbar = class {
1835
1764
  if (buttonName === taskbarElements.AuthorizationElements.CONFIGURATOR) {
1836
1765
  return this._permissions
1837
1766
  ? this._permissions.isSup
1838
- || this._permissions[dataExporterOption.AuthorizationConfig.CONFIG_GRID]
1839
- || this._permissions[dataExporterOption.AuthorizationConfig.CONFIG]
1767
+ || this._permissions[AuthorizationConfig.AuthorizationConfig.CONFIG_GRID]
1768
+ || this._permissions[AuthorizationConfig.AuthorizationConfig.CONFIG]
1840
1769
  : false;
1841
1770
  }
1842
1771
  if (taskbarElements.AuthorizationElements[buttonName]) {
@@ -1982,7 +1911,6 @@ const SnkTaskbar = class {
1982
1911
  SnkTaskbar.style = snkTaskbarCss;
1983
1912
 
1984
1913
  exports.snk_data_exporter = SnkDataExporter;
1985
- exports.snk_exporter_email_sender = SnkExporterEmailSender;
1986
1914
  exports.snk_filter_bar = SnkFilterBar;
1987
1915
  exports.snk_filter_item = SnkFilterItem;
1988
1916
  exports.snk_filter_list = SnkFilterList;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const index = require('./index-2cd6f753.js');
6
6
  const core = require('@sankhyalabs/core');
7
7
  const utils = require('@sankhyalabs/ezui/dist/collection/utils');
8
- const SnkMessageBuilder = require('./SnkMessageBuilder-09b25b0a.js');
8
+ const SnkMessageBuilder = require('./SnkMessageBuilder-248b5105.js');
9
9
 
10
10
  const snkDataUnitCss = ".sc-snk-data-unit-h{display:flex;flex-direction:column;height:100%}";
11
11
 
@@ -0,0 +1,129 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-2cd6f753.js');
6
+ const core = require('@sankhyalabs/core');
7
+
8
+ const EmailInfoStep = ({ getMessage, changeInfo, data }) => {
9
+ const { format, email } = data || {};
10
+ return index.h("div", null,
11
+ index.h("ez-text-input", Object.assign({ label: `${getMessage("snkExporter.emailSenderInfoStep_sendTo")} (obrigatório) *`, required: true, value: email === null || email === void 0 ? void 0 : email.to, onEzChange: evt => changeInfo("to", evt.detail) }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${core.ElementIDUtils.getInternalIDInfo("sendTo")}` })),
12
+ index.h("ez-text-input", Object.assign({ label: `${getMessage("snkExporter.emailSenderInfoStep_subject")} (obrigatório) *`, required: true, value: email === null || email === void 0 ? void 0 : email.subject, onEzChange: evt => changeInfo("subject", evt.detail) }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${core.ElementIDUtils.getInternalIDInfo("subject")}` })),
13
+ index.h("ez-text-area", Object.assign({ label: getMessage("snkExporter.emailSenderInfoStep_message"), value: email === null || email === void 0 ? void 0 : email.message, onEzChange: evt => changeInfo("message", evt.detail) }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${core.ElementIDUtils.getInternalIDInfo("message")}` })),
14
+ ((email === null || email === void 0 ? void 0 : email.attachments) || [])
15
+ .map((file, index$1) => index.h("ez-file-item", Object.assign({ class: "ez-padding-bottom--large", fileName: `${file.name}.${format}`, fileSize: file.size, canRemove: false }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${core.ElementIDUtils.getInternalIDInfo("fileItem_") + (index$1 + 1)}` }))));
16
+ };
17
+
18
+ const OptionsStep = ({ getMessage, changeInfo, data }) => {
19
+ const selectionCount = (data === null || data === void 0 ? void 0 : data.selectedRows) || 0;
20
+ const formatOptions = [
21
+ { label: getMessage("snkExporter.emailSenderOptStep_formatPDF"), value: "pdf" },
22
+ { label: getMessage("snkExporter.emailSenderOptStep_formatXLSX"), value: "xlsx" }
23
+ ];
24
+ const typeOptions = [
25
+ { label: getMessage("snkExporter.emailSenderOptStep_allData"), value: "all" },
26
+ { label: getMessage("snkExporter.emailSenderOptStep_currentPage"), value: "page" },
27
+ ];
28
+ if (selectionCount > 0) {
29
+ const label = getMessage(selectionCount > 1 ? "snkExporter.emailSenderOptStep_someRecords" : "snkExporter.emailSenderOptStep_oneRecord", { SELECTION_COUNT: selectionCount });
30
+ typeOptions.push({
31
+ label,
32
+ value: "selection"
33
+ });
34
+ }
35
+ return index.h("div", null,
36
+ index.h("ez-radio-button", Object.assign({ class: "ez-margin-bottom--large" }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${core.ElementIDUtils.getInternalIDInfo("formato")}` }, { label: getMessage("snkExporter.emailSenderOptStep_lblFormat"), direction: "horizontal", value: data === null || data === void 0 ? void 0 : data.format, onEzChange: evt => changeInfo("format", evt.detail), options: formatOptions })),
37
+ index.h("ez-radio-button", Object.assign({ class: "ez-margin-bottom--large" }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${core.ElementIDUtils.getInternalIDInfo("type")}` }, { label: getMessage("snkExporter.emailSenderOptStep_export"), value: (data === null || data === void 0 ? void 0 : data.type) || "all", onEzChange: evt => changeInfo("type", evt.detail), options: typeOptions })));
38
+ };
39
+
40
+ const SnkExporterEmailSender = class {
41
+ constructor(hostRef) {
42
+ index.registerInstance(this, hostRef);
43
+ this._stepInfo = [
44
+ {
45
+ subTitle: "snkExporter.emailSenderOptStep_subtitle",
46
+ firstButton: "snkExporter.emailSenderCancelButton",
47
+ secondButton: "snkExporter.emailSenderNextButton",
48
+ firstButtonAction: () => this.close(),
49
+ secondButtonAction: () => this.changeStep(1)
50
+ },
51
+ {
52
+ subTitle: "snkExporter.emailSenderInfoStep_subtitle",
53
+ firstButton: "snkExporter.emailSenderBackButton",
54
+ secondButton: "snkExporter.emailSenderSendButton",
55
+ firstButtonAction: () => this.changeStep(0),
56
+ secondButtonAction: () => this.send(),
57
+ secondButtonEnabledTester: () => this.isFilled(),
58
+ secondButtonClass: "ez-button--primary"
59
+ }
60
+ ];
61
+ this._opened = false;
62
+ this._currentStep = 0;
63
+ }
64
+ open(config) {
65
+ var _a;
66
+ this._config = Object.assign(Object.assign({}, config), { format: (_a = config === null || config === void 0 ? void 0 : config.format) !== null && _a !== void 0 ? _a : "pdf" });
67
+ this._opened = true;
68
+ this.changeStep(0);
69
+ return new Promise(accept => {
70
+ this._promiseResolver = accept;
71
+ });
72
+ }
73
+ close() {
74
+ this._opened = false;
75
+ return new Promise(accept => {
76
+ this._promiseResolver = accept;
77
+ });
78
+ }
79
+ getStepMessage(key) {
80
+ const stepInfo = this._stepInfo[this._currentStep] || {};
81
+ return this.getMessage(stepInfo[key]);
82
+ }
83
+ executeButtonAction(first) {
84
+ const stepInfo = this._stepInfo[this._currentStep] || {};
85
+ stepInfo[first ? "firstButtonAction" : "secondButtonAction"]();
86
+ }
87
+ checkButtonEnabled(first) {
88
+ const stepInfo = this._stepInfo[this._currentStep] || {};
89
+ const testFunction = stepInfo[first ? "firstButtonEnabledTester" : "secondButtonEnabledTester"];
90
+ if (testFunction) {
91
+ return testFunction();
92
+ }
93
+ return true;
94
+ }
95
+ changeStep(index) {
96
+ this._currentStep = index;
97
+ if (this._viewStack) {
98
+ this._viewStack.show(this._currentStep);
99
+ }
100
+ }
101
+ send() {
102
+ const { format, type, email } = this._config;
103
+ this._promiseResolver({ format, type, email, report: undefined });
104
+ }
105
+ isFilled() {
106
+ var _a, _b;
107
+ return ((_a = this._config.email) === null || _a === void 0 ? void 0 : _a.to) && ((_b = this._config.email) === null || _b === void 0 ? void 0 : _b.subject) ? true : false;
108
+ }
109
+ updateEmailInfo(field, value) {
110
+ this._config = Object.assign(Object.assign({}, this._config), { email: Object.assign(Object.assign({}, this._config.email), { [field]: value }) });
111
+ }
112
+ updateConfigInfo(field, value) {
113
+ this._config = Object.assign(Object.assign({}, this._config), { [field]: value });
114
+ }
115
+ getSecondButtonClass() {
116
+ const stepInfo = this._stepInfo[this._currentStep] || {};
117
+ return stepInfo["secondButtonClass"] || "ez-button--secondary";
118
+ }
119
+ render() {
120
+ core.ElementIDUtils.addIDInfoIfNotExists(this._element, 'snkExporterEmailSender');
121
+ return (index.h("ez-popup", { useHeader: false, size: "x-small", heightMode: "auto", opened: this._opened }, index.h("ez-modal-container", { onEzModalAction: evt => {
122
+ if (evt.detail === "CLOSE")
123
+ this.close();
124
+ }, modalTitle: this.getMessage("snkExporter.emailSenderTitle"), modalSubTitle: this.getStepMessage("subTitle") }, index.h("ez-view-stack", { ref: ref => this._viewStack = ref }, index.h("stack-item", null, index.h(OptionsStep, { getMessage: this.getMessage, data: this._config, changeInfo: (field, value) => this.updateConfigInfo(field, value) })), index.h("stack-item", null, index.h(EmailInfoStep, { getMessage: this.getMessage, data: this._config, changeInfo: (field, value) => this.updateEmailInfo(field, value) }))), index.h("div", { class: "ez-col ez-col--sd-12 ez-flex--justify-end ez-margin-vertical--small" }, index.h("ez-button", Object.assign({ class: "ez-button--tertiary ez-padding-right--medium", label: this.getStepMessage("firstButton"), onClick: () => this.executeButtonAction(true), enabled: this.checkButtonEnabled(true) }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${core.ElementIDUtils.getInternalIDInfo("firstButton")}` })), index.h("ez-button", Object.assign({ class: this.getSecondButtonClass(), label: this.getStepMessage("secondButton"), onClick: () => this.executeButtonAction(false), enabled: this.checkButtonEnabled(false) }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${core.ElementIDUtils.getInternalIDInfo("secondButton")}` }))))));
125
+ }
126
+ get _element() { return index.getElement(this); }
127
+ };
128
+
129
+ exports.snk_exporter_email_sender = SnkExporterEmailSender;
@@ -575,6 +575,20 @@ export class SnkApplication {
575
575
  accept(window['isDebugMode']);
576
576
  });
577
577
  }
578
+ /**
579
+ * Obtém o nome das telas da aplicação
580
+ */
581
+ async getAppLabel() {
582
+ if ((window === null || window === void 0 ? void 0 : window["workspace"]) == undefined) {
583
+ return;
584
+ }
585
+ if (window["workspace"].getAppLabel == undefined) {
586
+ window["workspace"].getAppLabel = (resourceID) => {
587
+ return (resourceID || "").split(".").pop();
588
+ };
589
+ }
590
+ return window["workspace"].getAppLabel(this._resourceID);
591
+ }
578
592
  clearContent(container) {
579
593
  if (container) {
580
594
  Array.from(container.children).forEach(child => {
@@ -1722,6 +1736,22 @@ export class SnkApplication {
1722
1736
  "text": "Obt\u00E9m `true` caso a tela esteja em modo de debug.",
1723
1737
  "tags": []
1724
1738
  }
1739
+ },
1740
+ "getAppLabel": {
1741
+ "complexType": {
1742
+ "signature": "() => Promise<string>",
1743
+ "parameters": [],
1744
+ "references": {
1745
+ "Promise": {
1746
+ "location": "global"
1747
+ }
1748
+ },
1749
+ "return": "Promise<string>"
1750
+ },
1751
+ "docs": {
1752
+ "text": "Obt\u00E9m o nome das telas da aplica\u00E7\u00E3o",
1753
+ "tags": []
1754
+ }
1725
1755
  }
1726
1756
  };
1727
1757
  }
@@ -1,6 +1,7 @@
1
1
  import { h } from "@stencil/core";
2
2
  import { ElementIDUtils } from '@sankhyalabs/core';
3
3
  export const EmailInfoStep = ({ getMessage, changeInfo, data }) => {
4
- return h("div", null, h("ez-text-input", Object.assign({ label: `${getMessage("snkExporter.emailSenderInfoStep_sendTo")} (obrigatório) *`, required: true, value: data === null || data === void 0 ? void 0 : data.to, onEzChange: evt => changeInfo("to", evt.detail) }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo("sendTo")}` })), h("ez-text-input", Object.assign({ label: `${getMessage("snkExporter.emailSenderInfoStep_subject")} (obrigatório) *`, required: true, value: data === null || data === void 0 ? void 0 : data.subject, onEzChange: evt => changeInfo("subject", evt.detail) }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo("subject")}` })), h("ez-text-area", Object.assign({ label: getMessage("snkExporter.emailSenderInfoStep_message"), value: data === null || data === void 0 ? void 0 : data.message, onEzChange: evt => changeInfo("message", evt.detail) }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo("message")}` })), ((data === null || data === void 0 ? void 0 : data.attachments) || [])
5
- .map((file, index) => h("ez-file-item", Object.assign({ class: "ez-padding-bottom--large", fileName: file.name, fileSize: file.size, canRemove: false }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo("fileItem_") + (index + 1)}` }))));
4
+ const { format, email } = data || {};
5
+ return h("div", null, h("ez-text-input", Object.assign({ label: `${getMessage("snkExporter.emailSenderInfoStep_sendTo")} (obrigatório) *`, required: true, value: email === null || email === void 0 ? void 0 : email.to, onEzChange: evt => changeInfo("to", evt.detail) }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo("sendTo")}` })), h("ez-text-input", Object.assign({ label: `${getMessage("snkExporter.emailSenderInfoStep_subject")} (obrigatório) *`, required: true, value: email === null || email === void 0 ? void 0 : email.subject, onEzChange: evt => changeInfo("subject", evt.detail) }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo("subject")}` })), h("ez-text-area", Object.assign({ label: getMessage("snkExporter.emailSenderInfoStep_message"), value: email === null || email === void 0 ? void 0 : email.message, onEzChange: evt => changeInfo("message", evt.detail) }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo("message")}` })), ((email === null || email === void 0 ? void 0 : email.attachments) || [])
6
+ .map((file, index) => h("ez-file-item", Object.assign({ class: "ez-padding-bottom--large", fileName: `${file.name}.${format}`, fileSize: file.size, canRemove: false }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo("fileItem_") + (index + 1)}` }))));
6
7
  };
@@ -17,5 +17,5 @@ export const OptionsStep = ({ getMessage, changeInfo, data }) => {
17
17
  value: "selection"
18
18
  });
19
19
  }
20
- return h("div", null, h("ez-radio-button", Object.assign({ class: "ez-margin-bottom--large" }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo("formato")}` }, { label: getMessage("snkExporter.emailSenderOptStep_lblFormat"), direction: "horizontal", value: (data === null || data === void 0 ? void 0 : data.format) || "pdf", onEzChange: evt => changeInfo("format", evt.detail), options: formatOptions })), h("ez-radio-button", Object.assign({ class: "ez-margin-bottom--large" }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo("type")}` }, { label: getMessage("snkExporter.emailSenderOptStep_export"), value: (data === null || data === void 0 ? void 0 : data.type) || "all", onEzChange: evt => changeInfo("type", evt.detail), options: typeOptions })));
20
+ return h("div", null, h("ez-radio-button", Object.assign({ class: "ez-margin-bottom--large" }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo("formato")}` }, { label: getMessage("snkExporter.emailSenderOptStep_lblFormat"), direction: "horizontal", value: data === null || data === void 0 ? void 0 : data.format, onEzChange: evt => changeInfo("format", evt.detail), options: formatOptions })), h("ez-radio-button", Object.assign({ class: "ez-margin-bottom--large" }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo("type")}` }, { label: getMessage("snkExporter.emailSenderOptStep_export"), value: (data === null || data === void 0 ? void 0 : data.type) || "all", onEzChange: evt => changeInfo("type", evt.detail), options: typeOptions })));
21
21
  };