@sankhyalabs/sankhyablocks 8.2.0-dev.6 → 8.2.0-dev.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{ConfigStorage-12397f18.js → ConfigStorage-349cf0fd.js} +2 -2
- package/dist/cjs/{DataFetcher-f2da1f79.js → DataFetcher-7ba52c1d.js} +12 -206
- package/dist/cjs/PrintUtils-bcaeb82f.js +215 -0
- package/dist/cjs/{SnkFormConfigManager-13f79e37.js → SnkFormConfigManager-9083c12f.js} +2 -2
- package/dist/cjs/{auth-fetcher-319a4cb2.js → auth-fetcher-718ca8b4.js} +1 -1
- package/dist/cjs/{dataunit-fetcher-e72068c1.js → dataunit-fetcher-076fcbf7.js} +1 -1
- package/dist/cjs/{form-config-fetcher-5d62ab62.js → form-config-fetcher-c7ec4ff9.js} +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{pesquisa-fetcher-8c363096.js → pesquisa-fetcher-a9c5a2f5.js} +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button.cjs.entry.js +4 -3
- package/dist/cjs/snk-application.cjs.entry.js +17 -6
- package/dist/cjs/snk-attach.cjs.entry.js +3 -2
- package/dist/cjs/snk-crud.cjs.entry.js +5 -4
- package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -1
- package/dist/cjs/snk-detail-view.cjs.entry.js +7 -6
- package/dist/cjs/snk-filter-bar.cjs.entry.js +4 -3
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +4 -3
- package/dist/cjs/snk-form-config.cjs.entry.js +3 -2
- package/dist/cjs/snk-form.cjs.entry.js +5 -4
- package/dist/cjs/snk-grid-config.cjs.entry.js +4 -3
- package/dist/cjs/snk-grid.cjs.entry.js +4 -3
- package/dist/cjs/{snk-guides-viewer-71a7be3a.js → snk-guides-viewer-18e9666c.js} +4 -4
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +7 -6
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +4 -3
- package/dist/cjs/snk-print-selector.cjs.entry.js +2 -4
- package/dist/cjs/snk-simple-crud.cjs.entry.js +4 -3
- package/dist/collection/components/snk-application/snk-application.js +60 -0
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +10 -4
- package/dist/collection/lib/utils/PrintUtils.js +18 -9
- package/dist/components/DataFetcher.js +13 -206
- package/dist/components/PrintUtils.js +213 -0
- package/dist/components/snk-application2.js +11 -1
- package/dist/components/snk-print-selector.js +1 -1
- package/dist/esm/{ConfigStorage-932ab366.js → ConfigStorage-8d420626.js} +2 -2
- package/dist/esm/{DataFetcher-7e18aa30.js → DataFetcher-e97b3942.js} +13 -206
- package/dist/esm/PrintUtils-3e4ff0f5.js +213 -0
- package/dist/esm/{SnkFormConfigManager-bb9afc3f.js → SnkFormConfigManager-4c6a5b41.js} +2 -2
- package/dist/esm/{auth-fetcher-6d9664b7.js → auth-fetcher-55e5cbce.js} +1 -1
- package/dist/esm/{dataunit-fetcher-91a4eb82.js → dataunit-fetcher-716a99ca.js} +1 -1
- package/dist/esm/{form-config-fetcher-aaaa79a6.js → form-config-fetcher-b69da2f1.js} +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{pesquisa-fetcher-56b30fb4.js → pesquisa-fetcher-c9a53822.js} +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button.entry.js +4 -3
- package/dist/esm/snk-application.entry.js +17 -6
- package/dist/esm/snk-attach.entry.js +3 -2
- package/dist/esm/snk-crud.entry.js +5 -4
- package/dist/esm/snk-data-exporter.entry.js +2 -1
- package/dist/esm/snk-detail-view.entry.js +7 -6
- package/dist/esm/snk-filter-bar.entry.js +4 -3
- package/dist/esm/snk-filter-modal-item.entry.js +4 -3
- package/dist/esm/snk-form-config.entry.js +3 -2
- package/dist/esm/snk-form.entry.js +5 -4
- package/dist/esm/snk-grid-config.entry.js +4 -3
- package/dist/esm/snk-grid.entry.js +4 -3
- package/dist/esm/{snk-guides-viewer-d80999ea.js → snk-guides-viewer-2e97c0c3.js} +4 -4
- package/dist/esm/snk-guides-viewer.entry.js +7 -6
- package/dist/esm/snk-personalized-filter.entry.js +4 -3
- package/dist/esm/snk-print-selector.entry.js +1 -3
- package/dist/esm/snk-simple-crud.entry.js +4 -3
- package/dist/sankhyablocks/p-0b19beb9.entry.js +1 -0
- package/dist/sankhyablocks/p-110136be.entry.js +1 -0
- package/dist/sankhyablocks/p-12e48665.entry.js +1 -0
- package/dist/sankhyablocks/p-236cd346.js +1 -0
- package/dist/sankhyablocks/{p-ed41b38c.js → p-41f81c72.js} +1 -1
- package/dist/sankhyablocks/p-4e701fa7.js +1 -0
- package/dist/sankhyablocks/{p-41e897f1.js → p-615874db.js} +1 -1
- package/dist/sankhyablocks/p-72fc257b.entry.js +1 -0
- package/dist/sankhyablocks/p-7453735e.entry.js +1 -0
- package/dist/sankhyablocks/p-776514a8.entry.js +11 -0
- package/dist/sankhyablocks/{p-a52a6c9d.js → p-81392ced.js} +1 -1
- package/dist/sankhyablocks/p-8d884fab.js +1 -0
- package/dist/sankhyablocks/p-a2854b5a.entry.js +1 -0
- package/dist/sankhyablocks/p-c149dca8.entry.js +1 -0
- package/dist/sankhyablocks/p-c303d74f.entry.js +1 -0
- package/dist/sankhyablocks/p-c51a4f28.entry.js +1 -0
- package/dist/sankhyablocks/{p-74559a50.js → p-ce6d7e3f.js} +1 -1
- package/dist/sankhyablocks/p-cee68227.entry.js +1 -0
- package/dist/sankhyablocks/{p-2d333d22.js → p-e696a8f6.js} +1 -1
- package/dist/sankhyablocks/p-e6c00493.entry.js +1 -0
- package/dist/sankhyablocks/p-ecbb878e.entry.js +1 -0
- package/dist/sankhyablocks/{p-14eac6fe.js → p-f390386d.js} +1 -1
- package/dist/sankhyablocks/p-fbb4597a.entry.js +1 -0
- package/dist/sankhyablocks/p-ff2f2152.entry.js +1 -0
- package/dist/sankhyablocks/p-ff8778e6.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +1 -9
- package/dist/types/components.d.ts +1 -1
- package/dist/types/lib/utils/PrintUtils.d.ts +1 -0
- package/package.json +1 -1
- package/dist/sankhyablocks/p-01739b21.entry.js +0 -1
- package/dist/sankhyablocks/p-03bb1aea.entry.js +0 -1
- package/dist/sankhyablocks/p-6f154396.entry.js +0 -1
- package/dist/sankhyablocks/p-7b3b7664.entry.js +0 -1
- package/dist/sankhyablocks/p-8818d8f6.entry.js +0 -1
- package/dist/sankhyablocks/p-93f6ca04.entry.js +0 -1
- package/dist/sankhyablocks/p-951e98c9.entry.js +0 -1
- package/dist/sankhyablocks/p-9d6a8921.entry.js +0 -1
- package/dist/sankhyablocks/p-a5476e72.entry.js +0 -1
- package/dist/sankhyablocks/p-af3b56a5.entry.js +0 -1
- package/dist/sankhyablocks/p-b459f27b.entry.js +0 -1
- package/dist/sankhyablocks/p-b6003974.entry.js +0 -1
- package/dist/sankhyablocks/p-c74c6b25.entry.js +0 -1
- package/dist/sankhyablocks/p-d7638f45.entry.js +0 -11
- package/dist/sankhyablocks/p-e64f3e17.entry.js +0 -1
- package/dist/sankhyablocks/p-efc10705.entry.js +0 -1
- package/dist/sankhyablocks/p-f74fe358.js +0 -1
- package/dist/sankhyablocks/p-f8e6b97e.js +0 -1
@@ -155,9 +155,9 @@ export class DataFetcher {
|
|
155
155
|
}
|
156
156
|
});
|
157
157
|
}
|
158
|
-
processPrinting(payload) {
|
158
|
+
async processPrinting(payload) {
|
159
159
|
if ((payload === null || payload === void 0 ? void 0 : payload.pendingPrinting) === 'true') {
|
160
|
-
PrintUtils.getInstance().processPendingPrinting(payload === null || payload === void 0 ? void 0 : payload.transactionId);
|
160
|
+
await PrintUtils.getInstance().processPendingPrinting(payload === null || payload === void 0 ? void 0 : payload.transactionId);
|
161
161
|
}
|
162
162
|
if ('localPrintings' in payload) {
|
163
163
|
PrintUtils.getInstance().processLocalPrinting(payload === null || payload === void 0 ? void 0 : payload.localPrintings);
|
@@ -205,11 +205,18 @@ export class DataFetcher {
|
|
205
205
|
http.open("POST", url, true);
|
206
206
|
http.withCredentials = true;
|
207
207
|
http.send(ObjectUtils.objectToString(payloadJson));
|
208
|
-
http.onreadystatechange = () => {
|
208
|
+
http.onreadystatechange = async () => {
|
209
209
|
var _a;
|
210
210
|
if (http.readyState == 4 && http.status == 200) {
|
211
211
|
try {
|
212
212
|
const jsonResp = JSON.parse(http.responseText);
|
213
|
+
/**
|
214
|
+
* Este trecho difere do projeto HTML5 devido à decisão de adotar uma abordagem síncrona para esta chamada. Isso é justificado pelo fato de que, no cenário em questão, a abordagem assíncrona teria impactos negativos.
|
215
|
+
*
|
216
|
+
* Descrição do caso de uso:
|
217
|
+
* Ao concluir um recebimento com cartão (Movimentação Financeira), é acionado um EzDialog de confirmação. Posteriormente, a PopUp de impressão é exibida, e, ao ser cancelada, gera a invocação de um novo EzDialog.
|
218
|
+
*/
|
219
|
+
await this.processPrinting(jsonResp);
|
213
220
|
if (this.isServiceBrokerError(jsonResp)) {
|
214
221
|
reject(this.processServiceBrokerErrorInfo(jsonResp));
|
215
222
|
}
|
@@ -223,7 +230,6 @@ export class DataFetcher {
|
|
223
230
|
}
|
224
231
|
}
|
225
232
|
this.proccessServiceBorkerClientEvents(jsonResp === null || jsonResp === void 0 ? void 0 : jsonResp.clientEvents, serviceName, payloadJson, accept, reject);
|
226
|
-
this.processPrinting(jsonResp);
|
227
233
|
}
|
228
234
|
catch (err) {
|
229
235
|
console.warn(`Erro ao executar serviço: ${err}`);
|
@@ -1,8 +1,9 @@
|
|
1
|
-
import { StringUtils } from "@sankhyalabs/core";
|
2
|
-
import { DataFetcher } from "../http/data-fetcher/DataFetcher";
|
1
|
+
import { ApplicationContext, StringUtils } from "@sankhyalabs/core";
|
3
2
|
export class PrintUtils {
|
4
3
|
constructor() {
|
5
4
|
this.appletImpressao = new AppletImpressao();
|
5
|
+
const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
6
|
+
application.getDataFetcher().then(result => this.DataFetcher = result);
|
6
7
|
}
|
7
8
|
static getInstance() {
|
8
9
|
if (!PrintUtils.instance) {
|
@@ -23,12 +24,18 @@ export class PrintUtils {
|
|
23
24
|
}
|
24
25
|
]
|
25
26
|
};
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
Promise.resolve(this.DataFetcher).then(async (res) => {
|
28
|
+
res = await Promise.resolve(this.DataFetcher);
|
29
|
+
while (!res || !res.application) {
|
30
|
+
res = await Promise.resolve(this.DataFetcher);
|
31
|
+
}
|
32
|
+
const response = await res.application.callServiceBroker(PrintUtils.SERVICE_FIND_PENDING_PRINTS, JSON.stringify(requestBody));
|
33
|
+
const printJobData = this.parsePrintData(response);
|
34
|
+
const pendingPrints = await this.processDirectPrint(printJobData);
|
35
|
+
if (!pendingPrints.length)
|
36
|
+
return;
|
37
|
+
this.openSnkPrintSelector(Object.assign(Object.assign({}, printJobData), { pendingPrinters: pendingPrints }));
|
38
|
+
});
|
32
39
|
}
|
33
40
|
getLocalPrinters() {
|
34
41
|
const localPrinters = this.appletImpressao.findLocalPrinters();
|
@@ -125,7 +132,9 @@ export class PrintUtils {
|
|
125
132
|
}
|
126
133
|
}
|
127
134
|
};
|
128
|
-
|
135
|
+
Promise.resolve(this.DataFetcher).then(async (res) => {
|
136
|
+
await res.application.callServiceBroker(PrintUtils.SERVICE_SAVE_SUBSTITUTE_PRINTER, JSON.stringify(requestBody));
|
137
|
+
});
|
129
138
|
}
|
130
139
|
async processDirectPrint(printJobData) {
|
131
140
|
const isWCRunning = this.appletImpressao.checkWebConnection();
|
@@ -1,6 +1,7 @@
|
|
1
|
-
import { DataType,
|
1
|
+
import { DataType, ApplicationContext, ErrorException, WarningException, ObjectUtils, StringUtils } from '@sankhyalabs/core';
|
2
2
|
import { c as createCommonjsModule, a as commonjsGlobal } from './_commonjsHelpers.js';
|
3
3
|
import { DataUnitTransient } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
4
|
+
import { P as PrintUtils } from './PrintUtils.js';
|
4
5
|
|
5
6
|
var browserPonyfill = createCommonjsModule(function (module, exports) {
|
6
7
|
var global = typeof self !== 'undefined' ? self : commonjsGlobal;
|
@@ -6506,206 +6507,6 @@ class GraphQLRecaller {
|
|
6506
6507
|
}
|
6507
6508
|
}
|
6508
6509
|
|
6509
|
-
class PrintUtils {
|
6510
|
-
constructor() {
|
6511
|
-
this.appletImpressao = new AppletImpressao();
|
6512
|
-
}
|
6513
|
-
static getInstance() {
|
6514
|
-
if (!PrintUtils.instance) {
|
6515
|
-
PrintUtils.instance = new PrintUtils();
|
6516
|
-
}
|
6517
|
-
return PrintUtils.instance;
|
6518
|
-
}
|
6519
|
-
async processPendingPrinting(transactionId) {
|
6520
|
-
await this.findPendingPrints(transactionId);
|
6521
|
-
}
|
6522
|
-
async findPendingPrints(transactionId) {
|
6523
|
-
const requestBody = {
|
6524
|
-
transactionIds: [
|
6525
|
-
{
|
6526
|
-
transactionId: {
|
6527
|
-
$: transactionId
|
6528
|
-
}
|
6529
|
-
}
|
6530
|
-
]
|
6531
|
-
};
|
6532
|
-
const response = await DataFetcher.get().callServiceBroker(PrintUtils.SERVICE_FIND_PENDING_PRINTS, JSON.stringify(requestBody));
|
6533
|
-
const printJobData = this.parsePrintData(response);
|
6534
|
-
const pendingPrints = await this.processDirectPrint(printJobData);
|
6535
|
-
if (!pendingPrints.length)
|
6536
|
-
return;
|
6537
|
-
this.openSnkPrintSelector(Object.assign(Object.assign({}, printJobData), { pendingPrinters: pendingPrints }));
|
6538
|
-
}
|
6539
|
-
getLocalPrinters() {
|
6540
|
-
const localPrinters = this.appletImpressao.findLocalPrinters();
|
6541
|
-
const printers = [];
|
6542
|
-
for (const printerName of localPrinters) {
|
6543
|
-
printers.push({
|
6544
|
-
nome: printerName,
|
6545
|
-
printerUri: PrintUtils.LOCAL_SERVER_URI + printerName,
|
6546
|
-
isLocal: true
|
6547
|
-
});
|
6548
|
-
}
|
6549
|
-
return printers;
|
6550
|
-
}
|
6551
|
-
parsePrintData(payload) {
|
6552
|
-
const pendingPrintJobData = payload.pendindPrintJobData;
|
6553
|
-
if (!pendingPrintJobData)
|
6554
|
-
return undefined;
|
6555
|
-
let { printServers: { printServer }, pendingPrinters: { pendingPrinter } } = pendingPrintJobData;
|
6556
|
-
printServer = printServer ? (Array.isArray(printServer) ? printServer : [printServer]) : [];
|
6557
|
-
pendingPrinter = pendingPrinter ? (Array.isArray(pendingPrinter) ? pendingPrinter : [pendingPrinter]) : [];
|
6558
|
-
const normalizedPrintServer = printServer.map(item => {
|
6559
|
-
const printerList = Array.isArray(item.printerLocation) ? item.printerLocation : [item.printerLocation];
|
6560
|
-
return {
|
6561
|
-
printServerUri: item.printServerUri,
|
6562
|
-
printerList: printerList.map(this.normalize)
|
6563
|
-
};
|
6564
|
-
});
|
6565
|
-
const normalizedPendingPrinter = pendingPrinter.map(this.normalize);
|
6566
|
-
return {
|
6567
|
-
transactionId: pendingPrintJobData.transactionId.$,
|
6568
|
-
printServers: normalizedPrintServer,
|
6569
|
-
pendingPrinters: normalizedPendingPrinter,
|
6570
|
-
printServerActive: pendingPrintJobData.printServers.printServerActive === 'true'
|
6571
|
-
};
|
6572
|
-
}
|
6573
|
-
normalize(object) {
|
6574
|
-
const normalizedObject = {};
|
6575
|
-
Object.keys(object).forEach((key) => {
|
6576
|
-
normalizedObject[key] = PrintUtils.ENCODED_PROPERTIES.includes(key) ? window.atob(object[key].$) : object[key].$;
|
6577
|
-
});
|
6578
|
-
return normalizedObject;
|
6579
|
-
}
|
6580
|
-
processLocalPrinting(localPrintings) {
|
6581
|
-
const transactionIds = localPrintings.map((item) => item.transactionId);
|
6582
|
-
this.appletImpressao.doLocalPrinting(transactionIds.join());
|
6583
|
-
}
|
6584
|
-
async openSnkPrintSelector(printJobData) {
|
6585
|
-
let printSelector = document.querySelector('snk-print-selector');
|
6586
|
-
if (!printSelector) {
|
6587
|
-
printSelector = document.createElement('snk-print-selector');
|
6588
|
-
printSelector.setAttribute('id', StringUtils.generateUUID());
|
6589
|
-
window.document.body.appendChild(printSelector);
|
6590
|
-
}
|
6591
|
-
const { selectedPrinter, saveSubstitute } = await printSelector.openPrintSelector(printJobData);
|
6592
|
-
if (!selectedPrinter)
|
6593
|
-
return;
|
6594
|
-
const params = {
|
6595
|
-
transactionId: printJobData.transactionId,
|
6596
|
-
pendingPrinters: printJobData.pendingPrinters,
|
6597
|
-
printerUri: selectedPrinter.printerUri,
|
6598
|
-
saveSubstitutePrinters: saveSubstitute
|
6599
|
-
};
|
6600
|
-
await this.saveSubstitutePrinter(params);
|
6601
|
-
}
|
6602
|
-
async saveSubstitutePrinter(params) {
|
6603
|
-
const { transactionId, pendingPrinters, printerUri, saveSubstitutePrinters = false } = params;
|
6604
|
-
const parsedPendingPrinters = pendingPrinters.map((item) => ({
|
6605
|
-
printerUri: {
|
6606
|
-
$: item.printerUri || printerUri
|
6607
|
-
},
|
6608
|
-
originalPrinterName: {
|
6609
|
-
$: item.originalPrinterName
|
6610
|
-
},
|
6611
|
-
printJobCount: {
|
6612
|
-
$: item.printJobCount
|
6613
|
-
},
|
6614
|
-
docType: {
|
6615
|
-
$: item.docType
|
6616
|
-
},
|
6617
|
-
docTypeDescription: {
|
6618
|
-
$: item.docTypeDescription
|
6619
|
-
}
|
6620
|
-
}));
|
6621
|
-
const requestBody = {
|
6622
|
-
substitutePrintersRequest: {
|
6623
|
-
substitutePrinters: {
|
6624
|
-
pendingPrinter: parsedPendingPrinters
|
6625
|
-
},
|
6626
|
-
saveSubstitutePrinters: {
|
6627
|
-
$: saveSubstitutePrinters.toString()
|
6628
|
-
},
|
6629
|
-
transactionId: {
|
6630
|
-
$: transactionId
|
6631
|
-
}
|
6632
|
-
}
|
6633
|
-
};
|
6634
|
-
await DataFetcher.get().callServiceBroker(PrintUtils.SERVICE_SAVE_SUBSTITUTE_PRINTER, JSON.stringify(requestBody));
|
6635
|
-
}
|
6636
|
-
async processDirectPrint(printJobData) {
|
6637
|
-
const isWCRunning = this.appletImpressao.checkWebConnection();
|
6638
|
-
if (!isWCRunning) {
|
6639
|
-
return [];
|
6640
|
-
}
|
6641
|
-
const localPrinters = this.getLocalPrinters();
|
6642
|
-
if (!localPrinters.length)
|
6643
|
-
return [];
|
6644
|
-
const directPendingPrints = [];
|
6645
|
-
const pendingPrints = printJobData.pendingPrinters.filter(item => {
|
6646
|
-
const defaultPrinterName = this.getDefaultPrinterName(item.originalPrinterName);
|
6647
|
-
const isDirectPrint = !!localPrinters.find(localPrinter => localPrinter.nome === defaultPrinterName) || this.isPrinterNameAFile(defaultPrinterName);
|
6648
|
-
if (isDirectPrint) {
|
6649
|
-
directPendingPrints.push(Object.assign(Object.assign({}, item), { printerUri: PrintUtils.LOCAL_SERVER_URI + defaultPrinterName }));
|
6650
|
-
return false;
|
6651
|
-
}
|
6652
|
-
return true;
|
6653
|
-
});
|
6654
|
-
if (!directPendingPrints.length)
|
6655
|
-
return pendingPrints;
|
6656
|
-
const params = {
|
6657
|
-
transactionId: printJobData.transactionId,
|
6658
|
-
pendingPrinters: directPendingPrints
|
6659
|
-
};
|
6660
|
-
await this.saveSubstitutePrinter(params);
|
6661
|
-
return pendingPrints;
|
6662
|
-
}
|
6663
|
-
getDefaultPrinterName(printerName) {
|
6664
|
-
const defaultPrinterName = this.appletImpressao.getDefaultPrinter();
|
6665
|
-
const isDefaultPrinterName = /padr[aã]o/ig.test(printerName);
|
6666
|
-
return (defaultPrinterName && isDefaultPrinterName) ? defaultPrinterName : printerName;
|
6667
|
-
}
|
6668
|
-
isPrinterNameAFile(printerName) {
|
6669
|
-
const regExp = new RegExp("^(\w:)?[/\\\w\s]+?\.\w{3}$", "mis");
|
6670
|
-
return regExp.test(printerName);
|
6671
|
-
}
|
6672
|
-
}
|
6673
|
-
PrintUtils.SERVICE_FIND_PENDING_PRINTS = 'mge@PrintServiceSP.findPendingPrinters';
|
6674
|
-
PrintUtils.SERVICE_SAVE_SUBSTITUTE_PRINTER = 'mge@PrintServiceSP.saveSubstitutePrinter';
|
6675
|
-
PrintUtils.LOCAL_SERVER_URI = 'LOCAL:0/';
|
6676
|
-
PrintUtils.ENCODED_PROPERTIES = ['printerName', 'printerUri'];
|
6677
|
-
class AppletImpressao {
|
6678
|
-
constructor() {
|
6679
|
-
this.appletImpressao = document.getElementById('centralNotaAppletImpressao');
|
6680
|
-
}
|
6681
|
-
checkWebConnection() {
|
6682
|
-
if (!this.appletImpressao)
|
6683
|
-
return false;
|
6684
|
-
if (!this.appletImpressao.testRunningWC)
|
6685
|
-
return false;
|
6686
|
-
const isRunning = this.appletImpressao.testRunningWC();
|
6687
|
-
return !!isRunning;
|
6688
|
-
}
|
6689
|
-
findLocalPrinters() {
|
6690
|
-
if (!this.appletImpressao)
|
6691
|
-
return [];
|
6692
|
-
const localPrinters = this.appletImpressao.getLocalPrinters();
|
6693
|
-
if (!localPrinters)
|
6694
|
-
return [];
|
6695
|
-
return localPrinters.split(",");
|
6696
|
-
}
|
6697
|
-
doLocalPrinting(transactionIds) {
|
6698
|
-
if (!this.appletImpressao)
|
6699
|
-
return;
|
6700
|
-
this.appletImpressao.doLocalPrinting(transactionIds);
|
6701
|
-
}
|
6702
|
-
getDefaultPrinter() {
|
6703
|
-
if (!this.appletImpressao)
|
6704
|
-
return '';
|
6705
|
-
return this.appletImpressao.getPrintDefault();
|
6706
|
-
}
|
6707
|
-
}
|
6708
|
-
|
6709
6510
|
class DataFetcher {
|
6710
6511
|
constructor() {
|
6711
6512
|
this.GRAPHQL_PATH = `/${window.MGE_MODULE_NAME || 'mgefin-bff'}/graphql`;
|
@@ -6856,9 +6657,9 @@ class DataFetcher {
|
|
6856
6657
|
}
|
6857
6658
|
});
|
6858
6659
|
}
|
6859
|
-
processPrinting(payload) {
|
6660
|
+
async processPrinting(payload) {
|
6860
6661
|
if ((payload === null || payload === void 0 ? void 0 : payload.pendingPrinting) === 'true') {
|
6861
|
-
PrintUtils.getInstance().processPendingPrinting(payload === null || payload === void 0 ? void 0 : payload.transactionId);
|
6662
|
+
await PrintUtils.getInstance().processPendingPrinting(payload === null || payload === void 0 ? void 0 : payload.transactionId);
|
6862
6663
|
}
|
6863
6664
|
if ('localPrintings' in payload) {
|
6864
6665
|
PrintUtils.getInstance().processLocalPrinting(payload === null || payload === void 0 ? void 0 : payload.localPrintings);
|
@@ -6906,11 +6707,18 @@ class DataFetcher {
|
|
6906
6707
|
http.open("POST", url, true);
|
6907
6708
|
http.withCredentials = true;
|
6908
6709
|
http.send(ObjectUtils.objectToString(payloadJson));
|
6909
|
-
http.onreadystatechange = () => {
|
6710
|
+
http.onreadystatechange = async () => {
|
6910
6711
|
var _a;
|
6911
6712
|
if (http.readyState == 4 && http.status == 200) {
|
6912
6713
|
try {
|
6913
6714
|
const jsonResp = JSON.parse(http.responseText);
|
6715
|
+
/**
|
6716
|
+
* Este trecho difere do projeto HTML5 devido à decisão de adotar uma abordagem síncrona para esta chamada. Isso é justificado pelo fato de que, no cenário em questão, a abordagem assíncrona teria impactos negativos.
|
6717
|
+
*
|
6718
|
+
* Descrição do caso de uso:
|
6719
|
+
* Ao concluir um recebimento com cartão (Movimentação Financeira), é acionado um EzDialog de confirmação. Posteriormente, a PopUp de impressão é exibida, e, ao ser cancelada, gera a invocação de um novo EzDialog.
|
6720
|
+
*/
|
6721
|
+
await this.processPrinting(jsonResp);
|
6914
6722
|
if (this.isServiceBrokerError(jsonResp)) {
|
6915
6723
|
reject(this.processServiceBrokerErrorInfo(jsonResp));
|
6916
6724
|
}
|
@@ -6924,7 +6732,6 @@ class DataFetcher {
|
|
6924
6732
|
}
|
6925
6733
|
}
|
6926
6734
|
this.proccessServiceBorkerClientEvents(jsonResp === null || jsonResp === void 0 ? void 0 : jsonResp.clientEvents, serviceName, payloadJson, accept, reject);
|
6927
|
-
this.processPrinting(jsonResp);
|
6928
6735
|
}
|
6929
6736
|
catch (err) {
|
6930
6737
|
console.warn(`Erro ao executar serviço: ${err}`);
|
@@ -7117,4 +6924,4 @@ class WaitingRequest {
|
|
7117
6924
|
}
|
7118
6925
|
}
|
7119
6926
|
|
7120
|
-
export { DataFetcher as D,
|
6927
|
+
export { DataFetcher as D, UrlUtils as U, dist as d };
|
@@ -0,0 +1,213 @@
|
|
1
|
+
import { ApplicationContext, StringUtils } from '@sankhyalabs/core';
|
2
|
+
|
3
|
+
class PrintUtils {
|
4
|
+
constructor() {
|
5
|
+
this.appletImpressao = new AppletImpressao();
|
6
|
+
const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
7
|
+
application.getDataFetcher().then(result => this.DataFetcher = result);
|
8
|
+
}
|
9
|
+
static getInstance() {
|
10
|
+
if (!PrintUtils.instance) {
|
11
|
+
PrintUtils.instance = new PrintUtils();
|
12
|
+
}
|
13
|
+
return PrintUtils.instance;
|
14
|
+
}
|
15
|
+
async processPendingPrinting(transactionId) {
|
16
|
+
await this.findPendingPrints(transactionId);
|
17
|
+
}
|
18
|
+
async findPendingPrints(transactionId) {
|
19
|
+
const requestBody = {
|
20
|
+
transactionIds: [
|
21
|
+
{
|
22
|
+
transactionId: {
|
23
|
+
$: transactionId
|
24
|
+
}
|
25
|
+
}
|
26
|
+
]
|
27
|
+
};
|
28
|
+
Promise.resolve(this.DataFetcher).then(async (res) => {
|
29
|
+
res = await Promise.resolve(this.DataFetcher);
|
30
|
+
while (!res || !res.application) {
|
31
|
+
res = await Promise.resolve(this.DataFetcher);
|
32
|
+
}
|
33
|
+
const response = await res.application.callServiceBroker(PrintUtils.SERVICE_FIND_PENDING_PRINTS, JSON.stringify(requestBody));
|
34
|
+
const printJobData = this.parsePrintData(response);
|
35
|
+
const pendingPrints = await this.processDirectPrint(printJobData);
|
36
|
+
if (!pendingPrints.length)
|
37
|
+
return;
|
38
|
+
this.openSnkPrintSelector(Object.assign(Object.assign({}, printJobData), { pendingPrinters: pendingPrints }));
|
39
|
+
});
|
40
|
+
}
|
41
|
+
getLocalPrinters() {
|
42
|
+
const localPrinters = this.appletImpressao.findLocalPrinters();
|
43
|
+
const printers = [];
|
44
|
+
for (const printerName of localPrinters) {
|
45
|
+
printers.push({
|
46
|
+
nome: printerName,
|
47
|
+
printerUri: PrintUtils.LOCAL_SERVER_URI + printerName,
|
48
|
+
isLocal: true
|
49
|
+
});
|
50
|
+
}
|
51
|
+
return printers;
|
52
|
+
}
|
53
|
+
parsePrintData(payload) {
|
54
|
+
const pendingPrintJobData = payload.pendindPrintJobData;
|
55
|
+
if (!pendingPrintJobData)
|
56
|
+
return undefined;
|
57
|
+
let { printServers: { printServer }, pendingPrinters: { pendingPrinter } } = pendingPrintJobData;
|
58
|
+
printServer = printServer ? (Array.isArray(printServer) ? printServer : [printServer]) : [];
|
59
|
+
pendingPrinter = pendingPrinter ? (Array.isArray(pendingPrinter) ? pendingPrinter : [pendingPrinter]) : [];
|
60
|
+
const normalizedPrintServer = printServer.map(item => {
|
61
|
+
const printerList = Array.isArray(item.printerLocation) ? item.printerLocation : [item.printerLocation];
|
62
|
+
return {
|
63
|
+
printServerUri: item.printServerUri,
|
64
|
+
printerList: printerList.map(this.normalize)
|
65
|
+
};
|
66
|
+
});
|
67
|
+
const normalizedPendingPrinter = pendingPrinter.map(this.normalize);
|
68
|
+
return {
|
69
|
+
transactionId: pendingPrintJobData.transactionId.$,
|
70
|
+
printServers: normalizedPrintServer,
|
71
|
+
pendingPrinters: normalizedPendingPrinter,
|
72
|
+
printServerActive: pendingPrintJobData.printServers.printServerActive === 'true'
|
73
|
+
};
|
74
|
+
}
|
75
|
+
normalize(object) {
|
76
|
+
const normalizedObject = {};
|
77
|
+
Object.keys(object).forEach((key) => {
|
78
|
+
normalizedObject[key] = PrintUtils.ENCODED_PROPERTIES.includes(key) ? window.atob(object[key].$) : object[key].$;
|
79
|
+
});
|
80
|
+
return normalizedObject;
|
81
|
+
}
|
82
|
+
processLocalPrinting(localPrintings) {
|
83
|
+
const transactionIds = localPrintings.map((item) => item.transactionId);
|
84
|
+
this.appletImpressao.doLocalPrinting(transactionIds.join());
|
85
|
+
}
|
86
|
+
async openSnkPrintSelector(printJobData) {
|
87
|
+
let printSelector = document.querySelector('snk-print-selector');
|
88
|
+
if (!printSelector) {
|
89
|
+
printSelector = document.createElement('snk-print-selector');
|
90
|
+
printSelector.setAttribute('id', StringUtils.generateUUID());
|
91
|
+
window.document.body.appendChild(printSelector);
|
92
|
+
}
|
93
|
+
const { selectedPrinter, saveSubstitute } = await printSelector.openPrintSelector(printJobData);
|
94
|
+
if (!selectedPrinter)
|
95
|
+
return;
|
96
|
+
const params = {
|
97
|
+
transactionId: printJobData.transactionId,
|
98
|
+
pendingPrinters: printJobData.pendingPrinters,
|
99
|
+
printerUri: selectedPrinter.printerUri,
|
100
|
+
saveSubstitutePrinters: saveSubstitute
|
101
|
+
};
|
102
|
+
await this.saveSubstitutePrinter(params);
|
103
|
+
}
|
104
|
+
async saveSubstitutePrinter(params) {
|
105
|
+
const { transactionId, pendingPrinters, printerUri, saveSubstitutePrinters = false } = params;
|
106
|
+
const parsedPendingPrinters = pendingPrinters.map((item) => ({
|
107
|
+
printerUri: {
|
108
|
+
$: item.printerUri || printerUri
|
109
|
+
},
|
110
|
+
originalPrinterName: {
|
111
|
+
$: item.originalPrinterName
|
112
|
+
},
|
113
|
+
printJobCount: {
|
114
|
+
$: item.printJobCount
|
115
|
+
},
|
116
|
+
docType: {
|
117
|
+
$: item.docType
|
118
|
+
},
|
119
|
+
docTypeDescription: {
|
120
|
+
$: item.docTypeDescription
|
121
|
+
}
|
122
|
+
}));
|
123
|
+
const requestBody = {
|
124
|
+
substitutePrintersRequest: {
|
125
|
+
substitutePrinters: {
|
126
|
+
pendingPrinter: parsedPendingPrinters
|
127
|
+
},
|
128
|
+
saveSubstitutePrinters: {
|
129
|
+
$: saveSubstitutePrinters.toString()
|
130
|
+
},
|
131
|
+
transactionId: {
|
132
|
+
$: transactionId
|
133
|
+
}
|
134
|
+
}
|
135
|
+
};
|
136
|
+
Promise.resolve(this.DataFetcher).then(async (res) => {
|
137
|
+
await res.application.callServiceBroker(PrintUtils.SERVICE_SAVE_SUBSTITUTE_PRINTER, JSON.stringify(requestBody));
|
138
|
+
});
|
139
|
+
}
|
140
|
+
async processDirectPrint(printJobData) {
|
141
|
+
const isWCRunning = this.appletImpressao.checkWebConnection();
|
142
|
+
if (!isWCRunning) {
|
143
|
+
return [];
|
144
|
+
}
|
145
|
+
const localPrinters = this.getLocalPrinters();
|
146
|
+
if (!localPrinters.length)
|
147
|
+
return [];
|
148
|
+
const directPendingPrints = [];
|
149
|
+
const pendingPrints = printJobData.pendingPrinters.filter(item => {
|
150
|
+
const defaultPrinterName = this.getDefaultPrinterName(item.originalPrinterName);
|
151
|
+
const isDirectPrint = !!localPrinters.find(localPrinter => localPrinter.nome === defaultPrinterName) || this.isPrinterNameAFile(defaultPrinterName);
|
152
|
+
if (isDirectPrint) {
|
153
|
+
directPendingPrints.push(Object.assign(Object.assign({}, item), { printerUri: PrintUtils.LOCAL_SERVER_URI + defaultPrinterName }));
|
154
|
+
return false;
|
155
|
+
}
|
156
|
+
return true;
|
157
|
+
});
|
158
|
+
if (!directPendingPrints.length)
|
159
|
+
return pendingPrints;
|
160
|
+
const params = {
|
161
|
+
transactionId: printJobData.transactionId,
|
162
|
+
pendingPrinters: directPendingPrints
|
163
|
+
};
|
164
|
+
await this.saveSubstitutePrinter(params);
|
165
|
+
return pendingPrints;
|
166
|
+
}
|
167
|
+
getDefaultPrinterName(printerName) {
|
168
|
+
const defaultPrinterName = this.appletImpressao.getDefaultPrinter();
|
169
|
+
const isDefaultPrinterName = /padr[aã]o/ig.test(printerName);
|
170
|
+
return (defaultPrinterName && isDefaultPrinterName) ? defaultPrinterName : printerName;
|
171
|
+
}
|
172
|
+
isPrinterNameAFile(printerName) {
|
173
|
+
const regExp = new RegExp("^(\w:)?[/\\\w\s]+?\.\w{3}$", "mis");
|
174
|
+
return regExp.test(printerName);
|
175
|
+
}
|
176
|
+
}
|
177
|
+
PrintUtils.SERVICE_FIND_PENDING_PRINTS = 'mge@PrintServiceSP.findPendingPrinters';
|
178
|
+
PrintUtils.SERVICE_SAVE_SUBSTITUTE_PRINTER = 'mge@PrintServiceSP.saveSubstitutePrinter';
|
179
|
+
PrintUtils.LOCAL_SERVER_URI = 'LOCAL:0/';
|
180
|
+
PrintUtils.ENCODED_PROPERTIES = ['printerName', 'printerUri'];
|
181
|
+
class AppletImpressao {
|
182
|
+
constructor() {
|
183
|
+
this.appletImpressao = document.getElementById('centralNotaAppletImpressao');
|
184
|
+
}
|
185
|
+
checkWebConnection() {
|
186
|
+
if (!this.appletImpressao)
|
187
|
+
return false;
|
188
|
+
if (!this.appletImpressao.testRunningWC)
|
189
|
+
return false;
|
190
|
+
const isRunning = this.appletImpressao.testRunningWC();
|
191
|
+
return !!isRunning;
|
192
|
+
}
|
193
|
+
findLocalPrinters() {
|
194
|
+
if (!this.appletImpressao)
|
195
|
+
return [];
|
196
|
+
const localPrinters = this.appletImpressao.getLocalPrinters();
|
197
|
+
if (!localPrinters)
|
198
|
+
return [];
|
199
|
+
return localPrinters.split(",");
|
200
|
+
}
|
201
|
+
doLocalPrinting(transactionIds) {
|
202
|
+
if (!this.appletImpressao)
|
203
|
+
return;
|
204
|
+
this.appletImpressao.doLocalPrinting(transactionIds);
|
205
|
+
}
|
206
|
+
getDefaultPrinter() {
|
207
|
+
if (!this.appletImpressao)
|
208
|
+
return '';
|
209
|
+
return this.appletImpressao.getPrintDefault();
|
210
|
+
}
|
211
|
+
}
|
212
|
+
|
213
|
+
export { PrintUtils as P };
|
@@ -296,6 +296,16 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
296
296
|
});
|
297
297
|
});
|
298
298
|
}
|
299
|
+
/**
|
300
|
+
* Realiza a chamada ao Service Broker conforme o nome do serviço.
|
301
|
+
*
|
302
|
+
* @param serviceName - Nome do serviço
|
303
|
+
* @param payload - Dados que serão processados na ação
|
304
|
+
* @param options - Parâmetros de URL
|
305
|
+
*/
|
306
|
+
async callServiceBroker(serviceName, payload, options) {
|
307
|
+
return DataFetcher.get().callServiceBroker(serviceName, payload, options);
|
308
|
+
}
|
299
309
|
initOnboarding(onboardingKey) {
|
300
310
|
OnboardingUtils.getInstance().init(onboardingKey, window.envContext);
|
301
311
|
return Promise.resolve();
|
@@ -879,6 +889,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
879
889
|
"messagesBuilder": [1040],
|
880
890
|
"configName": [1, "config-name"],
|
881
891
|
"isUserSup": [64],
|
892
|
+
"callServiceBroker": [64],
|
882
893
|
"initOnboarding": [64],
|
883
894
|
"hasAccess": [64],
|
884
895
|
"getAllAccess": [64],
|
@@ -903,7 +914,6 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
903
914
|
"addClientEvent": [64],
|
904
915
|
"removeClientEvent": [64],
|
905
916
|
"hasClientEvent": [64],
|
906
|
-
"callServiceBroker": [64],
|
907
917
|
"getResourceID": [64],
|
908
918
|
"getUserID": [64],
|
909
919
|
"alert": [64],
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
|
2
|
-
import { P as PrintUtils } from './
|
2
|
+
import { P as PrintUtils } from './PrintUtils.js';
|
3
3
|
import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
|
4
4
|
import { ElementIDUtils, ApplicationContext } from '@sankhyalabs/core';
|
5
5
|
import ModalButtonStatus from '@sankhyalabs/ezui/dist/collection/components/ez-modal-container/modal-button-status';
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { R as ResourceFetcher, F as FormConfigFetcher } from './form-config-fetcher-
|
1
|
+
import { R as ResourceFetcher, F as FormConfigFetcher } from './form-config-fetcher-b69da2f1.js';
|
2
2
|
import { F as FilterItemType } from './filter-item-type.enum-5028ed3f.js';
|
3
|
-
import { d as dist, D as DataFetcher } from './DataFetcher-
|
3
|
+
import { d as dist, D as DataFetcher } from './DataFetcher-e97b3942.js';
|
4
4
|
|
5
5
|
class GridConfigFetcher extends ResourceFetcher {
|
6
6
|
constructor() {
|