@sankhyalabs/sankhyablocks 6.9.1 → 6.10.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.
- package/dist/cjs/{ConfigStorage-3aaa8a9f.js → ConfigStorage-da2bf3bf.js} +4 -4
- package/dist/cjs/{DataFetcher-093c47ae.js → DataFetcher-04c70ba9.js} +88 -24
- package/dist/cjs/{SnkFormConfigManager-ddad3cbb.js → SnkFormConfigManager-d7cc9118.js} +2 -2
- package/dist/cjs/{SnkMessageBuilder-e55c7afa.js → SnkMessageBuilder-a5a9b437.js} +2 -1
- package/dist/cjs/{dataunit-fetcher-2f67ac79.js → dataunit-fetcher-4102080d.js} +1 -1
- package/dist/cjs/{filter-bar-config-fetcher-81868495.js → filter-bar-config-fetcher-58cfc12e.js} +1 -1
- package/dist/cjs/{form-config-fetcher-affb0b28.js → form-config-fetcher-56442594.js} +2 -2
- package/dist/cjs/{pesquisa-fetcher-21c3afc9.js → pesquisa-fetcher-cab451b6.js} +1 -1
- package/dist/cjs/{resource-fetcher-e71a11b8.js → resource-fetcher-260e98a4.js} +1 -1
- package/dist/cjs/snk-actions-button.cjs.entry.js +2 -2
- package/dist/cjs/snk-application.cjs.entry.js +48 -32
- package/dist/cjs/snk-attach.cjs.entry.js +2 -2
- package/dist/cjs/snk-crud.cjs.entry.js +2 -2
- package/dist/cjs/snk-data-exporter.cjs.entry.js +3 -3
- package/dist/cjs/{snk-data-unit-26cf970c.js → snk-data-unit-9d03800c.js} +1 -1
- package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +9 -9
- package/dist/cjs/snk-filter-bar.cjs.entry.js +5 -5
- package/dist/cjs/snk-filter-detail.cjs.entry.js +3 -3
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +5 -5
- package/dist/cjs/snk-form-config.cjs.entry.js +3 -3
- package/dist/cjs/snk-form.cjs.entry.js +6 -6
- package/dist/cjs/snk-grid-config.cjs.entry.js +5 -5
- package/dist/cjs/snk-grid.cjs.entry.js +5 -5
- package/dist/cjs/{snk-guides-viewer-b0f98cf4.js → snk-guides-viewer-36766466.js} +3 -3
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -8
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +5 -5
- package/dist/cjs/snk-print-selector.cjs.entry.js +15 -11
- package/dist/cjs/snk-simple-crud.cjs.entry.js +2 -2
- package/dist/collection/components/snk-print-selector/snk-print-selector.css +9 -1
- package/dist/collection/components/snk-print-selector/snk-print-selector.js +17 -14
- package/dist/collection/lib/http/data-fetcher/fetchers/totals-fetcher.js +40 -24
- package/dist/collection/lib/message/resources/snk-print-selector.msg.js +2 -1
- package/dist/collection/lib/utils/PrintUtils.js +88 -24
- package/dist/components/DataFetcher.js +88 -24
- package/dist/components/SnkMessageBuilder.js +2 -1
- package/dist/components/snk-application2.js +40 -24
- package/dist/components/snk-print-selector.js +14 -10
- package/dist/esm/{ConfigStorage-24b221ba.js → ConfigStorage-f1e805a0.js} +4 -4
- package/dist/esm/{DataFetcher-6153ff3e.js → DataFetcher-fddeb917.js} +88 -24
- package/dist/esm/{SnkFormConfigManager-fcbefc1a.js → SnkFormConfigManager-324f6dc7.js} +2 -2
- package/dist/esm/{SnkMessageBuilder-96e66d9c.js → SnkMessageBuilder-76f62087.js} +2 -1
- package/dist/esm/{dataunit-fetcher-09586248.js → dataunit-fetcher-66f42154.js} +1 -1
- package/dist/esm/{filter-bar-config-fetcher-73ebc12f.js → filter-bar-config-fetcher-a358b8e0.js} +1 -1
- package/dist/esm/{form-config-fetcher-01e9985d.js → form-config-fetcher-533b895e.js} +2 -2
- package/dist/esm/{pesquisa-fetcher-829ec5a9.js → pesquisa-fetcher-4a702655.js} +1 -1
- package/dist/esm/{resource-fetcher-d053e214.js → resource-fetcher-0f20a072.js} +1 -1
- package/dist/esm/snk-actions-button.entry.js +2 -2
- package/dist/esm/snk-application.entry.js +48 -32
- package/dist/esm/snk-attach.entry.js +2 -2
- package/dist/esm/snk-crud.entry.js +2 -2
- package/dist/esm/snk-data-exporter.entry.js +3 -3
- package/dist/esm/{snk-data-unit-0f2d3c74.js → snk-data-unit-0ff2d644.js} +1 -1
- package/dist/esm/snk-data-unit.entry.js +2 -2
- package/dist/esm/snk-detail-view.entry.js +9 -9
- package/dist/esm/snk-filter-bar.entry.js +5 -5
- package/dist/esm/snk-filter-detail.entry.js +3 -3
- package/dist/esm/snk-filter-modal-item.entry.js +5 -5
- package/dist/esm/snk-form-config.entry.js +3 -3
- package/dist/esm/snk-form.entry.js +6 -6
- package/dist/esm/snk-grid-config.entry.js +5 -5
- package/dist/esm/snk-grid.entry.js +5 -5
- package/dist/esm/{snk-guides-viewer-ab5c376c.js → snk-guides-viewer-e7209909.js} +3 -3
- package/dist/esm/snk-guides-viewer.entry.js +8 -8
- package/dist/esm/snk-personalized-filter.entry.js +5 -5
- package/dist/esm/snk-print-selector.entry.js +15 -11
- package/dist/esm/snk-simple-crud.entry.js +2 -2
- package/dist/sankhyablocks/{p-4ab8d0ee.entry.js → p-18b74675.entry.js} +1 -1
- package/dist/sankhyablocks/{p-85e6068d.entry.js → p-2ddf3e87.entry.js} +1 -1
- package/dist/sankhyablocks/{p-7dd92fb8.entry.js → p-3251999f.entry.js} +1 -1
- package/dist/sankhyablocks/{p-744d0fd2.js → p-432a73a8.js} +1 -1
- package/dist/sankhyablocks/{p-eb0c9f4c.js → p-4f3df9b6.js} +1 -1
- package/dist/sankhyablocks/p-4f550a1a.js +1 -0
- package/dist/sankhyablocks/{p-a4cd60bf.entry.js → p-522172e1.entry.js} +1 -1
- package/dist/sankhyablocks/{p-16ad23d5.entry.js → p-5596a2dd.entry.js} +1 -1
- package/dist/sankhyablocks/{p-9a7aafe4.js → p-56378a3b.js} +1 -1
- package/dist/sankhyablocks/{p-13f0ed88.entry.js → p-6490021d.entry.js} +1 -1
- package/dist/sankhyablocks/{p-bfe8b96d.js → p-652b9081.js} +1 -1
- package/dist/sankhyablocks/{p-eaec700d.js → p-7a075ae6.js} +1 -1
- package/dist/sankhyablocks/p-7fd8a0ab.entry.js +1 -0
- package/dist/sankhyablocks/p-82800006.entry.js +1 -0
- package/dist/sankhyablocks/{p-1b596ea1.entry.js → p-8d583a79.entry.js} +1 -1
- package/dist/sankhyablocks/{p-d20e2ce3.js → p-8f484733.js} +1 -1
- package/dist/sankhyablocks/{p-e665c93f.entry.js → p-8f6575c8.entry.js} +1 -1
- package/dist/sankhyablocks/{p-814f9247.js → p-982107dc.js} +1 -1
- package/dist/sankhyablocks/{p-feb6963e.entry.js → p-9f34a127.entry.js} +1 -1
- package/dist/sankhyablocks/{p-07cb8a03.entry.js → p-a357d13c.entry.js} +1 -1
- package/dist/sankhyablocks/{p-3e8748b1.entry.js → p-af8ed6d5.entry.js} +1 -1
- package/dist/sankhyablocks/{p-bd1f8640.entry.js → p-bc19b890.entry.js} +1 -1
- package/dist/sankhyablocks/p-bd840081.entry.js +11 -0
- package/dist/sankhyablocks/{p-e789eb2d.js → p-d4adf773.js} +1 -1
- package/dist/sankhyablocks/{p-89fb7531.js → p-d97eb781.js} +2 -2
- package/dist/sankhyablocks/p-eb30a52a.entry.js +1 -0
- package/dist/sankhyablocks/{p-05d82333.entry.js → p-ed9e1e52.entry.js} +1 -1
- package/dist/sankhyablocks/{p-432dd007.entry.js → p-eef26a01.entry.js} +1 -1
- package/dist/sankhyablocks/{p-60ad0dea.js → p-f034254e.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-print-selector/snk-print-selector.d.ts +7 -1
- package/dist/types/components.d.ts +3 -2
- package/dist/types/lib/http/data-fetcher/fetchers/totals-fetcher.d.ts +3 -2
- package/dist/types/lib/utils/PrintUtils.d.ts +5 -2
- package/package.json +1 -1
- package/dist/sankhyablocks/p-2b449454.js +0 -1
- package/dist/sankhyablocks/p-43e18073.entry.js +0 -11
- package/dist/sankhyablocks/p-6f49f5d4.entry.js +0 -1
- package/dist/sankhyablocks/p-9404ad4d.entry.js +0 -1
- package/dist/sankhyablocks/p-ad4bb9d2.entry.js +0 -1
@@ -6466,6 +6466,7 @@ class GraphQLRecaller {
|
|
6466
6466
|
|
6467
6467
|
class PrintUtils {
|
6468
6468
|
constructor() {
|
6469
|
+
this.appletImpressao = new AppletImpressao();
|
6469
6470
|
}
|
6470
6471
|
static getInstance() {
|
6471
6472
|
if (!PrintUtils.instance) {
|
@@ -6488,17 +6489,15 @@ class PrintUtils {
|
|
6488
6489
|
};
|
6489
6490
|
const response = await DataFetcher.get().callServiceBroker(PrintUtils.SERVICE_FIND_PENDING_PRINTS, JSON.stringify(requestBody));
|
6490
6491
|
const printJobData = this.parsePrintData(response);
|
6491
|
-
this.
|
6492
|
+
const pendingPrints = await this.processDirectPrint(printJobData);
|
6493
|
+
if (!pendingPrints.length)
|
6494
|
+
return;
|
6495
|
+
this.openSnkPrintSelector(Object.assign(Object.assign({}, printJobData), { pendingPrinters: pendingPrints }));
|
6492
6496
|
}
|
6493
|
-
|
6494
|
-
const
|
6495
|
-
if (!appletImpressao)
|
6496
|
-
return [];
|
6497
|
-
const localPrinters = appletImpressao.getLocalPrinters();
|
6498
|
-
if (!localPrinters)
|
6499
|
-
return [];
|
6497
|
+
getLocalPrinters() {
|
6498
|
+
const localPrinters = this.appletImpressao.findLocalPrinters();
|
6500
6499
|
const printers = [];
|
6501
|
-
for (const printerName of localPrinters
|
6500
|
+
for (const printerName of localPrinters) {
|
6502
6501
|
printers.push({
|
6503
6502
|
nome: printerName,
|
6504
6503
|
printerUri: PrintUtils.LOCAL_SERVER_URI + printerName,
|
@@ -6507,9 +6506,6 @@ class PrintUtils {
|
|
6507
6506
|
}
|
6508
6507
|
return printers;
|
6509
6508
|
}
|
6510
|
-
getLocalPrinters() {
|
6511
|
-
return this.findLocalPrinters();
|
6512
|
-
}
|
6513
6509
|
parsePrintData(payload) {
|
6514
6510
|
const pendingPrintJobData = payload.pendindPrintJobData;
|
6515
6511
|
if (!pendingPrintJobData)
|
@@ -6541,13 +6537,7 @@ class PrintUtils {
|
|
6541
6537
|
}
|
6542
6538
|
processLocalPrinting(localPrintings) {
|
6543
6539
|
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);
|
6540
|
+
this.appletImpressao.doLocalPrinting(transactionIds.join());
|
6551
6541
|
}
|
6552
6542
|
async openSnkPrintSelector(printJobData) {
|
6553
6543
|
let printSelector = document.querySelector('snk-print-selector');
|
@@ -6556,15 +6546,22 @@ class PrintUtils {
|
|
6556
6546
|
printSelector.setAttribute('id', StringUtils.generateUUID());
|
6557
6547
|
window.document.body.appendChild(printSelector);
|
6558
6548
|
}
|
6559
|
-
const selectedPrinter = await printSelector.openPrintSelector(printJobData);
|
6549
|
+
const { selectedPrinter, saveSubstitute } = await printSelector.openPrintSelector(printJobData);
|
6560
6550
|
if (!selectedPrinter)
|
6561
6551
|
return;
|
6562
|
-
|
6552
|
+
const params = {
|
6553
|
+
transactionId: printJobData.transactionId,
|
6554
|
+
pendingPrinters: printJobData.pendingPrinters,
|
6555
|
+
printerUri: selectedPrinter.printerUri,
|
6556
|
+
saveSubstitutePrinters: saveSubstitute
|
6557
|
+
};
|
6558
|
+
await this.saveSubstitutePrinter(params);
|
6563
6559
|
}
|
6564
|
-
async saveSubstitutePrinter(
|
6560
|
+
async saveSubstitutePrinter(params) {
|
6561
|
+
const { transactionId, pendingPrinters, printerUri, saveSubstitutePrinters = false } = params;
|
6565
6562
|
const parsedPendingPrinters = pendingPrinters.map((item) => ({
|
6566
6563
|
printerUri: {
|
6567
|
-
$:
|
6564
|
+
$: item.printerUri || printerUri
|
6568
6565
|
},
|
6569
6566
|
originalPrinterName: {
|
6570
6567
|
$: item.originalPrinterName
|
@@ -6585,7 +6582,7 @@ class PrintUtils {
|
|
6585
6582
|
pendingPrinter: parsedPendingPrinters
|
6586
6583
|
},
|
6587
6584
|
saveSubstitutePrinters: {
|
6588
|
-
$:
|
6585
|
+
$: saveSubstitutePrinters.toString()
|
6589
6586
|
},
|
6590
6587
|
transactionId: {
|
6591
6588
|
$: transactionId
|
@@ -6594,11 +6591,78 @@ class PrintUtils {
|
|
6594
6591
|
};
|
6595
6592
|
await DataFetcher.get().callServiceBroker(PrintUtils.SERVICE_SAVE_SUBSTITUTE_PRINTER, JSON.stringify(requestBody));
|
6596
6593
|
}
|
6594
|
+
async processDirectPrint(printJobData) {
|
6595
|
+
const isWCRunning = this.appletImpressao.checkWebConnection();
|
6596
|
+
if (!isWCRunning) {
|
6597
|
+
return [];
|
6598
|
+
}
|
6599
|
+
const localPrinters = this.getLocalPrinters();
|
6600
|
+
if (!localPrinters.length)
|
6601
|
+
return [];
|
6602
|
+
const directPendingPrints = [];
|
6603
|
+
const pendingPrints = printJobData.pendingPrinters.filter(item => {
|
6604
|
+
const defaultPrinterName = this.getDefaultPrinterName(item.originalPrinterName);
|
6605
|
+
const isDirectPrint = !!localPrinters.find(localPrinter => localPrinter.nome === defaultPrinterName) || this.isPrinterNameAFile(defaultPrinterName);
|
6606
|
+
if (isDirectPrint) {
|
6607
|
+
directPendingPrints.push(Object.assign(Object.assign({}, item), { printerUri: PrintUtils.LOCAL_SERVER_URI + defaultPrinterName }));
|
6608
|
+
return false;
|
6609
|
+
}
|
6610
|
+
return true;
|
6611
|
+
});
|
6612
|
+
if (!directPendingPrints.length)
|
6613
|
+
return pendingPrints;
|
6614
|
+
const params = {
|
6615
|
+
transactionId: printJobData.transactionId,
|
6616
|
+
pendingPrinters: directPendingPrints
|
6617
|
+
};
|
6618
|
+
await this.saveSubstitutePrinter(params);
|
6619
|
+
return pendingPrints;
|
6620
|
+
}
|
6621
|
+
getDefaultPrinterName(printerName) {
|
6622
|
+
const defaultPrinterName = this.appletImpressao.getDefaultPrinter();
|
6623
|
+
const isDefaultPrinterName = /padr[aã]o/ig.test(printerName);
|
6624
|
+
return (defaultPrinterName && isDefaultPrinterName) ? defaultPrinterName : printerName;
|
6625
|
+
}
|
6626
|
+
isPrinterNameAFile(printerName) {
|
6627
|
+
const regExp = new RegExp("^(\w:)?[/\\\w\s]+?\.\w{3}$", "mis");
|
6628
|
+
return regExp.test(printerName);
|
6629
|
+
}
|
6597
6630
|
}
|
6598
6631
|
PrintUtils.SERVICE_FIND_PENDING_PRINTS = 'mge@PrintServiceSP.findPendingPrinters';
|
6599
6632
|
PrintUtils.SERVICE_SAVE_SUBSTITUTE_PRINTER = 'mge@PrintServiceSP.saveSubstitutePrinter';
|
6600
6633
|
PrintUtils.LOCAL_SERVER_URI = 'LOCAL:0/';
|
6601
6634
|
PrintUtils.ENCODED_PROPERTIES = ['printerName', 'printerUri'];
|
6635
|
+
class AppletImpressao {
|
6636
|
+
constructor() {
|
6637
|
+
this.appletImpressao = document.getElementById('centralNotaAppletImpressao');
|
6638
|
+
}
|
6639
|
+
checkWebConnection() {
|
6640
|
+
if (!this.appletImpressao)
|
6641
|
+
return false;
|
6642
|
+
if (!this.appletImpressao.testRunningWC)
|
6643
|
+
return false;
|
6644
|
+
const isRunning = this.appletImpressao.testRunningWC();
|
6645
|
+
return !!isRunning;
|
6646
|
+
}
|
6647
|
+
findLocalPrinters() {
|
6648
|
+
if (!this.appletImpressao)
|
6649
|
+
return [];
|
6650
|
+
const localPrinters = this.appletImpressao.getLocalPrinters();
|
6651
|
+
if (!localPrinters)
|
6652
|
+
return [];
|
6653
|
+
return localPrinters.split(",");
|
6654
|
+
}
|
6655
|
+
doLocalPrinting(transactionIds) {
|
6656
|
+
if (!this.appletImpressao)
|
6657
|
+
return;
|
6658
|
+
this.appletImpressao.doLocalPrinting(transactionIds);
|
6659
|
+
}
|
6660
|
+
getDefaultPrinter() {
|
6661
|
+
if (!this.appletImpressao)
|
6662
|
+
return '';
|
6663
|
+
return this.appletImpressao.getPrintDefault();
|
6664
|
+
}
|
6665
|
+
}
|
6602
6666
|
|
6603
6667
|
class DataFetcher {
|
6604
6668
|
constructor() {
|
@@ -452,7 +452,8 @@ const snkPrintSelectorMessages = {
|
|
452
452
|
},
|
453
453
|
message: {
|
454
454
|
canceledPrint: "A impressão será cancelada. Deseja mesmo continuar?",
|
455
|
-
noPrinters: "Não há impressoras para seleção"
|
455
|
+
noPrinters: "Não há impressoras para seleção",
|
456
|
+
savePrinter: "Usar sempre esta seleção"
|
456
457
|
},
|
457
458
|
button: {
|
458
459
|
print: "Imprimir",
|
@@ -74,9 +74,10 @@ function _0x53e1(){const _0x340df8=['2909523kXwted','CompanyName=Sankhya\x20Jiva
|
|
74
74
|
class TotalsFetcher {
|
75
75
|
constructor() {
|
76
76
|
this.templateByQuery = new Map();
|
77
|
-
this.
|
77
|
+
this.cancel = [];
|
78
|
+
this.buildTemplates();
|
78
79
|
}
|
79
|
-
|
80
|
+
buildTemplates() {
|
80
81
|
this.templateByQuery.set("fetchTotals", dist.gql `query($filters: [InputFilter!] $name: String!) {
|
81
82
|
$queryAlias$: fetchTotals(name: $name, filters: $filters ){
|
82
83
|
name
|
@@ -84,35 +85,50 @@ class TotalsFetcher {
|
|
84
85
|
}
|
85
86
|
}`);
|
86
87
|
}
|
87
|
-
|
88
|
-
const
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
88
|
+
fetchTotals(name, resourceID, filters = []) {
|
89
|
+
const cancelKey = `${name}_${resourceID}`;
|
90
|
+
const anotherPromiseIndex = this.cancel.findIndex(promiseExecuting => promiseExecuting[cancelKey]);
|
91
|
+
if (anotherPromiseIndex >= 0) {
|
92
|
+
this.cancel[anotherPromiseIndex][cancelKey]();
|
93
|
+
this.cancel.splice(anotherPromiseIndex, 1);
|
94
|
+
}
|
95
|
+
return Promise
|
96
|
+
.race([
|
97
|
+
new Promise(resolve => this.cancel.push({ [cancelKey]: resolve })),
|
98
|
+
this.getTotals(name, resourceID, filters)
|
99
|
+
])
|
100
|
+
.then((results) => {
|
101
|
+
let dataResult = new Map();
|
102
|
+
if (results) {
|
103
|
+
dataResult = results;
|
104
|
+
const myPromiseIndex = this.cancel.findIndex(promiseExecuting => promiseExecuting[cancelKey]);
|
105
|
+
if (myPromiseIndex >= 0) {
|
106
|
+
this.cancel.splice(myPromiseIndex, 1);
|
107
|
+
}
|
108
|
+
}
|
109
|
+
return dataResult;
|
96
110
|
});
|
97
111
|
}
|
98
|
-
|
112
|
+
getTotals(name, resourceID, filters = []) {
|
99
113
|
return new Promise((accept, reject) => {
|
100
|
-
|
101
|
-
.
|
114
|
+
DataFetcher
|
115
|
+
.get()
|
116
|
+
.callGraphQL({
|
117
|
+
query: this.templateByQuery.get("fetchTotals"),
|
118
|
+
values: {
|
119
|
+
name: `totals://${name}/${resourceID}`,
|
120
|
+
filters: filters
|
121
|
+
},
|
122
|
+
})
|
123
|
+
.then(result => {
|
102
124
|
if (result.length > 0) {
|
103
125
|
const totalsData = new Map();
|
104
|
-
result.forEach(total =>
|
105
|
-
|
106
|
-
});
|
107
|
-
accept(totalsData);
|
108
|
-
}
|
109
|
-
else {
|
110
|
-
reject(`Não foi possível recuperar os totalizadores`);
|
126
|
+
result.forEach(total => totalsData.set(total.name, parseFloat(total.value)));
|
127
|
+
return accept(totalsData);
|
111
128
|
}
|
129
|
+
return reject("Não foi possível recuperar os totalizadores");
|
112
130
|
})
|
113
|
-
.catch(
|
114
|
-
reject(error);
|
115
|
-
});
|
131
|
+
.catch(reject);
|
116
132
|
});
|
117
133
|
}
|
118
134
|
}
|
@@ -4,7 +4,7 @@ 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';
|
6
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{
|
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{height:100%;overflow-y:auto;padding-right:var(--snk-grid-config__main--padding-right)}.with-header.sc-snk-print-selector{max-height:calc(100% - 125px)}.without-header.sc-snk-print-selector{max-height:calc(100% - 85px)}.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
8
|
|
9
9
|
const SnkPrintSelector$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
10
10
|
constructor() {
|
@@ -19,17 +19,18 @@ const SnkPrintSelector$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
|
|
19
19
|
this._hasLocalPrinters = false;
|
20
20
|
this._localPrinters = [];
|
21
21
|
this._isSingleJob = false;
|
22
|
+
this._saveSubstitute = false;
|
22
23
|
this.buildIdTabSelector = () => {
|
23
24
|
const defaultTabs = [
|
24
25
|
{
|
25
|
-
label: this.
|
26
|
+
label: this.getMessage("snkPrintSelector.title.localPrintersTab"),
|
26
27
|
tabKey: this.LOCAL_PRINTERS_TAB,
|
27
28
|
index: Number(this.LOCAL_PRINTERS_TAB)
|
28
29
|
}
|
29
30
|
];
|
30
31
|
if (this._printServerActive) {
|
31
32
|
defaultTabs.unshift({
|
32
|
-
label: this.
|
33
|
+
label: this.getMessage("snkPrintSelector.title.remotePrintersTab"),
|
33
34
|
tabKey: this.REMOTE_PRINTERS_TAB,
|
34
35
|
index: Number(this.REMOTE_PRINTERS_TAB)
|
35
36
|
});
|
@@ -74,14 +75,14 @@ const SnkPrintSelector$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
|
|
74
75
|
}
|
75
76
|
}
|
76
77
|
async handleCancel() {
|
77
|
-
const result = await ApplicationUtils.confirm(this.
|
78
|
+
const result = await ApplicationUtils.confirm(this.getMessage("snkPrintSelector.title.warning"), this.getMessage("snkPrintSelector.message.canceledPrint"));
|
78
79
|
if (result) {
|
79
80
|
this.closePrintSelector();
|
80
|
-
this._printerResolver(undefined);
|
81
|
+
this._printerResolver({ selectedPrinter: undefined, saveSubstitute: false });
|
81
82
|
}
|
82
83
|
}
|
83
84
|
handleApply() {
|
84
|
-
this._printerResolver(this._selectedPrinter);
|
85
|
+
this._printerResolver({ selectedPrinter: this._selectedPrinter, saveSubstitute: this._saveSubstitute });
|
85
86
|
this.closePrintSelector();
|
86
87
|
}
|
87
88
|
onChangeTab(evt) {
|
@@ -126,7 +127,7 @@ const SnkPrintSelector$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
|
|
126
127
|
this._selectedPrinter = serverGroup === null || serverGroup === void 0 ? void 0 : serverGroup.printerList.find((item) => item.printerName === printer.label);
|
127
128
|
}
|
128
129
|
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.
|
130
|
+
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.getMessage("snkPrintSelector.message.noPrinters"))));
|
130
131
|
}
|
131
132
|
buildPrinterIcon() {
|
132
133
|
return (h("ez-icon", { iconName: "print", style: { marginRight: 'var(--space--small)' } }));
|
@@ -136,6 +137,9 @@ const SnkPrintSelector$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
|
|
136
137
|
[ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: ElementIDUtils.getInternalIDInfo(sufix)
|
137
138
|
};
|
138
139
|
}
|
140
|
+
getMessage(path) {
|
141
|
+
return this._application.messagesBuilder.getMessage(path, undefined);
|
142
|
+
}
|
139
143
|
componentWillLoad() {
|
140
144
|
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
141
145
|
}
|
@@ -145,9 +149,9 @@ const SnkPrintSelector$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
|
|
145
149
|
ElementIDUtils.addIDInfo(this.element);
|
146
150
|
}
|
147
151
|
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.
|
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.
|
150
|
-
h("div", { class:
|
152
|
+
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.getMessage("snkPrintSelector.title.printerSelection"), okButtonLabel: this.getMessage("snkPrintSelector.button.print"), okButtonStatus: this._selectedPrinter ? ModalButtonStatus.ENABLED : ModalButtonStatus.DISABLED, cancelButtonLabel: this.getMessage("snkPrintSelector.button.cancel"), onEzModalAction: (evt) => this.handleModalAction(evt.detail) }, this._isSingleJob &&
|
153
|
+
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.getMessage("snkPrintSelector.subtitle.document")), 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.getMessage("snkPrintSelector.subtitle.jobs")), 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 &&
|
154
|
+
h("div", { class: `list-scroll ez-size-height--full ${this._isSingleJob ? 'with-header' : 'without-header'}` }, 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 ${this._isSingleJob ? 'with-header' : 'without-header'}` }, 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()))), h("ez-check", { label: this.getMessage("snkPrintSelector.message.savePrinter"), onEzChange: evt => this._saveSubstitute = evt.detail, compact: true })))));
|
151
155
|
}
|
152
156
|
get element() { return this; }
|
153
157
|
static get style() { return snkPrintSelectorCss; }
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { ApplicationContext } from '@sankhyalabs/core';
|
2
|
-
import { F as FormConfigFetcher } from './form-config-fetcher-
|
3
|
-
import { R as ResourceFetcher } from './resource-fetcher-
|
4
|
-
import { F as FilterBarConfigFetcher } from './filter-bar-config-fetcher-
|
5
|
-
import { d as dist, D as DataFetcher } from './DataFetcher-
|
2
|
+
import { F as FormConfigFetcher } from './form-config-fetcher-533b895e.js';
|
3
|
+
import { R as ResourceFetcher } from './resource-fetcher-0f20a072.js';
|
4
|
+
import { F as FilterBarConfigFetcher } from './filter-bar-config-fetcher-a358b8e0.js';
|
5
|
+
import { d as dist, D as DataFetcher } from './DataFetcher-fddeb917.js';
|
6
6
|
|
7
7
|
class GridConfigFetcher extends ResourceFetcher {
|
8
8
|
constructor() {
|
@@ -6466,6 +6466,7 @@ class GraphQLRecaller {
|
|
6466
6466
|
|
6467
6467
|
class PrintUtils {
|
6468
6468
|
constructor() {
|
6469
|
+
this.appletImpressao = new AppletImpressao();
|
6469
6470
|
}
|
6470
6471
|
static getInstance() {
|
6471
6472
|
if (!PrintUtils.instance) {
|
@@ -6488,17 +6489,15 @@ class PrintUtils {
|
|
6488
6489
|
};
|
6489
6490
|
const response = await DataFetcher.get().callServiceBroker(PrintUtils.SERVICE_FIND_PENDING_PRINTS, JSON.stringify(requestBody));
|
6490
6491
|
const printJobData = this.parsePrintData(response);
|
6491
|
-
this.
|
6492
|
+
const pendingPrints = await this.processDirectPrint(printJobData);
|
6493
|
+
if (!pendingPrints.length)
|
6494
|
+
return;
|
6495
|
+
this.openSnkPrintSelector(Object.assign(Object.assign({}, printJobData), { pendingPrinters: pendingPrints }));
|
6492
6496
|
}
|
6493
|
-
|
6494
|
-
const
|
6495
|
-
if (!appletImpressao)
|
6496
|
-
return [];
|
6497
|
-
const localPrinters = appletImpressao.getLocalPrinters();
|
6498
|
-
if (!localPrinters)
|
6499
|
-
return [];
|
6497
|
+
getLocalPrinters() {
|
6498
|
+
const localPrinters = this.appletImpressao.findLocalPrinters();
|
6500
6499
|
const printers = [];
|
6501
|
-
for (const printerName of localPrinters
|
6500
|
+
for (const printerName of localPrinters) {
|
6502
6501
|
printers.push({
|
6503
6502
|
nome: printerName,
|
6504
6503
|
printerUri: PrintUtils.LOCAL_SERVER_URI + printerName,
|
@@ -6507,9 +6506,6 @@ class PrintUtils {
|
|
6507
6506
|
}
|
6508
6507
|
return printers;
|
6509
6508
|
}
|
6510
|
-
getLocalPrinters() {
|
6511
|
-
return this.findLocalPrinters();
|
6512
|
-
}
|
6513
6509
|
parsePrintData(payload) {
|
6514
6510
|
const pendingPrintJobData = payload.pendindPrintJobData;
|
6515
6511
|
if (!pendingPrintJobData)
|
@@ -6541,13 +6537,7 @@ class PrintUtils {
|
|
6541
6537
|
}
|
6542
6538
|
processLocalPrinting(localPrintings) {
|
6543
6539
|
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);
|
6540
|
+
this.appletImpressao.doLocalPrinting(transactionIds.join());
|
6551
6541
|
}
|
6552
6542
|
async openSnkPrintSelector(printJobData) {
|
6553
6543
|
let printSelector = document.querySelector('snk-print-selector');
|
@@ -6556,15 +6546,22 @@ class PrintUtils {
|
|
6556
6546
|
printSelector.setAttribute('id', StringUtils.generateUUID());
|
6557
6547
|
window.document.body.appendChild(printSelector);
|
6558
6548
|
}
|
6559
|
-
const selectedPrinter = await printSelector.openPrintSelector(printJobData);
|
6549
|
+
const { selectedPrinter, saveSubstitute } = await printSelector.openPrintSelector(printJobData);
|
6560
6550
|
if (!selectedPrinter)
|
6561
6551
|
return;
|
6562
|
-
|
6552
|
+
const params = {
|
6553
|
+
transactionId: printJobData.transactionId,
|
6554
|
+
pendingPrinters: printJobData.pendingPrinters,
|
6555
|
+
printerUri: selectedPrinter.printerUri,
|
6556
|
+
saveSubstitutePrinters: saveSubstitute
|
6557
|
+
};
|
6558
|
+
await this.saveSubstitutePrinter(params);
|
6563
6559
|
}
|
6564
|
-
async saveSubstitutePrinter(
|
6560
|
+
async saveSubstitutePrinter(params) {
|
6561
|
+
const { transactionId, pendingPrinters, printerUri, saveSubstitutePrinters = false } = params;
|
6565
6562
|
const parsedPendingPrinters = pendingPrinters.map((item) => ({
|
6566
6563
|
printerUri: {
|
6567
|
-
$:
|
6564
|
+
$: item.printerUri || printerUri
|
6568
6565
|
},
|
6569
6566
|
originalPrinterName: {
|
6570
6567
|
$: item.originalPrinterName
|
@@ -6585,7 +6582,7 @@ class PrintUtils {
|
|
6585
6582
|
pendingPrinter: parsedPendingPrinters
|
6586
6583
|
},
|
6587
6584
|
saveSubstitutePrinters: {
|
6588
|
-
$:
|
6585
|
+
$: saveSubstitutePrinters.toString()
|
6589
6586
|
},
|
6590
6587
|
transactionId: {
|
6591
6588
|
$: transactionId
|
@@ -6594,11 +6591,78 @@ class PrintUtils {
|
|
6594
6591
|
};
|
6595
6592
|
await DataFetcher.get().callServiceBroker(PrintUtils.SERVICE_SAVE_SUBSTITUTE_PRINTER, JSON.stringify(requestBody));
|
6596
6593
|
}
|
6594
|
+
async processDirectPrint(printJobData) {
|
6595
|
+
const isWCRunning = this.appletImpressao.checkWebConnection();
|
6596
|
+
if (!isWCRunning) {
|
6597
|
+
return [];
|
6598
|
+
}
|
6599
|
+
const localPrinters = this.getLocalPrinters();
|
6600
|
+
if (!localPrinters.length)
|
6601
|
+
return [];
|
6602
|
+
const directPendingPrints = [];
|
6603
|
+
const pendingPrints = printJobData.pendingPrinters.filter(item => {
|
6604
|
+
const defaultPrinterName = this.getDefaultPrinterName(item.originalPrinterName);
|
6605
|
+
const isDirectPrint = !!localPrinters.find(localPrinter => localPrinter.nome === defaultPrinterName) || this.isPrinterNameAFile(defaultPrinterName);
|
6606
|
+
if (isDirectPrint) {
|
6607
|
+
directPendingPrints.push(Object.assign(Object.assign({}, item), { printerUri: PrintUtils.LOCAL_SERVER_URI + defaultPrinterName }));
|
6608
|
+
return false;
|
6609
|
+
}
|
6610
|
+
return true;
|
6611
|
+
});
|
6612
|
+
if (!directPendingPrints.length)
|
6613
|
+
return pendingPrints;
|
6614
|
+
const params = {
|
6615
|
+
transactionId: printJobData.transactionId,
|
6616
|
+
pendingPrinters: directPendingPrints
|
6617
|
+
};
|
6618
|
+
await this.saveSubstitutePrinter(params);
|
6619
|
+
return pendingPrints;
|
6620
|
+
}
|
6621
|
+
getDefaultPrinterName(printerName) {
|
6622
|
+
const defaultPrinterName = this.appletImpressao.getDefaultPrinter();
|
6623
|
+
const isDefaultPrinterName = /padr[aã]o/ig.test(printerName);
|
6624
|
+
return (defaultPrinterName && isDefaultPrinterName) ? defaultPrinterName : printerName;
|
6625
|
+
}
|
6626
|
+
isPrinterNameAFile(printerName) {
|
6627
|
+
const regExp = new RegExp("^(\w:)?[/\\\w\s]+?\.\w{3}$", "mis");
|
6628
|
+
return regExp.test(printerName);
|
6629
|
+
}
|
6597
6630
|
}
|
6598
6631
|
PrintUtils.SERVICE_FIND_PENDING_PRINTS = 'mge@PrintServiceSP.findPendingPrinters';
|
6599
6632
|
PrintUtils.SERVICE_SAVE_SUBSTITUTE_PRINTER = 'mge@PrintServiceSP.saveSubstitutePrinter';
|
6600
6633
|
PrintUtils.LOCAL_SERVER_URI = 'LOCAL:0/';
|
6601
6634
|
PrintUtils.ENCODED_PROPERTIES = ['printerName', 'printerUri'];
|
6635
|
+
class AppletImpressao {
|
6636
|
+
constructor() {
|
6637
|
+
this.appletImpressao = document.getElementById('centralNotaAppletImpressao');
|
6638
|
+
}
|
6639
|
+
checkWebConnection() {
|
6640
|
+
if (!this.appletImpressao)
|
6641
|
+
return false;
|
6642
|
+
if (!this.appletImpressao.testRunningWC)
|
6643
|
+
return false;
|
6644
|
+
const isRunning = this.appletImpressao.testRunningWC();
|
6645
|
+
return !!isRunning;
|
6646
|
+
}
|
6647
|
+
findLocalPrinters() {
|
6648
|
+
if (!this.appletImpressao)
|
6649
|
+
return [];
|
6650
|
+
const localPrinters = this.appletImpressao.getLocalPrinters();
|
6651
|
+
if (!localPrinters)
|
6652
|
+
return [];
|
6653
|
+
return localPrinters.split(",");
|
6654
|
+
}
|
6655
|
+
doLocalPrinting(transactionIds) {
|
6656
|
+
if (!this.appletImpressao)
|
6657
|
+
return;
|
6658
|
+
this.appletImpressao.doLocalPrinting(transactionIds);
|
6659
|
+
}
|
6660
|
+
getDefaultPrinter() {
|
6661
|
+
if (!this.appletImpressao)
|
6662
|
+
return '';
|
6663
|
+
return this.appletImpressao.getPrintDefault();
|
6664
|
+
}
|
6665
|
+
}
|
6602
6666
|
|
6603
6667
|
class DataFetcher {
|
6604
6668
|
constructor() {
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { C as ConfigStorage } from './ConfigStorage-
|
1
|
+
import { C as ConfigStorage } from './ConfigStorage-f1e805a0.js';
|
2
2
|
import { ObjectUtils } from '@sankhyalabs/core';
|
3
|
-
import { F as FormConfigFetcher } from './form-config-fetcher-
|
3
|
+
import { F as FormConfigFetcher } from './form-config-fetcher-533b895e.js';
|
4
4
|
|
5
5
|
class SnkFormConfigManager {
|
6
6
|
constructor(configName, onConfigChange) {
|
@@ -452,7 +452,8 @@ const snkPrintSelectorMessages = {
|
|
452
452
|
},
|
453
453
|
message: {
|
454
454
|
canceledPrint: "A impressão será cancelada. Deseja mesmo continuar?",
|
455
|
-
noPrinters: "Não há impressoras para seleção"
|
455
|
+
noPrinters: "Não há impressoras para seleção",
|
456
|
+
savePrinter: "Usar sempre esta seleção"
|
456
457
|
},
|
457
458
|
button: {
|
458
459
|
print: "Imprimir",
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { DataUnit, StringUtils, DataType, DataUnitStorage, ChangeOperation } from '@sankhyalabs/core';
|
2
|
-
import { d as dist, D as DataFetcher } from './DataFetcher-
|
2
|
+
import { d as dist, D as DataFetcher } from './DataFetcher-fddeb917.js';
|
3
3
|
import { DISTINCT_FILTER_NAME_PREFIX } from '@sankhyalabs/ezui/dist/collection/utils/constants';
|
4
4
|
import { DataUnitTransient } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
5
5
|
|
package/dist/esm/{filter-bar-config-fetcher-73ebc12f.js → filter-bar-config-fetcher-a358b8e0.js}
RENAMED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { F as FilterItemType } from './filter-item-type.enum-5028ed3f.js';
|
2
|
-
import { R as ResourceFetcher } from './resource-fetcher-
|
2
|
+
import { R as ResourceFetcher } from './resource-fetcher-0f20a072.js';
|
3
3
|
|
4
4
|
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
5
5
|
var t = {};
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { d as dist, D as DataFetcher } from './DataFetcher-
|
1
|
+
import { d as dist, D as DataFetcher } from './DataFetcher-fddeb917.js';
|
2
2
|
import { ObjectUtils } from '@sankhyalabs/core';
|
3
|
-
import { R as ResourceFetcher } from './resource-fetcher-
|
3
|
+
import { R as ResourceFetcher } from './resource-fetcher-0f20a072.js';
|
4
4
|
|
5
5
|
class FormConfigFetcher extends ResourceFetcher {
|
6
6
|
constructor() {
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { r as registerInstance, h, H as Host, g as getElement } from './index-a7d3d3f1.js';
|
2
2
|
import { ApplicationContext, StringUtils, ErrorException, WarningException, ObjectUtils, DateUtils, ArrayUtils, ElementIDUtils } from '@sankhyalabs/core';
|
3
|
-
import { D as DataFetcher } from './DataFetcher-
|
3
|
+
import { D as DataFetcher } from './DataFetcher-fddeb917.js';
|
4
4
|
import { P as ParamType } from './ParamType-d5152b06.js';
|
5
|
-
import './pesquisa-fetcher-
|
5
|
+
import './pesquisa-fetcher-4a702655.js';
|
6
6
|
import './index-1564817d.js';
|
7
7
|
import './_commonjsHelpers-9943807e.js';
|
8
8
|
|