@sankhyalabs/sankhyablocks 6.8.0 → 6.9.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 (117) hide show
  1. package/dist/cjs/{ConfigStorage-86ffc4ab.js → ConfigStorage-3aaa8a9f.js} +4 -4
  2. package/dist/cjs/{DataFetcher-35849b28.js → DataFetcher-093c47ae.js} +146 -0
  3. package/dist/cjs/{SnkFormConfigManager-3b8e7c8a.js → SnkFormConfigManager-ddad3cbb.js} +2 -2
  4. package/dist/cjs/{SnkMessageBuilder-ba6d4ade.js → SnkMessageBuilder-e55c7afa.js} +25 -1
  5. package/dist/cjs/{dataunit-fetcher-75d7d77d.js → dataunit-fetcher-2f67ac79.js} +1 -1
  6. package/dist/cjs/{filter-bar-config-fetcher-2c62fb37.js → filter-bar-config-fetcher-81868495.js} +1 -1
  7. package/dist/cjs/{form-config-fetcher-f137bca0.js → form-config-fetcher-affb0b28.js} +2 -2
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/cjs/{pesquisa-fetcher-d53d9d40.js → pesquisa-fetcher-21c3afc9.js} +1 -1
  10. package/dist/cjs/{resource-fetcher-28fb554b.js → resource-fetcher-e71a11b8.js} +1 -1
  11. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  12. package/dist/cjs/snk-actions-button.cjs.entry.js +2 -2
  13. package/dist/cjs/snk-application.cjs.entry.js +8 -8
  14. package/dist/cjs/snk-attach.cjs.entry.js +2 -2
  15. package/dist/cjs/snk-crud.cjs.entry.js +2 -2
  16. package/dist/cjs/snk-data-exporter.cjs.entry.js +3 -3
  17. package/dist/cjs/{snk-data-unit-60e7965f.js → snk-data-unit-26cf970c.js} +1 -1
  18. package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
  19. package/dist/cjs/snk-detail-view.cjs.entry.js +9 -9
  20. package/dist/cjs/snk-filter-bar.cjs.entry.js +5 -5
  21. package/dist/cjs/snk-filter-detail.cjs.entry.js +3 -3
  22. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +5 -5
  23. package/dist/cjs/snk-form-config.cjs.entry.js +3 -3
  24. package/dist/cjs/snk-form.cjs.entry.js +6 -6
  25. package/dist/cjs/snk-grid-config.cjs.entry.js +5 -5
  26. package/dist/cjs/snk-grid.cjs.entry.js +5 -5
  27. package/dist/cjs/{snk-guides-viewer-40808d6c.js → snk-guides-viewer-b0f98cf4.js} +3 -3
  28. package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -8
  29. package/dist/cjs/snk-personalized-filter.cjs.entry.js +5 -5
  30. package/dist/cjs/snk-print-selector.cjs.entry.js +164 -0
  31. package/dist/cjs/snk-simple-crud.cjs.entry.js +2 -2
  32. package/dist/collection/collection-manifest.json +1 -0
  33. package/dist/collection/components/snk-print-selector/snk-print-selector.css +27 -0
  34. package/dist/collection/components/snk-print-selector/snk-print-selector.js +200 -0
  35. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +10 -0
  36. package/dist/collection/lib/message/SnkMessageBuilder.js +3 -1
  37. package/dist/collection/lib/message/resources/snk-print-selector.msg.js +22 -0
  38. package/dist/collection/lib/utils/PrintUtils.js +137 -0
  39. package/dist/components/DataFetcher.js +147 -2
  40. package/dist/components/SnkMessageBuilder.js +25 -1
  41. package/dist/components/index.d.ts +1 -0
  42. package/dist/components/index.js +1 -0
  43. package/dist/components/snk-print-selector.d.ts +11 -0
  44. package/dist/components/snk-print-selector.js +179 -0
  45. package/dist/esm/{ConfigStorage-a4e8c4ab.js → ConfigStorage-24b221ba.js} +4 -4
  46. package/dist/esm/{DataFetcher-74c98125.js → DataFetcher-6153ff3e.js} +147 -2
  47. package/dist/esm/{SnkFormConfigManager-cc85f865.js → SnkFormConfigManager-fcbefc1a.js} +2 -2
  48. package/dist/esm/{SnkMessageBuilder-9d2becfb.js → SnkMessageBuilder-96e66d9c.js} +25 -1
  49. package/dist/esm/{dataunit-fetcher-30631ab4.js → dataunit-fetcher-09586248.js} +1 -1
  50. package/dist/esm/{filter-bar-config-fetcher-34892dca.js → filter-bar-config-fetcher-73ebc12f.js} +1 -1
  51. package/dist/esm/{form-config-fetcher-055ecbac.js → form-config-fetcher-01e9985d.js} +2 -2
  52. package/dist/esm/loader.js +1 -1
  53. package/dist/esm/{pesquisa-fetcher-f03c9cd5.js → pesquisa-fetcher-829ec5a9.js} +1 -1
  54. package/dist/esm/{resource-fetcher-c1210690.js → resource-fetcher-d053e214.js} +1 -1
  55. package/dist/esm/sankhyablocks.js +1 -1
  56. package/dist/esm/snk-actions-button.entry.js +2 -2
  57. package/dist/esm/snk-application.entry.js +8 -8
  58. package/dist/esm/snk-attach.entry.js +2 -2
  59. package/dist/esm/snk-crud.entry.js +2 -2
  60. package/dist/esm/snk-data-exporter.entry.js +3 -3
  61. package/dist/esm/{snk-data-unit-5e4fe819.js → snk-data-unit-0f2d3c74.js} +1 -1
  62. package/dist/esm/snk-data-unit.entry.js +2 -2
  63. package/dist/esm/snk-detail-view.entry.js +9 -9
  64. package/dist/esm/snk-filter-bar.entry.js +5 -5
  65. package/dist/esm/snk-filter-detail.entry.js +3 -3
  66. package/dist/esm/snk-filter-modal-item.entry.js +5 -5
  67. package/dist/esm/snk-form-config.entry.js +3 -3
  68. package/dist/esm/snk-form.entry.js +6 -6
  69. package/dist/esm/snk-grid-config.entry.js +5 -5
  70. package/dist/esm/snk-grid.entry.js +5 -5
  71. package/dist/esm/{snk-guides-viewer-9e9b5290.js → snk-guides-viewer-ab5c376c.js} +3 -3
  72. package/dist/esm/snk-guides-viewer.entry.js +8 -8
  73. package/dist/esm/snk-personalized-filter.entry.js +5 -5
  74. package/dist/esm/snk-print-selector.entry.js +156 -0
  75. package/dist/esm/snk-simple-crud.entry.js +2 -2
  76. package/dist/sankhyablocks/{p-c2cb015f.entry.js → p-05d82333.entry.js} +1 -1
  77. package/dist/sankhyablocks/{p-cfcd8f5b.entry.js → p-07cb8a03.entry.js} +1 -1
  78. package/dist/sankhyablocks/{p-4acd4b0c.entry.js → p-13f0ed88.entry.js} +1 -1
  79. package/dist/sankhyablocks/{p-a029d9a4.entry.js → p-16ad23d5.entry.js} +1 -1
  80. package/dist/sankhyablocks/{p-0a0985c9.entry.js → p-1b596ea1.entry.js} +1 -1
  81. package/dist/sankhyablocks/{p-77fe6eae.entry.js → p-1cf9d5a6.entry.js} +1 -1
  82. package/dist/sankhyablocks/{p-6871a878.js → p-2b449454.js} +1 -1
  83. package/dist/sankhyablocks/{p-f8499a4e.entry.js → p-3e8748b1.entry.js} +1 -1
  84. package/dist/sankhyablocks/{p-cad72c62.entry.js → p-432dd007.entry.js} +1 -1
  85. package/dist/sankhyablocks/p-43e18073.entry.js +11 -0
  86. package/dist/sankhyablocks/{p-c7be0415.entry.js → p-4ab8d0ee.entry.js} +1 -1
  87. package/dist/sankhyablocks/{p-3d8120ef.js → p-60ad0dea.js} +1 -1
  88. package/dist/sankhyablocks/p-6f49f5d4.entry.js +1 -0
  89. package/dist/sankhyablocks/{p-3ab6b96d.js → p-744d0fd2.js} +1 -1
  90. package/dist/sankhyablocks/{p-187b54d0.entry.js → p-7dd92fb8.entry.js} +1 -1
  91. package/dist/sankhyablocks/{p-79e24321.js → p-814f9247.js} +1 -1
  92. package/dist/sankhyablocks/{p-00f584c7.entry.js → p-85e6068d.entry.js} +1 -1
  93. package/dist/sankhyablocks/{p-548af336.js → p-89fb7531.js} +2 -2
  94. package/dist/sankhyablocks/p-9404ad4d.entry.js +1 -0
  95. package/dist/sankhyablocks/{p-93935922.js → p-9a7aafe4.js} +1 -1
  96. package/dist/sankhyablocks/p-ad4bb9d2.entry.js +1 -0
  97. package/dist/sankhyablocks/{p-d15777d0.entry.js → p-bd1f8640.entry.js} +1 -1
  98. package/dist/sankhyablocks/{p-a1b76ddf.js → p-bfe8b96d.js} +1 -1
  99. package/dist/sankhyablocks/{p-12699076.js → p-d20e2ce3.js} +1 -1
  100. package/dist/sankhyablocks/{p-c0be90a3.entry.js → p-e665c93f.entry.js} +1 -1
  101. package/dist/sankhyablocks/{p-59e539a4.js → p-e789eb2d.js} +1 -1
  102. package/dist/sankhyablocks/{p-425addc3.js → p-eaec700d.js} +1 -1
  103. package/dist/sankhyablocks/{p-01070d6d.js → p-eb0c9f4c.js} +1 -1
  104. package/dist/sankhyablocks/{p-e6dc5f63.entry.js → p-feb6963e.entry.js} +1 -1
  105. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  106. package/dist/types/components/snk-print-selector/snk-print-selector.d.ts +40 -0
  107. package/dist/types/components.d.ts +15 -0
  108. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +1 -0
  109. package/dist/types/lib/message/resources/snk-print-selector.msg.d.ts +1 -0
  110. package/dist/types/lib/utils/PrintUtils.d.ts +51 -0
  111. package/package.json +1 -1
  112. package/react/components.d.ts +1 -0
  113. package/react/components.js +1 -0
  114. package/react/components.js.map +1 -1
  115. package/dist/sankhyablocks/p-1a2d8996.entry.js +0 -1
  116. package/dist/sankhyablocks/p-47f8fef4.entry.js +0 -1
  117. package/dist/sankhyablocks/p-9cb9a049.entry.js +0 -11
