@sankhyalabs/sankhyablocks 8.2.0-dev.1 → 8.2.0-dev.3
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/snk-filter-detail.cjs.entry.js +6 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +22 -13
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +6 -1
- package/dist/collection/lib/dataUnit/InMemoryLoader.js +22 -13
- package/dist/components/snk-filter-detail2.js +6 -1
- package/dist/components/snk-simple-crud2.js +22 -13
- package/dist/esm/snk-filter-detail.entry.js +6 -1
- package/dist/esm/snk-simple-crud.entry.js +22 -13
- package/dist/sankhyablocks/p-989937ee.entry.js +1 -0
- package/dist/sankhyablocks/p-cfb33a4a.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +2 -1
- package/package.json +1 -1
- package/dist/sankhyablocks/p-8481bb59.entry.js +0 -1
- package/dist/sankhyablocks/p-ed705cbb.entry.js +0 -1
@@ -60,7 +60,12 @@ const SnkFilterDetail = class {
|
|
60
60
|
};
|
61
61
|
return snkFilterPersonalizedProps;
|
62
62
|
case filterItemType_enum.FilterItemType.MULTI_LIST:
|
63
|
-
return {
|
63
|
+
return {
|
64
|
+
tag: "snk-entity-list",
|
65
|
+
props: {
|
66
|
+
onValueChanged: evt => this.config = Object.assign(Object.assign({}, this.config), { value: evt.detail })
|
67
|
+
}
|
68
|
+
};
|
64
69
|
}
|
65
70
|
return { tag: "snk-filter-text" };
|
66
71
|
}
|
@@ -21,30 +21,44 @@ require('./_commonjsHelpers-537d719a.js');
|
|
21
21
|
|
22
22
|
class InMemoryLoader {
|
23
23
|
constructor(metadata, records) {
|
24
|
-
this.records = records
|
24
|
+
this.records = records;
|
25
25
|
this.metadata = metadata;
|
26
26
|
this._dataUnit = new core.DataUnit(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME);
|
27
27
|
this._dataUnit.metadataLoader = () => this.metadaLoader();
|
28
|
-
this._dataUnit.dataLoader = (dataUnit, request) => core.defaultDataLoader(dataUnit, request, this.
|
28
|
+
this._dataUnit.dataLoader = (dataUnit, request) => core.defaultDataLoader(dataUnit, request, this.getRecordsToLoad());
|
29
29
|
this._dataUnit.saveLoader = (_dataUnit, changes) => this.saveLoader(_dataUnit, changes);
|
30
30
|
this._dataUnit.removeLoader = (_dataUnit, recordIds) => this.removeLoader(_dataUnit, recordIds);
|
31
31
|
this.dataUnit.loadMetadata().then(() => this.dataUnit.loadData());
|
32
32
|
}
|
33
|
+
getRecordsToLoad() {
|
34
|
+
if (this._initialRecords) {
|
35
|
+
try {
|
36
|
+
return this._initialRecords;
|
37
|
+
}
|
38
|
+
finally {
|
39
|
+
this._initialRecords = undefined;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
return this.dataUnit.records;
|
43
|
+
}
|
33
44
|
get dataUnit() {
|
34
45
|
return this._dataUnit;
|
35
46
|
}
|
36
47
|
get records() {
|
37
|
-
return this.
|
48
|
+
return this.dataUnit.records;
|
38
49
|
}
|
39
50
|
set records(records) {
|
40
|
-
|
51
|
+
const newRecords = records === null || records === void 0 ? void 0 : records.map(record => {
|
41
52
|
if (!record["__record__id__"]) {
|
42
53
|
record["__record__id__"] = this.generateUniqueId();
|
43
54
|
}
|
44
55
|
return record;
|
45
56
|
});
|
46
57
|
if (this._dataUnit) {
|
47
|
-
this._dataUnit.records =
|
58
|
+
this._dataUnit.records = newRecords;
|
59
|
+
}
|
60
|
+
else {
|
61
|
+
this._initialRecords = newRecords;
|
48
62
|
}
|
49
63
|
}
|
50
64
|
get metadata() {
|
@@ -67,15 +81,11 @@ class InMemoryLoader {
|
|
67
81
|
let dataUnitRecords = [];
|
68
82
|
changes.forEach(change => {
|
69
83
|
let { record, updatingFields, operation } = change;
|
70
|
-
|
84
|
+
const changedRecord = Object.assign(Object.assign({}, record), updatingFields);
|
71
85
|
if (operation === core.ChangeOperation.INSERT ||
|
72
86
|
operation === core.ChangeOperation.COPY) {
|
73
|
-
|
74
|
-
|
75
|
-
isAdd = true;
|
76
|
-
}
|
77
|
-
const changedRecord = Object.assign(Object.assign({}, record), updatingFields);
|
78
|
-
if (isAdd) {
|
87
|
+
changedRecord["__old__id__"] = record["__record__id__"];
|
88
|
+
changedRecord["__record__id__"] = this.generateUniqueId();
|
79
89
|
this.records.push(changedRecord);
|
80
90
|
}
|
81
91
|
else {
|
@@ -89,7 +99,6 @@ class InMemoryLoader {
|
|
89
99
|
}
|
90
100
|
removeLoader(_dataUnit, recordIds) {
|
91
101
|
return new Promise((resolve) => {
|
92
|
-
this._records = this._records.filter(record => !recordIds.includes(record["__record__id__"]));
|
93
102
|
resolve(recordIds);
|
94
103
|
});
|
95
104
|
}
|
@@ -52,7 +52,12 @@ export class SnkFilterDetail {
|
|
52
52
|
};
|
53
53
|
return snkFilterPersonalizedProps;
|
54
54
|
case FilterItemType.MULTI_LIST:
|
55
|
-
return {
|
55
|
+
return {
|
56
|
+
tag: "snk-entity-list",
|
57
|
+
props: {
|
58
|
+
onValueChanged: evt => this.config = Object.assign(Object.assign({}, this.config), { value: evt.detail })
|
59
|
+
}
|
60
|
+
};
|
56
61
|
}
|
57
62
|
return { tag: "snk-filter-text" };
|
58
63
|
}
|
@@ -1,30 +1,44 @@
|
|
1
1
|
import { ChangeOperation, DataUnit, defaultDataLoader, StringUtils, } from '@sankhyalabs/core';
|
2
2
|
export default class InMemoryLoader {
|
3
3
|
constructor(metadata, records) {
|
4
|
-
this.records = records
|
4
|
+
this.records = records;
|
5
5
|
this.metadata = metadata;
|
6
6
|
this._dataUnit = new DataUnit(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME);
|
7
7
|
this._dataUnit.metadataLoader = () => this.metadaLoader();
|
8
|
-
this._dataUnit.dataLoader = (dataUnit, request) => defaultDataLoader(dataUnit, request, this.
|
8
|
+
this._dataUnit.dataLoader = (dataUnit, request) => defaultDataLoader(dataUnit, request, this.getRecordsToLoad());
|
9
9
|
this._dataUnit.saveLoader = (_dataUnit, changes) => this.saveLoader(_dataUnit, changes);
|
10
10
|
this._dataUnit.removeLoader = (_dataUnit, recordIds) => this.removeLoader(_dataUnit, recordIds);
|
11
11
|
this.dataUnit.loadMetadata().then(() => this.dataUnit.loadData());
|
12
12
|
}
|
13
|
+
getRecordsToLoad() {
|
14
|
+
if (this._initialRecords) {
|
15
|
+
try {
|
16
|
+
return this._initialRecords;
|
17
|
+
}
|
18
|
+
finally {
|
19
|
+
this._initialRecords = undefined;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
return this.dataUnit.records;
|
23
|
+
}
|
13
24
|
get dataUnit() {
|
14
25
|
return this._dataUnit;
|
15
26
|
}
|
16
27
|
get records() {
|
17
|
-
return this.
|
28
|
+
return this.dataUnit.records;
|
18
29
|
}
|
19
30
|
set records(records) {
|
20
|
-
|
31
|
+
const newRecords = records === null || records === void 0 ? void 0 : records.map(record => {
|
21
32
|
if (!record["__record__id__"]) {
|
22
33
|
record["__record__id__"] = this.generateUniqueId();
|
23
34
|
}
|
24
35
|
return record;
|
25
36
|
});
|
26
37
|
if (this._dataUnit) {
|
27
|
-
this._dataUnit.records =
|
38
|
+
this._dataUnit.records = newRecords;
|
39
|
+
}
|
40
|
+
else {
|
41
|
+
this._initialRecords = newRecords;
|
28
42
|
}
|
29
43
|
}
|
30
44
|
get metadata() {
|
@@ -47,15 +61,11 @@ export default class InMemoryLoader {
|
|
47
61
|
let dataUnitRecords = [];
|
48
62
|
changes.forEach(change => {
|
49
63
|
let { record, updatingFields, operation } = change;
|
50
|
-
|
64
|
+
const changedRecord = Object.assign(Object.assign({}, record), updatingFields);
|
51
65
|
if (operation === ChangeOperation.INSERT ||
|
52
66
|
operation === ChangeOperation.COPY) {
|
53
|
-
|
54
|
-
|
55
|
-
isAdd = true;
|
56
|
-
}
|
57
|
-
const changedRecord = Object.assign(Object.assign({}, record), updatingFields);
|
58
|
-
if (isAdd) {
|
67
|
+
changedRecord["__old__id__"] = record["__record__id__"];
|
68
|
+
changedRecord["__record__id__"] = this.generateUniqueId();
|
59
69
|
this.records.push(changedRecord);
|
60
70
|
}
|
61
71
|
else {
|
@@ -69,7 +79,6 @@ export default class InMemoryLoader {
|
|
69
79
|
}
|
70
80
|
removeLoader(_dataUnit, recordIds) {
|
71
81
|
return new Promise((resolve) => {
|
72
|
-
this._records = this._records.filter(record => !recordIds.includes(record["__record__id__"]));
|
73
82
|
resolve(recordIds);
|
74
83
|
});
|
75
84
|
}
|
@@ -56,7 +56,12 @@ const SnkFilterDetail = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
56
56
|
};
|
57
57
|
return snkFilterPersonalizedProps;
|
58
58
|
case FilterItemType.MULTI_LIST:
|
59
|
-
return {
|
59
|
+
return {
|
60
|
+
tag: "snk-entity-list",
|
61
|
+
props: {
|
62
|
+
onValueChanged: evt => this.config = Object.assign(Object.assign({}, this.config), { value: evt.detail })
|
63
|
+
}
|
64
|
+
};
|
60
65
|
}
|
61
66
|
return { tag: "snk-filter-text" };
|
62
67
|
}
|
@@ -17,30 +17,44 @@ import { d as defineCustomElement$2 } from './snk-exporter-email-sender2.js';
|
|
17
17
|
|
18
18
|
class InMemoryLoader {
|
19
19
|
constructor(metadata, records) {
|
20
|
-
this.records = records
|
20
|
+
this.records = records;
|
21
21
|
this.metadata = metadata;
|
22
22
|
this._dataUnit = new DataUnit(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME);
|
23
23
|
this._dataUnit.metadataLoader = () => this.metadaLoader();
|
24
|
-
this._dataUnit.dataLoader = (dataUnit, request) => defaultDataLoader(dataUnit, request, this.
|
24
|
+
this._dataUnit.dataLoader = (dataUnit, request) => defaultDataLoader(dataUnit, request, this.getRecordsToLoad());
|
25
25
|
this._dataUnit.saveLoader = (_dataUnit, changes) => this.saveLoader(_dataUnit, changes);
|
26
26
|
this._dataUnit.removeLoader = (_dataUnit, recordIds) => this.removeLoader(_dataUnit, recordIds);
|
27
27
|
this.dataUnit.loadMetadata().then(() => this.dataUnit.loadData());
|
28
28
|
}
|
29
|
+
getRecordsToLoad() {
|
30
|
+
if (this._initialRecords) {
|
31
|
+
try {
|
32
|
+
return this._initialRecords;
|
33
|
+
}
|
34
|
+
finally {
|
35
|
+
this._initialRecords = undefined;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
return this.dataUnit.records;
|
39
|
+
}
|
29
40
|
get dataUnit() {
|
30
41
|
return this._dataUnit;
|
31
42
|
}
|
32
43
|
get records() {
|
33
|
-
return this.
|
44
|
+
return this.dataUnit.records;
|
34
45
|
}
|
35
46
|
set records(records) {
|
36
|
-
|
47
|
+
const newRecords = records === null || records === void 0 ? void 0 : records.map(record => {
|
37
48
|
if (!record["__record__id__"]) {
|
38
49
|
record["__record__id__"] = this.generateUniqueId();
|
39
50
|
}
|
40
51
|
return record;
|
41
52
|
});
|
42
53
|
if (this._dataUnit) {
|
43
|
-
this._dataUnit.records =
|
54
|
+
this._dataUnit.records = newRecords;
|
55
|
+
}
|
56
|
+
else {
|
57
|
+
this._initialRecords = newRecords;
|
44
58
|
}
|
45
59
|
}
|
46
60
|
get metadata() {
|
@@ -63,15 +77,11 @@ class InMemoryLoader {
|
|
63
77
|
let dataUnitRecords = [];
|
64
78
|
changes.forEach(change => {
|
65
79
|
let { record, updatingFields, operation } = change;
|
66
|
-
|
80
|
+
const changedRecord = Object.assign(Object.assign({}, record), updatingFields);
|
67
81
|
if (operation === ChangeOperation.INSERT ||
|
68
82
|
operation === ChangeOperation.COPY) {
|
69
|
-
|
70
|
-
|
71
|
-
isAdd = true;
|
72
|
-
}
|
73
|
-
const changedRecord = Object.assign(Object.assign({}, record), updatingFields);
|
74
|
-
if (isAdd) {
|
83
|
+
changedRecord["__old__id__"] = record["__record__id__"];
|
84
|
+
changedRecord["__record__id__"] = this.generateUniqueId();
|
75
85
|
this.records.push(changedRecord);
|
76
86
|
}
|
77
87
|
else {
|
@@ -85,7 +95,6 @@ class InMemoryLoader {
|
|
85
95
|
}
|
86
96
|
removeLoader(_dataUnit, recordIds) {
|
87
97
|
return new Promise((resolve) => {
|
88
|
-
this._records = this._records.filter(record => !recordIds.includes(record["__record__id__"]));
|
89
98
|
resolve(recordIds);
|
90
99
|
});
|
91
100
|
}
|
@@ -56,7 +56,12 @@ const SnkFilterDetail = class {
|
|
56
56
|
};
|
57
57
|
return snkFilterPersonalizedProps;
|
58
58
|
case FilterItemType.MULTI_LIST:
|
59
|
-
return {
|
59
|
+
return {
|
60
|
+
tag: "snk-entity-list",
|
61
|
+
props: {
|
62
|
+
onValueChanged: evt => this.config = Object.assign(Object.assign({}, this.config), { value: evt.detail })
|
63
|
+
}
|
64
|
+
};
|
60
65
|
}
|
61
66
|
return { tag: "snk-filter-text" };
|
62
67
|
}
|
@@ -17,30 +17,44 @@ import './_commonjsHelpers-9943807e.js';
|
|
17
17
|
|
18
18
|
class InMemoryLoader {
|
19
19
|
constructor(metadata, records) {
|
20
|
-
this.records = records
|
20
|
+
this.records = records;
|
21
21
|
this.metadata = metadata;
|
22
22
|
this._dataUnit = new DataUnit(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME);
|
23
23
|
this._dataUnit.metadataLoader = () => this.metadaLoader();
|
24
|
-
this._dataUnit.dataLoader = (dataUnit, request) => defaultDataLoader(dataUnit, request, this.
|
24
|
+
this._dataUnit.dataLoader = (dataUnit, request) => defaultDataLoader(dataUnit, request, this.getRecordsToLoad());
|
25
25
|
this._dataUnit.saveLoader = (_dataUnit, changes) => this.saveLoader(_dataUnit, changes);
|
26
26
|
this._dataUnit.removeLoader = (_dataUnit, recordIds) => this.removeLoader(_dataUnit, recordIds);
|
27
27
|
this.dataUnit.loadMetadata().then(() => this.dataUnit.loadData());
|
28
28
|
}
|
29
|
+
getRecordsToLoad() {
|
30
|
+
if (this._initialRecords) {
|
31
|
+
try {
|
32
|
+
return this._initialRecords;
|
33
|
+
}
|
34
|
+
finally {
|
35
|
+
this._initialRecords = undefined;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
return this.dataUnit.records;
|
39
|
+
}
|
29
40
|
get dataUnit() {
|
30
41
|
return this._dataUnit;
|
31
42
|
}
|
32
43
|
get records() {
|
33
|
-
return this.
|
44
|
+
return this.dataUnit.records;
|
34
45
|
}
|
35
46
|
set records(records) {
|
36
|
-
|
47
|
+
const newRecords = records === null || records === void 0 ? void 0 : records.map(record => {
|
37
48
|
if (!record["__record__id__"]) {
|
38
49
|
record["__record__id__"] = this.generateUniqueId();
|
39
50
|
}
|
40
51
|
return record;
|
41
52
|
});
|
42
53
|
if (this._dataUnit) {
|
43
|
-
this._dataUnit.records =
|
54
|
+
this._dataUnit.records = newRecords;
|
55
|
+
}
|
56
|
+
else {
|
57
|
+
this._initialRecords = newRecords;
|
44
58
|
}
|
45
59
|
}
|
46
60
|
get metadata() {
|
@@ -63,15 +77,11 @@ class InMemoryLoader {
|
|
63
77
|
let dataUnitRecords = [];
|
64
78
|
changes.forEach(change => {
|
65
79
|
let { record, updatingFields, operation } = change;
|
66
|
-
|
80
|
+
const changedRecord = Object.assign(Object.assign({}, record), updatingFields);
|
67
81
|
if (operation === ChangeOperation.INSERT ||
|
68
82
|
operation === ChangeOperation.COPY) {
|
69
|
-
|
70
|
-
|
71
|
-
isAdd = true;
|
72
|
-
}
|
73
|
-
const changedRecord = Object.assign(Object.assign({}, record), updatingFields);
|
74
|
-
if (isAdd) {
|
83
|
+
changedRecord["__old__id__"] = record["__record__id__"];
|
84
|
+
changedRecord["__record__id__"] = this.generateUniqueId();
|
75
85
|
this.records.push(changedRecord);
|
76
86
|
}
|
77
87
|
else {
|
@@ -85,7 +95,6 @@ class InMemoryLoader {
|
|
85
95
|
}
|
86
96
|
removeLoader(_dataUnit, recordIds) {
|
87
97
|
return new Promise((resolve) => {
|
88
|
-
this._records = this._records.filter(record => !recordIds.includes(record["__record__id__"]));
|
89
98
|
resolve(recordIds);
|
90
99
|
});
|
91
100
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as t,c as i,h as e,F as s,H as l,g as r}from"./p-d2d301a6.js";import{ApplicationUtils as n}from"@sankhyalabs/ezui/dist/collection/utils";import{F as a}from"./p-584d7212.js";import{ElementIDUtils as o,ObjectUtils as h}from"@sankhyalabs/core";import{E as c}from"./p-1a68fb59.js";import{P as d}from"./p-5c1aacc7.js";import"./p-933c0c0b.js";const u=class{constructor(e){t(this,e),this.filterChange=i(this,"filterChange",7),this.config=void 0,this.getMessage=void 0}async show(){var t,i;null===(i=null===(t=this._editor)||void 0===t?void 0:t.show)||void 0===i||i.call(t)}observeConfig(t){var i,e;this._editor&&(this._editor.config=t),null===(e=null===(i=this._editor)||void 0===i?void 0:i.reloadList)||void 0===e||e.call(i)}componentDidLoad(){if(this._element){o.addIDInfo(this._element);const t=this._element.getAttribute(o.DATA_ELEMENT_ID_ATTRIBUTE_NAME);this._idContentEditor=`${t}_${this.config.id}`}}changeConfig(t){this.filterChange.emit(t)}getContentEditor(){switch(this.config.type){case a.BINARY_SELECT:return{tag:"snk-filter-binary-select"};case a.MULTI_SELECT:return{tag:"snk-filter-multi-select"};case a.PERIOD:return{tag:"snk-filter-period"};case a.SEARCH:return{tag:"snk-filter-search"};case a.NUMBER:return{tag:"snk-filter-number"};case a.PERSONALIZED:return{tag:"snk-personalized-filter-editor",props:{presentationMode:c.CHIP,onValueChanged:t=>this.handleValueChanged(t)}};case a.MULTI_LIST:return{tag:"snk-entity-list",props:{onValueChanged:t=>this.config=Object.assign(Object.assign({},this.config),{value:t.detail})}}}return{tag:"snk-filter-text"}}handleValueChanged({detail:t}){const i=(null==t?void 0:t.items)||this.config.groupedItems;this.config=Object.assign(Object.assign({},this.config),{groupedItems:i,visible:(i||[]).filter((t=>t.visible)).length>0})}removeItem(){const t=this.config.type===a.MULTI_LIST&&Array.isArray(this.config.value)?this.config.value.map((t=>Object.assign(Object.assign({},t),{check:!1}))):void 0,i=Object.assign(Object.assign({},this.config),{visible:!1,fixed:!1,value:t});null!=i.groupedItems&&(i.groupedItems=i.groupedItems.map((t=>Object.assign(Object.assign({},t),{visible:!1,fixed:!1,value:void 0})))),this.changeConfig(i)}removeItemFromGroup(t){return Object.assign(Object.assign({},t),{visible:!1,fixed:!1,value:void 0})}getPopUpHeaderButtons(){return e(s,null,!this.config.removalBlocked&&this.buildIcon(this.getMessage("snkFilterBar.removeFilter"),"delete",(()=>this.removeItem())),!this.config.hardFixed&&this.buildIcon(this.getMessage(this.config.fixed?"snkFilterBar.unpinFilter":"snkFilterBar.pinFilter"),this.config.fixed?"un-pin":"push-pin",(()=>this.changeConfig(Object.assign(Object.assign({},this.config),{fixed:!this.config.fixed})))))}buildIcon(t,i,s){return e("button",{onClick:()=>s(),class:"sc-snk-filter-bar snk-filter-item__editor-header-button",ref:i=>i&&this.buildIdButton(i,t)},e("ez-icon",Object.assign({title:t,iconName:i},{[o.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${o.getInternalIDInfo(`_${t}`)}`})))}buildIdButton(t,i){if(!t)return;const e={id:i};t.removeAttribute(o.DATA_ELEMENT_ID_ATTRIBUTE_NAME),o.addIDInfoIfNotExists(t,"button",e)}clearBinarySelectValues(){var t;const i=this._editor||{};null===(t=i.resetValues)||void 0===t||t.call(i),this.config=h.copy(this.originalConfig),this.changeConfig(Object.assign(Object.assign({},this.config),{value:void 0}))}apply(){if(!d.validateVariableValues(this.config,this._editor.value))return n.alert(this.getMessage("snkFilterBar.filterModal.validations.notFullFilled.title"),this.getMessage("snkFilterBar.filterModal.validations.notFullFilled.message"));const t=void 0!==this._editor.value?this._editor.value:this.config.value;this.changeConfig(Object.assign(Object.assign({},this.config),{visible:this.isVisible(),value:t}))}isVisible(){return!(this.config.groupedItems&&this.config.groupedItems.length>0)||this.config.groupedItems.filter((t=>t.visible)).length>0}clear(){var t;if(this.config.type!==a.BINARY_SELECT){if(a.MULTI_LIST===this.config.type){const i=h.copy(this.config);return null===(t=i.value)||void 0===t||t.forEach((t=>!!t&&(t.check=!1))),void(this.config=h.copy(i))}this.changeConfig(Object.assign(Object.assign({},this.config),{value:void 0}))}else this.clearBinarySelectValues()}filterCanBeCleared(){return this.config.type!==a.PERSONALIZED}onKeyDonwListener(t){"Enter"===t.key&&this._applyButton.setFocus().then((()=>this.apply()))}buildRightSlot(t){return e("ez-icon",{iconName:"delete",onClick:()=>this.removeValueFromConfig(t)})}removeValueFromConfig(t){var i,e;if(this.config){const s=h.copy(this.config),l=null===(i=s.value)||void 0===i?void 0:i.findIndex((i=>(null==i?void 0:i.id)===t.id));null===(e=s.value)||void 0===e||e.splice(l,1),this.config=h.copy(s)}}componentWillLoad(){this.originalConfig=h.copy(this.config)}render(){const{tag:t,props:i}=this.getContentEditor();return e(l,null,e("div",{class:"col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center"},e("div",{class:"ez-text ez-title ez-title--small ez-padding--small sc-snk-filter-bar snk-filter-item__editor-header"},this.config.detailTitle),this.getPopUpHeaderButtons()),e(t,Object.assign({maxHeightList:"240px",ref:t=>this._editor=t,value:this.config.value,config:this.config,onKeyDown:t=>this.onKeyDonwListener(t),"data-element-id":this._idContentEditor,getMessage:this.getMessage,rightListSlotBuilder:t=>this.buildRightSlot(t)},i)),e("hr",{class:"sc-snk-filter-bar snk-filter__popover-rule"}),e("div",{class:"ez-col ez-col--sd-12 ez-align--right"},this.filterCanBeCleared()&&e("ez-button",{label:this.getMessage("snkFilterBar.cleanFilter"),onClick:()=>this.clear(),size:"small"}),e("ez-button",{ref:t=>this._applyButton=t,label:this.getMessage("snkFilterBar.applyFilter"),onClick:()=>this.apply(),size:"small",class:"ez-button--primary ez-padding-left--medium"})))}get _element(){return r(this)}static get watchers(){return{config:["observeConfig"]}}};export{u as snk_filter_detail}
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as t,c as i,h as s,g as e}from"./p-d2d301a6.js";import{DataUnit as a,defaultDataLoader as r,StringUtils as o,ChangeOperation as n,ObjectUtils as h,ApplicationContext as d,DataType as l,UserInterface as m}from"@sankhyalabs/core";import{c,S as u}from"./p-4a78e118.js";import{T as p}from"./p-a2493d11.js";import"./p-f8e6b97e.js";import"./p-14eac6fe.js";import{P as g}from"./p-5534e08c.js";import"./p-9e7d65a4.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-584d7212.js";import"./p-a52a6c9d.js";import{T as v}from"./p-c2beb95c.js";import{S as b}from"./p-fa9d3f73.js";import"./p-6dc031de.js";import"./p-112455b1.js";class f{constructor(t,i){this.records=i,this.metadata=t,this._dataUnit=new a(f.IN_MEMORY_DATA_UNIT_NAME),this._dataUnit.metadataLoader=()=>this.metadaLoader(),this._dataUnit.dataLoader=(t,i)=>r(t,i,this.getRecordsToLoad()),this._dataUnit.saveLoader=(t,i)=>this.saveLoader(t,i),this._dataUnit.removeLoader=(t,i)=>this.removeLoader(t,i),this.dataUnit.loadMetadata().then((()=>this.dataUnit.loadData()))}getRecordsToLoad(){if(this._initialRecords)try{return this._initialRecords}finally{this._initialRecords=void 0}return this.dataUnit.records}get dataUnit(){return this._dataUnit}get records(){return this.dataUnit.records}set records(t){const i=null==t?void 0:t.map((t=>(t.__record__id__||(t.__record__id__=this.generateUniqueId()),t)));this._dataUnit?this._dataUnit.records=i:this._initialRecords=i}get metadata(){return this._metadata}set metadata(t){this._metadata=t,this._dataUnit&&(this._dataUnit.metadata=this._metadata)}generateUniqueId(){return o.generateUUID()}metadaLoader(){return Promise.resolve(this._metadata)}saveLoader(t,i){return new Promise((t=>{let s=[];i.forEach((t=>{let{record:i,updatingFields:e,operation:a}=t;const r=Object.assign(Object.assign({},i),e);if(a===n.INSERT||a===n.COPY)r.__old__id__=i.__record__id__,r.__record__id__=this.generateUniqueId(),this.records.push(r);else{const t=this.records.findIndex((t=>t.__record__id__==r.__record__id__));this.records[t]=r}s.push(r)})),t(s)}))}removeLoader(t,i){return new Promise((t=>{t(i)}))}}f.IN_MEMORY_DATA_UNIT_NAME="InMemoryDataUnit";const k=class{constructor(s){t(this,s),this.dataStateChange=i(this,"dataStateChange",3),this.dataUnitReady=i(this,"dataUnitReady",3),this.actionClick=i(this,"actionClick",7),this.formItemsReady=i(this,"formItemsReady",7),this.REGULAR_DEFAULT_BTNS=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER"],this.REGULAR_SELECTED_BTNS=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","DIVIDER"],this._multiSelectionListDataSource=new b,this._taskbarProcessor=new v({"snkSimpleCrudTaskbar.form_regular":this.resolveInMemoryBtns(this.REGULAR_DEFAULT_BTNS).concat(p.GRID_MODE),"snkSimpleCrudTaskbar.grid_regular":this.resolveInMemoryBtns(this.REGULAR_DEFAULT_BTNS).concat(p.FORM_MODE),"snkSimpleCrudTaskbar.form_selected":this.resolveInMemoryBtns(this.REGULAR_SELECTED_BTNS).concat(p.GRID_MODE),"snkSimpleCrudTaskbar.grid_selected":this.resolveInMemoryBtns(this.REGULAR_SELECTED_BTNS).concat(p.FORM_MODE),"snkSimpleCrudTaskbar.finish_edition":["CANCEL","SAVE"]}),this._currentViewMode=c.GRID,this._config=void 0,this.dataState=void 0,this.dataUnit=void 0,this.mode=u.SERVER,this.gridConfig=void 0,this.formConfig=void 0,this.multipleSelection=void 0,this.useCancelConfirm=!0,this.taskbarManager=void 0,this.messagesBuilder=void 0,this.useEnterLikeTab=!1}resolveInMemoryBtns(t){const i=[...t];return this.mode===u.IN_MEMORY&&i.splice(1,1),i}async goToView(t){this._currentViewMode=t,this._viewStack&&this._viewStack.show(t)}actionClickListener(t){const i=t.detail;i===p.GRID_MODE?this.goToView(c.GRID):i===p.FORM_MODE&&this.goToView(c.FORM),t.stopPropagation()}onModeChange(){this.mode==u.IN_MEMORY&&this.initInMemoryDataUnit()}observeDataState(t,i){h.objectToString(i)!=h.objectToString(t)&&this.dataStateChange.emit(t)}componentWillRender(){this._taskbarProcessor.process(this.getTaskBarId(),this.taskbarManager,this.dataState,this.getTaskBarDisabledButtons())}componentWillLoad(){this.processMetadata(),this.onModeChange(),this.configDatasource()}configDatasource(){const t=d.getContextValue("__SNK__APPLICATION__");this._multiSelectionListDataSource.setApplication(t),this._multiSelectionListDataSource.setDataUnit(this.dataUnit)}getTaskBarId(){var t,i,s;return(null===(t=this.dataState)||void 0===t?void 0:t.isDirty)?"snkSimpleCrudTaskbar.finish_edition":(null===(i=this.dataState)||void 0===i?void 0:i.selectionInfo)&&!this.dataState.selectionInfo.isAllRecords()&&(null===(s=this.dataState.selectionInfo.records)||void 0===s?void 0:s.length)>0?this._currentViewMode===c.GRID?"snkSimpleCrudTaskbar.grid_selected":"snkSimpleCrudTaskbar.form_selected":this._currentViewMode===c.GRID?"snkSimpleCrudTaskbar.grid_regular":"snkSimpleCrudTaskbar.form_regular"}initInMemoryDataUnit(){this._inMemoryLoader=new f(this._metadata),this.dataUnit=this._inMemoryLoader.dataUnit,this.dataUnitReady.emit(this.dataUnit)}setMetadata(t){return this._inMemoryLoader?this._inMemoryLoader.metadata=t:this.dataUnit&&(this.dataUnit.metadata=t),Promise.resolve()}setRecords(t){return this._inMemoryLoader?this._inMemoryLoader.records=t:this.dataUnit&&(this.dataUnit.records=t),Promise.resolve()}getRecords(){return Promise.resolve(this.dataUnit.records)}processMetadata(){const t=this._element.querySelectorAll("snk-field-metadata"),i=[],s={fields:[],emptyConfig:!1};t.forEach((t=>{const e={name:t.getAttribute("name")||t.getAttribute("label"),label:t.getAttribute("label"),dataType:l[t.getAttribute("dataType")]||l.TEXT,userInterface:m[t.getAttribute("userInterface")]||m.SHORTTEXT,readOnly:"true"==t.getAttribute("readOnly"),required:"true"==t.getAttribute("required"),tab:t.getAttribute("tab")||void 0,visible:"false"!=t.getAttribute("visible")};s.fields.push({name:e.name,tab:e.tab,visible:e.visible}),i.push(e)})),i.length>0&&(this.formConfig||(this.formConfig=s),this._metadata={name:"SimpleCrud",label:"SimpleCrud",fields:i})}onDataStateChange(t){this.dataState=Object.assign({},t.detail)}getTaskBarDisabledButtons(){var t,i,s,e;const a=[];return(null===(t=this.dataState)||void 0===t?void 0:t.hasNext)||a.push(p.NEXT),(null===(i=this.dataState)||void 0===i?void 0:i.hasPrevious)||a.push(p.PREVIOUS),(null===(e=null===(s=this.dataState)||void 0===s?void 0:s.selectionInfo)||void 0===e?void 0:e.isEmpty())&&a.push(p.FORM_MODE),a}handleCancelEdit(){var t;(null===(t=this.dataState)||void 0===t?void 0:t.recordsIsEmpty)&&(this.goToView(c.GRID),this.dataUnit.clearSelection())}render(){var t;return s("snk-data-unit",{class:"simple-crud__container",dataUnit:this.dataUnit,useCancelConfirm:this.useCancelConfirm,onDataStateChange:t=>this.onDataStateChange(t),onCancelEdition:this.handleCancelEdit.bind(this),onInsertionMode:()=>this.goToView(c.FORM),onDataUnitReady:t=>this.dataUnitReady.emit(t.detail),ignoreSaveMessage:this._currentViewMode===c.GRID,onMessagesBuilderUpdated:t=>this.messagesBuilder=t.detail},s("header",null,s("slot",{name:"snkSimpleCrudHeader"})),s("section",{class:"ez-flex ez-box ez-box--shadow"},s("snk-taskbar",{class:"ez-box ez-box--shadow ez-padding--medium ez-margin-bottom--large",dataUnit:this.dataUnit,primaryButton:(null===(t=this.dataState)||void 0===t?void 0:t.isDirty)?"SAVE":"INSERT","data-element-id":"grid_left",messagesBuilder:this.messagesBuilder,buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,slot:"leftButtons",presentationMode:g.SECONDARY}),s("ez-view-stack",{class:"ez-flex ez-flex--column",ref:t=>this._viewStack=t,"data-element-id":"simple-crud"},s("stack-item",null,s("ez-grid",{dataUnit:this.dataUnit,config:this.gridConfig,"no-header":!0,multipleSelection:this.multipleSelection,onEzDoubleClick:()=>this.goToView(c.FORM),columnfilterDataSource:this.dataUnit.name.includes(f.IN_MEMORY_DATA_UNIT_NAME)?void 0:this._multiSelectionListDataSource,useEnterLikeTab:this.useEnterLikeTab},s("div",{slot:"footer"},s("slot",{name:"snkSimpleCrudFooter"})))),s("stack-item",null,s("ez-form",{dataUnit:this.dataUnit,config:this.formConfig})))))}get _element(){return e(this)}static get watchers(){return{mode:["onModeChange"],dataState:["observeDataState"]}}};k.style=".sc-snk-simple-crud-h{display:flex;height:100%;width:100%}.simple-crud__container.sc-snk-simple-crud{display:grid;grid-template-rows:auto;row-gap:12px;height:100%;width:100%}ez-grid.sc-snk-simple-crud{--ez-grid__container--shadow:none;min-height:300px}ez-form.sc-snk-simple-crud{min-height:300px}";export{k as snk_simple_crud}
|
@@ -1 +1 @@
|
|
1
|
-
import{p as e,b as t}from"./p-d2d301a6.js";export{s as setNonce}from"./p-d2d301a6.js";(()=>{const t=import.meta.url,i={};return""!==t&&(i.resourcesUrl=new URL(".",t).href),e(i)})().then((e=>t(JSON.parse('[["p-118e769b",[[1,"teste-pesquisa"]]],["p-5d04ae42",[[0,"snk-filter-modal",{"getMessage":[16],"configName":[1025,"config-name"],"filters":[1040],"applyFilters":[16],"closeModal":[16],"addPersonalizedFilter":[16],"editPersonalizedFilter":[16]}]]],["p-ac8d1cd6",[[2,"snk-actions-form",{"action":[16],"applyParameters":[16],"dataUnit":[32],"openPopup":[64]}]]],["p-9531fd46",[[2,"snk-client-confirm",{"titleMessage":[1,"title-message"],"message":[1],"accept":[16],"cancel":[16],"openPopup":[64]}]]],["p-d4f9ee17",[[2,"snk-entity-list",{"config":[1040],"rightListSlotBuilder":[1040],"maxHeightList":[1,"max-height-list"],"_searchValue":[32],"_ezListSource":[32],"reloadList":[64]}]]],["p-eb636e15",[[0,"snk-filter-binary-select",{"value":[1544],"config":[16],"presentationMode":[2,"presentation-mode"],"resetValues":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-a1e1b305",[[4,"snk-filter-list",{"label":[1],"iconName":[1,"icon-name"],"items":[16],"getMessage":[16],"emptyText":[1,"empty-text"],"findFilterText":[1,"find-filter-text"],"buttonClass":[1,"button-class"],"_filterArgument":[32],"_showAll":[32],"hideDetail":[64]},[[2,"keydown","keyDownHandler"]]]]],["p-cb37982f",[[0,"snk-filter-multi-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-e3a82e1c",[[0,"snk-filter-number",{"config":[16],"value":[2],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-959e0835",[[0,"snk-filter-period",{"config":[16],"getMessage":[16],"value":[8],"presentationMode":[2,"presentation-mode"],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-fe49067d",[[0,"snk-filter-search",{"config":[16],"value":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-96a89d58",[[0,"snk-filter-text",{"config":[16],"value":[1]},[[0,"ezChange","ezChangeListener"]]]]],["p-26ad62b9",[[2,"snk-personalized-filter-editor",{"messagesBuilder":[1040],"presentationMode":[2,"presentation-mode"],"config":[16],"value":[1040],"items":[32],"show":[64]}]]],["p-03bb1aea",[[2,"snk-print-selector",{"_printServerActive":[32],"_selectedPrinter":[32],"_remotePrintersDataSource":[32],"_localPrintersDataSource":[32],"_printJobData":[32],"openPrintSelector":[64]}]]],["p-8818d8f6",[[0,"snk-filter-modal-item",{"filterItem":[1040],"configName":[1025,"config-name"],"resourceID":[1,"resource-i-d"]}]]],["p-d53a9169",[[2,"snk-detail-view",{"formConfigManager":[1040],"dataUnitName":[1,"data-unit-name"],"resourceID":[1,"resource-i-d"],"guideItemPath":[16],"entityName":[1,"entity-name"],"label":[1],"dataUnit":[1040],"selectedForm":[1025,"selected-form"],"dataState":[1040],"messagesBuilder":[1040],"branchGuide":[16],"canEdit":[4,"can-edit"],"_disabledButtons":[32],"_currentView":[32],"attachmentRegisterKey":[32],"changeViewMode":[64],"configGrid":[64],"showUp":[64]},[[0,"snkContentCardChanged","onContentCardChanged"]]]]],["p-9a270401",[[6,"snk-configurator",{"showActionButtons":[4,"show-action-buttons"],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"viewMode":[2,"view-mode"],"messagesBuilder":[1040],"_opened":[32],"_permissions":[32],"open":[64],"close":[64]}]]],["p-247a8b36",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["p-01739b21",[[2,"snk-filter-bar",{"dataUnit":[1040],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"filterConfig":[1040],"messagesBuilder":[1040],"allowDefault":[32],"scrollerLocked":[32],"showPersonalizedFilter":[32],"personalizedFilterId":[32],"reload":[64]},[[0,"filterChange","filterChangeListener"]]]]],["p-838f8234",[[1,"snk-select-box",{"selectedOption":[1,"selected-option"]}]]],["p-efc10705",[[2,"snk-grid-config",{"selectedIndex":[1026,"selected-index"],"application":[16],"columns":[1040],"config":[1040],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"]}]]],["p-bd628455",[[2,"snk-config-options",{"fieldConfig":[16],"idConfig":[513,"id-config"],"dataUnit":[16],"messagesBuilder":[1040],"_defaultType":[32]}]]],["p-f30526a7",[[2,"snk-field-config",{"isConfigActive":[16],"fieldConfig":[16],"modeInsertion":[516,"mode-insertion"],"dataUnit":[16],"messagesBuilder":[1040]}]]],["p-d3ec3586",[[6,"snk-tab-config",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1],"tabItems":[16],"messagesBuilder":[1040],"_processedTabs":[32],"_activeEditText":[32],"_activeEditTextIndex":[32],"_actionsHide":[32],"_actionsShow":[32]}]]],["p-b6003974",[[2,"snk-form-config",{"dataUnit":[16],"configManager":[16],"messagesBuilder":[1040],"_formConfigOptions":[32],"_fieldConfigSelected":[32],"_layoutFormConfig":[32],"_fieldsAvailable":[32],"_formConfig":[32],"_formConfigChanged":[32],"_optionFormConfigSelected":[32],"_optionFormConfigChanged":[32],"_tempGroups":[32]}]]],["p-6f154396",[[2,"snk-personalized-filter",{"messagesBuilder":[1040],"entityUri":[1025,"entity-uri"],"filterId":[1025,"filter-id"],"configName":[1025,"config-name"],"resourceID":[1,"resource-i-d"],"_filterAssistentMode":[32],"_filterAssistent":[32],"createPersonalizedFilter":[64]}]]],["p-ed705cbb",[[0,"snk-filter-detail",{"config":[1040],"getMessage":[16],"show":[64]}]]],["p-f9395c20",[[0,"snk-filter-item",{"config":[1040],"getMessage":[16],"detailIsVisible":[32],"showUp":[64],"hideDetail":[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]]]],["p-e086cc2a",[[2,"snk-data-unit",{"dataState":[1040],"messagesBuilder":[1040],"dataUnitName":[1,"data-unit-name"],"entityName":[1,"entity-name"],"pageSize":[2,"page-size"],"dataUnit":[1040],"beforeSave":[16],"afterSave":[16],"useCancelConfirm":[4,"use-cancel-confirm"],"ignoreSaveMessage":[4,"ignore-save-message"],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"getDataUnit":[64],"getSelectedRecordsIDsInfo":[64]}]]],["p-219f888d",[[0,"snk-exporter-email-sender",{"getMessage":[16],"_config":[32],"_opened":[32],"_currentStep":[32],"open":[64],"close":[64]}]]],["p-d13c00b6",[[2,"snk-data-exporter",{"provider":[16],"messagesBuilder":[1040],"_items":[32],"_showDropdown":[32],"_releasedToExport":[32]}]]],["p-e64f3e17",[[2,"snk-actions-button",{"_items":[32],"_showDropdown":[32],"_actions":[32],"_isOrderActions":[32]}]]],["p-fa523d6b",[[6,"snk-taskbar",{"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"buttons":[1],"customButtons":[16],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"presentationMode":[1537,"presentation-mode"],"messagesBuilder":[1040],"_permissions":[32]}]]],["p-0885ed3c",[[2,"snk-filter-field-search",{"searchable":[4],"fieldsDataSource":[16],"breadcrumbItems":[32],"linkItems":[32],"fieldItems":[32],"searchEmpty":[32],"groupEmpty":[32],"show":[64],"applyFilter":[64]}],[0,"snk-filter-param-config",{"messagesBuilder":[1040],"_opened":[32],"_configType":[32],"_expressionItem":[32],"_informedInstance":[32],"_canSave":[32],"open":[64],"close":[64]}]]],["p-9d3a025a",[[2,"snk-expression-group",{"parentTop":[1026,"parent-top"],"group":[1040],"messagesBuilder":[1040],"filterId":[1025,"filter-id"],"entityURI":[1025,"entity-u-r-i"],"_conditionOperator":[32],"_group":[32],"_selfTop":[32],"canAddExpression":[32],"_showDashes":[32],"getExpressionGroup":[64]},[[8,"ezExpressionLayoutChanged","todoCompletedHandler"]]],[2,"snk-expression-item",{"expression":[16],"canRemove":[516,"can-remove"],"messagesBuilder":[1040],"entityURI":[1025,"entity-u-r-i"],"_showValueVariable":[32],"_fieldSelected":[32],"_optionNotNull":[32]}]]],["p-f91e0c5d",[[6,"snk-grid",{"columnFilterDataSource":[1040],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"selectionToastConfig":[16],"actionsList":[16],"isDetail":[4,"is-detail"],"taskbarManager":[16],"statusResolver":[16],"multipleSelection":[4,"multiple-selection"],"presentationMode":[1,"presentation-mode"],"messagesBuilder":[1040],"useEnterLikeTab":[4,"use-enter-like-tab"],"recordsValidator":[16],"canEdit":[4,"can-edit"],"_dataUnit":[32],"_dataState":[32],"_gridConfig":[32],"_popUpGridConfig":[32],"showConfig":[64],"hideConfig":[64],"setConfig":[64],"reloadFilterBar":[64]}]]],["p-66bb8c20",[[2,"snk-guides-viewer",{"dataUnit":[16],"dataState":[16],"configName":[1,"config-name"],"entityPath":[1,"entity-path"],"actionsList":[16],"recordsValidator":[16],"masterFormConfig":[1040],"selectedGuide":[16],"taskbarManager":[16],"messagesBuilder":[1040],"canEdit":[4,"can-edit"],"presentationMode":[1,"presentation-mode"],"resourceID":[1,"resource-i-d"],"_breadcrumbItems":[32],"_guides":[32],"_formEditorConfigManager":[32],"_formEditorDataUnit":[32],"showFormConfig":[64]},[[2,"actionClick","onActionClick"],[0,"snkContentCardChanged","onContentCardChanged"]]]]],["p-05dbc70e",[[6,"snk-crud",{"configName":[1025,"config-name"],"selectionToastConfig":[16],"showActionButtons":[4,"show-action-buttons"],"actionsList":[16],"taskbarManager":[16],"recordsValidator":[16],"statusResolver":[16],"multipleSelection":[4,"multiple-selection"],"presentationMode":[1,"presentation-mode"],"messagesBuilder":[1040],"useEnterLikeTab":[4,"use-enter-like-tab"],"_dataUnit":[32],"_dataState":[32],"attachmentRegisterKey":[32],"_currentViewMode":[32],"_canEdit":[32],"_resourceID":[32],"goToView":[64],"openConfigurator":[64],"closeConfigurator":[64],"reloadFilterBar":[64]}]]],["p-93f6ca04",[[2,"snk-form",{"configName":[1,"config-name"],"recordsValidator":[16],"messagesBuilder":[1040],"resourceID":[1,"resource-i-d"],"_dataUnit":[32],"_dataState":[32],"_showFormConfig":[32],"_configManager":[32],"showConfig":[64],"hideConfig":[64]}]]],["p-d7638f45",[[2,"snk-application",{"messagesBuilder":[1040],"configName":[1,"config-name"],"isUserSup":[64],"initOnboarding":[64],"hasAccess":[64],"getAllAccess":[64],"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"showModal":[64],"closeModal":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"webConnection":[64],"createDataunit":[64],"updateDataunitCache":[64],"getDataUnit":[64],"addClientEvent":[64],"removeClientEvent":[64],"hasClientEvent":[64],"callServiceBroker":[64],"getResourceID":[64],"getUserID":[64],"alert":[64],"error":[64],"success":[64],"message":[64],"confirm":[64],"info":[64],"loadTotals":[64],"executeSearch":[64],"executePreparedSearch":[64],"isDebugMode":[64],"getAppLabel":[64],"addSearchListener":[64],"importScript":[64],"getApplicationPath":[64],"executeSelectDistinct":[64],"getDataFetcher":[64]}]]],["p-8481bb59",[[6,"snk-simple-crud",{"dataState":[16],"dataUnit":[16],"mode":[2],"gridConfig":[16],"formConfig":[16],"multipleSelection":[4,"multiple-selection"],"useCancelConfirm":[4,"use-cancel-confirm"],"taskbarManager":[16],"messagesBuilder":[1040],"useEnterLikeTab":[4,"use-enter-like-tab"],"_currentViewMode":[32],"_config":[32],"goToView":[64],"setMetadata":[64],"setRecords":[64],"getRecords":[64]},[[0,"actionClick","actionClickListener"]]]]],["p-611aa624",[[2,"snk-attach",{"registerKey":[1,"register-key"],"entityName":[1,"entity-name"],"messagesBuilder":[1040],"dataUnit":[32],"crudConfig":[32]}]]],["p-26b0ce3e",[[2,"snk-form-summary",{"fixed":[1540],"contracted":[1540],"summary":[16]}]]],["p-c555075c",[[6,"snk-form-view",{"levelPath":[1,"level-path"],"label":[1],"name":[1],"fields":[16],"formMetadata":[8,"form-metadata"],"dataUnit":[16],"contracted":[4],"fixed":[1540],"summaryFields":[16],"canExpand":[4,"can-expand"],"canFix":[4,"can-fix"],"recordsValidator":[16],"showUp":[64]}]]],["p-88aa931b",[[6,"snk-simple-bar",{"label":[1],"breadcrumbItens":[16],"messagesBuilder":[1040]}]]],["p-25c5428f",[[2,"snk-filter-assistent-mode",{"filterAssistent":[1040],"messagesBuilder":[1040],"filterId":[1025,"filter-id"],"entityUri":[1025,"entity-uri"],"application":[1040]}],[2,"snk-filter-advanced-mode",{"filterAssistent":[1040],"application":[1040]}]]]]'),e)));
|
1
|
+
import{p as e,b as t}from"./p-d2d301a6.js";export{s as setNonce}from"./p-d2d301a6.js";(()=>{const t=import.meta.url,i={};return""!==t&&(i.resourcesUrl=new URL(".",t).href),e(i)})().then((e=>t(JSON.parse('[["p-118e769b",[[1,"teste-pesquisa"]]],["p-5d04ae42",[[0,"snk-filter-modal",{"getMessage":[16],"configName":[1025,"config-name"],"filters":[1040],"applyFilters":[16],"closeModal":[16],"addPersonalizedFilter":[16],"editPersonalizedFilter":[16]}]]],["p-ac8d1cd6",[[2,"snk-actions-form",{"action":[16],"applyParameters":[16],"dataUnit":[32],"openPopup":[64]}]]],["p-9531fd46",[[2,"snk-client-confirm",{"titleMessage":[1,"title-message"],"message":[1],"accept":[16],"cancel":[16],"openPopup":[64]}]]],["p-d4f9ee17",[[2,"snk-entity-list",{"config":[1040],"rightListSlotBuilder":[1040],"maxHeightList":[1,"max-height-list"],"_searchValue":[32],"_ezListSource":[32],"reloadList":[64]}]]],["p-eb636e15",[[0,"snk-filter-binary-select",{"value":[1544],"config":[16],"presentationMode":[2,"presentation-mode"],"resetValues":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-a1e1b305",[[4,"snk-filter-list",{"label":[1],"iconName":[1,"icon-name"],"items":[16],"getMessage":[16],"emptyText":[1,"empty-text"],"findFilterText":[1,"find-filter-text"],"buttonClass":[1,"button-class"],"_filterArgument":[32],"_showAll":[32],"hideDetail":[64]},[[2,"keydown","keyDownHandler"]]]]],["p-cb37982f",[[0,"snk-filter-multi-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-e3a82e1c",[[0,"snk-filter-number",{"config":[16],"value":[2],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-959e0835",[[0,"snk-filter-period",{"config":[16],"getMessage":[16],"value":[8],"presentationMode":[2,"presentation-mode"],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-fe49067d",[[0,"snk-filter-search",{"config":[16],"value":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-96a89d58",[[0,"snk-filter-text",{"config":[16],"value":[1]},[[0,"ezChange","ezChangeListener"]]]]],["p-26ad62b9",[[2,"snk-personalized-filter-editor",{"messagesBuilder":[1040],"presentationMode":[2,"presentation-mode"],"config":[16],"value":[1040],"items":[32],"show":[64]}]]],["p-03bb1aea",[[2,"snk-print-selector",{"_printServerActive":[32],"_selectedPrinter":[32],"_remotePrintersDataSource":[32],"_localPrintersDataSource":[32],"_printJobData":[32],"openPrintSelector":[64]}]]],["p-8818d8f6",[[0,"snk-filter-modal-item",{"filterItem":[1040],"configName":[1025,"config-name"],"resourceID":[1,"resource-i-d"]}]]],["p-d53a9169",[[2,"snk-detail-view",{"formConfigManager":[1040],"dataUnitName":[1,"data-unit-name"],"resourceID":[1,"resource-i-d"],"guideItemPath":[16],"entityName":[1,"entity-name"],"label":[1],"dataUnit":[1040],"selectedForm":[1025,"selected-form"],"dataState":[1040],"messagesBuilder":[1040],"branchGuide":[16],"canEdit":[4,"can-edit"],"_disabledButtons":[32],"_currentView":[32],"attachmentRegisterKey":[32],"changeViewMode":[64],"configGrid":[64],"showUp":[64]},[[0,"snkContentCardChanged","onContentCardChanged"]]]]],["p-9a270401",[[6,"snk-configurator",{"showActionButtons":[4,"show-action-buttons"],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"viewMode":[2,"view-mode"],"messagesBuilder":[1040],"_opened":[32],"_permissions":[32],"open":[64],"close":[64]}]]],["p-247a8b36",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["p-01739b21",[[2,"snk-filter-bar",{"dataUnit":[1040],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"filterConfig":[1040],"messagesBuilder":[1040],"allowDefault":[32],"scrollerLocked":[32],"showPersonalizedFilter":[32],"personalizedFilterId":[32],"reload":[64]},[[0,"filterChange","filterChangeListener"]]]]],["p-838f8234",[[1,"snk-select-box",{"selectedOption":[1,"selected-option"]}]]],["p-efc10705",[[2,"snk-grid-config",{"selectedIndex":[1026,"selected-index"],"application":[16],"columns":[1040],"config":[1040],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"]}]]],["p-bd628455",[[2,"snk-config-options",{"fieldConfig":[16],"idConfig":[513,"id-config"],"dataUnit":[16],"messagesBuilder":[1040],"_defaultType":[32]}]]],["p-f30526a7",[[2,"snk-field-config",{"isConfigActive":[16],"fieldConfig":[16],"modeInsertion":[516,"mode-insertion"],"dataUnit":[16],"messagesBuilder":[1040]}]]],["p-d3ec3586",[[6,"snk-tab-config",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1],"tabItems":[16],"messagesBuilder":[1040],"_processedTabs":[32],"_activeEditText":[32],"_activeEditTextIndex":[32],"_actionsHide":[32],"_actionsShow":[32]}]]],["p-b6003974",[[2,"snk-form-config",{"dataUnit":[16],"configManager":[16],"messagesBuilder":[1040],"_formConfigOptions":[32],"_fieldConfigSelected":[32],"_layoutFormConfig":[32],"_fieldsAvailable":[32],"_formConfig":[32],"_formConfigChanged":[32],"_optionFormConfigSelected":[32],"_optionFormConfigChanged":[32],"_tempGroups":[32]}]]],["p-6f154396",[[2,"snk-personalized-filter",{"messagesBuilder":[1040],"entityUri":[1025,"entity-uri"],"filterId":[1025,"filter-id"],"configName":[1025,"config-name"],"resourceID":[1,"resource-i-d"],"_filterAssistentMode":[32],"_filterAssistent":[32],"createPersonalizedFilter":[64]}]]],["p-989937ee",[[0,"snk-filter-detail",{"config":[1040],"getMessage":[16],"show":[64]}]]],["p-f9395c20",[[0,"snk-filter-item",{"config":[1040],"getMessage":[16],"detailIsVisible":[32],"showUp":[64],"hideDetail":[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]]]],["p-e086cc2a",[[2,"snk-data-unit",{"dataState":[1040],"messagesBuilder":[1040],"dataUnitName":[1,"data-unit-name"],"entityName":[1,"entity-name"],"pageSize":[2,"page-size"],"dataUnit":[1040],"beforeSave":[16],"afterSave":[16],"useCancelConfirm":[4,"use-cancel-confirm"],"ignoreSaveMessage":[4,"ignore-save-message"],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"getDataUnit":[64],"getSelectedRecordsIDsInfo":[64]}]]],["p-219f888d",[[0,"snk-exporter-email-sender",{"getMessage":[16],"_config":[32],"_opened":[32],"_currentStep":[32],"open":[64],"close":[64]}]]],["p-d13c00b6",[[2,"snk-data-exporter",{"provider":[16],"messagesBuilder":[1040],"_items":[32],"_showDropdown":[32],"_releasedToExport":[32]}]]],["p-e64f3e17",[[2,"snk-actions-button",{"_items":[32],"_showDropdown":[32],"_actions":[32],"_isOrderActions":[32]}]]],["p-fa523d6b",[[6,"snk-taskbar",{"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"buttons":[1],"customButtons":[16],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"presentationMode":[1537,"presentation-mode"],"messagesBuilder":[1040],"_permissions":[32]}]]],["p-0885ed3c",[[2,"snk-filter-field-search",{"searchable":[4],"fieldsDataSource":[16],"breadcrumbItems":[32],"linkItems":[32],"fieldItems":[32],"searchEmpty":[32],"groupEmpty":[32],"show":[64],"applyFilter":[64]}],[0,"snk-filter-param-config",{"messagesBuilder":[1040],"_opened":[32],"_configType":[32],"_expressionItem":[32],"_informedInstance":[32],"_canSave":[32],"open":[64],"close":[64]}]]],["p-9d3a025a",[[2,"snk-expression-group",{"parentTop":[1026,"parent-top"],"group":[1040],"messagesBuilder":[1040],"filterId":[1025,"filter-id"],"entityURI":[1025,"entity-u-r-i"],"_conditionOperator":[32],"_group":[32],"_selfTop":[32],"canAddExpression":[32],"_showDashes":[32],"getExpressionGroup":[64]},[[8,"ezExpressionLayoutChanged","todoCompletedHandler"]]],[2,"snk-expression-item",{"expression":[16],"canRemove":[516,"can-remove"],"messagesBuilder":[1040],"entityURI":[1025,"entity-u-r-i"],"_showValueVariable":[32],"_fieldSelected":[32],"_optionNotNull":[32]}]]],["p-f91e0c5d",[[6,"snk-grid",{"columnFilterDataSource":[1040],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"selectionToastConfig":[16],"actionsList":[16],"isDetail":[4,"is-detail"],"taskbarManager":[16],"statusResolver":[16],"multipleSelection":[4,"multiple-selection"],"presentationMode":[1,"presentation-mode"],"messagesBuilder":[1040],"useEnterLikeTab":[4,"use-enter-like-tab"],"recordsValidator":[16],"canEdit":[4,"can-edit"],"_dataUnit":[32],"_dataState":[32],"_gridConfig":[32],"_popUpGridConfig":[32],"showConfig":[64],"hideConfig":[64],"setConfig":[64],"reloadFilterBar":[64]}]]],["p-66bb8c20",[[2,"snk-guides-viewer",{"dataUnit":[16],"dataState":[16],"configName":[1,"config-name"],"entityPath":[1,"entity-path"],"actionsList":[16],"recordsValidator":[16],"masterFormConfig":[1040],"selectedGuide":[16],"taskbarManager":[16],"messagesBuilder":[1040],"canEdit":[4,"can-edit"],"presentationMode":[1,"presentation-mode"],"resourceID":[1,"resource-i-d"],"_breadcrumbItems":[32],"_guides":[32],"_formEditorConfigManager":[32],"_formEditorDataUnit":[32],"showFormConfig":[64]},[[2,"actionClick","onActionClick"],[0,"snkContentCardChanged","onContentCardChanged"]]]]],["p-05dbc70e",[[6,"snk-crud",{"configName":[1025,"config-name"],"selectionToastConfig":[16],"showActionButtons":[4,"show-action-buttons"],"actionsList":[16],"taskbarManager":[16],"recordsValidator":[16],"statusResolver":[16],"multipleSelection":[4,"multiple-selection"],"presentationMode":[1,"presentation-mode"],"messagesBuilder":[1040],"useEnterLikeTab":[4,"use-enter-like-tab"],"_dataUnit":[32],"_dataState":[32],"attachmentRegisterKey":[32],"_currentViewMode":[32],"_canEdit":[32],"_resourceID":[32],"goToView":[64],"openConfigurator":[64],"closeConfigurator":[64],"reloadFilterBar":[64]}]]],["p-93f6ca04",[[2,"snk-form",{"configName":[1,"config-name"],"recordsValidator":[16],"messagesBuilder":[1040],"resourceID":[1,"resource-i-d"],"_dataUnit":[32],"_dataState":[32],"_showFormConfig":[32],"_configManager":[32],"showConfig":[64],"hideConfig":[64]}]]],["p-d7638f45",[[2,"snk-application",{"messagesBuilder":[1040],"configName":[1,"config-name"],"isUserSup":[64],"initOnboarding":[64],"hasAccess":[64],"getAllAccess":[64],"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"showModal":[64],"closeModal":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"webConnection":[64],"createDataunit":[64],"updateDataunitCache":[64],"getDataUnit":[64],"addClientEvent":[64],"removeClientEvent":[64],"hasClientEvent":[64],"callServiceBroker":[64],"getResourceID":[64],"getUserID":[64],"alert":[64],"error":[64],"success":[64],"message":[64],"confirm":[64],"info":[64],"loadTotals":[64],"executeSearch":[64],"executePreparedSearch":[64],"isDebugMode":[64],"getAppLabel":[64],"addSearchListener":[64],"importScript":[64],"getApplicationPath":[64],"executeSelectDistinct":[64],"getDataFetcher":[64]}]]],["p-cfb33a4a",[[6,"snk-simple-crud",{"dataState":[16],"dataUnit":[16],"mode":[2],"gridConfig":[16],"formConfig":[16],"multipleSelection":[4,"multiple-selection"],"useCancelConfirm":[4,"use-cancel-confirm"],"taskbarManager":[16],"messagesBuilder":[1040],"useEnterLikeTab":[4,"use-enter-like-tab"],"_currentViewMode":[32],"_config":[32],"goToView":[64],"setMetadata":[64],"setRecords":[64],"getRecords":[64]},[[0,"actionClick","actionClickListener"]]]]],["p-611aa624",[[2,"snk-attach",{"registerKey":[1,"register-key"],"entityName":[1,"entity-name"],"messagesBuilder":[1040],"dataUnit":[32],"crudConfig":[32]}]]],["p-26b0ce3e",[[2,"snk-form-summary",{"fixed":[1540],"contracted":[1540],"summary":[16]}]]],["p-c555075c",[[6,"snk-form-view",{"levelPath":[1,"level-path"],"label":[1],"name":[1],"fields":[16],"formMetadata":[8,"form-metadata"],"dataUnit":[16],"contracted":[4],"fixed":[1540],"summaryFields":[16],"canExpand":[4,"can-expand"],"canFix":[4,"can-fix"],"recordsValidator":[16],"showUp":[64]}]]],["p-88aa931b",[[6,"snk-simple-bar",{"label":[1],"breadcrumbItens":[16],"messagesBuilder":[1040]}]]],["p-25c5428f",[[2,"snk-filter-assistent-mode",{"filterAssistent":[1040],"messagesBuilder":[1040],"filterId":[1025,"filter-id"],"entityUri":[1025,"entity-uri"],"application":[1040]}],[2,"snk-filter-advanced-mode",{"filterAssistent":[1040],"application":[1040]}]]]]'),e)));
|
@@ -1,10 +1,11 @@
|
|
1
1
|
import { DataUnit, Record, UnitMetadata } from '@sankhyalabs/core';
|
2
2
|
export default class InMemoryLoader {
|
3
3
|
private _dataUnit;
|
4
|
-
private _records;
|
5
4
|
private _metadata;
|
5
|
+
private _initialRecords;
|
6
6
|
static readonly IN_MEMORY_DATA_UNIT_NAME = "InMemoryDataUnit";
|
7
7
|
constructor(metadata?: UnitMetadata, records?: Array<Record>);
|
8
|
+
private getRecordsToLoad;
|
8
9
|
get dataUnit(): DataUnit;
|
9
10
|
get records(): Array<Record>;
|
10
11
|
set records(records: Array<Record>);
|
package/package.json
CHANGED
@@ -1 +0,0 @@
|
|
1
|
-
import{r as t,c as i,h as s,g as e}from"./p-d2d301a6.js";import{DataUnit as a,defaultDataLoader as r,StringUtils as o,ChangeOperation as n,ObjectUtils as h,ApplicationContext as d,DataType as l,UserInterface as m}from"@sankhyalabs/core";import{c,S as u}from"./p-4a78e118.js";import{T as p}from"./p-a2493d11.js";import"./p-f8e6b97e.js";import"./p-14eac6fe.js";import{P as g}from"./p-5534e08c.js";import"./p-9e7d65a4.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-584d7212.js";import"./p-a52a6c9d.js";import{T as v}from"./p-c2beb95c.js";import{S as b}from"./p-fa9d3f73.js";import"./p-6dc031de.js";import"./p-112455b1.js";class k{constructor(t,i){this.records=i||[],this.metadata=t,this._dataUnit=new a(k.IN_MEMORY_DATA_UNIT_NAME),this._dataUnit.metadataLoader=()=>this.metadaLoader(),this._dataUnit.dataLoader=(t,i)=>r(t,i,this._records),this._dataUnit.saveLoader=(t,i)=>this.saveLoader(t,i),this._dataUnit.removeLoader=(t,i)=>this.removeLoader(t,i),this.dataUnit.loadMetadata().then((()=>this.dataUnit.loadData()))}get dataUnit(){return this._dataUnit}get records(){return this._records}set records(t){this._records=null==t?void 0:t.map((t=>(t.__record__id__||(t.__record__id__=this.generateUniqueId()),t))),this._dataUnit&&(this._dataUnit.records=[...this._records])}get metadata(){return this._metadata}set metadata(t){this._metadata=t,this._dataUnit&&(this._dataUnit.metadata=this._metadata)}generateUniqueId(){return o.generateUUID()}metadaLoader(){return Promise.resolve(this._metadata)}saveLoader(t,i){return new Promise((t=>{let s=[];i.forEach((t=>{let{record:i,updatingFields:e,operation:a}=t,r=!1;a!==n.INSERT&&a!==n.COPY||(i.__old__id__=i.__record__id__,i.__record__id__=this.generateUniqueId(),r=!0);const o=Object.assign(Object.assign({},i),e);if(r)this.records.push(o);else{const t=this.records.findIndex((t=>t.__record__id__==o.__record__id__));this.records[t]=o}s.push(o)})),t(s)}))}removeLoader(t,i){return new Promise((t=>{this._records=this._records.filter((t=>!i.includes(t.__record__id__))),t(i)}))}}k.IN_MEMORY_DATA_UNIT_NAME="InMemoryDataUnit";const f=class{constructor(s){t(this,s),this.dataStateChange=i(this,"dataStateChange",3),this.dataUnitReady=i(this,"dataUnitReady",3),this.actionClick=i(this,"actionClick",7),this.formItemsReady=i(this,"formItemsReady",7),this.REGULAR_DEFAULT_BTNS=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER"],this.REGULAR_SELECTED_BTNS=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","DIVIDER"],this._multiSelectionListDataSource=new b,this._taskbarProcessor=new v({"snkSimpleCrudTaskbar.form_regular":this.resolveInMemoryBtns(this.REGULAR_DEFAULT_BTNS).concat(p.GRID_MODE),"snkSimpleCrudTaskbar.grid_regular":this.resolveInMemoryBtns(this.REGULAR_DEFAULT_BTNS).concat(p.FORM_MODE),"snkSimpleCrudTaskbar.form_selected":this.resolveInMemoryBtns(this.REGULAR_SELECTED_BTNS).concat(p.GRID_MODE),"snkSimpleCrudTaskbar.grid_selected":this.resolveInMemoryBtns(this.REGULAR_SELECTED_BTNS).concat(p.FORM_MODE),"snkSimpleCrudTaskbar.finish_edition":["CANCEL","SAVE"]}),this._currentViewMode=c.GRID,this._config=void 0,this.dataState=void 0,this.dataUnit=void 0,this.mode=u.SERVER,this.gridConfig=void 0,this.formConfig=void 0,this.multipleSelection=void 0,this.useCancelConfirm=!0,this.taskbarManager=void 0,this.messagesBuilder=void 0,this.useEnterLikeTab=!1}resolveInMemoryBtns(t){const i=[...t];return this.mode===u.IN_MEMORY&&i.splice(1,1),i}async goToView(t){this._currentViewMode=t,this._viewStack&&this._viewStack.show(t)}actionClickListener(t){const i=t.detail;i===p.GRID_MODE?this.goToView(c.GRID):i===p.FORM_MODE&&this.goToView(c.FORM),t.stopPropagation()}onModeChange(){this.mode==u.IN_MEMORY&&this.initInMemoryDataUnit()}observeDataState(t,i){h.objectToString(i)!=h.objectToString(t)&&this.dataStateChange.emit(t)}componentWillRender(){this._taskbarProcessor.process(this.getTaskBarId(),this.taskbarManager,this.dataState,this.getTaskBarDisabledButtons())}componentWillLoad(){this.processMetadata(),this.onModeChange(),this.configDatasource()}configDatasource(){const t=d.getContextValue("__SNK__APPLICATION__");this._multiSelectionListDataSource.setApplication(t),this._multiSelectionListDataSource.setDataUnit(this.dataUnit)}getTaskBarId(){var t,i,s;return(null===(t=this.dataState)||void 0===t?void 0:t.isDirty)?"snkSimpleCrudTaskbar.finish_edition":(null===(i=this.dataState)||void 0===i?void 0:i.selectionInfo)&&!this.dataState.selectionInfo.isAllRecords()&&(null===(s=this.dataState.selectionInfo.records)||void 0===s?void 0:s.length)>0?this._currentViewMode===c.GRID?"snkSimpleCrudTaskbar.grid_selected":"snkSimpleCrudTaskbar.form_selected":this._currentViewMode===c.GRID?"snkSimpleCrudTaskbar.grid_regular":"snkSimpleCrudTaskbar.form_regular"}initInMemoryDataUnit(){this._inMemoryLoader=new k(this._metadata),this.dataUnit=this._inMemoryLoader.dataUnit,this.dataUnitReady.emit(this.dataUnit)}setMetadata(t){return this._inMemoryLoader?this._inMemoryLoader.metadata=t:this.dataUnit&&(this.dataUnit.metadata=t),Promise.resolve()}setRecords(t){return this._inMemoryLoader?this._inMemoryLoader.records=t:this.dataUnit&&(this.dataUnit.records=t),Promise.resolve()}getRecords(){return Promise.resolve(this.dataUnit.records)}processMetadata(){const t=this._element.querySelectorAll("snk-field-metadata"),i=[],s={fields:[],emptyConfig:!1};t.forEach((t=>{const e={name:t.getAttribute("name")||t.getAttribute("label"),label:t.getAttribute("label"),dataType:l[t.getAttribute("dataType")]||l.TEXT,userInterface:m[t.getAttribute("userInterface")]||m.SHORTTEXT,readOnly:"true"==t.getAttribute("readOnly"),required:"true"==t.getAttribute("required"),tab:t.getAttribute("tab")||void 0,visible:"false"!=t.getAttribute("visible")};s.fields.push({name:e.name,tab:e.tab,visible:e.visible}),i.push(e)})),i.length>0&&(this.formConfig||(this.formConfig=s),this._metadata={name:"SimpleCrud",label:"SimpleCrud",fields:i})}onDataStateChange(t){this.dataState=Object.assign({},t.detail)}getTaskBarDisabledButtons(){var t,i,s,e;const a=[];return(null===(t=this.dataState)||void 0===t?void 0:t.hasNext)||a.push(p.NEXT),(null===(i=this.dataState)||void 0===i?void 0:i.hasPrevious)||a.push(p.PREVIOUS),(null===(e=null===(s=this.dataState)||void 0===s?void 0:s.selectionInfo)||void 0===e?void 0:e.isEmpty())&&a.push(p.FORM_MODE),a}handleCancelEdit(){var t;(null===(t=this.dataState)||void 0===t?void 0:t.recordsIsEmpty)&&(this.goToView(c.GRID),this.dataUnit.clearSelection())}render(){var t;return s("snk-data-unit",{class:"simple-crud__container",dataUnit:this.dataUnit,useCancelConfirm:this.useCancelConfirm,onDataStateChange:t=>this.onDataStateChange(t),onCancelEdition:this.handleCancelEdit.bind(this),onInsertionMode:()=>this.goToView(c.FORM),onDataUnitReady:t=>this.dataUnitReady.emit(t.detail),ignoreSaveMessage:this._currentViewMode===c.GRID,onMessagesBuilderUpdated:t=>this.messagesBuilder=t.detail},s("header",null,s("slot",{name:"snkSimpleCrudHeader"})),s("section",{class:"ez-flex ez-box ez-box--shadow"},s("snk-taskbar",{class:"ez-box ez-box--shadow ez-padding--medium ez-margin-bottom--large",dataUnit:this.dataUnit,primaryButton:(null===(t=this.dataState)||void 0===t?void 0:t.isDirty)?"SAVE":"INSERT","data-element-id":"grid_left",messagesBuilder:this.messagesBuilder,buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,slot:"leftButtons",presentationMode:g.SECONDARY}),s("ez-view-stack",{class:"ez-flex ez-flex--column",ref:t=>this._viewStack=t,"data-element-id":"simple-crud"},s("stack-item",null,s("ez-grid",{dataUnit:this.dataUnit,config:this.gridConfig,"no-header":!0,multipleSelection:this.multipleSelection,onEzDoubleClick:()=>this.goToView(c.FORM),columnfilterDataSource:this.dataUnit.name.includes(k.IN_MEMORY_DATA_UNIT_NAME)?void 0:this._multiSelectionListDataSource,useEnterLikeTab:this.useEnterLikeTab},s("div",{slot:"footer"},s("slot",{name:"snkSimpleCrudFooter"})))),s("stack-item",null,s("ez-form",{dataUnit:this.dataUnit,config:this.formConfig})))))}get _element(){return e(this)}static get watchers(){return{mode:["onModeChange"],dataState:["observeDataState"]}}};f.style=".sc-snk-simple-crud-h{display:flex;height:100%;width:100%}.simple-crud__container.sc-snk-simple-crud{display:grid;grid-template-rows:auto;row-gap:12px;height:100%;width:100%}ez-grid.sc-snk-simple-crud{--ez-grid__container--shadow:none;min-height:300px}ez-form.sc-snk-simple-crud{min-height:300px}";export{f as snk_simple_crud}
|
@@ -1 +0,0 @@
|
|
1
|
-
import{r as t,c as i,h as e,F as s,H as l,g as r}from"./p-d2d301a6.js";import{ApplicationUtils as n}from"@sankhyalabs/ezui/dist/collection/utils";import{F as a}from"./p-584d7212.js";import{ElementIDUtils as o,ObjectUtils as h}from"@sankhyalabs/core";import{E as c}from"./p-1a68fb59.js";import{P as d}from"./p-5c1aacc7.js";import"./p-933c0c0b.js";const u=class{constructor(e){t(this,e),this.filterChange=i(this,"filterChange",7),this.config=void 0,this.getMessage=void 0}async show(){var t,i;null===(i=null===(t=this._editor)||void 0===t?void 0:t.show)||void 0===i||i.call(t)}observeConfig(t){var i,e;this._editor&&(this._editor.config=t),null===(e=null===(i=this._editor)||void 0===i?void 0:i.reloadList)||void 0===e||e.call(i)}componentDidLoad(){if(this._element){o.addIDInfo(this._element);const t=this._element.getAttribute(o.DATA_ELEMENT_ID_ATTRIBUTE_NAME);this._idContentEditor=`${t}_${this.config.id}`}}changeConfig(t){this.filterChange.emit(t)}getContentEditor(){switch(this.config.type){case a.BINARY_SELECT:return{tag:"snk-filter-binary-select"};case a.MULTI_SELECT:return{tag:"snk-filter-multi-select"};case a.PERIOD:return{tag:"snk-filter-period"};case a.SEARCH:return{tag:"snk-filter-search"};case a.NUMBER:return{tag:"snk-filter-number"};case a.PERSONALIZED:return{tag:"snk-personalized-filter-editor",props:{presentationMode:c.CHIP,onValueChanged:t=>this.handleValueChanged(t)}};case a.MULTI_LIST:return{tag:"snk-entity-list"}}return{tag:"snk-filter-text"}}handleValueChanged({detail:t}){const i=(null==t?void 0:t.items)||this.config.groupedItems;this.config=Object.assign(Object.assign({},this.config),{groupedItems:i,visible:(i||[]).filter((t=>t.visible)).length>0})}removeItem(){const t=this.config.type===a.MULTI_LIST&&Array.isArray(this.config.value)?this.config.value.map((t=>Object.assign(Object.assign({},t),{check:!1}))):void 0,i=Object.assign(Object.assign({},this.config),{visible:!1,fixed:!1,value:t});null!=i.groupedItems&&(i.groupedItems=i.groupedItems.map((t=>Object.assign(Object.assign({},t),{visible:!1,fixed:!1,value:void 0})))),this.changeConfig(i)}removeItemFromGroup(t){return Object.assign(Object.assign({},t),{visible:!1,fixed:!1,value:void 0})}getPopUpHeaderButtons(){return e(s,null,!this.config.removalBlocked&&this.buildIcon(this.getMessage("snkFilterBar.removeFilter"),"delete",(()=>this.removeItem())),!this.config.hardFixed&&this.buildIcon(this.getMessage(this.config.fixed?"snkFilterBar.unpinFilter":"snkFilterBar.pinFilter"),this.config.fixed?"un-pin":"push-pin",(()=>this.changeConfig(Object.assign(Object.assign({},this.config),{fixed:!this.config.fixed})))))}buildIcon(t,i,s){return e("button",{onClick:()=>s(),class:"sc-snk-filter-bar snk-filter-item__editor-header-button",ref:i=>i&&this.buildIdButton(i,t)},e("ez-icon",Object.assign({title:t,iconName:i},{[o.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${o.getInternalIDInfo(`_${t}`)}`})))}buildIdButton(t,i){if(!t)return;const e={id:i};t.removeAttribute(o.DATA_ELEMENT_ID_ATTRIBUTE_NAME),o.addIDInfoIfNotExists(t,"button",e)}clearBinarySelectValues(){var t;const i=this._editor||{};null===(t=i.resetValues)||void 0===t||t.call(i),this.config=h.copy(this.originalConfig),this.changeConfig(Object.assign(Object.assign({},this.config),{value:void 0}))}apply(){if(!d.validateVariableValues(this.config,this._editor.value))return n.alert(this.getMessage("snkFilterBar.filterModal.validations.notFullFilled.title"),this.getMessage("snkFilterBar.filterModal.validations.notFullFilled.message"));const t=void 0!==this._editor.value?this._editor.value:this.config.value;this.changeConfig(Object.assign(Object.assign({},this.config),{visible:this.isVisible(),value:t}))}isVisible(){return!(this.config.groupedItems&&this.config.groupedItems.length>0)||this.config.groupedItems.filter((t=>t.visible)).length>0}clear(){var t;if(this.config.type!==a.BINARY_SELECT){if(a.MULTI_LIST===this.config.type){const i=h.copy(this.config);return null===(t=i.value)||void 0===t||t.forEach((t=>!!t&&(t.check=!1))),void(this.config=h.copy(i))}this.changeConfig(Object.assign(Object.assign({},this.config),{value:void 0}))}else this.clearBinarySelectValues()}filterCanBeCleared(){return this.config.type!==a.PERSONALIZED}onKeyDonwListener(t){"Enter"===t.key&&this._applyButton.setFocus().then((()=>this.apply()))}buildRightSlot(t){return e("ez-icon",{iconName:"delete",onClick:()=>this.removeValueFromConfig(t)})}removeValueFromConfig(t){var i,e;if(this.config){const s=h.copy(this.config),l=null===(i=s.value)||void 0===i?void 0:i.findIndex((i=>(null==i?void 0:i.id)===t.id));null===(e=s.value)||void 0===e||e.splice(l,1),this.config=h.copy(s)}}componentWillLoad(){this.originalConfig=h.copy(this.config)}render(){const{tag:t,props:i}=this.getContentEditor();return e(l,null,e("div",{class:"col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center"},e("div",{class:"ez-text ez-title ez-title--small ez-padding--small sc-snk-filter-bar snk-filter-item__editor-header"},this.config.detailTitle),this.getPopUpHeaderButtons()),e(t,Object.assign({maxHeightList:"240px",ref:t=>this._editor=t,value:this.config.value,config:this.config,onKeyDown:t=>this.onKeyDonwListener(t),"data-element-id":this._idContentEditor,getMessage:this.getMessage,rightListSlotBuilder:t=>this.buildRightSlot(t)},i)),e("hr",{class:"sc-snk-filter-bar snk-filter__popover-rule"}),e("div",{class:"ez-col ez-col--sd-12 ez-align--right"},this.filterCanBeCleared()&&e("ez-button",{label:this.getMessage("snkFilterBar.cleanFilter"),onClick:()=>this.clear(),size:"small"}),e("ez-button",{ref:t=>this._applyButton=t,label:this.getMessage("snkFilterBar.applyFilter"),onClick:()=>this.apply(),size:"small",class:"ez-button--primary ez-padding-left--medium"})))}get _element(){return r(this)}static get watchers(){return{config:["observeConfig"]}}};export{u as snk_filter_detail}
|