@sankhyalabs/sankhyablocks 8.8.0-dev.1 → 8.8.0-dev.2
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-56db34ee.js → SnkMultiSelectionListDataSource-4e3de426.js} +1 -1
- package/dist/cjs/{dataunit-fetcher-4f7d4ee7.js → dataunit-fetcher-a4e8352b.js} +34 -6
- package/dist/cjs/snk-actions-button.cjs.entry.js +1 -1
- 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-aab80f66.js → snk-guides-viewer-c540f4c5.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/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +1 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.js +22 -4
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.js +11 -1
- package/dist/components/dataunit-fetcher.js +34 -6
- package/dist/esm/{SnkMultiSelectionListDataSource-b9410c72.js → SnkMultiSelectionListDataSource-36887f31.js} +1 -1
- package/dist/esm/{dataunit-fetcher-1c2ccae2.js → dataunit-fetcher-c22b889c.js} +34 -6
- package/dist/esm/snk-actions-button.entry.js +1 -1
- 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-62b0fa69.js → snk-guides-viewer-e87b77d5.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-d264da22.entry.js → p-182246c9.entry.js} +1 -1
- package/dist/sankhyablocks/{p-acb1374c.entry.js → p-42de2707.entry.js} +1 -1
- package/dist/sankhyablocks/{p-e473ca13.entry.js → p-5356efdd.entry.js} +1 -1
- package/dist/sankhyablocks/{p-3253e7f2.entry.js → p-9e705c91.entry.js} +1 -1
- package/dist/sankhyablocks/{p-193971ad.js → p-a046a2e1.js} +1 -1
- package/dist/sankhyablocks/{p-b481e5ad.js → p-a221bc67.js} +1 -1
- package/dist/sankhyablocks/{p-19cbe6e2.entry.js → p-b3cd0dd1.entry.js} +2 -2
- package/dist/sankhyablocks/{p-2c7c1323.entry.js → p-b7798801.entry.js} +1 -1
- package/dist/sankhyablocks/p-bcc2b79d.js +59 -0
- package/dist/sankhyablocks/{p-d56b65e3.entry.js → p-d07651cc.entry.js} +1 -1
- package/dist/sankhyablocks/{p-b36053da.entry.js → p-eab2c97d.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/package.json +1 -1
- package/dist/sankhyablocks/p-e86d4a53.js +0 -59
@@ -1,7 +1,7 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
3
|
const core = require('@sankhyalabs/core');
|
4
|
-
const dataunitFetcher = require('./dataunit-fetcher-
|
4
|
+
const dataunitFetcher = require('./dataunit-fetcher-a4e8352b.js');
|
5
5
|
|
6
6
|
class SnkMultiSelectionListDataSource {
|
7
7
|
setDataUnit(dataUnit) {
|
@@ -28,9 +28,20 @@ class ArrayRepository {
|
|
28
28
|
return Promise.resolve({ result, count });
|
29
29
|
}
|
30
30
|
async distict(itemProcessor) {
|
31
|
-
const processedItems =
|
32
|
-
|
33
|
-
|
31
|
+
const processedItems = [];
|
32
|
+
let hasEmpty = false;
|
33
|
+
for (const item of this._list) {
|
34
|
+
const processedItem = itemProcessor(item);
|
35
|
+
if (processedItem == undefined) {
|
36
|
+
hasEmpty = true;
|
37
|
+
continue;
|
38
|
+
}
|
39
|
+
processedItems.push(processedItem);
|
40
|
+
}
|
41
|
+
if (hasEmpty) {
|
42
|
+
processedItems.push({ key: "", value: null });
|
43
|
+
}
|
44
|
+
return Promise.resolve(new Map(processedItems.map(item => [item.key, item.value])));
|
34
45
|
}
|
35
46
|
async push(items) {
|
36
47
|
this._list.push(...items);
|
@@ -39,7 +50,14 @@ class ArrayRepository {
|
|
39
50
|
this._list = [];
|
40
51
|
}
|
41
52
|
async delete(items) {
|
42
|
-
this._list = this._list.filter(item =>
|
53
|
+
this._list = this._list.filter(item => {
|
54
|
+
for (const removed of items) {
|
55
|
+
if (this._equalsFunction(item, removed)) {
|
56
|
+
return false;
|
57
|
+
}
|
58
|
+
}
|
59
|
+
return true;
|
60
|
+
});
|
43
61
|
}
|
44
62
|
async update(items) {
|
45
63
|
this._list = this._list.map(existingItem => {
|
@@ -119,7 +137,17 @@ class PreloadManager {
|
|
119
137
|
const value = fieldValue.value != undefined ? fieldValue.value : fieldValue;
|
120
138
|
return { key: dataUnit.getFormattedValue(fieldName, fieldValue), value };
|
121
139
|
})
|
122
|
-
.then(
|
140
|
+
.then(result => {
|
141
|
+
if (result != undefined && result.size > 0) {
|
142
|
+
const field = dataUnit.getField(fieldName);
|
143
|
+
const sortedMap = new Map(Array.from(result.entries())
|
144
|
+
.sort((itemA, itemB) => core.FieldComparator.compareValues(field, itemA[1], itemB[1]))
|
145
|
+
.map(([key, value]) => key === "" ? ["(Vazio)", value] : [key, value]));
|
146
|
+
accept(sortedMap);
|
147
|
+
return;
|
148
|
+
}
|
149
|
+
accept(result);
|
150
|
+
})
|
123
151
|
.catch(reason => reject(reason));
|
124
152
|
});
|
125
153
|
}
|
@@ -565,7 +593,7 @@ class DataUnitDataLoader {
|
|
565
593
|
offset = 0;
|
566
594
|
}
|
567
595
|
const { total, count, loadingInProgress } = loadingInfo;
|
568
|
-
const firstRecord = count === 0 ? 0 : offset + 1;
|
596
|
+
const firstRecord = (count === 0 || pageSize === 0) ? 0 : offset + 1;
|
569
597
|
const lastRecord = offset + Math.min(pageSize, limit);
|
570
598
|
return {
|
571
599
|
total,
|
@@ -11,7 +11,7 @@ require('./index-0e663819.js');
|
|
11
11
|
require('./ISave-d68ce3cd.js');
|
12
12
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
13
13
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
14
|
-
require('./dataunit-fetcher-
|
14
|
+
require('./dataunit-fetcher-a4e8352b.js');
|
15
15
|
require('./filter-item-type.enum-aa823a00.js');
|
16
16
|
require('./form-config-fetcher-a322a522.js');
|
17
17
|
const ResourceIDUtils = require('./ResourceIDUtils-5ff86aa7.js');
|
@@ -8,7 +8,7 @@ const utils = require('@sankhyalabs/ezui/dist/collection/utils');
|
|
8
8
|
const ConfigStorage = require('./ConfigStorage-a97ca159.js');
|
9
9
|
const DataFetcher = require('./DataFetcher-2a99283c.js');
|
10
10
|
const authFetcher = require('./auth-fetcher-78231356.js');
|
11
|
-
const dataunitFetcher = require('./dataunit-fetcher-
|
11
|
+
const dataunitFetcher = require('./dataunit-fetcher-a4e8352b.js');
|
12
12
|
const pesquisaFetcher = require('./pesquisa-fetcher-7ef61508.js');
|
13
13
|
const SnkMessageBuilder = require('./SnkMessageBuilder-dbc8d14e.js');
|
14
14
|
require('./form-config-fetcher-a322a522.js');
|
@@ -7,7 +7,7 @@ const core = require('@sankhyalabs/core');
|
|
7
7
|
const DataFetcher = require('./DataFetcher-2a99283c.js');
|
8
8
|
const ISave = require('./ISave-d68ce3cd.js');
|
9
9
|
const constants = require('./constants-d187e03e.js');
|
10
|
-
const dataunitFetcher = require('./dataunit-fetcher-
|
10
|
+
const dataunitFetcher = require('./dataunit-fetcher-a4e8352b.js');
|
11
11
|
const taskbarElements = require('./taskbar-elements-39949c7a.js');
|
12
12
|
require('./_commonjsHelpers-537d719a.js');
|
13
13
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
@@ -11,7 +11,7 @@ const index$1 = require('./index-0e663819.js');
|
|
11
11
|
require('./ISave-d68ce3cd.js');
|
12
12
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
13
13
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
14
|
-
require('./dataunit-fetcher-
|
14
|
+
require('./dataunit-fetcher-a4e8352b.js');
|
15
15
|
require('./filter-item-type.enum-aa823a00.js');
|
16
16
|
require('./form-config-fetcher-a322a522.js');
|
17
17
|
const constants = require('./constants-d187e03e.js');
|
@@ -12,12 +12,12 @@ const index$1 = require('./index-0e663819.js');
|
|
12
12
|
require('./ISave-d68ce3cd.js');
|
13
13
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
14
14
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
15
|
-
require('./dataunit-fetcher-
|
15
|
+
require('./dataunit-fetcher-a4e8352b.js');
|
16
16
|
require('./filter-item-type.enum-aa823a00.js');
|
17
17
|
require('./form-config-fetcher-a322a522.js');
|
18
18
|
const taskbarElements = require('./taskbar-elements-39949c7a.js');
|
19
19
|
const constants = require('./constants-d187e03e.js');
|
20
|
-
const snkGuidesViewer = require('./snk-guides-viewer-
|
20
|
+
const snkGuidesViewer = require('./snk-guides-viewer-c540f4c5.js');
|
21
21
|
const SnkMessageBuilder = require('./SnkMessageBuilder-dbc8d14e.js');
|
22
22
|
require('./ConfigStorage-a97ca159.js');
|
23
23
|
require('./_commonjsHelpers-537d719a.js');
|
@@ -10,14 +10,14 @@ const ConfigStorage = require('./ConfigStorage-a97ca159.js');
|
|
10
10
|
const index$1 = require('./index-0e663819.js');
|
11
11
|
const taskbarProcessor = require('./taskbar-processor-bce3f499.js');
|
12
12
|
const index$2 = require('./index-102ba62d.js');
|
13
|
-
const SnkMultiSelectionListDataSource = require('./SnkMultiSelectionListDataSource-
|
13
|
+
const SnkMultiSelectionListDataSource = require('./SnkMultiSelectionListDataSource-4e3de426.js');
|
14
14
|
const DataUnit = require('@sankhyalabs/core/dist/dataunit/DataUnit');
|
15
15
|
require('./form-config-fetcher-a322a522.js');
|
16
16
|
require('./DataFetcher-2a99283c.js');
|
17
17
|
require('./_commonjsHelpers-537d719a.js');
|
18
18
|
require('./PrintUtils-bcaeb82f.js');
|
19
19
|
require('./filter-item-type.enum-aa823a00.js');
|
20
|
-
require('./dataunit-fetcher-
|
20
|
+
require('./dataunit-fetcher-a4e8352b.js');
|
21
21
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
22
22
|
require('./ResourceIDUtils-5ff86aa7.js');
|
23
23
|
|
@@ -13,7 +13,7 @@ const index$1 = require('./index-0e663819.js');
|
|
13
13
|
require('./ISave-d68ce3cd.js');
|
14
14
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
15
15
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
16
|
-
require('./dataunit-fetcher-
|
16
|
+
require('./dataunit-fetcher-a4e8352b.js');
|
17
17
|
require('./filter-item-type.enum-aa823a00.js');
|
18
18
|
require('./form-config-fetcher-a322a522.js');
|
19
19
|
const DataUnit = require('@sankhyalabs/core/dist/dataunit/DataUnit');
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
const snkGuidesViewer = require('./snk-guides-viewer-
|
5
|
+
const snkGuidesViewer = require('./snk-guides-viewer-c540f4c5.js');
|
6
6
|
require('./index-f9e81701.js');
|
7
7
|
require('@sankhyalabs/core');
|
8
8
|
require('./SnkFormConfigManager-f641f502.js');
|
@@ -22,7 +22,7 @@ require('./constants-d187e03e.js');
|
|
22
22
|
require('./pesquisa-fetcher-7ef61508.js');
|
23
23
|
require('./ISave-d68ce3cd.js');
|
24
24
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
25
|
-
require('./dataunit-fetcher-
|
25
|
+
require('./dataunit-fetcher-a4e8352b.js');
|
26
26
|
require('./ResourceIDUtils-5ff86aa7.js');
|
27
27
|
require('@sankhyalabs/core/dist/dataunit/DataUnit');
|
28
28
|
|
@@ -12,11 +12,11 @@ const index$1 = require('./index-0e663819.js');
|
|
12
12
|
require('./ISave-d68ce3cd.js');
|
13
13
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
14
14
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
15
|
-
const dataunitFetcher = require('./dataunit-fetcher-
|
15
|
+
const dataunitFetcher = require('./dataunit-fetcher-a4e8352b.js');
|
16
16
|
require('./filter-item-type.enum-aa823a00.js');
|
17
17
|
require('./form-config-fetcher-a322a522.js');
|
18
18
|
const taskbarProcessor = require('./taskbar-processor-bce3f499.js');
|
19
|
-
const SnkMultiSelectionListDataSource = require('./SnkMultiSelectionListDataSource-
|
19
|
+
const SnkMultiSelectionListDataSource = require('./SnkMultiSelectionListDataSource-4e3de426.js');
|
20
20
|
require('./index-102ba62d.js');
|
21
21
|
require('./_commonjsHelpers-537d719a.js');
|
22
22
|
require('./PrintUtils-bcaeb82f.js');
|
@@ -97,7 +97,7 @@ export default class DataUnitDataLoader {
|
|
97
97
|
offset = 0;
|
98
98
|
}
|
99
99
|
const { total, count, loadingInProgress } = loadingInfo;
|
100
|
-
const firstRecord = count === 0 ? 0 : offset + 1;
|
100
|
+
const firstRecord = (count === 0 || pageSize === 0) ? 0 : offset + 1;
|
101
101
|
const lastRecord = offset + Math.min(pageSize, limit);
|
102
102
|
return {
|
103
103
|
total,
|
@@ -20,9 +20,20 @@ export class ArrayRepository {
|
|
20
20
|
return Promise.resolve({ result, count });
|
21
21
|
}
|
22
22
|
async distict(itemProcessor) {
|
23
|
-
const processedItems =
|
24
|
-
|
25
|
-
|
23
|
+
const processedItems = [];
|
24
|
+
let hasEmpty = false;
|
25
|
+
for (const item of this._list) {
|
26
|
+
const processedItem = itemProcessor(item);
|
27
|
+
if (processedItem == undefined) {
|
28
|
+
hasEmpty = true;
|
29
|
+
continue;
|
30
|
+
}
|
31
|
+
processedItems.push(processedItem);
|
32
|
+
}
|
33
|
+
if (hasEmpty) {
|
34
|
+
processedItems.push({ key: "", value: null });
|
35
|
+
}
|
36
|
+
return Promise.resolve(new Map(processedItems.map(item => [item.key, item.value])));
|
26
37
|
}
|
27
38
|
async push(items) {
|
28
39
|
this._list.push(...items);
|
@@ -31,7 +42,14 @@ export class ArrayRepository {
|
|
31
42
|
this._list = [];
|
32
43
|
}
|
33
44
|
async delete(items) {
|
34
|
-
this._list = this._list.filter(item =>
|
45
|
+
this._list = this._list.filter(item => {
|
46
|
+
for (const removed of items) {
|
47
|
+
if (this._equalsFunction(item, removed)) {
|
48
|
+
return false;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
return true;
|
52
|
+
});
|
35
53
|
}
|
36
54
|
async update(items) {
|
37
55
|
this._list = this._list.map(existingItem => {
|
@@ -54,7 +54,17 @@ export default class PreloadManager {
|
|
54
54
|
const value = fieldValue.value != undefined ? fieldValue.value : fieldValue;
|
55
55
|
return { key: dataUnit.getFormattedValue(fieldName, fieldValue), value };
|
56
56
|
})
|
57
|
-
.then(
|
57
|
+
.then(result => {
|
58
|
+
if (result != undefined && result.size > 0) {
|
59
|
+
const field = dataUnit.getField(fieldName);
|
60
|
+
const sortedMap = new Map(Array.from(result.entries())
|
61
|
+
.sort((itemA, itemB) => FieldComparator.compareValues(field, itemA[1], itemB[1]))
|
62
|
+
.map(([key, value]) => key === "" ? ["(Vazio)", value] : [key, value]));
|
63
|
+
accept(sortedMap);
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
accept(result);
|
67
|
+
})
|
58
68
|
.catch(reason => reject(reason));
|
59
69
|
});
|
60
70
|
}
|
@@ -187,9 +187,20 @@ class ArrayRepository {
|
|
187
187
|
return Promise.resolve({ result, count });
|
188
188
|
}
|
189
189
|
async distict(itemProcessor) {
|
190
|
-
const processedItems =
|
191
|
-
|
192
|
-
|
190
|
+
const processedItems = [];
|
191
|
+
let hasEmpty = false;
|
192
|
+
for (const item of this._list) {
|
193
|
+
const processedItem = itemProcessor(item);
|
194
|
+
if (processedItem == undefined) {
|
195
|
+
hasEmpty = true;
|
196
|
+
continue;
|
197
|
+
}
|
198
|
+
processedItems.push(processedItem);
|
199
|
+
}
|
200
|
+
if (hasEmpty) {
|
201
|
+
processedItems.push({ key: "", value: null });
|
202
|
+
}
|
203
|
+
return Promise.resolve(new Map(processedItems.map(item => [item.key, item.value])));
|
193
204
|
}
|
194
205
|
async push(items) {
|
195
206
|
this._list.push(...items);
|
@@ -198,7 +209,14 @@ class ArrayRepository {
|
|
198
209
|
this._list = [];
|
199
210
|
}
|
200
211
|
async delete(items) {
|
201
|
-
this._list = this._list.filter(item =>
|
212
|
+
this._list = this._list.filter(item => {
|
213
|
+
for (const removed of items) {
|
214
|
+
if (this._equalsFunction(item, removed)) {
|
215
|
+
return false;
|
216
|
+
}
|
217
|
+
}
|
218
|
+
return true;
|
219
|
+
});
|
202
220
|
}
|
203
221
|
async update(items) {
|
204
222
|
this._list = this._list.map(existingItem => {
|
@@ -278,7 +296,17 @@ class PreloadManager {
|
|
278
296
|
const value = fieldValue.value != undefined ? fieldValue.value : fieldValue;
|
279
297
|
return { key: dataUnit.getFormattedValue(fieldName, fieldValue), value };
|
280
298
|
})
|
281
|
-
.then(
|
299
|
+
.then(result => {
|
300
|
+
if (result != undefined && result.size > 0) {
|
301
|
+
const field = dataUnit.getField(fieldName);
|
302
|
+
const sortedMap = new Map(Array.from(result.entries())
|
303
|
+
.sort((itemA, itemB) => FieldComparator.compareValues(field, itemA[1], itemB[1]))
|
304
|
+
.map(([key, value]) => key === "" ? ["(Vazio)", value] : [key, value]));
|
305
|
+
accept(sortedMap);
|
306
|
+
return;
|
307
|
+
}
|
308
|
+
accept(result);
|
309
|
+
})
|
282
310
|
.catch(reason => reject(reason));
|
283
311
|
});
|
284
312
|
}
|
@@ -724,7 +752,7 @@ class DataUnitDataLoader {
|
|
724
752
|
offset = 0;
|
725
753
|
}
|
726
754
|
const { total, count, loadingInProgress } = loadingInfo;
|
727
|
-
const firstRecord = count === 0 ? 0 : offset + 1;
|
755
|
+
const firstRecord = (count === 0 || pageSize === 0) ? 0 : offset + 1;
|
728
756
|
const lastRecord = offset + Math.min(pageSize, limit);
|
729
757
|
return {
|
730
758
|
total,
|
@@ -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-c22b889c.js';
|
3
3
|
|
4
4
|
class SnkMultiSelectionListDataSource {
|
5
5
|
setDataUnit(dataUnit) {
|
@@ -26,9 +26,20 @@ class ArrayRepository {
|
|
26
26
|
return Promise.resolve({ result, count });
|
27
27
|
}
|
28
28
|
async distict(itemProcessor) {
|
29
|
-
const processedItems =
|
30
|
-
|
31
|
-
|
29
|
+
const processedItems = [];
|
30
|
+
let hasEmpty = false;
|
31
|
+
for (const item of this._list) {
|
32
|
+
const processedItem = itemProcessor(item);
|
33
|
+
if (processedItem == undefined) {
|
34
|
+
hasEmpty = true;
|
35
|
+
continue;
|
36
|
+
}
|
37
|
+
processedItems.push(processedItem);
|
38
|
+
}
|
39
|
+
if (hasEmpty) {
|
40
|
+
processedItems.push({ key: "", value: null });
|
41
|
+
}
|
42
|
+
return Promise.resolve(new Map(processedItems.map(item => [item.key, item.value])));
|
32
43
|
}
|
33
44
|
async push(items) {
|
34
45
|
this._list.push(...items);
|
@@ -37,7 +48,14 @@ class ArrayRepository {
|
|
37
48
|
this._list = [];
|
38
49
|
}
|
39
50
|
async delete(items) {
|
40
|
-
this._list = this._list.filter(item =>
|
51
|
+
this._list = this._list.filter(item => {
|
52
|
+
for (const removed of items) {
|
53
|
+
if (this._equalsFunction(item, removed)) {
|
54
|
+
return false;
|
55
|
+
}
|
56
|
+
}
|
57
|
+
return true;
|
58
|
+
});
|
41
59
|
}
|
42
60
|
async update(items) {
|
43
61
|
this._list = this._list.map(existingItem => {
|
@@ -117,7 +135,17 @@ class PreloadManager {
|
|
117
135
|
const value = fieldValue.value != undefined ? fieldValue.value : fieldValue;
|
118
136
|
return { key: dataUnit.getFormattedValue(fieldName, fieldValue), value };
|
119
137
|
})
|
120
|
-
.then(
|
138
|
+
.then(result => {
|
139
|
+
if (result != undefined && result.size > 0) {
|
140
|
+
const field = dataUnit.getField(fieldName);
|
141
|
+
const sortedMap = new Map(Array.from(result.entries())
|
142
|
+
.sort((itemA, itemB) => FieldComparator.compareValues(field, itemA[1], itemB[1]))
|
143
|
+
.map(([key, value]) => key === "" ? ["(Vazio)", value] : [key, value]));
|
144
|
+
accept(sortedMap);
|
145
|
+
return;
|
146
|
+
}
|
147
|
+
accept(result);
|
148
|
+
})
|
121
149
|
.catch(reason => reject(reason));
|
122
150
|
});
|
123
151
|
}
|
@@ -563,7 +591,7 @@ class DataUnitDataLoader {
|
|
563
591
|
offset = 0;
|
564
592
|
}
|
565
593
|
const { total, count, loadingInProgress } = loadingInfo;
|
566
|
-
const firstRecord = count === 0 ? 0 : offset + 1;
|
594
|
+
const firstRecord = (count === 0 || pageSize === 0) ? 0 : offset + 1;
|
567
595
|
const lastRecord = offset + Math.min(pageSize, limit);
|
568
596
|
return {
|
569
597
|
total,
|
@@ -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-c22b889c.js';
|
11
11
|
import './filter-item-type.enum-5028ed3f.js';
|
12
12
|
import './form-config-fetcher-7c3b6273.js';
|
13
13
|
import { R as ResourceIDUtils } from './ResourceIDUtils-a114189a.js';
|
@@ -4,7 +4,7 @@ import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
4
4
|
import { C as ConfigStorage } from './ConfigStorage-26f89143.js';
|
5
5
|
import { d as dist, D as DataFetcher, U as UrlUtils } from './DataFetcher-90e91631.js';
|
6
6
|
import { A as AutorizationType, a as AuthFetcher } from './auth-fetcher-a8c8ee7e.js';
|
7
|
-
import { D as DataUnitFetcher } from './dataunit-fetcher-
|
7
|
+
import { D as DataUnitFetcher } from './dataunit-fetcher-c22b889c.js';
|
8
8
|
import { P as PesquisaFetcher } from './pesquisa-fetcher-90d6853b.js';
|
9
9
|
import { S as SnkMessageBuilder } from './SnkMessageBuilder-7ac66e9c.js';
|
10
10
|
import './form-config-fetcher-7c3b6273.js';
|
@@ -3,7 +3,7 @@ import { ApplicationContext, DataType, Action } from '@sankhyalabs/core';
|
|
3
3
|
import { D as DataFetcher } from './DataFetcher-90e91631.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-c22b889c.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-c22b889c.js';
|
11
11
|
import './filter-item-type.enum-5028ed3f.js';
|
12
12
|
import './form-config-fetcher-7c3b6273.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-c22b889c.js';
|
12
12
|
import './filter-item-type.enum-5028ed3f.js';
|
13
13
|
import './form-config-fetcher-7c3b6273.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-e87b77d5.js';
|
17
17
|
import { S as SnkMessageBuilder } from './SnkMessageBuilder-7ac66e9c.js';
|
18
18
|
import './ConfigStorage-26f89143.js';
|
19
19
|
import './_commonjsHelpers-9943807e.js';
|
@@ -6,14 +6,14 @@ import { C as ConfigStorage } from './ConfigStorage-26f89143.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-36887f31.js';
|
10
10
|
import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
|
11
11
|
import './form-config-fetcher-7c3b6273.js';
|
12
12
|
import './DataFetcher-90e91631.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-c22b889c.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-c22b889c.js';
|
15
15
|
import './filter-item-type.enum-5028ed3f.js';
|
16
16
|
import './form-config-fetcher-7c3b6273.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-e87b77d5.js';
|
2
2
|
import './index-a7d3d3f1.js';
|
3
3
|
import '@sankhyalabs/core';
|
4
4
|
import './SnkFormConfigManager-18948123.js';
|
@@ -18,6 +18,6 @@ import './constants-3644f1b6.js';
|
|
18
18
|
import './pesquisa-fetcher-90d6853b.js';
|
19
19
|
import './ISave-4412b20c.js';
|
20
20
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
21
|
-
import './dataunit-fetcher-
|
21
|
+
import './dataunit-fetcher-c22b889c.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-c22b889c.js';
|
12
12
|
import './filter-item-type.enum-5028ed3f.js';
|
13
13
|
import './form-config-fetcher-7c3b6273.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-36887f31.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,h as s,H as i,g as e}from"./p-d2d301a6.js";import{ApplicationContext as n,StringUtils as o,ErrorException as a,WarningException as c,ObjectUtils as r,DateUtils as l,ArrayUtils as h,ElementIDUtils as u}from"@sankhyalabs/core";import{D as d}from"./p-5d51bff4.js";import{P as p}from"./p-eaad0aa8.js";import"./p-240f5892.js";import"./p-5534e08c.js";import"./p-9e7d65a4.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-e86d4a53.js";import"./p-584d7212.js";import"./p-d47bbee3.js";import{R as m}from"./p-688dcb4c.js";import"./p-112455b1.js";import"./p-8d884fab.js";class v{execute(t){var s;const i={actionID:t.actionID,refreshType:null===(s=t.actionConfig.javaCall)||void 0===s?void 0:s.refreshType};return new Promise((t=>{t({execSource:i,callback:this.callExecJava})}))}callExecJava(t){const s={requestBody:{javaCall:t}};d.get().callServiceBroker("ActionButtonsSP.executeJava",JSON.stringify(s))}}class b{execute(t){var s;const i={actionID:t.actionID,refreshType:null===(s=t.actionConfig.runScript)||void 0===s?void 0:s.refreshType};return new Promise((t=>{t({execSource:i,callback:this.callExecScript})}))}callExecScript(t){const s={runScript:t};d.get().callServiceBroker("ActionButtonsSP.executeScript",s)}}class k{constructor(){this._application=n.getContextValue("__SNK__APPLICATION__")}async execute(t,s){const i=t.resourceID;if(!i)return;let e=await this.buildLaunchObject(t,s);return this._application.openApp(i,e),null}buildLaunchObject(t,s){return new Promise((i=>{let e=t.actionConfig.params.param;if(e&&e.length>0){let n={},c=[];e.forEach((i=>{const e=i.localField;let r=s.getFieldValue(e);if(!r){let i=s.getField(e).label;throw i=o.isEmpty(s.getField(e).label)?e:i,new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.launchScreen.emptyField",{description:t.description,localFieldLabel:i}))}r=o.isEmpty(r.toString())?void 0:r.toString(),n[i.targetField]=r,c.push({fieldName:i.targetField,value:r})})),n.ACTION_PARAMETERS=c,n.call_time=Date.now(),i(n)}i(null)}))}}class f{execute(t){var s,i,e;const n=null===(s=t.actionConfig.dbCall)||void 0===s?void 0:s.name,o=null===(i=t.actionConfig.dbCall)||void 0===i?void 0:i.rootEntity,a={actionID:t.actionID,refreshType:null===(e=t.actionConfig.dbCall)||void 0===e?void 0:e.refreshType,procName:n,rootEntity:o};return new Promise((t=>{t({execSource:a,callback:this.callExecProcedure})}))}callExecProcedure(t){const s={requestBody:{stpCall:t}};d.get().callServiceBroker("ActionButtonsSP.executeSTP",JSON.stringify(s))}}var w,_;!function(t){t.LAUNCH_SCREEN="LC",t.JAVASCRIPT="SC",t.JAVA="RJ",t.PROCEDURE="SP",t.EMBEDDED="EB"}(w||(w={}));class S{constructor(t){this.actionType=t,this._application=n.getContextValue("__SNK__APPLICATION__")}get executor(){switch(this.actionType){case w.LAUNCH_SCREEN:return new k;case w.JAVASCRIPT:return new b;case w.JAVA:return new v;case w.PROCEDURE:return new f;default:throw new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.nonExistentType",{actionType:this.actionType}))}}}!function(t){t.NONE="NONE",t.PARENT="PARENT",t.MASTER="MASTER",t.ALL="ALL"}(_||(_={}));const y="__MASTER_ROW__";class P{constructor(t,s,i){var e;this._lastValuesCache={},this._actionsExecuteInterface=t,this._dataUnit=s,this._selectedRows=(null===(e=null==s?void 0:s.getSelectionInfo())||void 0===e?void 0:e.isAllRecords())?[]:null==s?void 0:s.getSelectionInfo().records,this._application=n.getContextValue("__SNK__APPLICATION__"),this._appResourceId=i}apply(t,s){this._application.closePopUp(),this._actionsExecuteInterface.execute(t,this._dataUnit).then((({execSource:i,callback:e})=>{this.resolvePromptParams(t,i,s).then((()=>{this.actionExecute(i,e)}))}))}async execute(t){var s;if(!t.actionConfig)throw new c(this._application.messagesBuilder.getMessage("snkActionsButton.title.warning",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.incorrectAction",{description:t.description}));if(null===(s=t.actionConfig.params)||void 0===s?void 0:s.promptParam){const s=t.actionConfig.params.promptParam;let i=!1;for(let t=0;t<s.length;t++)if(!i&&"true"===s[t].saveLast){i=!0;break}i&&(t.actionConfig.params.promptParam=await this.loadSavedValuesIntoParams(t));const e=document.createElement("snk-actions-form");window.document.body.appendChild(e),e.action=r.copy(t),e.applyParameters=t=>{this.apply(t,i)},e.openPopup()}else t.type!=w.LAUNCH_SCREEN?this._actionsExecuteInterface.execute(t,this._dataUnit).then((({execSource:t,callback:s})=>{this.actionExecute(t,s)})):this._actionsExecuteInterface.execute(t,this._dataUnit)}loadSavedValuesIntoParams(t){return this.loadLastValues(t).then((s=>{let i=t.actionConfig.params.promptParam;return s&&s.param.forEach((t=>{i=i.map((s=>s.name!==t.paramName?s:Object.assign(Object.assign({},s),"B"===s.paramType?{value:"S"===t.$}:{value:t.$})))})),i}))}actionExecute(t,s){t.virtualPage=this.buildVirtualPage(),this.prepareAndExecute(t,s),this.recordsReloader(t.refreshType)}resolvePromptParams(t,s,i){return new Promise((e=>{let n=[];t.actionConfig.params.promptParam.forEach((t=>{n.push(this.buildPromptParam(t))})),this.putParamsOnExecSource(n,s),i&&this.saveLastValues(t,n),e()}))}buildPromptParam(t){let s,i,e=t.paramType,n=!1,o=t.value;switch(e){case p.DATE:e="D";break;case p.DATETIME:e="H";break;case p.DECIMAL:e="F",s={"sk-precision":Number(t.precision)};break;case p.BOOLEAN:e="S",n=!0,o=t.value?"S":"N";break;case p.ENTITY:s={"sk-entity-name":t.entityName,"sk-allow-show-hierarchical-mode":t.hierarchyEntity,"sk-data-type":"S"},t.hierarchyEntity&&t.entityPK&&(i=t.entityPK),o=t.value?Number(t.value):null;break;case p.OPTIONS:e="O";let a=t.options.split(";").map((function(t,s){let i,e;if(t.indexOf("=")>-1){let s=t.split("=");i=s[0],e=s[1]}else i=s+1,e=t;return{data:i,value:e}}));s={"sk-options":a}}return{description:t.label,required:"true"==t.required,fieldName:t.name,fieldNameOri:t.name,entityPK:i,paramType:t.paramType,type:e,isCheckbox:n,saveLast:t.saveLast,fieldProp:s,value:o,isGeneratedName:t.isGeneratedName}}putParamsOnExecSource(t,s){s.params={param:[]},t.forEach((t=>{if(t.isGeneratedName&&t.value)throw new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.emptyParamName",void 0));o.isEmpty(t.value)||s.params.param.push({type:this.getParamDataType(t.paramType),paramName:t.fieldName,$:this.getParamValue(t)})}))}getParamDataType(t){let s;switch(t){case"D":s="F";break;case"DT":case"DH":s="D";break;case"B":case"ENTITY":case"SO":s="S";break;default:s=t}return s}getParamValue(t){let s=t.value;return s?("DT"==t.paramType?s=l.formatDate(s):"DH"==t.paramType&&(s=l.formatDateTime(s)),s):s}async loadLastValues(t){const s=await this.buildResourceId(t.actionID);return new Promise(((t,i)=>{if(this._lastValuesCache[s])t(this._lastValuesCache[s]);else{const e={config:{chave:s,tipo:"T"}};d.get().callServiceBroker("SystemUtilsSP.getConf",e).then((i=>{var e,n;let o;(null===(n=null===(e=i.config)||void 0===e?void 0:e.data)||void 0===n?void 0:n.params)&&(o=i.config.data.params,Array.isArray(o.param)||(o.param=[o.param])),this._lastValuesCache[s]=o,t(o)})).catch((t=>{i(t)}))}}))}async saveLastValues(t,s){if(this._application){let i={params:{param:[]}};s.forEach((t=>{"true"==t.saveLast&&i.params.param.push({paramName:t.fieldName,$:t.value})}));const e=await this.buildResourceId(t.actionID);this._lastValuesCache[e]=i.params,this._application.saveConfig(e,i)}}async buildResourceId(t){return this._appResourceId+".actionconfig."+t}prepareAndExecute(t,s){this.addRows(t),s(t)}addRows(t){const s={row:[]},i=this._selectedRows;for(const t in i){const e=i[t],n={};e.hasOwnProperty(y)&&(n.master="S",n.entityName=e.__ENTITY_NAME__,delete e[y],delete e.__ENTITY_NAME__);for(const t in e)"NUFIN"===t&&(n.field||(n.field=[]),n.field.push({fieldName:t,$:e[t]}));s.row.push(n)}s.row.length>0&&(t.rows=s)}recordsReloader(t){switch(t){case _.NONE:break;case _.PARENT:case _.MASTER:case _.ALL:this._dataUnit.loadData();break;default:this._dataUnit.reloadCurrentRecord()}}buildVirtualPage(){var t,s,i,e;if(null===(s=null===(t=this._dataUnit)||void 0===t?void 0:t.getSelectionInfo())||void 0===s?void 0:s.isAllRecords())return{filters:{filters:null===(i=this._dataUnit)||void 0===i?void 0:i.getAppliedFilters()},orders:{orders:null===(e=this._dataUnit)||void 0===e?void 0:e.getSort()}}}}class A{clientConfirm(t,s){const i=n.getContextValue("__SNK__APPLICATION__");let e="";t.content.event.hasOwnProperty("stpCall")?(s.requestBody=t.content.event.stpCall,e=w.PROCEDURE):t.content.event.hasOwnProperty("runScript")?(s.requestBody=t.content.event.runScript,e=w.JAVASCRIPT):t.content.event.hasOwnProperty("javaCall")&&(s.requestBody=t.content.event.javaCall,e=w.JAVA);let o={type:"S",sequence:t.content.event.sequence};s.requestBody.params?Array.isArray(s.requestBody.params.param)||(s.requestBody.params.param=[s.requestBody.params.param]):s.requestBody.params={param:[]},s.requestBody.params.param.push(o);const a=t.content.event.title.$,c=t.content.event.message.$;let r;switch(e){case w.JAVASCRIPT:r={runScript:s.requestBody};break;case w.PROCEDURE:r={requestBody:{stpCall:s.requestBody}};break;case w.JAVA:r={requestBody:{javaCall:s.requestBody}}}if("S"==t.content.event.showNoOption){o.paramName="__ESCOLHA_SIMNAO__";const t=document.createElement("snk-client-confirm");window.document.body.appendChild(t),t.titleMessage=a,t.message=c,t.accept=()=>{o.$="S",s.reCall(r)},t.cancel=()=>{o.$="N",s.reCall(r)},t.openPopup()}else i.confirm(a,c,null,"warn",{labelCancel:"Cancelar",labelConfirm:"Sim"}).then((t=>{t&&(o.paramName="__CONFIRMACAO__",o.$="S",s.reCall(r))}))}}const N=class{constructor(s){t(this,s),this.CLIENT_EVENT_CONFIRM_NAME="br.com.sankhya.actionbutton.clientconfirm",this.handleClick=t=>{const s=this._actions.find((s=>s.actionID==t.detail.id)),i=new S(s.type).executor;new P(i,this._dataUnit,this._resourceID).execute(Object.assign({},s)),this._showDropdown=!1},this._items=[],this._showDropdown=!1,this._actions=[],this._isOrderActions=!1}async getActions(){let t={param:{entityName:this._entityName,resourceID:this._resourceID}};return d.get().callServiceBroker("ActionButtonsSP.getActions",t).then((t=>{var s;(null===(s=t.actions)||void 0===s?void 0:s.action)&&(this._actions=this._isOrderActions?h.sortAlphabetically(t.actions.action,"description"):t.actions.action)}))}controlDropdown(){this._showDropdown=!this._showDropdown}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this._items)||void 0===t?void 0:t.length)>0}positionDropdown(){var t;const s=null===(t=this._ezButton)||void 0===t?void 0:t.getBoundingClientRect();s&&this._dropdownParent&&(this._dropdownParent.style.top=s.y+s.height+5+"px",this._dropdownParent.style.left=s.x+"px")}closeDropdown(t){const s=null==t?void 0:t.target;s&&(s.closest(".snk-actions-button")||(this._showDropdown=!1))}setEvents(){document.removeEventListener("click",this.closeDropdown.bind(this)),document.addEventListener("click",this.closeDropdown.bind(this)),document.removeEventListener("scroll",this.positionDropdown.bind(this)),document.addEventListener("scroll",this.positionDropdown.bind(this))}async componentWillLoad(){this._application=n.getContextValue("__SNK__APPLICATION__"),this._isOrderActions=await this._application.getBooleanParam("global.ordenar.acoes.personalizadas");const t=this._element.parentElement;this._dataUnit=null==t?void 0:t.dataUnit,this._resourceID=null==t?void 0:t.resourceID,this._entityName=this._dataUnit.name.split("/")[2],null==this._resourceID&&(this._resourceID=await m.getResourceID()),this.setEvents(),this.getActions().then((()=>{this.loadItems()}))}async componentDidLoad(){if(this._element&&(u.addIDInfo(this._element),this.positionDropdown(),!await this._application.hasClientEvent(this.CLIENT_EVENT_CONFIRM_NAME))){const t=new A;this._application.addClientEvent(this.CLIENT_EVENT_CONFIRM_NAME,t.clientConfirm)}}componentDidUpdate(){this.positionDropdown()}loadItems(){this._actions&&0!=this._actions.length&&this._actions.forEach((t=>{this._items.push({id:t.actionID,label:t.description})}))}getElementID(t){return{[u.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:u.getInternalIDInfo(t)}}render(){return s(i,null,this._actions&&this._actions.length>0&&s("div",{class:`ez-padding-left--medium snk-actions-button \n ${this.canShowDropdown()?" snk-actions-button--overlap":""}\n `},s("ez-button",Object.assign({ref:t=>this._ezButton=t,iconName:"acao",size:"small",mode:"icon",title:this._application.messagesBuilder.getMessage("snkActionsButton.title.actions",void 0),onClick:()=>this.controlDropdown()},this.getElementID("button"))),s("div",Object.assign({ref:t=>this._dropdownParent=t,class:(this.canShowDropdown()?"snk-actions-button__dropdown--show":"snk-actions-button__dropdown")+"\n "},this.getElementID("dropdown")),this.canShowDropdown()&&s("ez-dropdown",Object.assign({items:this._items,onEzClick:t=>this.handleClick(t)},this.getElementID("dropdown"))))),this.canShowDropdown()&&s("div",Object.assign({class:"ez-scrim ez-scrim--light"},this.getElementID("ezScrim"))))}get _element(){return e(this)}};N.style=".sc-snk-actions-button-h{--snk-actions-button--z-index:var(--most-visible, 3);display:flex;width:fit-content;height:fit-content}.snk-actions-button.sc-snk-actions-button{display:flex;width:fit-content;height:fit-content}.snk-actions-button__dropdown--show.sc-snk-actions-button{display:flex;flex-direction:column;position:fixed}.snk-actions-button__dropdown.sc-snk-actions-button>ez-dropdown.sc-snk-actions-button{position:relative}.snk-actions-button--overlap.sc-snk-actions-button{z-index:var(--snk-actions-button--z-index)}.snk-actions-button__dropdown.sc-snk-actions-button{display:none}";export{N as snk_actions_button}
|
1
|
+
import{r as t,h as s,H as i,g as e}from"./p-d2d301a6.js";import{ApplicationContext as n,StringUtils as o,ErrorException as a,WarningException as c,ObjectUtils as r,DateUtils as l,ArrayUtils as h,ElementIDUtils as u}from"@sankhyalabs/core";import{D as d}from"./p-5d51bff4.js";import{P as p}from"./p-eaad0aa8.js";import"./p-240f5892.js";import"./p-5534e08c.js";import"./p-9e7d65a4.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-bcc2b79d.js";import"./p-584d7212.js";import"./p-d47bbee3.js";import{R as m}from"./p-688dcb4c.js";import"./p-112455b1.js";import"./p-8d884fab.js";class v{execute(t){var s;const i={actionID:t.actionID,refreshType:null===(s=t.actionConfig.javaCall)||void 0===s?void 0:s.refreshType};return new Promise((t=>{t({execSource:i,callback:this.callExecJava})}))}callExecJava(t){const s={requestBody:{javaCall:t}};d.get().callServiceBroker("ActionButtonsSP.executeJava",JSON.stringify(s))}}class b{execute(t){var s;const i={actionID:t.actionID,refreshType:null===(s=t.actionConfig.runScript)||void 0===s?void 0:s.refreshType};return new Promise((t=>{t({execSource:i,callback:this.callExecScript})}))}callExecScript(t){const s={runScript:t};d.get().callServiceBroker("ActionButtonsSP.executeScript",s)}}class k{constructor(){this._application=n.getContextValue("__SNK__APPLICATION__")}async execute(t,s){const i=t.resourceID;if(!i)return;let e=await this.buildLaunchObject(t,s);return this._application.openApp(i,e),null}buildLaunchObject(t,s){return new Promise((i=>{let e=t.actionConfig.params.param;if(e&&e.length>0){let n={},c=[];e.forEach((i=>{const e=i.localField;let r=s.getFieldValue(e);if(!r){let i=s.getField(e).label;throw i=o.isEmpty(s.getField(e).label)?e:i,new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.launchScreen.emptyField",{description:t.description,localFieldLabel:i}))}r=o.isEmpty(r.toString())?void 0:r.toString(),n[i.targetField]=r,c.push({fieldName:i.targetField,value:r})})),n.ACTION_PARAMETERS=c,n.call_time=Date.now(),i(n)}i(null)}))}}class f{execute(t){var s,i,e;const n=null===(s=t.actionConfig.dbCall)||void 0===s?void 0:s.name,o=null===(i=t.actionConfig.dbCall)||void 0===i?void 0:i.rootEntity,a={actionID:t.actionID,refreshType:null===(e=t.actionConfig.dbCall)||void 0===e?void 0:e.refreshType,procName:n,rootEntity:o};return new Promise((t=>{t({execSource:a,callback:this.callExecProcedure})}))}callExecProcedure(t){const s={requestBody:{stpCall:t}};d.get().callServiceBroker("ActionButtonsSP.executeSTP",JSON.stringify(s))}}var w,_;!function(t){t.LAUNCH_SCREEN="LC",t.JAVASCRIPT="SC",t.JAVA="RJ",t.PROCEDURE="SP",t.EMBEDDED="EB"}(w||(w={}));class S{constructor(t){this.actionType=t,this._application=n.getContextValue("__SNK__APPLICATION__")}get executor(){switch(this.actionType){case w.LAUNCH_SCREEN:return new k;case w.JAVASCRIPT:return new b;case w.JAVA:return new v;case w.PROCEDURE:return new f;default:throw new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.nonExistentType",{actionType:this.actionType}))}}}!function(t){t.NONE="NONE",t.PARENT="PARENT",t.MASTER="MASTER",t.ALL="ALL"}(_||(_={}));const y="__MASTER_ROW__";class P{constructor(t,s,i){var e;this._lastValuesCache={},this._actionsExecuteInterface=t,this._dataUnit=s,this._selectedRows=(null===(e=null==s?void 0:s.getSelectionInfo())||void 0===e?void 0:e.isAllRecords())?[]:null==s?void 0:s.getSelectionInfo().records,this._application=n.getContextValue("__SNK__APPLICATION__"),this._appResourceId=i}apply(t,s){this._application.closePopUp(),this._actionsExecuteInterface.execute(t,this._dataUnit).then((({execSource:i,callback:e})=>{this.resolvePromptParams(t,i,s).then((()=>{this.actionExecute(i,e)}))}))}async execute(t){var s;if(!t.actionConfig)throw new c(this._application.messagesBuilder.getMessage("snkActionsButton.title.warning",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.incorrectAction",{description:t.description}));if(null===(s=t.actionConfig.params)||void 0===s?void 0:s.promptParam){const s=t.actionConfig.params.promptParam;let i=!1;for(let t=0;t<s.length;t++)if(!i&&"true"===s[t].saveLast){i=!0;break}i&&(t.actionConfig.params.promptParam=await this.loadSavedValuesIntoParams(t));const e=document.createElement("snk-actions-form");window.document.body.appendChild(e),e.action=r.copy(t),e.applyParameters=t=>{this.apply(t,i)},e.openPopup()}else t.type!=w.LAUNCH_SCREEN?this._actionsExecuteInterface.execute(t,this._dataUnit).then((({execSource:t,callback:s})=>{this.actionExecute(t,s)})):this._actionsExecuteInterface.execute(t,this._dataUnit)}loadSavedValuesIntoParams(t){return this.loadLastValues(t).then((s=>{let i=t.actionConfig.params.promptParam;return s&&s.param.forEach((t=>{i=i.map((s=>s.name!==t.paramName?s:Object.assign(Object.assign({},s),"B"===s.paramType?{value:"S"===t.$}:{value:t.$})))})),i}))}actionExecute(t,s){t.virtualPage=this.buildVirtualPage(),this.prepareAndExecute(t,s),this.recordsReloader(t.refreshType)}resolvePromptParams(t,s,i){return new Promise((e=>{let n=[];t.actionConfig.params.promptParam.forEach((t=>{n.push(this.buildPromptParam(t))})),this.putParamsOnExecSource(n,s),i&&this.saveLastValues(t,n),e()}))}buildPromptParam(t){let s,i,e=t.paramType,n=!1,o=t.value;switch(e){case p.DATE:e="D";break;case p.DATETIME:e="H";break;case p.DECIMAL:e="F",s={"sk-precision":Number(t.precision)};break;case p.BOOLEAN:e="S",n=!0,o=t.value?"S":"N";break;case p.ENTITY:s={"sk-entity-name":t.entityName,"sk-allow-show-hierarchical-mode":t.hierarchyEntity,"sk-data-type":"S"},t.hierarchyEntity&&t.entityPK&&(i=t.entityPK),o=t.value?Number(t.value):null;break;case p.OPTIONS:e="O";let a=t.options.split(";").map((function(t,s){let i,e;if(t.indexOf("=")>-1){let s=t.split("=");i=s[0],e=s[1]}else i=s+1,e=t;return{data:i,value:e}}));s={"sk-options":a}}return{description:t.label,required:"true"==t.required,fieldName:t.name,fieldNameOri:t.name,entityPK:i,paramType:t.paramType,type:e,isCheckbox:n,saveLast:t.saveLast,fieldProp:s,value:o,isGeneratedName:t.isGeneratedName}}putParamsOnExecSource(t,s){s.params={param:[]},t.forEach((t=>{if(t.isGeneratedName&&t.value)throw new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.emptyParamName",void 0));o.isEmpty(t.value)||s.params.param.push({type:this.getParamDataType(t.paramType),paramName:t.fieldName,$:this.getParamValue(t)})}))}getParamDataType(t){let s;switch(t){case"D":s="F";break;case"DT":case"DH":s="D";break;case"B":case"ENTITY":case"SO":s="S";break;default:s=t}return s}getParamValue(t){let s=t.value;return s?("DT"==t.paramType?s=l.formatDate(s):"DH"==t.paramType&&(s=l.formatDateTime(s)),s):s}async loadLastValues(t){const s=await this.buildResourceId(t.actionID);return new Promise(((t,i)=>{if(this._lastValuesCache[s])t(this._lastValuesCache[s]);else{const e={config:{chave:s,tipo:"T"}};d.get().callServiceBroker("SystemUtilsSP.getConf",e).then((i=>{var e,n;let o;(null===(n=null===(e=i.config)||void 0===e?void 0:e.data)||void 0===n?void 0:n.params)&&(o=i.config.data.params,Array.isArray(o.param)||(o.param=[o.param])),this._lastValuesCache[s]=o,t(o)})).catch((t=>{i(t)}))}}))}async saveLastValues(t,s){if(this._application){let i={params:{param:[]}};s.forEach((t=>{"true"==t.saveLast&&i.params.param.push({paramName:t.fieldName,$:t.value})}));const e=await this.buildResourceId(t.actionID);this._lastValuesCache[e]=i.params,this._application.saveConfig(e,i)}}async buildResourceId(t){return this._appResourceId+".actionconfig."+t}prepareAndExecute(t,s){this.addRows(t),s(t)}addRows(t){const s={row:[]},i=this._selectedRows;for(const t in i){const e=i[t],n={};e.hasOwnProperty(y)&&(n.master="S",n.entityName=e.__ENTITY_NAME__,delete e[y],delete e.__ENTITY_NAME__);for(const t in e)"NUFIN"===t&&(n.field||(n.field=[]),n.field.push({fieldName:t,$:e[t]}));s.row.push(n)}s.row.length>0&&(t.rows=s)}recordsReloader(t){switch(t){case _.NONE:break;case _.PARENT:case _.MASTER:case _.ALL:this._dataUnit.loadData();break;default:this._dataUnit.reloadCurrentRecord()}}buildVirtualPage(){var t,s,i,e;if(null===(s=null===(t=this._dataUnit)||void 0===t?void 0:t.getSelectionInfo())||void 0===s?void 0:s.isAllRecords())return{filters:{filters:null===(i=this._dataUnit)||void 0===i?void 0:i.getAppliedFilters()},orders:{orders:null===(e=this._dataUnit)||void 0===e?void 0:e.getSort()}}}}class A{clientConfirm(t,s){const i=n.getContextValue("__SNK__APPLICATION__");let e="";t.content.event.hasOwnProperty("stpCall")?(s.requestBody=t.content.event.stpCall,e=w.PROCEDURE):t.content.event.hasOwnProperty("runScript")?(s.requestBody=t.content.event.runScript,e=w.JAVASCRIPT):t.content.event.hasOwnProperty("javaCall")&&(s.requestBody=t.content.event.javaCall,e=w.JAVA);let o={type:"S",sequence:t.content.event.sequence};s.requestBody.params?Array.isArray(s.requestBody.params.param)||(s.requestBody.params.param=[s.requestBody.params.param]):s.requestBody.params={param:[]},s.requestBody.params.param.push(o);const a=t.content.event.title.$,c=t.content.event.message.$;let r;switch(e){case w.JAVASCRIPT:r={runScript:s.requestBody};break;case w.PROCEDURE:r={requestBody:{stpCall:s.requestBody}};break;case w.JAVA:r={requestBody:{javaCall:s.requestBody}}}if("S"==t.content.event.showNoOption){o.paramName="__ESCOLHA_SIMNAO__";const t=document.createElement("snk-client-confirm");window.document.body.appendChild(t),t.titleMessage=a,t.message=c,t.accept=()=>{o.$="S",s.reCall(r)},t.cancel=()=>{o.$="N",s.reCall(r)},t.openPopup()}else i.confirm(a,c,null,"warn",{labelCancel:"Cancelar",labelConfirm:"Sim"}).then((t=>{t&&(o.paramName="__CONFIRMACAO__",o.$="S",s.reCall(r))}))}}const N=class{constructor(s){t(this,s),this.CLIENT_EVENT_CONFIRM_NAME="br.com.sankhya.actionbutton.clientconfirm",this.handleClick=t=>{const s=this._actions.find((s=>s.actionID==t.detail.id)),i=new S(s.type).executor;new P(i,this._dataUnit,this._resourceID).execute(Object.assign({},s)),this._showDropdown=!1},this._items=[],this._showDropdown=!1,this._actions=[],this._isOrderActions=!1}async getActions(){let t={param:{entityName:this._entityName,resourceID:this._resourceID}};return d.get().callServiceBroker("ActionButtonsSP.getActions",t).then((t=>{var s;(null===(s=t.actions)||void 0===s?void 0:s.action)&&(this._actions=this._isOrderActions?h.sortAlphabetically(t.actions.action,"description"):t.actions.action)}))}controlDropdown(){this._showDropdown=!this._showDropdown}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this._items)||void 0===t?void 0:t.length)>0}positionDropdown(){var t;const s=null===(t=this._ezButton)||void 0===t?void 0:t.getBoundingClientRect();s&&this._dropdownParent&&(this._dropdownParent.style.top=s.y+s.height+5+"px",this._dropdownParent.style.left=s.x+"px")}closeDropdown(t){const s=null==t?void 0:t.target;s&&(s.closest(".snk-actions-button")||(this._showDropdown=!1))}setEvents(){document.removeEventListener("click",this.closeDropdown.bind(this)),document.addEventListener("click",this.closeDropdown.bind(this)),document.removeEventListener("scroll",this.positionDropdown.bind(this)),document.addEventListener("scroll",this.positionDropdown.bind(this))}async componentWillLoad(){this._application=n.getContextValue("__SNK__APPLICATION__"),this._isOrderActions=await this._application.getBooleanParam("global.ordenar.acoes.personalizadas");const t=this._element.parentElement;this._dataUnit=null==t?void 0:t.dataUnit,this._resourceID=null==t?void 0:t.resourceID,this._entityName=this._dataUnit.name.split("/")[2],null==this._resourceID&&(this._resourceID=await m.getResourceID()),this.setEvents(),this.getActions().then((()=>{this.loadItems()}))}async componentDidLoad(){if(this._element&&(u.addIDInfo(this._element),this.positionDropdown(),!await this._application.hasClientEvent(this.CLIENT_EVENT_CONFIRM_NAME))){const t=new A;this._application.addClientEvent(this.CLIENT_EVENT_CONFIRM_NAME,t.clientConfirm)}}componentDidUpdate(){this.positionDropdown()}loadItems(){this._actions&&0!=this._actions.length&&this._actions.forEach((t=>{this._items.push({id:t.actionID,label:t.description})}))}getElementID(t){return{[u.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:u.getInternalIDInfo(t)}}render(){return s(i,null,this._actions&&this._actions.length>0&&s("div",{class:`ez-padding-left--medium snk-actions-button \n ${this.canShowDropdown()?" snk-actions-button--overlap":""}\n `},s("ez-button",Object.assign({ref:t=>this._ezButton=t,iconName:"acao",size:"small",mode:"icon",title:this._application.messagesBuilder.getMessage("snkActionsButton.title.actions",void 0),onClick:()=>this.controlDropdown()},this.getElementID("button"))),s("div",Object.assign({ref:t=>this._dropdownParent=t,class:(this.canShowDropdown()?"snk-actions-button__dropdown--show":"snk-actions-button__dropdown")+"\n "},this.getElementID("dropdown")),this.canShowDropdown()&&s("ez-dropdown",Object.assign({items:this._items,onEzClick:t=>this.handleClick(t)},this.getElementID("dropdown"))))),this.canShowDropdown()&&s("div",Object.assign({class:"ez-scrim ez-scrim--light"},this.getElementID("ezScrim"))))}get _element(){return e(this)}};N.style=".sc-snk-actions-button-h{--snk-actions-button--z-index:var(--most-visible, 3);display:flex;width:fit-content;height:fit-content}.snk-actions-button.sc-snk-actions-button{display:flex;width:fit-content;height:fit-content}.snk-actions-button__dropdown--show.sc-snk-actions-button{display:flex;flex-direction:column;position:fixed}.snk-actions-button__dropdown.sc-snk-actions-button>ez-dropdown.sc-snk-actions-button{position:relative}.snk-actions-button--overlap.sc-snk-actions-button{z-index:var(--snk-actions-button--z-index)}.snk-actions-button__dropdown.sc-snk-actions-button{display:none}";export{N as snk_actions_button}
|