@sankhyalabs/sankhyablocks 8.8.0-rc.3 → 8.8.0-rc.5
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/{SnkMultiSelectionListDataSource-9fd9c742.js → SnkMultiSelectionListDataSource-45893a0c.js} +1 -1
- package/dist/cjs/{dataunit-fetcher-1433ce24.js → dataunit-fetcher-2454608a.js} +2 -0
- package/dist/cjs/snk-actions-button.cjs.entry.js +88 -83
- package/dist/cjs/snk-application.cjs.entry.js +1 -1
- package/dist/cjs/snk-attach.cjs.entry.js +1 -1
- package/dist/cjs/snk-crud.cjs.entry.js +1 -1
- package/dist/cjs/snk-detail-view.cjs.entry.js +2 -2
- package/dist/cjs/snk-grid.cjs.entry.js +2 -2
- package/dist/cjs/{snk-guides-viewer-0f03d633.js → snk-guides-viewer-018c1c8e.js} +1 -1
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +2 -2
- package/dist/cjs/snk-simple-crud.cjs.entry.js +2 -2
- package/dist/collection/components/snk-actions-button/actions/executor/java.executor.js +2 -2
- package/dist/collection/components/snk-actions-button/actions/executor/javascript.executor.js +2 -2
- package/dist/collection/components/snk-actions-button/actions/executor/procedure.executor.js +2 -2
- package/dist/collection/components/snk-actions-button/clientEvent/index.js +81 -76
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +2 -0
- package/dist/components/dataunit-fetcher.js +2 -0
- package/dist/components/snk-actions-button2.js +87 -82
- package/dist/esm/{SnkMultiSelectionListDataSource-447cd9e8.js → SnkMultiSelectionListDataSource-a0b69ac4.js} +1 -1
- package/dist/esm/{dataunit-fetcher-0162ce17.js → dataunit-fetcher-493182bc.js} +2 -0
- package/dist/esm/snk-actions-button.entry.js +88 -83
- package/dist/esm/snk-application.entry.js +1 -1
- package/dist/esm/snk-attach.entry.js +1 -1
- package/dist/esm/snk-crud.entry.js +1 -1
- package/dist/esm/snk-detail-view.entry.js +2 -2
- package/dist/esm/snk-grid.entry.js +2 -2
- package/dist/esm/{snk-guides-viewer-64c24a05.js → snk-guides-viewer-7c120bc6.js} +1 -1
- package/dist/esm/snk-guides-viewer.entry.js +2 -2
- package/dist/esm/snk-simple-crud.entry.js +2 -2
- package/dist/sankhyablocks/{p-cc232268.entry.js → p-21d01a8c.entry.js} +1 -1
- package/dist/sankhyablocks/{p-a84035fa.js → p-53091bcd.js} +1 -1
- package/dist/sankhyablocks/{p-1161cb2d.js → p-7650d823.js} +1 -1
- package/dist/sankhyablocks/{p-441cce40.entry.js → p-8f7e0bbd.entry.js} +1 -1
- package/dist/sankhyablocks/{p-f5dbb069.entry.js → p-9256574e.entry.js} +1 -1
- package/dist/sankhyablocks/p-b9b7bfce.entry.js +1 -0
- package/dist/sankhyablocks/{p-85635c64.js → p-bdfcc2e2.js} +1 -1
- package/dist/sankhyablocks/{p-5bd7932e.entry.js → p-db45a464.entry.js} +1 -1
- package/dist/sankhyablocks/{p-7cbbb6e3.entry.js → p-e13c3fbc.entry.js} +1 -1
- package/dist/sankhyablocks/{p-503c9774.entry.js → p-e33b308f.entry.js} +1 -1
- package/dist/sankhyablocks/{p-e350860d.entry.js → p-f34b9087.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-actions-button/clientEvent/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/sankhyablocks/p-617bc4c1.entry.js +0 -1
@@ -22,13 +22,13 @@ class JavaExecutor {
|
|
22
22
|
resolve({ execSource, callback: this.callExecJava });
|
23
23
|
});
|
24
24
|
}
|
25
|
-
callExecJava(execSource) {
|
25
|
+
async callExecJava(execSource) {
|
26
26
|
const request = {
|
27
27
|
requestBody: {
|
28
28
|
javaCall: execSource
|
29
29
|
}
|
30
30
|
};
|
31
|
-
DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_JAVA, JSON.stringify(request));
|
31
|
+
await DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_JAVA, JSON.stringify(request));
|
32
32
|
}
|
33
33
|
}
|
34
34
|
|
@@ -44,11 +44,11 @@ class JavascriptExecutor {
|
|
44
44
|
resolve({ execSource, callback: this.callExecScript });
|
45
45
|
});
|
46
46
|
}
|
47
|
-
callExecScript(execSource) {
|
47
|
+
async callExecScript(execSource) {
|
48
48
|
const request = {
|
49
49
|
runScript: execSource
|
50
50
|
};
|
51
|
-
DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_SCRIPT, request);
|
51
|
+
await DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_SCRIPT, request);
|
52
52
|
}
|
53
53
|
}
|
54
54
|
|
@@ -110,13 +110,13 @@ class ProcedureExecutor {
|
|
110
110
|
resolve({ execSource, callback: this.callExecProcedure });
|
111
111
|
});
|
112
112
|
}
|
113
|
-
callExecProcedure(execSource) {
|
113
|
+
async callExecProcedure(execSource) {
|
114
114
|
const request = {
|
115
115
|
requestBody: {
|
116
116
|
stpCall: execSource
|
117
117
|
}
|
118
118
|
};
|
119
|
-
DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_STP, JSON.stringify(request));
|
119
|
+
await DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_STP, JSON.stringify(request));
|
120
120
|
}
|
121
121
|
}
|
122
122
|
|
@@ -506,86 +506,91 @@ class Actions {
|
|
506
506
|
const CONFIRMACAO = "__CONFIRMACAO__";
|
507
507
|
const ESCOLHA_SIM_NAO = "__ESCOLHA_SIMNAO__";
|
508
508
|
class ClientEventConfirm {
|
509
|
-
clientConfirm(clientEvent, recaller) {
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
if (!recaller.requestBody.params) {
|
529
|
-
recaller.requestBody.params = {
|
530
|
-
param: []
|
509
|
+
async clientConfirm(clientEvent, recaller) {
|
510
|
+
return new Promise((resolve) => {
|
511
|
+
const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
512
|
+
let actionType = "";
|
513
|
+
if (clientEvent.content.event.hasOwnProperty('stpCall')) {
|
514
|
+
recaller.requestBody = clientEvent.content.event.stpCall;
|
515
|
+
actionType = ActionsType.PROCEDURE;
|
516
|
+
}
|
517
|
+
else if (clientEvent.content.event.hasOwnProperty('runScript')) {
|
518
|
+
recaller.requestBody = clientEvent.content.event.runScript;
|
519
|
+
actionType = ActionsType.JAVASCRIPT;
|
520
|
+
}
|
521
|
+
else if (clientEvent.content.event.hasOwnProperty('javaCall')) {
|
522
|
+
recaller.requestBody = clientEvent.content.event.javaCall;
|
523
|
+
actionType = ActionsType.JAVA;
|
524
|
+
}
|
525
|
+
let param = {
|
526
|
+
type: 'S',
|
527
|
+
sequence: clientEvent.content.event.sequence
|
531
528
|
};
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
529
|
+
if (!recaller.requestBody.params) {
|
530
|
+
recaller.requestBody.params = {
|
531
|
+
param: []
|
532
|
+
};
|
536
533
|
}
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
requestBody:
|
549
|
-
|
550
|
-
|
534
|
+
else {
|
535
|
+
if (!Array.isArray(recaller.requestBody.params.param)) {
|
536
|
+
recaller.requestBody.params.param = [recaller.requestBody.params.param];
|
537
|
+
}
|
538
|
+
}
|
539
|
+
recaller.requestBody.params.param.push(param);
|
540
|
+
const title = clientEvent.content.event.title.$;
|
541
|
+
const message = clientEvent.content.event.message.$;
|
542
|
+
let requestBody;
|
543
|
+
switch (actionType) {
|
544
|
+
case ActionsType.JAVASCRIPT:
|
545
|
+
requestBody = { runScript: recaller.requestBody };
|
546
|
+
break;
|
547
|
+
case ActionsType.PROCEDURE:
|
548
|
+
requestBody = {
|
549
|
+
requestBody: {
|
550
|
+
stpCall: recaller.requestBody
|
551
|
+
}
|
552
|
+
};
|
553
|
+
break;
|
554
|
+
case ActionsType.JAVA:
|
555
|
+
requestBody = {
|
556
|
+
requestBody: {
|
557
|
+
javaCall: recaller.requestBody
|
558
|
+
}
|
559
|
+
};
|
560
|
+
break;
|
561
|
+
}
|
562
|
+
if (clientEvent.content.event.showNoOption == 'S') {
|
563
|
+
param.paramName = ESCOLHA_SIM_NAO;
|
564
|
+
const form = document.createElement("snk-client-confirm");
|
565
|
+
window.document.body.appendChild(form);
|
566
|
+
form.titleMessage = title;
|
567
|
+
form.message = message;
|
568
|
+
form.accept = async () => {
|
569
|
+
param.$ = 'S';
|
570
|
+
await recaller.reCall(requestBody);
|
571
|
+
resolve();
|
551
572
|
};
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
javaCall: recaller.requestBody
|
557
|
-
}
|
573
|
+
form.cancel = async () => {
|
574
|
+
param.$ = 'N';
|
575
|
+
await recaller.reCall(requestBody);
|
576
|
+
resolve();
|
558
577
|
};
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
form.openPopup();
|
576
|
-
}
|
577
|
-
else {
|
578
|
-
application.confirm(title, message, null, 'warn', {
|
579
|
-
labelCancel: "Cancelar",
|
580
|
-
labelConfirm: "Sim"
|
581
|
-
}).then((confirmResult) => {
|
582
|
-
if (confirmResult) {
|
583
|
-
param.paramName = CONFIRMACAO;
|
584
|
-
param.$ = 'S';
|
585
|
-
recaller.reCall(requestBody);
|
586
|
-
}
|
587
|
-
});
|
588
|
-
}
|
578
|
+
form.openPopup();
|
579
|
+
}
|
580
|
+
else {
|
581
|
+
application.confirm(title, message, null, 'warn', {
|
582
|
+
labelCancel: "Cancelar",
|
583
|
+
labelConfirm: "Sim"
|
584
|
+
}).then(async (confirmResult) => {
|
585
|
+
if (confirmResult) {
|
586
|
+
param.paramName = CONFIRMACAO;
|
587
|
+
param.$ = 'S';
|
588
|
+
await recaller.reCall(requestBody);
|
589
|
+
resolve();
|
590
|
+
}
|
591
|
+
});
|
592
|
+
}
|
593
|
+
});
|
589
594
|
}
|
590
595
|
}
|
591
596
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { UserInterface, DateUtils } from '@sankhyalabs/core';
|
2
|
-
import { P as PreloadManager } from './dataunit-fetcher-
|
2
|
+
import { P as PreloadManager } from './dataunit-fetcher-493182bc.js';
|
3
3
|
|
4
4
|
class SnkMultiSelectionListDataSource {
|
5
5
|
setDataUnit(dataUnit) {
|
@@ -396,6 +396,8 @@ class DatasetStrategy {
|
|
396
396
|
getFieldsList(dataUnit) {
|
397
397
|
let fields = ["__record__id__", "__record__label__"];
|
398
398
|
dataUnit.metadata.fields.forEach(descriptor => {
|
399
|
+
if (descriptor.standAlone)
|
400
|
+
return;
|
399
401
|
fields = fields.concat(this.getFieldNames(descriptor));
|
400
402
|
});
|
401
403
|
return fields;
|
@@ -7,7 +7,7 @@ import './index-1564817d.js';
|
|
7
7
|
import './ISave-4412b20c.js';
|
8
8
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
9
9
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
10
|
-
import './dataunit-fetcher-
|
10
|
+
import './dataunit-fetcher-493182bc.js';
|
11
11
|
import './filter-item-type.enum-5028ed3f.js';
|
12
12
|
import './form-config-fetcher-5b886892.js';
|
13
13
|
import { R as ResourceIDUtils } from './ResourceIDUtils-a114189a.js';
|
@@ -26,13 +26,13 @@ class JavaExecutor {
|
|
26
26
|
resolve({ execSource, callback: this.callExecJava });
|
27
27
|
});
|
28
28
|
}
|
29
|
-
callExecJava(execSource) {
|
29
|
+
async callExecJava(execSource) {
|
30
30
|
const request = {
|
31
31
|
requestBody: {
|
32
32
|
javaCall: execSource
|
33
33
|
}
|
34
34
|
};
|
35
|
-
DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_JAVA, JSON.stringify(request));
|
35
|
+
await DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_JAVA, JSON.stringify(request));
|
36
36
|
}
|
37
37
|
}
|
38
38
|
|
@@ -48,11 +48,11 @@ class JavascriptExecutor {
|
|
48
48
|
resolve({ execSource, callback: this.callExecScript });
|
49
49
|
});
|
50
50
|
}
|
51
|
-
callExecScript(execSource) {
|
51
|
+
async callExecScript(execSource) {
|
52
52
|
const request = {
|
53
53
|
runScript: execSource
|
54
54
|
};
|
55
|
-
DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_SCRIPT, request);
|
55
|
+
await DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_SCRIPT, request);
|
56
56
|
}
|
57
57
|
}
|
58
58
|
|
@@ -114,13 +114,13 @@ class ProcedureExecutor {
|
|
114
114
|
resolve({ execSource, callback: this.callExecProcedure });
|
115
115
|
});
|
116
116
|
}
|
117
|
-
callExecProcedure(execSource) {
|
117
|
+
async callExecProcedure(execSource) {
|
118
118
|
const request = {
|
119
119
|
requestBody: {
|
120
120
|
stpCall: execSource
|
121
121
|
}
|
122
122
|
};
|
123
|
-
DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_STP, JSON.stringify(request));
|
123
|
+
await DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_STP, JSON.stringify(request));
|
124
124
|
}
|
125
125
|
}
|
126
126
|
|
@@ -503,86 +503,91 @@ class Actions {
|
|
503
503
|
const CONFIRMACAO = "__CONFIRMACAO__";
|
504
504
|
const ESCOLHA_SIM_NAO = "__ESCOLHA_SIMNAO__";
|
505
505
|
class ClientEventConfirm {
|
506
|
-
clientConfirm(clientEvent, recaller) {
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
if (!recaller.requestBody.params) {
|
526
|
-
recaller.requestBody.params = {
|
527
|
-
param: []
|
506
|
+
async clientConfirm(clientEvent, recaller) {
|
507
|
+
return new Promise((resolve) => {
|
508
|
+
const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
509
|
+
let actionType = "";
|
510
|
+
if (clientEvent.content.event.hasOwnProperty('stpCall')) {
|
511
|
+
recaller.requestBody = clientEvent.content.event.stpCall;
|
512
|
+
actionType = ActionsType.PROCEDURE;
|
513
|
+
}
|
514
|
+
else if (clientEvent.content.event.hasOwnProperty('runScript')) {
|
515
|
+
recaller.requestBody = clientEvent.content.event.runScript;
|
516
|
+
actionType = ActionsType.JAVASCRIPT;
|
517
|
+
}
|
518
|
+
else if (clientEvent.content.event.hasOwnProperty('javaCall')) {
|
519
|
+
recaller.requestBody = clientEvent.content.event.javaCall;
|
520
|
+
actionType = ActionsType.JAVA;
|
521
|
+
}
|
522
|
+
let param = {
|
523
|
+
type: 'S',
|
524
|
+
sequence: clientEvent.content.event.sequence
|
528
525
|
};
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
526
|
+
if (!recaller.requestBody.params) {
|
527
|
+
recaller.requestBody.params = {
|
528
|
+
param: []
|
529
|
+
};
|
533
530
|
}
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
requestBody:
|
546
|
-
|
547
|
-
|
531
|
+
else {
|
532
|
+
if (!Array.isArray(recaller.requestBody.params.param)) {
|
533
|
+
recaller.requestBody.params.param = [recaller.requestBody.params.param];
|
534
|
+
}
|
535
|
+
}
|
536
|
+
recaller.requestBody.params.param.push(param);
|
537
|
+
const title = clientEvent.content.event.title.$;
|
538
|
+
const message = clientEvent.content.event.message.$;
|
539
|
+
let requestBody;
|
540
|
+
switch (actionType) {
|
541
|
+
case ActionsType.JAVASCRIPT:
|
542
|
+
requestBody = { runScript: recaller.requestBody };
|
543
|
+
break;
|
544
|
+
case ActionsType.PROCEDURE:
|
545
|
+
requestBody = {
|
546
|
+
requestBody: {
|
547
|
+
stpCall: recaller.requestBody
|
548
|
+
}
|
549
|
+
};
|
550
|
+
break;
|
551
|
+
case ActionsType.JAVA:
|
552
|
+
requestBody = {
|
553
|
+
requestBody: {
|
554
|
+
javaCall: recaller.requestBody
|
555
|
+
}
|
556
|
+
};
|
557
|
+
break;
|
558
|
+
}
|
559
|
+
if (clientEvent.content.event.showNoOption == 'S') {
|
560
|
+
param.paramName = ESCOLHA_SIM_NAO;
|
561
|
+
const form = document.createElement("snk-client-confirm");
|
562
|
+
window.document.body.appendChild(form);
|
563
|
+
form.titleMessage = title;
|
564
|
+
form.message = message;
|
565
|
+
form.accept = async () => {
|
566
|
+
param.$ = 'S';
|
567
|
+
await recaller.reCall(requestBody);
|
568
|
+
resolve();
|
548
569
|
};
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
javaCall: recaller.requestBody
|
554
|
-
}
|
570
|
+
form.cancel = async () => {
|
571
|
+
param.$ = 'N';
|
572
|
+
await recaller.reCall(requestBody);
|
573
|
+
resolve();
|
555
574
|
};
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
form.openPopup();
|
573
|
-
}
|
574
|
-
else {
|
575
|
-
application.confirm(title, message, null, 'warn', {
|
576
|
-
labelCancel: "Cancelar",
|
577
|
-
labelConfirm: "Sim"
|
578
|
-
}).then((confirmResult) => {
|
579
|
-
if (confirmResult) {
|
580
|
-
param.paramName = CONFIRMACAO;
|
581
|
-
param.$ = 'S';
|
582
|
-
recaller.reCall(requestBody);
|
583
|
-
}
|
584
|
-
});
|
585
|
-
}
|
575
|
+
form.openPopup();
|
576
|
+
}
|
577
|
+
else {
|
578
|
+
application.confirm(title, message, null, 'warn', {
|
579
|
+
labelCancel: "Cancelar",
|
580
|
+
labelConfirm: "Sim"
|
581
|
+
}).then(async (confirmResult) => {
|
582
|
+
if (confirmResult) {
|
583
|
+
param.paramName = CONFIRMACAO;
|
584
|
+
param.$ = 'S';
|
585
|
+
await recaller.reCall(requestBody);
|
586
|
+
resolve();
|
587
|
+
}
|
588
|
+
});
|
589
|
+
}
|
590
|
+
});
|
586
591
|
}
|
587
592
|
}
|
588
593
|
|
@@ -4,7 +4,7 @@ import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
4
4
|
import { C as ConfigStorage } from './ConfigStorage-9840d004.js';
|
5
5
|
import { d as dist, D as DataFetcher, U as UrlUtils } from './DataFetcher-07935045.js';
|
6
6
|
import { A as AutorizationType, a as AuthFetcher } from './auth-fetcher-1afab780.js';
|
7
|
-
import { D as DataUnitFetcher } from './dataunit-fetcher-
|
7
|
+
import { D as DataUnitFetcher } from './dataunit-fetcher-493182bc.js';
|
8
8
|
import { P as PesquisaFetcher } from './pesquisa-fetcher-7c46996d.js';
|
9
9
|
import { S as SnkMessageBuilder } from './SnkMessageBuilder-7ac66e9c.js';
|
10
10
|
import './form-config-fetcher-5b886892.js';
|
@@ -3,7 +3,7 @@ import { ApplicationContext, DataType, Action } from '@sankhyalabs/core';
|
|
3
3
|
import { D as DataFetcher } from './DataFetcher-07935045.js';
|
4
4
|
import { S as SaveErrorsEnum } from './ISave-4412b20c.js';
|
5
5
|
import { c as VIEW_MODE } from './constants-3644f1b6.js';
|
6
|
-
import { D as DataUnitFetcher } from './dataunit-fetcher-
|
6
|
+
import { D as DataUnitFetcher } from './dataunit-fetcher-493182bc.js';
|
7
7
|
import { T as TaskbarElement } from './taskbar-elements-0a6b8b95.js';
|
8
8
|
import './_commonjsHelpers-9943807e.js';
|
9
9
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
@@ -7,7 +7,7 @@ import { P as PresentationMode } from './index-1564817d.js';
|
|
7
7
|
import './ISave-4412b20c.js';
|
8
8
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
9
9
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
10
|
-
import './dataunit-fetcher-
|
10
|
+
import './dataunit-fetcher-493182bc.js';
|
11
11
|
import './filter-item-type.enum-5028ed3f.js';
|
12
12
|
import './form-config-fetcher-5b886892.js';
|
13
13
|
import { c as VIEW_MODE } from './constants-3644f1b6.js';
|
@@ -8,12 +8,12 @@ import { P as PresentationMode } from './index-1564817d.js';
|
|
8
8
|
import './ISave-4412b20c.js';
|
9
9
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
10
10
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
11
|
-
import './dataunit-fetcher-
|
11
|
+
import './dataunit-fetcher-493182bc.js';
|
12
12
|
import './filter-item-type.enum-5028ed3f.js';
|
13
13
|
import './form-config-fetcher-5b886892.js';
|
14
14
|
import { T as TaskbarElement } from './taskbar-elements-0a6b8b95.js';
|
15
15
|
import { c as VIEW_MODE } from './constants-3644f1b6.js';
|
16
|
-
import { S as SnkGuidesViewer } from './snk-guides-viewer-
|
16
|
+
import { S as SnkGuidesViewer } from './snk-guides-viewer-7c120bc6.js';
|
17
17
|
import { S as SnkMessageBuilder } from './SnkMessageBuilder-7ac66e9c.js';
|
18
18
|
import './ConfigStorage-9840d004.js';
|
19
19
|
import './_commonjsHelpers-9943807e.js';
|
@@ -6,14 +6,14 @@ import { C as ConfigStorage } from './ConfigStorage-9840d004.js';
|
|
6
6
|
import { P as PresentationMode } from './index-1564817d.js';
|
7
7
|
import { T as TaskbarProcessor } from './taskbar-processor-94402e6e.js';
|
8
8
|
import { s as store } from './index-bdf75557.js';
|
9
|
-
import { S as SnkMultiSelectionListDataSource } from './SnkMultiSelectionListDataSource-
|
9
|
+
import { S as SnkMultiSelectionListDataSource } from './SnkMultiSelectionListDataSource-a0b69ac4.js';
|
10
10
|
import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
|
11
11
|
import './form-config-fetcher-5b886892.js';
|
12
12
|
import './DataFetcher-07935045.js';
|
13
13
|
import './_commonjsHelpers-9943807e.js';
|
14
14
|
import './PrintUtils-3e4ff0f5.js';
|
15
15
|
import './filter-item-type.enum-5028ed3f.js';
|
16
|
-
import './dataunit-fetcher-
|
16
|
+
import './dataunit-fetcher-493182bc.js';
|
17
17
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
18
18
|
import './ResourceIDUtils-a114189a.js';
|
19
19
|
|
@@ -11,7 +11,7 @@ import { P as PresentationMode } from './index-1564817d.js';
|
|
11
11
|
import './ISave-4412b20c.js';
|
12
12
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
13
13
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
14
|
-
import './dataunit-fetcher-
|
14
|
+
import './dataunit-fetcher-493182bc.js';
|
15
15
|
import './filter-item-type.enum-5028ed3f.js';
|
16
16
|
import './form-config-fetcher-5b886892.js';
|
17
17
|
import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export { S as snk_guides_viewer } from './snk-guides-viewer-
|
1
|
+
export { S as snk_guides_viewer } from './snk-guides-viewer-7c120bc6.js';
|
2
2
|
import './index-a7d3d3f1.js';
|
3
3
|
import '@sankhyalabs/core';
|
4
4
|
import './SnkFormConfigManager-a7c4ac16.js';
|
@@ -18,6 +18,6 @@ import './constants-3644f1b6.js';
|
|
18
18
|
import './pesquisa-fetcher-7c46996d.js';
|
19
19
|
import './ISave-4412b20c.js';
|
20
20
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
21
|
-
import './dataunit-fetcher-
|
21
|
+
import './dataunit-fetcher-493182bc.js';
|
22
22
|
import './ResourceIDUtils-a114189a.js';
|
23
23
|
import '@sankhyalabs/core/dist/dataunit/DataUnit';
|
@@ -8,11 +8,11 @@ import { P as PresentationMode } from './index-1564817d.js';
|
|
8
8
|
import './ISave-4412b20c.js';
|
9
9
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
10
10
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
11
|
-
import { I as InMemoryLoader } from './dataunit-fetcher-
|
11
|
+
import { I as InMemoryLoader } from './dataunit-fetcher-493182bc.js';
|
12
12
|
import './filter-item-type.enum-5028ed3f.js';
|
13
13
|
import './form-config-fetcher-5b886892.js';
|
14
14
|
import { T as TaskbarProcessor } from './taskbar-processor-94402e6e.js';
|
15
|
-
import { S as SnkMultiSelectionListDataSource } from './SnkMultiSelectionListDataSource-
|
15
|
+
import { S as SnkMultiSelectionListDataSource } from './SnkMultiSelectionListDataSource-a0b69ac4.js';
|
16
16
|
import './index-bdf75557.js';
|
17
17
|
import './_commonjsHelpers-9943807e.js';
|
18
18
|
import './PrintUtils-3e4ff0f5.js';
|
@@ -1 +1 @@
|
|
1
|
-
import{r as t,c as i,h as e}from"./p-d2d301a6.js";import{ApplicationContext as s,DataType as n,Action as a}from"@sankhyalabs/core";import{D as r}from"./p-4f7b9c50.js";import{S as o}from"./p-9e7d65a4.js";import{c as h}from"./p-4a78e118.js";import{D as d}from"./p-85635c64.js";import{T as l}from"./p-c9841939.js";import"./p-112455b1.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"./p-688dcb4c.js";import"./p-5534e08c.js";import"./p-6dc031de.js";class c{constructor(t,i,e){var s;this.entityName=t,this.registerKey=i,this.dataUnitName=e,this.validateFields=t=>{if(t.LINK&&t.NOMEARQUIVO)throw new Error(o.LINK_AND_FILE_AT_THE_SAME_TIME);if(!t.LINK&&!t.NOMEARQUIVO)throw new Error(o.ANY_LINK_OR_FILE_FILLED);if(!this.registerKey)throw new Error("Register key can not be null")},this.resourceID=window.resourceID||(null===(s=window.workspace)||void 0===s?void 0:s.resourceID)}async save(t){var i,e;const s="AnexoSistemaSP.salvar";let{updatingFields:n}=t;n=Object.assign(Object.assign({},n),{NOMEARQUIVO:null===(i=n.NOMEARQUIVO)||void 0===i?void 0:i[0]});try{this.validateFields(n);const t=n.LINK?null:n.NOMEARQUIVO,i={serviceName:s,requestBody:{params:{resourceID:this.resourceID,description:n.DESCRICAO,fileSelect:t?1:0,keySession:null===(e=null==t?void 0:t.properties)||void 0===e?void 0:e.fileNameTmp,nameAttach:null==t?void 0:t.name,link:n.LINK,nameEntity:this.entityName,pkEntity:this.registerKey,typeAcess:n.TIPOACESSO,typeApres:n.TIPOAPRES}}},a=await r.get().callServiceBroker(s,JSON.stringify(i));return Promise.resolve([Object.assign(Object.assign(Object.assign({},a),n),{ARQUIVOOULINK:n.LINK?n.LINK:null==t?void 0:t.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}async edit(t){var i,e,s;const n="AnexoSistemaSP.salvar";let{updatingFields:a,record:o}=t;const h=t=>void 0!==a[t]?a[t]:o[t],d=h("NOMEARQUIVO"),l=null===(e=null===(i=a.NOMEARQUIVO)||void 0===i?void 0:i[0])||void 0===e?void 0:e.downloadURL;a=Object.assign(Object.assign({},a),{DESCRICAO:h("DESCRICAO"),LINK:h("LINK"),TIPOACESSO:h("TIPOACESSO"),TIPOAPRES:h("TIPOAPRES"),CHAVEARQUIVO:o.CHAVEARQUIVO,NOMEARQUIVO:null==d?void 0:d[0]});const c=a.LINK?null:a.NOMEARQUIVO;try{this.validateFields(a);const t={serviceName:n,requestBody:{params:{resourceID:this.resourceID,nuAttach:null==o?void 0:o.NUATTACH,description:a.DESCRICAO,fileSelect:l?1:0,keySession:null===(s=null==c?void 0:c.properties)||void 0===s?void 0:s.fileNameTmp,keyAttach:a.CHAVEARQUIVO,nameAttach:null==c?void 0:c.name,link:a.LINK,nameEntity:this.entityName,pkEntity:this.registerKey,typeAcess:a.TIPOACESSO,typeApres:a.TIPOAPRES}}},i=await r.get().callServiceBroker(n,JSON.stringify(t));return Promise.resolve([Object.assign(Object.assign(Object.assign({},i),a),{ARQUIVOOULINK:a.LINK?a.LINK:null==c?void 0:c.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}delete(t){var i;const e="AnexoSistemaSP.excluir",s=(null===(i=t.NOMEARQUIVO)||void 0===i?void 0:i[0])||{},n={serviceName:e,requestBody:{paramsDelete:{keyAttach:t.CHAVEARQUIVO,nameAttach:null==s?void 0:s.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO}}};return new Promise(((t,i)=>{r.get().callServiceBroker(e,JSON.stringify(n)).then((i=>t(i))).catch((t=>i(t)))}))}getDownloadKey(t){var i;const e="AnexoSistemaSP.baixar",s=(null===(i=t.NOMEARQUIVO)||void 0===i?void 0:i[0])||{},n={serviceName:e,requestBody:{paramsDown:{nameAttach:null==s?void 0:s.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO,keyAttach:t.CHAVEARQUIVO}}};return new Promise(((t,i)=>{r.get().callServiceBroker(e,JSON.stringify(n)).then((i=>t(i))).catch((t=>i(t)))}))}}class m{constructor(t,i){this.entityName=t,this.getMessage=i,this._application=s.getContextValue("__SNK__APPLICATION__")}initLoaders(t,i,e){this.loader||(this.loader=t.dataLoader),t.dataLoader=(t,i)=>this.dataLoader(t,i),t.saveLoader=(t,s)=>this.saveLoader(s,i).then((t=>(t.length&&e(),t))),t.removeLoader=(t,s)=>this.removeLoader(t,s,i).then((t=>(t.length&&e(),t)))}dataLoader(t,i){return new Promise((e=>{this.loader(t,i).then((t=>{const i=((null==t?void 0:t.records)||[]).map((t=>{let i;return t.LINK||(i=[{name:t.NOMEARQUIVO}]),Object.assign(Object.assign({},t),{ARQUIVOOULINK:t.LINK?t.LINK:t.NOMEARQUIVO,NOMEARQUIVO:i})}));e(Object.assign(Object.assign({},t),{records:i}))}))}))}saveLoader(t,i){return new Promise((e=>{var s;const n=Array.isArray(t)?t[0]:{};((null===(s=null==n?void 0:n.record)||void 0===s?void 0:s.NUATTACH)>=0?i.edit.bind(i):i.save.bind(i))(n).then((t=>{e(t)})).catch((t=>t.message===o.LINK_AND_FILE_AT_THE_SAME_TIME?(this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),e([])):t.message===o.ANY_LINK_OR_FILE_FILLED?(this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),e([])):t.message?(this._application.error(t.title||t.name,t.message),e([])):void e([])))}))}removeLoader(t,i,e){return new Promise((s=>{const{records:n}=t.getSelectionInfo();e.delete(n[0]).then((()=>s(i)))}))}getFilters(t){return[{name:"AttachmentsByPK",expression:"this.PKREGISTRO = :PKREGISTRO",params:[{name:"PKREGISTRO",dataType:n.TEXT,value:`${t}_${this.entityName}`}]}]}getInterceptions(t,i,e){return new Promise((s=>i.type===a.EDITION_CANCELED?t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(e.goToView(h.GRID),s(i)):s(void 0))):s(i):i.type===a.DATA_SAVED?(t.loadData(),s(i)):void s(i)))}}const u=s.getContextValue("__SNK__APPLICATION__"),v=t=>{var i,e;return null===(e=null===(i=null==u?void 0:u.messagesBuilder)||void 0===i?void 0:i.getMessage)||void 0===e?void 0:e.call(i,t,null)},A={DOWNLOAD:{hint:v("snkAttach.taskbar.titleDownload"),name:"DOWNLOAD",iconName:"file-download"},LINK:{hint:v("snkAttach.taskbar.titleLink"),name:"LINK",iconName:"launch"}},O=()=>{const t=[l.REMOVE,"DOWNLOAD","LINK"];return{getButtons:(t,i,e)=>{if((null==i?void 0:i.insertionMode)||(null==i?void 0:i.isDirty))return e.reverse();e.splice(e.indexOf(l.REFRESH),1);const{selectedRecord:s}=i||{},n=(null==s?void 0:s.LINK)?A.LINK:A.DOWNLOAD;e.splice(e.indexOf(l.DIVIDER)+1,0,l.REMOVE,n,l.DIVIDER);const a=Array.from(new Set(e.filter((t=>t!==l.CLONE))));return a.splice(a.indexOf(n)+1,0,l.DIVIDER),a},isEnabled:(i,e,s)=>{const n=void 0!==(null==e?void 0:e.selectedRecord);return!(t.includes(s)&&!n)}}},p={grid:{columns:[{name:"ARQUIVOOULINK",orderIndex:0,width:0},{name:"DESCRICAO",orderIndex:1,width:0},{name:"DHCAD",orderIndex:2,width:0},{name:"DHALTER",orderIndex:3,width:0},{name:"TIPOAPRES",orderIndex:4,width:0},{name:"TIPOACESSO",orderIndex:5,width:0},{name:"CODUSU",orderIndex:6,width:0},{name:"CODUSUALT",orderIndex:7,width:0}]},form:{emptyConfig:!1,fields:[{name:"DESCRICAO",required:!0},{name:"TIPOAPRES",required:!0},{name:"TIPOACESSO",required:!0},{name:"LINK"},{name:"NOMEARQUIVO"}]}},k=class{constructor(e){t(this,e),this.back=i(this,"back",7),this.handleTaskbarClick=({detail:t})=>{if(["DOWNLOAD","LINK"].includes(t))return this.downloadAttachment(this.dataUnit.getSelectedRecord())},this.handleBack=()=>{this.dataUnit.cancelEdition().then((t=>{t&&this.back.emit()}))},this.handleFinish=()=>{if(!this.dataUnit.isDirty())return this.back.emit();this.dataUnit.saveData().then((()=>{this.showFinishedToast(),this.back.emit()}))},this.registerKey=void 0,this.entityName=void 0,this.messagesBuilder=void 0,this.dataUnit=void 0,this.crudConfig=void 0}registerKeyWatcher(t,i){var e;i!==t&&(this.returnToGridMode(),this._attachFetcher=new c(this.entityName,this.registerKey,null===(e=this.dataUnit)||void 0===e?void 0:e.name),this._dataUnitBuilder.initLoaders(this.dataUnit,this._attachFetcher,(()=>{this.returnToGridMode()})),this.dataUnit.loadData())}getMessage(t,i){if(this.messagesBuilder)return this.messagesBuilder.getMessage(t,i)}showFinishedToast(){this._application.info(this.getMessage("snkAttach.finishedMessage"),{iconName:"check"})}downloadAttachment(t){if(!t)throw new Error("Nenhum registro selecionado");t.LINK?window.open(`${t.LINK}`):this._attachFetcher.getDownloadKey(t).then((({chave:t})=>{window.open(`/mge/visualizadorArquivos.mge?chaveArquivo=${t.valor}&forcarDownload=S`)}))}returnToGridMode(){this.dataUnit.clearSelection(),this._crudElement&&this._crudElement.goToView(h.GRID)}loadAttachmentDataUnit(){var t;try{const i=this.dataUnit||(new d).getDataUnit("AnexoSistema","br.com.sankhya.core.v3.anexoSistema");return this._attachFetcher=new c(this.entityName,this.registerKey,null===(t=this.dataUnit)||void 0===t?void 0:t.name),i.metadata||i.loadMetadata().then((()=>{this.crudConfig=p})),this._dataUnitBuilder=new m(this.entityName,this.getMessage.bind(this)),i.addFilterProvider({getFilter:()=>this._dataUnitBuilder.getFilters(this.registerKey)}),i.addInterceptor({interceptAction:t=>this._dataUnitBuilder.getInterceptions(i,t,this._crudElement)}),this.dataUnit=i,this.dataUnit.loadData().then((()=>{this.disableEditFieldsNotInForm()})),this.dataUnit}catch(t){throw new Error("There was an error while creating the data unit")}}disableEditFieldsNotInForm(){var t;null===(t=this.crudConfig)||void 0===t||t.grid.columns.forEach((t=>{var i;const e=t.name;(null===(i=this.crudConfig)||void 0===i?void 0:i.form.fields.some((t=>t.name===e)))||this.dataUnit.disableField(e)}))}componentWillLoad(){this._application=s.getContextValue("__SNK__APPLICATION__"),this.loadAttachmentDataUnit()}render(){var t,i;return this.dataUnit?e("main",{class:"snk-attach__main"},e("header",{class:"snk-attach__header"},e("snk-simple-bar",{onExit:this.handleBack,messagesBuilder:this.messagesBuilder},e("div",{slot:"rightSlot"},e("ez-button",{class:"ez-button--primary",label:this.getMessage("snkAttach.finish"),onClick:this.handleFinish})))),e("div",{class:"snk-attach__crud-section ez-size-height--full ez-size-width--full ez-flex ez-flex--column"},e("div",{class:"ez-box__container"},e("snk-simple-crud",{ref:t=>this._crudElement=t,dataUnit:this.dataUnit,taskbarManager:O(),gridConfig:null===(t=this.crudConfig)||void 0===t?void 0:t.grid,formConfig:null===(i=this.crudConfig)||void 0===i?void 0:i.form,useCancelConfirm:!1,onActionClick:this.handleTaskbarClick},e("div",{slot:"snkSimpleCrudHeader"},e("div",{class:"ez-flex ez-flex--column"},e("span",{class:"ez-title--primary ez-text ez-text--large ez-text--bold ez-padding-bottom--medium"},this.getMessage("snkAttach.title")),e("span",{class:"ez-text ez-text--medium ez-text--secondary"},this.getMessage("snkAttach.description")))))))):null}static get watchers(){return{registerKey:["registerKeyWatcher"]}}};k.style=".snk-attach__header.sc-snk-attach,.snk-attach__crud-section.sc-snk-attach{padding:0 var(--space--lg)}.snk-attach__file-info.sc-snk-attach{padding:var(--space--small);max-width:50%}.snk-attach__main.sc-snk-attach{height:85%}.ez-box__container.sc-snk-attach{height:100%}";export{k as snk_attach}
|
1
|
+
import{r as t,c as e,h as i}from"./p-d2d301a6.js";import{ApplicationContext as s,DataType as n,Action as a}from"@sankhyalabs/core";import{D as r}from"./p-4f7b9c50.js";import{S as o}from"./p-9e7d65a4.js";import{c as h}from"./p-4a78e118.js";import{D as d}from"./p-bdfcc2e2.js";import{T as l}from"./p-c9841939.js";import"./p-112455b1.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"./p-688dcb4c.js";import"./p-5534e08c.js";import"./p-6dc031de.js";class c{constructor(t,e,i){var s;this.entityName=t,this.registerKey=e,this.dataUnitName=i,this.validateFields=t=>{if(t.LINK&&t.NOMEARQUIVO)throw new Error(o.LINK_AND_FILE_AT_THE_SAME_TIME);if(!t.LINK&&!t.NOMEARQUIVO)throw new Error(o.ANY_LINK_OR_FILE_FILLED);if(!this.registerKey)throw new Error("Register key can not be null")},this.resourceID=window.resourceID||(null===(s=window.workspace)||void 0===s?void 0:s.resourceID)}async save(t){var e,i;const s="AnexoSistemaSP.salvar";let{updatingFields:n}=t;n=Object.assign(Object.assign({},n),{NOMEARQUIVO:null===(e=n.NOMEARQUIVO)||void 0===e?void 0:e[0]});try{this.validateFields(n);const t=n.LINK?null:n.NOMEARQUIVO,e={serviceName:s,requestBody:{params:{resourceID:this.resourceID,description:n.DESCRICAO,fileSelect:t?1:0,keySession:null===(i=null==t?void 0:t.properties)||void 0===i?void 0:i.fileNameTmp,nameAttach:null==t?void 0:t.name,link:n.LINK,nameEntity:this.entityName,pkEntity:this.registerKey,typeAcess:n.TIPOACESSO,typeApres:n.TIPOAPRES}}},a=await r.get().callServiceBroker(s,JSON.stringify(e));return Promise.resolve([Object.assign(Object.assign(Object.assign({},a),n),{ARQUIVOOULINK:n.LINK?n.LINK:null==t?void 0:t.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}async edit(t){var e,i,s;const n="AnexoSistemaSP.salvar";let{updatingFields:a,record:o}=t;const h=t=>void 0!==a[t]?a[t]:o[t],d=h("NOMEARQUIVO"),l=null===(i=null===(e=a.NOMEARQUIVO)||void 0===e?void 0:e[0])||void 0===i?void 0:i.downloadURL;a=Object.assign(Object.assign({},a),{DESCRICAO:h("DESCRICAO"),LINK:h("LINK"),TIPOACESSO:h("TIPOACESSO"),TIPOAPRES:h("TIPOAPRES"),CHAVEARQUIVO:o.CHAVEARQUIVO,NOMEARQUIVO:null==d?void 0:d[0]});const c=a.LINK?null:a.NOMEARQUIVO;try{this.validateFields(a);const t={serviceName:n,requestBody:{params:{resourceID:this.resourceID,nuAttach:null==o?void 0:o.NUATTACH,description:a.DESCRICAO,fileSelect:l?1:0,keySession:null===(s=null==c?void 0:c.properties)||void 0===s?void 0:s.fileNameTmp,keyAttach:a.CHAVEARQUIVO,nameAttach:null==c?void 0:c.name,link:a.LINK,nameEntity:this.entityName,pkEntity:this.registerKey,typeAcess:a.TIPOACESSO,typeApres:a.TIPOAPRES}}},e=await r.get().callServiceBroker(n,JSON.stringify(t));return Promise.resolve([Object.assign(Object.assign(Object.assign({},e),a),{ARQUIVOOULINK:a.LINK?a.LINK:null==c?void 0:c.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}delete(t){var e;const i="AnexoSistemaSP.excluir",s=(null===(e=t.NOMEARQUIVO)||void 0===e?void 0:e[0])||{},n={serviceName:i,requestBody:{paramsDelete:{keyAttach:t.CHAVEARQUIVO,nameAttach:null==s?void 0:s.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO}}};return new Promise(((t,e)=>{r.get().callServiceBroker(i,JSON.stringify(n)).then((e=>t(e))).catch((t=>e(t)))}))}getDownloadKey(t){var e;const i="AnexoSistemaSP.baixar",s=(null===(e=t.NOMEARQUIVO)||void 0===e?void 0:e[0])||{},n={serviceName:i,requestBody:{paramsDown:{nameAttach:null==s?void 0:s.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO,keyAttach:t.CHAVEARQUIVO}}};return new Promise(((t,e)=>{r.get().callServiceBroker(i,JSON.stringify(n)).then((e=>t(e))).catch((t=>e(t)))}))}}class m{constructor(t,e){this.entityName=t,this.getMessage=e,this._application=s.getContextValue("__SNK__APPLICATION__")}initLoaders(t,e,i){this.loader||(this.loader=t.dataLoader),t.dataLoader=(t,e)=>this.dataLoader(t,e),t.saveLoader=(t,s)=>this.saveLoader(s,e).then((t=>(t.length&&i(),t))),t.removeLoader=(t,s)=>this.removeLoader(t,s,e).then((t=>(t.length&&i(),t)))}dataLoader(t,e){return new Promise((i=>{this.loader(t,e).then((t=>{const e=((null==t?void 0:t.records)||[]).map((t=>{let e;return t.LINK||(e=[{name:t.NOMEARQUIVO}]),Object.assign(Object.assign({},t),{ARQUIVOOULINK:t.LINK?t.LINK:t.NOMEARQUIVO,NOMEARQUIVO:e})}));i(Object.assign(Object.assign({},t),{records:e}))}))}))}saveLoader(t,e){return new Promise((i=>{var s;const n=Array.isArray(t)?t[0]:{};((null===(s=null==n?void 0:n.record)||void 0===s?void 0:s.NUATTACH)>=0?e.edit.bind(e):e.save.bind(e))(n).then((t=>{i(t)})).catch((t=>t.message===o.LINK_AND_FILE_AT_THE_SAME_TIME?(this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),i([])):t.message===o.ANY_LINK_OR_FILE_FILLED?(this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),i([])):t.message?(this._application.error(t.title||t.name,t.message),i([])):void i([])))}))}removeLoader(t,e,i){return new Promise((s=>{const{records:n}=t.getSelectionInfo();i.delete(n[0]).then((()=>s(e)))}))}getFilters(t){return[{name:"AttachmentsByPK",expression:"this.PKREGISTRO = :PKREGISTRO",params:[{name:"PKREGISTRO",dataType:n.TEXT,value:`${t}_${this.entityName}`}]}]}getInterceptions(t,e,i){return new Promise((s=>e.type===a.EDITION_CANCELED?t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(i.goToView(h.GRID),s(e)):s(void 0))):s(e):e.type===a.DATA_SAVED?(t.loadData(),s(e)):void s(e)))}}const u=s.getContextValue("__SNK__APPLICATION__"),v=t=>{var e,i;return null===(i=null===(e=null==u?void 0:u.messagesBuilder)||void 0===e?void 0:e.getMessage)||void 0===i?void 0:i.call(e,t,null)},A={DOWNLOAD:{hint:v("snkAttach.taskbar.titleDownload"),name:"DOWNLOAD",iconName:"file-download"},LINK:{hint:v("snkAttach.taskbar.titleLink"),name:"LINK",iconName:"launch"}},O=()=>{const t=[l.REMOVE,"DOWNLOAD","LINK"];return{getButtons:(t,e,i)=>{if((null==e?void 0:e.insertionMode)||(null==e?void 0:e.isDirty))return i.reverse();i.splice(i.indexOf(l.REFRESH),1);const{selectedRecord:s}=e||{},n=(null==s?void 0:s.LINK)?A.LINK:A.DOWNLOAD;i.splice(i.indexOf(l.DIVIDER)+1,0,l.REMOVE,n,l.DIVIDER);const a=Array.from(new Set(i.filter((t=>t!==l.CLONE))));return a.splice(a.indexOf(n)+1,0,l.DIVIDER),a},isEnabled:(e,i,s)=>{const n=void 0!==(null==i?void 0:i.selectedRecord);return!(t.includes(s)&&!n)}}},p={grid:{columns:[{name:"ARQUIVOOULINK",orderIndex:0,width:0},{name:"DESCRICAO",orderIndex:1,width:0},{name:"DHCAD",orderIndex:2,width:0},{name:"DHALTER",orderIndex:3,width:0},{name:"TIPOAPRES",orderIndex:4,width:0},{name:"TIPOACESSO",orderIndex:5,width:0},{name:"CODUSU",orderIndex:6,width:0},{name:"CODUSUALT",orderIndex:7,width:0}]},form:{emptyConfig:!1,fields:[{name:"DESCRICAO",required:!0},{name:"TIPOAPRES",required:!0},{name:"TIPOACESSO",required:!0},{name:"LINK"},{name:"NOMEARQUIVO"}]}},k=class{constructor(i){t(this,i),this.back=e(this,"back",7),this.handleTaskbarClick=({detail:t})=>{if(["DOWNLOAD","LINK"].includes(t))return this.downloadAttachment(this.dataUnit.getSelectedRecord())},this.handleBack=()=>{this.dataUnit.cancelEdition().then((t=>{t&&this.back.emit()}))},this.handleFinish=()=>{if(!this.dataUnit.isDirty())return this.back.emit();this.dataUnit.saveData().then((()=>{this.showFinishedToast(),this.back.emit()}))},this.registerKey=void 0,this.entityName=void 0,this.messagesBuilder=void 0,this.dataUnit=void 0,this.crudConfig=void 0}registerKeyWatcher(t,e){var i;e!==t&&(this.returnToGridMode(),this._attachFetcher=new c(this.entityName,this.registerKey,null===(i=this.dataUnit)||void 0===i?void 0:i.name),this._dataUnitBuilder.initLoaders(this.dataUnit,this._attachFetcher,(()=>{this.returnToGridMode()})),this.dataUnit.loadData())}getMessage(t,e){if(this.messagesBuilder)return this.messagesBuilder.getMessage(t,e)}showFinishedToast(){this._application.info(this.getMessage("snkAttach.finishedMessage"),{iconName:"check"})}downloadAttachment(t){if(!t)throw new Error("Nenhum registro selecionado");t.LINK?window.open(`${t.LINK}`):this._attachFetcher.getDownloadKey(t).then((({chave:t})=>{window.open(`/mge/visualizadorArquivos.mge?chaveArquivo=${t.valor}&forcarDownload=S`)}))}returnToGridMode(){this.dataUnit.clearSelection(),this._crudElement&&this._crudElement.goToView(h.GRID)}loadAttachmentDataUnit(){var t;try{const e=this.dataUnit||(new d).getDataUnit("AnexoSistema","br.com.sankhya.core.v3.anexoSistema");return this._attachFetcher=new c(this.entityName,this.registerKey,null===(t=this.dataUnit)||void 0===t?void 0:t.name),e.metadata||e.loadMetadata().then((()=>{this.crudConfig=p})),this._dataUnitBuilder=new m(this.entityName,this.getMessage.bind(this)),e.addFilterProvider({getFilter:()=>this._dataUnitBuilder.getFilters(this.registerKey)}),e.addInterceptor({interceptAction:t=>this._dataUnitBuilder.getInterceptions(e,t,this._crudElement)}),this.dataUnit=e,this.dataUnit.loadData().then((()=>{this.disableEditFieldsNotInForm()})),this.dataUnit}catch(t){throw new Error("There was an error while creating the data unit")}}disableEditFieldsNotInForm(){var t;null===(t=this.crudConfig)||void 0===t||t.grid.columns.forEach((t=>{var e;const i=t.name;(null===(e=this.crudConfig)||void 0===e?void 0:e.form.fields.some((t=>t.name===i)))||this.dataUnit.disableField(i)}))}componentWillLoad(){this._application=s.getContextValue("__SNK__APPLICATION__"),this.loadAttachmentDataUnit()}render(){var t,e;return this.dataUnit?i("main",{class:"snk-attach__main"},i("header",{class:"snk-attach__header"},i("snk-simple-bar",{onExit:this.handleBack,messagesBuilder:this.messagesBuilder},i("div",{slot:"rightSlot"},i("ez-button",{class:"ez-button--primary",label:this.getMessage("snkAttach.finish"),onClick:this.handleFinish})))),i("div",{class:"snk-attach__crud-section ez-size-height--full ez-size-width--full ez-flex ez-flex--column"},i("div",{class:"ez-box__container"},i("snk-simple-crud",{ref:t=>this._crudElement=t,dataUnit:this.dataUnit,taskbarManager:O(),gridConfig:null===(t=this.crudConfig)||void 0===t?void 0:t.grid,formConfig:null===(e=this.crudConfig)||void 0===e?void 0:e.form,useCancelConfirm:!1,onActionClick:this.handleTaskbarClick},i("div",{slot:"snkSimpleCrudHeader"},i("div",{class:"ez-flex ez-flex--column"},i("span",{class:"ez-title--primary ez-text ez-text--large ez-text--bold ez-padding-bottom--medium"},this.getMessage("snkAttach.title")),i("span",{class:"ez-text ez-text--medium ez-text--secondary"},this.getMessage("snkAttach.description")))))))):null}static get watchers(){return{registerKey:["registerKeyWatcher"]}}};k.style=".snk-attach__header.sc-snk-attach,.snk-attach__crud-section.sc-snk-attach{padding:0 var(--space--lg)}.snk-attach__file-info.sc-snk-attach{padding:var(--space--small);max-width:50%}.snk-attach__main.sc-snk-attach{height:85%}.ez-box__container.sc-snk-attach{height:100%}";export{k as snk_attach}
|
@@ -1 +1 @@
|
|
1
|
-
import{UserInterface as t,DateUtils as e}from"@sankhyalabs/core";import{P as s}from"./p-
|
1
|
+
import{UserInterface as t,DateUtils as e}from"@sankhyalabs/core";import{P as s}from"./p-bdfcc2e2.js";class i{setDataUnit(t){this._dataUnit=t}setApplication(t){this._application=t}formatLabel(s,i){const{userInterface:r}=this._dataUnit.getField(s);return r===t.DATETIME?e.formatDate(this._dataUnit.valueFromString(s,i)):String(this._dataUnit.getFormattedValue(s,i))}async getStaticOptions(t){if(null==t)return Promise.resolve(void 0);const e=await s.getDistinct(this._dataUnit,t);return Promise.resolve(null==e?void 0:Array.from(e.entries()).map((([t,e])=>({label:String(t),value:e,check:!0}))))}fetchData(e,s){return new Promise((i=>{this._application.executeSelectDistinct(this._dataUnit,s,e).then((e=>{i(e.map((e=>this._dataUnit.getField(s).userInterface===t.SEARCH?Object.assign(Object.assign({},JSON.parse(e)),{check:!0}):{value:e,label:this.formatLabel(s,e),check:!0})))}))}))}}export{i as S}
|