@@ -4,6 +4,7 @@ import UrlUtils from "../../../lib/utils/urlutils";
4
4
  import { StringUtils } from '@sankhyalabs/core';
5
5
  import { ServiceBrokerRecaller } from './recaller/ServiceBrokerRecaller';
6
6
  import { GraphQLRecaller } from './recaller/GraphQLRecaller';
7
+ import { PrintUtils } from '../../utils/PrintUtils';
7
8
  export class DataFetcher {
8
9
  constructor() {
9
10
  this.GRAPHQL_PATH = "/mgefin-bff/graphql";
@@ -146,6 +147,14 @@ export class DataFetcher {
146
147
  }
147
148
  });
148
149
  }
150
+ processPrinting(payload) {
151
+ if ((payload === null || payload === void 0 ? void 0 : payload.pendingPrinting) === 'true') {
152
+ PrintUtils.getInstance().processPendingPrinting(payload === null || payload === void 0 ? void 0 : payload.transactionId);
153
+ }
154
+ if ('localPrintings' in payload) {
155
+ PrintUtils.getInstance().processLocalPrinting(payload === null || payload === void 0 ? void 0 : payload.localPrintings);
156
+ }
157
+ }
149
158
  getContext(module) {
150
159
  var _a;
151
160
  const urlParams = UrlUtils.getQueryParams(location.search);
@@ -205,6 +214,7 @@ export class DataFetcher {
205
214
  }
206
215
  }
207
216
  this.proccessServiceBorkerClientEvents(jsonResp === null || jsonResp === void 0 ? void 0 : jsonResp.clientEvents, serviceName, payloadJson, accept, reject);
217
+ this.processPrinting(jsonResp);
208
218
  }
209
219
  catch (err) {
210
220
  console.warn(`Erro ao executar serviço: ${err}`);
@@ -16,6 +16,7 @@ import { snkAttachMessages } from "./resources/snk-attach.msg";
16
16
  import { snkPersonalizedFilterMessages } from "./resources/snk-personalized-filter.msg.js";
17
17
  import { snkEntityListMessages } from "./resources/snk-entity-list.msg.js";
18
18
  import { snkActionsButtonMessages } from "./resources/snk-actions-button.msg.js";
19
+ import { snkPrintSelectorMessages } from "./resources/snk-print-selector.msg.js";
19
20
  import { ApplicationContext } from "@sankhyalabs/core";
20
21
  export class SnkMessageBuilder {
21
22
  constructor(domainName) {
@@ -41,7 +42,8 @@ export class SnkMessageBuilder {
41
42
  snkAttach: snkAttachMessages,
42
43
  snkPersonalizedFilter: snkPersonalizedFilterMessages,
43
44
  snkEntityList: snkEntityListMessages,
44
- snkActionsButton: snkActionsButtonMessages
45
+ snkActionsButton: snkActionsButtonMessages,
46
+ snkPrintSelector: snkPrintSelectorMessages
45
47
  };
46
48
  this._currentOperation = OperationMap.CLEAN;
47
49
  this._domainName = domainName;
@@ -0,0 +1,22 @@
1
+ export const snkPrintSelectorMessages = {
2
+ title: {
3
+ warning: "Aviso",
4
+ printerSelection: "Seleção de impressora",
5
+ remotePrintersTab: "Impressoras remotas",
6
+ localPrintersTab: "Impressoras locais"
7
+ },
8
+ subtitle: {
9
+ document: "Documento:",
10
+ jobs: "Trabalhos:"
11
+ },
12
+ message: {
13
+ canceledPrint: "A impressão será cancelada. Deseja mesmo continuar?",
14
+ noPrinters: "Não há impressoras para seleção"
15
+ },
16
+ button: {
17
+ print: "Imprimir",
18
+ cancel: "Cancelar",
19
+ yes: "Sim",
20
+ no: "Não"
21
+ }
22
+ };
@@ -0,0 +1,137 @@
1
+ import { StringUtils } from "@sankhyalabs/core";
2
+ import { DataFetcher } from "../http/data-fetcher/DataFetcher";
3
+ export class PrintUtils {
4
+ constructor() {
5
+ }
6
+ static getInstance() {
7
+ if (!PrintUtils.instance) {
8
+ PrintUtils.instance = new PrintUtils();
9
+ }
10
+ return PrintUtils.instance;
11
+ }
12
+ async processPendingPrinting(transactionId) {
13
+ await this.findPendingPrints(transactionId);
14
+ }
15
+ async findPendingPrints(transactionId) {
16
+ const requestBody = {
17
+ transactionIds: [
18
+ {
19
+ transactionId: {
20
+ $: transactionId
21
+ }
22
+ }
23
+ ]
24
+ };
25
+ const response = await DataFetcher.get().callServiceBroker(PrintUtils.SERVICE_FIND_PENDING_PRINTS, JSON.stringify(requestBody));
26
+ const printJobData = this.parsePrintData(response);
27
+ this.openSnkPrintSelector(printJobData);
28
+ }
29
+ findLocalPrinters() {
30
+ const appletImpressao = document.getElementById('centralNotaAppletImpressao');
31
+ if (!appletImpressao)
32
+ return [];
33
+ const localPrinters = appletImpressao.getLocalPrinters();
34
+ if (!localPrinters)
35
+ return [];
36
+ const printers = [];
37
+ for (const printerName of localPrinters.split(',')) {
38
+ printers.push({
39
+ nome: printerName,
40
+ printerUri: PrintUtils.LOCAL_SERVER_URI + printerName,
41
+ isLocal: true
42
+ });
43
+ }
44
+ return printers;
45
+ }
46
+ getLocalPrinters() {
47
+ return this.findLocalPrinters();
48
+ }
49
+ parsePrintData(payload) {
50
+ const pendingPrintJobData = payload.pendindPrintJobData;
51
+ if (!pendingPrintJobData)
52
+ return undefined;
53
+ let { printServers: { printServer }, pendingPrinters: { pendingPrinter } } = pendingPrintJobData;
54
+ printServer = printServer ? (Array.isArray(printServer) ? printServer : [printServer]) : [];
55
+ pendingPrinter = pendingPrinter ? (Array.isArray(pendingPrinter) ? pendingPrinter : [pendingPrinter]) : [];
56
+ const normalizedPrintServer = printServer.map(item => {
57
+ const printerList = Array.isArray(item.printerLocation) ? item.printerLocation : [item.printerLocation];
58
+ return {
59
+ printServerUri: item.printServerUri,
60
+ printerList: printerList.map(this.normalize)
61
+ };
62
+ });
63
+ const normalizedPendingPrinter = pendingPrinter.map(this.normalize);
64
+ return {
65
+ transactionId: pendingPrintJobData.transactionId.$,
66
+ printServers: normalizedPrintServer,
67
+ pendingPrinters: normalizedPendingPrinter,
68
+ printServerActive: pendingPrintJobData.printServers.printServerActive === 'true'
69
+ };
70
+ }
71
+ normalize(object) {
72
+ const normalizedObject = {};
73
+ Object.keys(object).forEach((key) => {
74
+ normalizedObject[key] = PrintUtils.ENCODED_PROPERTIES.includes(key) ? window.atob(object[key].$) : object[key].$;
75
+ });
76
+ return normalizedObject;
77
+ }
78
+ processLocalPrinting(localPrintings) {
79
+ const transactionIds = localPrintings.map((item) => item.transactionId);
80
+ this.doLocalPrinting(transactionIds.join());
81
+ }
82
+ doLocalPrinting(transactionIds) {
83
+ const appletImpressao = document.getElementById('centralNotaAppletImpressao');
84
+ if (!appletImpressao)
85
+ return;
86
+ appletImpressao.doLocalPrinting(transactionIds);
87
+ }
88
+ async openSnkPrintSelector(printJobData) {
89
+ let printSelector = document.querySelector('snk-print-selector');
90
+ if (!printSelector) {
91
+ printSelector = document.createElement('snk-print-selector');
92
+ printSelector.setAttribute('id', StringUtils.generateUUID());
93
+ window.document.body.appendChild(printSelector);
94
+ }
95
+ const selectedPrinter = await printSelector.openPrintSelector(printJobData);
96
+ if (!selectedPrinter)
97
+ return;
98
+ await this.saveSubstitutePrinter(printJobData.transactionId, printJobData.pendingPrinters, selectedPrinter);
99
+ }
100
+ async saveSubstitutePrinter(transactionId, pendingPrinters, printer) {
101
+ const parsedPendingPrinters = pendingPrinters.map((item) => ({
102
+ printerUri: {
103
+ $: printer.printerUri
104
+ },
105
+ originalPrinterName: {
106
+ $: item.originalPrinterName
107
+ },
108
+ printJobCount: {
109
+ $: item.printJobCount
110
+ },
111
+ docType: {
112
+ $: item.docType
113
+ },
114
+ docTypeDescription: {
115
+ $: item.docTypeDescription
116
+ }
117
+ }));
118
+ const requestBody = {
119
+ substitutePrintersRequest: {
120
+ substitutePrinters: {
121
+ pendingPrinter: parsedPendingPrinters
122
+ },
123
+ saveSubstitutePrinters: {
124
+ $: 'false'
125
+ },
126
+ transactionId: {
127
+ $: transactionId
128
+ }
129
+ }
130
+ };
131
+ await DataFetcher.get().callServiceBroker(PrintUtils.SERVICE_SAVE_SUBSTITUTE_PRINTER, JSON.stringify(requestBody));
132
+ }
133
+ }
134
+ PrintUtils.SERVICE_FIND_PENDING_PRINTS = 'mge@PrintServiceSP.findPendingPrinters';
135
+ PrintUtils.SERVICE_SAVE_SUBSTITUTE_PRINTER = 'mge@PrintServiceSP.saveSubstitutePrinter';
136
+ PrintUtils.LOCAL_SERVER_URI = 'LOCAL:0/';
137
+ PrintUtils.ENCODED_PROPERTIES = ['printerName', 'printerUri'];
@@ -1,4 +1,4 @@
1
- import { ApplicationContext, ErrorException, WarningException, ObjectUtils, StringUtils } from '@sankhyalabs/core';
1
+ import { StringUtils, ApplicationContext, ErrorException, WarningException, ObjectUtils } from '@sankhyalabs/core';
2
2
  import { c as createCommonjsModule, a as commonjsGlobal } from './_commonjsHelpers.js';
3
3
 
4
4
  var browserPonyfill = createCommonjsModule(function (module, exports) {
@@ -6464,6 +6464,142 @@ class GraphQLRecaller {
6464
6464
  }
6465
6465
  }
6466
6466
 
6467
+ class PrintUtils {
6468
+ constructor() {
6469
+ }
6470
+ static getInstance() {
6471
+ if (!PrintUtils.instance) {
6472
+ PrintUtils.instance = new PrintUtils();
6473
+ }
6474
+ return PrintUtils.instance;
6475
+ }
6476
+ async processPendingPrinting(transactionId) {
6477
+ await this.findPendingPrints(transactionId);
6478
+ }
6479
+ async findPendingPrints(transactionId) {
6480
+ const requestBody = {
6481
+ transactionIds: [
6482
+ {
6483
+ transactionId: {
6484
+ $: transactionId
6485
+ }
6486
+ }
6487
+ ]
6488
+ };
6489
+ const response = await DataFetcher.get().callServiceBroker(PrintUtils.SERVICE_FIND_PENDING_PRINTS, JSON.stringify(requestBody));
6490
+ const printJobData = this.parsePrintData(response);
6491
+ this.openSnkPrintSelector(printJobData);
6492
+ }
6493
+ findLocalPrinters() {
6494
+ const appletImpressao = document.getElementById('centralNotaAppletImpressao');
6495
+ if (!appletImpressao)
6496
+ return [];
6497
+ const localPrinters = appletImpressao.getLocalPrinters();
6498
+ if (!localPrinters)
6499
+ return [];
6500
+ const printers = [];
6501
+ for (const printerName of localPrinters.split(',')) {
6502
+ printers.push({
6503
+ nome: printerName,
6504
+ printerUri: PrintUtils.LOCAL_SERVER_URI + printerName,
6505
+ isLocal: true
6506
+ });
6507
+ }
6508
+ return printers;
6509
+ }
6510
+ getLocalPrinters() {
6511
+ return this.findLocalPrinters();
6512
+ }
6513
+ parsePrintData(payload) {
6514
+ const pendingPrintJobData = payload.pendindPrintJobData;
6515
+ if (!pendingPrintJobData)
6516
+ return undefined;
6517
+ let { printServers: { printServer }, pendingPrinters: { pendingPrinter } } = pendingPrintJobData;
6518
+ printServer = printServer ? (Array.isArray(printServer) ? printServer : [printServer]) : [];
6519
+ pendingPrinter = pendingPrinter ? (Array.isArray(pendingPrinter) ? pendingPrinter : [pendingPrinter]) : [];
6520
+ const normalizedPrintServer = printServer.map(item => {
6521
+ const printerList = Array.isArray(item.printerLocation) ? item.printerLocation : [item.printerLocation];
6522
+ return {
6523
+ printServerUri: item.printServerUri,
6524
+ printerList: printerList.map(this.normalize)
6525
+ };
6526
+ });
6527
+ const normalizedPendingPrinter = pendingPrinter.map(this.normalize);
6528
+ return {
6529
+ transactionId: pendingPrintJobData.transactionId.$,
6530
+ printServers: normalizedPrintServer,
6531
+ pendingPrinters: normalizedPendingPrinter,
6532
+ printServerActive: pendingPrintJobData.printServers.printServerActive === 'true'
6533
+ };
6534
+ }
6535
+ normalize(object) {
6536
+ const normalizedObject = {};
6537
+ Object.keys(object).forEach((key) => {
6538
+ normalizedObject[key] = PrintUtils.ENCODED_PROPERTIES.includes(key) ? window.atob(object[key].$) : object[key].$;
6539
+ });
6540
+ return normalizedObject;
6541
+ }
6542
+ processLocalPrinting(localPrintings) {
6543
+ const transactionIds = localPrintings.map((item) => item.transactionId);
6544
+ this.doLocalPrinting(transactionIds.join());
6545
+ }
6546
+ doLocalPrinting(transactionIds) {
6547
+ const appletImpressao = document.getElementById('centralNotaAppletImpressao');
6548
+ if (!appletImpressao)
6549
+ return;
6550
+ appletImpressao.doLocalPrinting(transactionIds);
6551
+ }
6552
+ async openSnkPrintSelector(printJobData) {
6553
+ let printSelector = document.querySelector('snk-print-selector');
6554
+ if (!printSelector) {
6555
+ printSelector = document.createElement('snk-print-selector');
6556
+ printSelector.setAttribute('id', StringUtils.generateUUID());
6557
+ window.document.body.appendChild(printSelector);
6558
+ }
6559
+ const selectedPrinter = await printSelector.openPrintSelector(printJobData);
6560
+ if (!selectedPrinter)
6561
+ return;
6562
+ await this.saveSubstitutePrinter(printJobData.transactionId, printJobData.pendingPrinters, selectedPrinter);
6563
+ }
6564
+ async saveSubstitutePrinter(transactionId, pendingPrinters, printer) {
6565
+ const parsedPendingPrinters = pendingPrinters.map((item) => ({
6566
+ printerUri: {
6567
+ $: printer.printerUri
6568
+ },
6569
+ originalPrinterName: {
6570
+ $: item.originalPrinterName
6571
+ },
6572
+ printJobCount: {
6573
+ $: item.printJobCount
6574
+ },
6575
+ docType: {
6576
+ $: item.docType
6577
+ },
6578
+ docTypeDescription: {
6579
+ $: item.docTypeDescription
6580
+ }
6581
+ }));
6582
+ const requestBody = {
6583
+ substitutePrintersRequest: {
6584
+ substitutePrinters: {
6585
+ pendingPrinter: parsedPendingPrinters
6586
+ },
6587
+ saveSubstitutePrinters: {
6588
+ $: 'false'
6589
+ },
6590
+ transactionId: {
6591
+ $: transactionId
6592
+ }
6593
+ }
6594
+ };
6595
+ await DataFetcher.get().callServiceBroker(PrintUtils.SERVICE_SAVE_SUBSTITUTE_PRINTER, JSON.stringify(requestBody));
6596
+ }
6597
+ }
6598
+ PrintUtils.SERVICE_FIND_PENDING_PRINTS = 'mge@PrintServiceSP.findPendingPrinters';
6599
+ PrintUtils.SERVICE_SAVE_SUBSTITUTE_PRINTER = 'mge@PrintServiceSP.saveSubstitutePrinter';
6600
+ PrintUtils.LOCAL_SERVER_URI = 'LOCAL:0/';
6601
+ PrintUtils.ENCODED_PROPERTIES = ['printerName', 'printerUri'];
6602
+
6467
6603
  class DataFetcher {
6468
6604
  constructor() {
6469
6605
  this.GRAPHQL_PATH = "/mgefin-bff/graphql";
@@ -6606,6 +6742,14 @@ class DataFetcher {
6606
6742
  }
6607
6743
  });
6608
6744
  }
6745
+ processPrinting(payload) {
6746
+ if ((payload === null || payload === void 0 ? void 0 : payload.pendingPrinting) === 'true') {
6747
+ PrintUtils.getInstance().processPendingPrinting(payload === null || payload === void 0 ? void 0 : payload.transactionId);
6748
+ }
6749
+ if ('localPrintings' in payload) {
6750
+ PrintUtils.getInstance().processLocalPrinting(payload === null || payload === void 0 ? void 0 : payload.localPrintings);
6751
+ }
6752
+ }
6609
6753
  getContext(module) {
6610
6754
  var _a;
6611
6755
  const urlParams = UrlUtils.getQueryParams(location.search);
@@ -6665,6 +6809,7 @@ class DataFetcher {
6665
6809
  }
6666
6810
  }
6667
6811
  this.proccessServiceBorkerClientEvents(jsonResp === null || jsonResp === void 0 ? void 0 : jsonResp.clientEvents, serviceName, payloadJson, accept, reject);
6812
+ this.processPrinting(jsonResp);
6668
6813
  }
6669
6814
  catch (err) {
6670
6815
  console.warn(`Erro ao executar serviço: ${err}`);
@@ -6843,4 +6988,4 @@ class WaitingRequest {
6843
6988
  }
6844
6989
  }
6845
6990
 
6846
- export { DataFetcher as D, UrlUtils as U, dist as d };
6991
+ export { DataFetcher as D, PrintUtils as P, UrlUtils as U, dist as d };
@@ -439,6 +439,29 @@ const snkActionsButtonMessages = {
439
439
  }
440
440
  };
441
441
 
442
+ const snkPrintSelectorMessages = {
443
+ title: {
444
+ warning: "Aviso",
445
+ printerSelection: "Seleção de impressora",
446
+ remotePrintersTab: "Impressoras remotas",
447
+ localPrintersTab: "Impressoras locais"
448
+ },
449
+ subtitle: {
450
+ document: "Documento:",
451
+ jobs: "Trabalhos:"
452
+ },
453
+ message: {
454
+ canceledPrint: "A impressão será cancelada. Deseja mesmo continuar?",
455
+ noPrinters: "Não há impressoras para seleção"
456
+ },
457
+ button: {
458
+ print: "Imprimir",
459
+ cancel: "Cancelar",
460
+ yes: "Sim",
461
+ no: "Não"
462
+ }
463
+ };
464
+
442
465
  class SnkMessageBuilder {
443
466
  constructor(domainName) {
444
467
  this._defaults = {
@@ -463,7 +486,8 @@ class SnkMessageBuilder {
463
486
  snkAttach: snkAttachMessages,
464
487
  snkPersonalizedFilter: snkPersonalizedFilterMessages,
465
488
  snkEntityList: snkEntityListMessages,
466
- snkActionsButton: snkActionsButtonMessages
489
+ snkActionsButton: snkActionsButtonMessages,
490
+ snkPrintSelector: snkPrintSelectorMessages
467
491
  };
468
492
  this._currentOperation = OperationMap.CLEAN;
469
493
  this._domainName = domainName;
@@ -39,6 +39,7 @@ export { SnkGuidesViewer as SnkGuidesViewer } from '../types/components/snk-crud
39
39
  export { SnkPersonalizedFilter as SnkPersonalizedFilter } from '../types/components/snk-personalized-filter/snk-personalized-filter';
40
40
  export { SnkFilterPersonalized as SnkPersonalizedFilterEditor } from '../types/components/snk-filter-bar/filter-item/editors/snk-personalized-filter-editor/snk-personalized-filter-editor';
41
41
  export { SnkPesquisa as SnkPesquisa } from '../types/components/snk-pesquisa/snk-pesquisa';
42
+ export { SnkPrintSelector as SnkPrintSelector } from '../types/components/snk-print-selector/snk-print-selector';
42
43
  export { SelectBox as SnkSelectBox } from '../types/components/snk-grid/subcomponents/snk-select-box/snk-select-box';
43
44
  export { SnkSimpleBar as SnkSimpleBar } from '../types/components/snk-simple-bar/snk-simple-bar';
44
45
  export { SnkSimpleCrud as SnkSimpleCrud } from '../types/components/snk-simple-crud/snk-simple-crud';
@@ -39,6 +39,7 @@ export { SnkGuidesViewer, defineCustomElement as defineCustomElementSnkGuidesVie
39
39
  export { SnkPersonalizedFilter, defineCustomElement as defineCustomElementSnkPersonalizedFilter } from './snk-personalized-filter.js';
40
40
  export { SnkPersonalizedFilterEditor, defineCustomElement as defineCustomElementSnkPersonalizedFilterEditor } from './snk-personalized-filter-editor.js';
41
41
  export { SnkPesquisa, defineCustomElement as defineCustomElementSnkPesquisa } from './snk-pesquisa.js';
42
+ export { SnkPrintSelector, defineCustomElement as defineCustomElementSnkPrintSelector } from './snk-print-selector.js';
42
43
  export { SnkSelectBox, defineCustomElement as defineCustomElementSnkSelectBox } from './snk-select-box.js';
43
44
  export { SnkSimpleBar, defineCustomElement as defineCustomElementSnkSimpleBar } from './snk-simple-bar.js';
44
45
  export { SnkSimpleCrud, defineCustomElement as defineCustomElementSnkSimpleCrud } from './snk-simple-crud.js';
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface SnkPrintSelector extends Components.SnkPrintSelector, HTMLElement {}
4
+ export const SnkPrintSelector: {
5
+ prototype: SnkPrintSelector;
6
+ new (): SnkPrintSelector;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,179 @@
1
+ import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
2
+ import { P as PrintUtils } from './DataFetcher.js';
3
+ import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
4
+ import { ElementIDUtils, ApplicationContext } from '@sankhyalabs/core';
5
+ import ModalButtonStatus from '@sankhyalabs/ezui/dist/collection/components/ez-modal-container/modal-button-status';
6
+
7
+ const snkPrintSelectorCss = ".sc-snk-print-selector-h{max-height:100%}ez-modal-container.sc-snk-print-selector{--ez-modal-container-overflow-y:hidden}ez-list.sc-snk-print-selector{height:100%}.list-scroll.sc-snk-print-selector{max-height:calc(100% - 90px);overflow-y:auto;padding-right:var(--snk-grid-config__main--padding-right)}.list-scroll.sc-snk-print-selector::-webkit-scrollbar{width:var(--space--small);min-width:var(--space--small);max-width:var(--space--small)}.hidden.sc-snk-print-selector{display:none}";
8
+
9
+ const SnkPrintSelector$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
10
+ constructor() {
11
+ super();
12
+ this.__registerHost();
13
+ this.APPLY = "OK";
14
+ this.CANCEL = "CANCEL";
15
+ this.CLOSE = "CLOSE";
16
+ this.REMOTE_PRINTERS_TAB = '0';
17
+ this.LOCAL_PRINTERS_TAB = '1';
18
+ this._hasRemotePrinters = false;
19
+ this._hasLocalPrinters = false;
20
+ this._localPrinters = [];
21
+ this._isSingleJob = false;
22
+ this.buildIdTabSelector = () => {
23
+ const defaultTabs = [
24
+ {
25
+ label: this._application.messagesBuilder.getMessage("snkPrintSelector.title.localPrintersTab", undefined),
26
+ tabKey: this.LOCAL_PRINTERS_TAB,
27
+ index: Number(this.LOCAL_PRINTERS_TAB)
28
+ }
29
+ ];
30
+ if (this._printServerActive) {
31
+ defaultTabs.unshift({
32
+ label: this._application.messagesBuilder.getMessage("snkPrintSelector.title.remotePrintersTab", undefined),
33
+ tabKey: this.REMOTE_PRINTERS_TAB,
34
+ index: Number(this.REMOTE_PRINTERS_TAB)
35
+ });
36
+ }
37
+ return [...defaultTabs];
38
+ };
39
+ this._printServerActive = false;
40
+ this._selectedPrinter = undefined;
41
+ this._remotePrintersDataSource = [];
42
+ this._localPrintersDataSource = [];
43
+ this._printJobData = undefined;
44
+ }
45
+ async openPrintSelector(printJobData) {
46
+ return new Promise((resolve) => {
47
+ this._printJobData = printJobData;
48
+ this._isSingleJob = this._printJobData.pendingPrinters.length === 1;
49
+ this._printServerActive = this._printJobData.printServerActive;
50
+ if (this._printServerActive) {
51
+ this.buildRemotePrinters();
52
+ }
53
+ else {
54
+ this.buildLocalPrinters();
55
+ this._viewStack.show(+this.LOCAL_PRINTERS_TAB);
56
+ }
57
+ this._ezPopup.opened = true;
58
+ this._printerResolver = resolve;
59
+ });
60
+ }
61
+ closePrintSelector() {
62
+ this._ezPopup.opened = false;
63
+ this.element.remove();
64
+ }
65
+ handleModalAction(evt) {
66
+ switch (evt) {
67
+ case this.APPLY:
68
+ this.handleApply();
69
+ break;
70
+ case this.CANCEL:
71
+ case this.CLOSE:
72
+ this.handleCancel();
73
+ break;
74
+ }
75
+ }
76
+ async handleCancel() {
77
+ const result = await ApplicationUtils.confirm(this._application.messagesBuilder.getMessage("snkPrintSelector.title.warning", undefined), this._application.messagesBuilder.getMessage("snkPrintSelector.message.canceledPrint", undefined));
78
+ if (result) {
79
+ this.closePrintSelector();
80
+ this._printerResolver(undefined);
81
+ }
82
+ }
83
+ handleApply() {
84
+ this._printerResolver(this._selectedPrinter);
85
+ this.closePrintSelector();
86
+ }
87
+ onChangeTab(evt) {
88
+ if (evt.detail.tabKey === this.LOCAL_PRINTERS_TAB) {
89
+ this.buildLocalPrinters();
90
+ }
91
+ this._viewStack.show(+evt.detail.tabKey);
92
+ }
93
+ buildRemotePrinters() {
94
+ const dataSource = [];
95
+ this._printJobData.printServers.forEach((printServer) => {
96
+ dataSource.push({
97
+ group: printServer.printServerUri,
98
+ items: printServer.printerList.map((printer) => ({
99
+ label: printer.printerName,
100
+ group: printServer.printServerUri
101
+ }))
102
+ });
103
+ });
104
+ this._remotePrintersDataSource = dataSource;
105
+ this._hasRemotePrinters = this._remotePrintersDataSource.length > 0;
106
+ }
107
+ buildLocalPrinters() {
108
+ if (this._localPrintersDataSource.length > 0)
109
+ return;
110
+ this._localPrinters = PrintUtils.getInstance().getLocalPrinters();
111
+ this._localPrintersDataSource = this._localPrinters.map((printer) => ({
112
+ label: printer.nome
113
+ }));
114
+ this._hasLocalPrinters = this._localPrintersDataSource.length > 0;
115
+ }
116
+ onSelectPrinter(printer, isLocal) {
117
+ if (isLocal) {
118
+ if (this._hasRemotePrinters)
119
+ this._remotePrintersList.removeSelection();
120
+ this._selectedPrinter = this._localPrinters.find((item) => item.nome === printer.label);
121
+ return;
122
+ }
123
+ if (this._hasLocalPrinters)
124
+ this._localPrintersList.removeSelection();
125
+ const serverGroup = this._printJobData.printServers.find((item) => item.printServerUri === printer.group);
126
+ this._selectedPrinter = serverGroup === null || serverGroup === void 0 ? void 0 : serverGroup.printerList.find((item) => item.printerName === printer.label);
127
+ }
128
+ renderNoPrinters() {
129
+ return (h("div", { class: 'ez-flex ez-flex--justify-center ez-flex--align-items-center ez-size-height--full ez-size-width--full' }, h("span", { class: 'ez-text ez-text--primary ez-text--medium' }, this._application.messagesBuilder.getMessage("snkPrintSelector.message.noPrinters", undefined))));
130
+ }
131
+ buildPrinterIcon() {
132
+ return (h("ez-icon", { iconName: "print", style: { marginRight: 'var(--space--small)' } }));
133
+ }
134
+ getElementID(sufix) {
135
+ return {
136
+ [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: ElementIDUtils.getInternalIDInfo(sufix)
137
+ };
138
+ }
139
+ componentWillLoad() {
140
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
141
+ }
142
+ componentDidLoad() {
143
+ if (!this.element)
144
+ return;
145
+ ElementIDUtils.addIDInfo(this.element);
146
+ }
147
+ render() {
148
+ return (h(Host, null, h("ez-popup", Object.assign({ size: 'small', heightMode: 'full', useHeader: false, ref: (ref) => this._ezPopup = ref }, this.getElementID("snk-print-selector")), h("ez-modal-container", { modalTitle: this._application.messagesBuilder.getMessage("snkPrintSelector.title.printerSelection", undefined), okButtonLabel: this._application.messagesBuilder.getMessage("snkPrintSelector.button.print", undefined), okButtonStatus: this._selectedPrinter ? ModalButtonStatus.ENABLED : ModalButtonStatus.DISABLED, cancelButtonLabel: this._application.messagesBuilder.getMessage("snkPrintSelector.button.cancel", undefined), onEzModalAction: (evt) => this.handleModalAction(evt.detail) }, this._isSingleJob &&
149
+ h("div", { class: 'ez-flex ez-margin-bottom--large' }, h("div", { class: 'ez-flex ez-margin-right--large' }, h("span", { class: 'ez-text ez-text--bold ez-text--medium ez-padding-right--small' }, this._application.messagesBuilder.getMessage("snkPrintSelector.subtitle.document", undefined)), h("span", { class: 'ez-text ez-text--primary ez-text--medium' }, this._printJobData.pendingPrinters[0].docTypeDescription)), h("div", { class: 'ez-flex ez-margin-right--large' }, h("span", { class: 'ez-text ez-text--bold ez-text--medium ez-padding-right--small' }, this._application.messagesBuilder.getMessage("snkPrintSelector.subtitle.jobs", undefined)), h("span", { class: 'ez-text ez-text--primary ez-text--medium' }, this._printJobData.pendingPrinters[0].printJobCount))), h("ez-tabselector", { tabs: this.buildIdTabSelector(), onEzChange: (evt) => this.onChangeTab(evt), selectedTab: this._printServerActive ? this.REMOTE_PRINTERS_TAB : this.LOCAL_PRINTERS_TAB }), h("ez-view-stack", { ref: (ref) => this._viewStack = ref }, h("stack-item", { hidePolicy: 'hide' }, this._printServerActive &&
150
+ h("div", { class: "list-scroll ez-size-height--full" }, h("ez-list", { ref: (ref) => this._remotePrintersList = ref, class: `ez-padding-top--medium ${this._hasRemotePrinters ? '' : 'hidden'}`, dataSource: this._remotePrintersDataSource, onEzSelectItem: (evt) => this.onSelectPrinter(evt.detail, false), itemLeftSlotBuilder: this.buildPrinterIcon, useGroups: true, ezSelectable: true, hoverFeedback: true, "data-element-id": 'remotePrintersList' }), !this._hasRemotePrinters && this.renderNoPrinters())), h("stack-item", { hidePolicy: 'hide' }, h("div", { class: "list-scroll ez-size-height--full" }, h("ez-list", { ref: (ref) => this._localPrintersList = ref, class: `ez-padding-top--medium ${this._hasLocalPrinters ? '' : 'hidden'}`, dataSource: this._localPrintersDataSource, onEzSelectItem: (evt) => this.onSelectPrinter(evt.detail, true), itemLeftSlotBuilder: this.buildPrinterIcon, ezSelectable: true, hoverFeedback: true }), !this._hasLocalPrinters && this.renderNoPrinters())))))));
151
+ }
152
+ get element() { return this; }
153
+ static get style() { return snkPrintSelectorCss; }
154
+ }, [2, "snk-print-selector", {
155
+ "_printServerActive": [32],
156
+ "_selectedPrinter": [32],
157
+ "_remotePrintersDataSource": [32],
158
+ "_localPrintersDataSource": [32],
159
+ "_printJobData": [32],
160
+ "openPrintSelector": [64]
161
+ }]);
162
+ function defineCustomElement$1() {
163
+ if (typeof customElements === "undefined") {
164
+ return;
165
+ }
166
+ const components = ["snk-print-selector"];
167
+ components.forEach(tagName => { switch (tagName) {
168
+ case "snk-print-selector":
169
+ if (!customElements.get(tagName)) {
170
+ customElements.define(tagName, SnkPrintSelector$1);
171
+ }
172
+ break;
173
+ } });
174
+ }
175
+
176
+ const SnkPrintSelector = SnkPrintSelector$1;
177
+ const defineCustomElement = defineCustomElement$1;
178
+
179
+ export { SnkPrintSelector, defineCustomElement };
@@ -1,8 +1,8 @@
1
1
  import { ApplicationContext } from '@sankhyalabs/core';
2
- import { F as FormConfigFetcher } from './form-config-fetcher-055ecbac.js';
3
- import { R as ResourceFetcher } from './resource-fetcher-c1210690.js';
4
- import { F as FilterBarConfigFetcher } from './filter-bar-config-fetcher-34892dca.js';
5
- import { d as dist, D as DataFetcher } from './DataFetcher-74c98125.js';
2
+ import { F as FormConfigFetcher } from './form-config-fetcher-01e9985d.js';
3
+ import { R as ResourceFetcher } from './resource-fetcher-d053e214.js';
4
+ import { F as FilterBarConfigFetcher } from './filter-bar-config-fetcher-73ebc12f.js';
5
+ import { d as dist, D as DataFetcher } from './DataFetcher-6153ff3e.js';
6
6
 
7
7
  class GridConfigFetcher extends ResourceFetcher {
8
8
  constructor() {