@sankhyalabs/sankhyablocks 1.3.31-beta.7 → 1.3.31-beta.9

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.
Files changed (65) hide show
  1. package/dist/cjs/{index-532bcc28.js → index-c6671817.js} +0 -3
  2. package/dist/cjs/loader.cjs.js +2 -2
  3. package/dist/cjs/sankhyablocks.cjs.js +2 -2
  4. package/dist/cjs/snk-application.cjs.entry.js +67 -24
  5. package/dist/cjs/snk-crud.cjs.entry.js +64 -0
  6. package/dist/cjs/snk-data-unit.cjs.entry.js +14 -4
  7. package/dist/cjs/snk-form_2.cjs.entry.js +170 -0
  8. package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
  9. package/dist/cjs/snk-taskbar.cjs.entry.js +2 -2
  10. package/dist/cjs/{taskbar-elements-9d47b416.js → taskbar-elements-7f99f0c9.js} +2 -2
  11. package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
  12. package/dist/collection/collection-manifest.json +1 -0
  13. package/dist/collection/components/snk-application/errorhandler/snk-error-handler.js +2 -2
  14. package/dist/collection/components/snk-application/snk-application.js +71 -25
  15. package/dist/collection/components/snk-crud/snk-crud.css +5 -0
  16. package/dist/collection/components/snk-crud/snk-crud.js +149 -0
  17. package/dist/collection/components/snk-data-unit/snk-data-unit.js +27 -3
  18. package/dist/collection/components/snk-form/snk-form.js +59 -22
  19. package/dist/collection/components/snk-grid/snk-grid.js +33 -13
  20. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +1 -1
  21. package/dist/components/snk-application2.js +66 -23
  22. package/dist/components/snk-crud.d.ts +11 -0
  23. package/dist/components/snk-crud.js +102 -0
  24. package/dist/components/snk-data-unit.js +13 -3
  25. package/dist/components/snk-form.js +1 -116
  26. package/dist/components/snk-form2.js +134 -0
  27. package/dist/components/snk-grid.js +1 -83
  28. package/dist/components/snk-grid2.js +91 -0
  29. package/dist/components/snk-taskbar2.js +1 -1
  30. package/dist/esm/{index-0b078db7.js → index-6a83ac96.js} +0 -3
  31. package/dist/esm/loader.js +2 -2
  32. package/dist/esm/sankhyablocks.js +2 -2
  33. package/dist/esm/snk-application.entry.js +67 -24
  34. package/dist/esm/snk-crud.entry.js +60 -0
  35. package/dist/esm/snk-data-unit.entry.js +14 -4
  36. package/dist/esm/snk-form_2.entry.js +165 -0
  37. package/dist/esm/snk-pesquisa.entry.js +1 -1
  38. package/dist/esm/snk-taskbar.entry.js +2 -2
  39. package/dist/esm/{taskbar-elements-3ba30bf4.js → taskbar-elements-e0b8a285.js} +2 -2
  40. package/dist/esm/teste-pesquisa.entry.js +1 -1
  41. package/dist/sankhyablocks/{p-bc14f01e.entry.js → p-18fe0469.entry.js} +2 -2
  42. package/dist/sankhyablocks/p-4e2fcfe4.entry.js +1 -0
  43. package/dist/sankhyablocks/{p-1c19b89c.entry.js → p-5e2e9334.entry.js} +1 -1
  44. package/dist/sankhyablocks/{p-8f7b9a85.entry.js → p-7fe9e5c2.entry.js} +1 -1
  45. package/dist/sankhyablocks/p-8650ae26.entry.js +1 -0
  46. package/dist/sankhyablocks/p-a5439706.js +1 -0
  47. package/dist/sankhyablocks/p-c3d20542.entry.js +1 -0
  48. package/dist/sankhyablocks/p-cd1dc099.js +2 -0
  49. package/dist/sankhyablocks/{p-a8305c35.entry.js → p-d25637c9.entry.js} +1 -1
  50. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  51. package/dist/types/components/snk-application/snk-application.d.ts +12 -3
  52. package/dist/types/components.d.ts +48 -5
  53. package/package.json +1 -1
  54. package/react/components.d.ts +1 -0
  55. package/react/components.js +1 -0
  56. package/react/components.js.map +1 -1
  57. package/dist/cjs/snk-form.cjs.entry.js +0 -95
  58. package/dist/cjs/snk-grid.cjs.entry.js +0 -64
  59. package/dist/esm/snk-form.entry.js +0 -91
  60. package/dist/esm/snk-grid.entry.js +0 -60
  61. package/dist/sankhyablocks/p-21c2457b.entry.js +0 -1
  62. package/dist/sankhyablocks/p-560fdf54.entry.js +0 -1
  63. package/dist/sankhyablocks/p-574764bf.js +0 -1
  64. package/dist/sankhyablocks/p-9c225717.entry.js +0 -1
  65. package/dist/sankhyablocks/p-a45dba1a.js +0 -2
@@ -17,7 +17,9 @@ import { SnkErrorHandler } from "./errorhandler/snk-error-handler";
17
17
  import { agGridLicense } from '../../lib/licenses/sankhyalicense.module';
18
18
  export class SnkApplication {
19
19
  constructor() {
20
+ this._authPromises = [];
20
21
  this._duCache = new Map();
22
+ this._duPromises = new Map();
21
23
  this._requestListener = new RequestListenerLoadingBar();
22
24
  }
23
25
  get parameters() {
@@ -36,17 +38,27 @@ export class SnkApplication {
36
38
  return this._resourceID;
37
39
  }
38
40
  get auth() {
39
- return new Promise((resolve, reject) => {
40
- if (this._auth) {
41
- resolve(this._auth);
42
- }
43
- else {
44
- this.authFetcher.getData(this._resourceID).then((authList) => {
45
- this._auth = authList;
46
- resolve(authList);
47
- }).catch(error => reject(error));
48
- }
49
- });
41
+ if (this._auth) {
42
+ return Promise.resolve(this._auth);
43
+ }
44
+ else {
45
+ return new Promise((resolve, reject) => {
46
+ const waitingAuth = this._authPromises.length > 0;
47
+ this._authPromises.push(new PendingPromise(resolve, reject));
48
+ if (!waitingAuth) {
49
+ this.authFetcher.getData(this._resourceID).then((authList) => {
50
+ this._auth = authList;
51
+ while (this._authPromises.length > 0) {
52
+ this._authPromises.pop().resolve(this._auth);
53
+ }
54
+ }).catch(error => {
55
+ while (this._authPromises.length > 0) {
56
+ this._authPromises.pop().reject(error);
57
+ }
58
+ });
59
+ }
60
+ });
61
+ }
50
62
  }
51
63
  /**
52
64
  * Caso o usuário logado seja o SUP.
@@ -214,17 +226,45 @@ export class SnkApplication {
214
226
  async openApp(resourceId, pkObject) {
215
227
  Workspace.openAppActivity(resourceId, pkObject);
216
228
  }
229
+ getDuPromissesStack(dataUnitName) {
230
+ let stack;
231
+ if (dataUnitName) {
232
+ stack = this._duPromises.get(dataUnitName);
233
+ if (!stack) {
234
+ stack = [];
235
+ this._duPromises.set(dataUnitName, stack);
236
+ }
237
+ }
238
+ return stack || [];
239
+ }
217
240
  /**
218
- * Cria o DataUnit a partir do nome da entidade.
241
+ * Cria o DataUnit a partir do nome da entidade. É possível armazená-lo no cache
242
+ * passando o dataUnitName, assim, se mais de uma chamada for feita, o mesmo DataUnit será usado
219
243
  */
220
- async createDataunit(entityName) {
221
- return new Promise(resolve => {
222
- const dataUnit = this.dataUnitFetcher.getDataUnit(entityName, this.resourceID);
223
- dataUnit.loadMetadata().then(() => resolve(dataUnit));
244
+ async createDataunit(entityName, dataUnitName) {
245
+ return new Promise((resolve, reject) => {
246
+ const duPromisses = this.getDuPromissesStack(dataUnitName);
247
+ const waitingDu = duPromisses.length > 0;
248
+ duPromisses.push(new PendingPromise(resolve, reject));
249
+ if (!waitingDu) {
250
+ const dataUnit = this.dataUnitFetcher.getDataUnit(entityName, this.resourceID);
251
+ dataUnit.loadMetadata().then(() => {
252
+ if (dataUnitName) {
253
+ this._duCache.set(dataUnitName, dataUnit);
254
+ }
255
+ while (duPromisses.length > 0) {
256
+ duPromisses.pop().resolve(dataUnit);
257
+ }
258
+ }).catch(reason => {
259
+ while (duPromisses.length > 0) {
260
+ duPromisses.pop().reject(reason);
261
+ }
262
+ });
263
+ }
224
264
  });
225
265
  }
226
266
  /**
227
- * Cria e armazena o DataUnit em um cache
267
+ * Obtem um DataUnit do cache ou cria um caso ainda não tenha sido criado.
228
268
  */
229
269
  async getDataUnit(entityName, dataUnitName) {
230
270
  return new Promise((resolve, reject) => {
@@ -233,10 +273,7 @@ export class SnkApplication {
233
273
  resolve(dataUnit);
234
274
  }
235
275
  else {
236
- this.createDataunit(entityName).then(dataUnit => {
237
- if (dataUnitName) {
238
- this._duCache.set(dataUnitName, dataUnit);
239
- }
276
+ this.createDataunit(entityName, dataUnitName).then(dataUnit => {
240
277
  resolve(dataUnit);
241
278
  }).catch(reason => reject(reason));
242
279
  }
@@ -410,9 +447,9 @@ export class SnkApplication {
410
447
  });
411
448
  ApplicationContext.setContextValue("__EZUI__GRID_LICENSE__", agGridLicense);
412
449
  ErrorTracking.init();
413
- ApplicationContext.setContextValue("__SNK__APPLICATION__", this);
414
450
  }
415
451
  connectedCallback() {
452
+ ApplicationContext.setContextValue("__SNK__APPLICATION__", this);
416
453
  DataFetcher.addRequestListener(this._requestListener);
417
454
  }
418
455
  disconnectedCallback() {
@@ -769,10 +806,13 @@ export class SnkApplication {
769
806
  },
770
807
  "createDataunit": {
771
808
  "complexType": {
772
- "signature": "(entityName: string) => Promise<DataUnit>",
809
+ "signature": "(entityName: string, dataUnitName?: string) => Promise<DataUnit>",
773
810
  "parameters": [{
774
811
  "tags": [],
775
812
  "text": ""
813
+ }, {
814
+ "tags": [],
815
+ "text": ""
776
816
  }],
777
817
  "references": {
778
818
  "Promise": {
@@ -786,7 +826,7 @@ export class SnkApplication {
786
826
  "return": "Promise<DataUnit>"
787
827
  },
788
828
  "docs": {
789
- "text": "Cria o DataUnit a partir do nome da entidade.",
829
+ "text": "Cria o DataUnit a partir do nome da entidade. \u00C9 poss\u00EDvel armazen\u00E1-lo no cache\npassando o dataUnitName, assim, se mais de uma chamada for feita, o mesmo DataUnit ser\u00E1 usado",
790
830
  "tags": []
791
831
  }
792
832
  },
@@ -812,7 +852,7 @@ export class SnkApplication {
812
852
  "return": "Promise<DataUnit>"
813
853
  },
814
854
  "docs": {
815
- "text": "Cria e armazena o DataUnit em um cache",
855
+ "text": "Obtem um DataUnit do cache ou cria um caso ainda n\u00E3o tenha sido criado.",
816
856
  "tags": []
817
857
  }
818
858
  },
@@ -1113,3 +1153,9 @@ class RequestListenerLoadingBar {
1113
1153
  }
1114
1154
  ;
1115
1155
  }
1156
+ class PendingPromise {
1157
+ constructor(resolve, reject) {
1158
+ this.resolve = resolve;
1159
+ this.reject = reject;
1160
+ }
1161
+ }
@@ -0,0 +1,5 @@
1
+ :host {
2
+ display: flex;
3
+ height: 100%;
4
+ width: 100%;
5
+ }
@@ -0,0 +1,149 @@
1
+ import { Component, h, Prop, Element, State } from '@stencil/core';
2
+ const GRID_MODE = 0;
3
+ const FORM_MODE = 1;
4
+ export class SnkCrud {
5
+ async gridToForm(keepFormMode = false) {
6
+ this._backToGrid = !keepFormMode && await this._viewStack.getSelectedIndex() === GRID_MODE;
7
+ this._viewStack.show(FORM_MODE);
8
+ }
9
+ async executeAction(act) {
10
+ if (act === "GRID_MODE") {
11
+ this._viewStack.show(GRID_MODE);
12
+ }
13
+ else if (act === "FORM_MODE" || act === "UPDATE") {
14
+ this.gridToForm(act !== "UPDATE");
15
+ }
16
+ }
17
+ insertionModeHandler() {
18
+ this.gridToForm();
19
+ }
20
+ cancelHandler() {
21
+ if (this._backToGrid) {
22
+ this._viewStack.show(GRID_MODE);
23
+ }
24
+ }
25
+ componentWillLoad() {
26
+ let parent = this._element.parentElement;
27
+ while (parent) {
28
+ if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
29
+ this._snkDataUnit = parent;
30
+ this._snkDataUnit.addEventListener("insertionMode", () => this.insertionModeHandler());
31
+ this._snkDataUnit.addEventListener("cancelEdition", () => this.cancelHandler());
32
+ this._dataUnit = this._snkDataUnit.dataUnit;
33
+ this._dataState = this._snkDataUnit.dataState;
34
+ if (!this._dataUnit) {
35
+ this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
36
+ this._dataUnit = evt.detail;
37
+ });
38
+ }
39
+ this._snkDataUnit.addEventListener("dataStateChange", (evt) => {
40
+ this._dataState = evt.detail;
41
+ });
42
+ break;
43
+ }
44
+ parent = parent.parentElement;
45
+ }
46
+ }
47
+ render() {
48
+ return (h("ez-view-stack", { ref: (ref) => this._viewStack = ref },
49
+ h("stack-item", null,
50
+ h("snk-grid", { configName: this.configName, onGridDoubleClick: () => this.gridToForm(true), onActionClick: evt => this.executeAction(evt.detail), actionsList: this.actionsList },
51
+ h("slot", null))),
52
+ h("stack-item", null,
53
+ h("snk-form", { formTitle: this.formTitle, configName: this.configName, actionsList: this.actionsList, onExit: () => this._viewStack.show(GRID_MODE), recordsValidator: this.recordsValidator, onActionClick: evt => this.executeAction(evt.detail) }))));
54
+ }
55
+ static get is() { return "snk-crud"; }
56
+ static get encapsulation() { return "scoped"; }
57
+ static get originalStyleUrls() { return {
58
+ "$": ["snk-crud.css"]
59
+ }; }
60
+ static get styleUrls() { return {
61
+ "$": ["snk-crud.css"]
62
+ }; }
63
+ static get properties() { return {
64
+ "configName": {
65
+ "type": "string",
66
+ "mutable": false,
67
+ "complexType": {
68
+ "original": "string",
69
+ "resolved": "string",
70
+ "references": {}
71
+ },
72
+ "required": false,
73
+ "optional": false,
74
+ "docs": {
75
+ "tags": [],
76
+ "text": ""
77
+ },
78
+ "attribute": "config-name",
79
+ "reflect": false
80
+ },
81
+ "formTitle": {
82
+ "type": "string",
83
+ "mutable": false,
84
+ "complexType": {
85
+ "original": "string",
86
+ "resolved": "string",
87
+ "references": {}
88
+ },
89
+ "required": false,
90
+ "optional": false,
91
+ "docs": {
92
+ "tags": [],
93
+ "text": ""
94
+ },
95
+ "attribute": "form-title",
96
+ "reflect": false
97
+ },
98
+ "actionsList": {
99
+ "type": "unknown",
100
+ "mutable": false,
101
+ "complexType": {
102
+ "original": "Array<Action>",
103
+ "resolved": "Action[]",
104
+ "references": {
105
+ "Array": {
106
+ "location": "global"
107
+ },
108
+ "Action": {
109
+ "location": "import",
110
+ "path": "../snk-taskbar/snk-taskbar"
111
+ }
112
+ }
113
+ },
114
+ "required": false,
115
+ "optional": false,
116
+ "docs": {
117
+ "tags": [],
118
+ "text": ""
119
+ }
120
+ },
121
+ "recordsValidator": {
122
+ "type": "any",
123
+ "mutable": false,
124
+ "complexType": {
125
+ "original": "RecordValidator",
126
+ "resolved": "RecordValidator",
127
+ "references": {
128
+ "RecordValidator": {
129
+ "location": "import",
130
+ "path": "@sankhyalabs/ezui/dist/types/components/ez-form/ez-form"
131
+ }
132
+ }
133
+ },
134
+ "required": false,
135
+ "optional": false,
136
+ "docs": {
137
+ "tags": [],
138
+ "text": "Validador respons\u00E1vel por checar a integridade das informa\u00E7\u00F5es do registro"
139
+ },
140
+ "attribute": "records-validator",
141
+ "reflect": false
142
+ }
143
+ }; }
144
+ static get states() { return {
145
+ "_dataUnit": {},
146
+ "_dataState": {}
147
+ }; }
148
+ static get elementRef() { return "_element"; }
149
+ }
@@ -23,12 +23,16 @@ export class SnkDataUnit {
23
23
  if (action.type === Action.RECORDS_ADDED || action.type === Action.RECORDS_COPIED) {
24
24
  this.insertionMode.emit();
25
25
  }
26
+ if (action.type === Action.EDITION_CANCELED) {
27
+ this.cancelEdition.emit();
28
+ }
26
29
  const duState = {
27
30
  insertionMode: false,
28
31
  hasNext: this.dataUnit.hasNext(),
29
32
  hasPrevious: this.dataUnit.hasPrevious(),
30
33
  copyMode: false,
31
34
  isDirty: this.dataUnit.isDirty(),
35
+ hasDirtyRecords: this.dataUnit.hasDirtyRecords(),
32
36
  selectedRecords: this.dataUnit.getSelectedRecords()
33
37
  };
34
38
  this.dataUnit.records.forEach(r => {
@@ -108,8 +112,13 @@ export class SnkDataUnit {
108
112
  }
109
113
  break;
110
114
  case Action.EDITION_CANCELED:
111
- ApplicationUtils.confirm(this.i18n("components.warning"), this.i18n("components.confirmCancelEdition"))
112
- .then((result) => resolve(result ? action : undefined));
115
+ if (this.dataState.hasDirtyRecords) {
116
+ ApplicationUtils.confirm(this.i18n("components.warning"), this.i18n("components.confirmCancelEdition"))
117
+ .then((result) => resolve(result ? action : undefined));
118
+ }
119
+ else {
120
+ resolve(action);
121
+ }
113
122
  break;
114
123
  case Action.REMOVING_RECORDS:
115
124
  let msg = undefined;
@@ -177,7 +186,7 @@ export class SnkDataUnit {
177
186
  //---------------------------------------------
178
187
  // Lifecycle web component
179
188
  //---------------------------------------------
180
- componentDidRender() {
189
+ componentWillLoad() {
181
190
  this.loadDataUnit();
182
191
  }
183
192
  render() {
@@ -422,6 +431,21 @@ export class SnkDataUnit {
422
431
  "resolved": "void",
423
432
  "references": {}
424
433
  }
434
+ }, {
435
+ "method": "cancelEdition",
436
+ "name": "cancelEdition",
437
+ "bubbles": true,
438
+ "cancelable": true,
439
+ "composed": true,
440
+ "docs": {
441
+ "tags": [],
442
+ "text": "Disparado quando se cancela uma insers\u00E3o/c\u00F3pia"
443
+ },
444
+ "complexType": {
445
+ "original": "void",
446
+ "resolved": "void",
447
+ "references": {}
448
+ }
425
449
  }]; }
426
450
  static get methods() { return {
427
451
  "getDataUnit": {
@@ -32,16 +32,47 @@ export class SnkForm {
32
32
  }
33
33
  return disabled;
34
34
  }
35
+ loadInsertionConfig() {
36
+ if (this._dataUnit && this._configLoaded) {
37
+ this._insertionFormConfig = this._editionFormConfig.filter(fieldCfg => {
38
+ const def = this._dataUnit.getField(fieldCfg.name);
39
+ if (def === null || def === void 0 ? void 0 : def.readOnly) {
40
+ return false;
41
+ }
42
+ return true;
43
+ });
44
+ }
45
+ }
46
+ i18n(key) {
47
+ const pt_br = {
48
+ "components.back": "Voltar"
49
+ };
50
+ return pt_br[key];
51
+ }
35
52
  componentWillLoad() {
53
+ const snkApplication = ApplicationContext.getContextValue("__SNK__APPLICATION__");
54
+ if (snkApplication) {
55
+ snkApplication.loadFormConfig(this.configName).then(cfg => {
56
+ this._configLoaded = true;
57
+ this._editionFormConfig = cfg;
58
+ this.loadInsertionConfig();
59
+ });
60
+ //Forçamos a carga dos acessos pra aproveitar a request inicial.
61
+ snkApplication.getAllAccess();
62
+ }
36
63
  let parent = this._element.parentElement;
37
64
  while (parent) {
38
65
  if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
39
66
  this._snkDataUnit = parent;
40
67
  this._dataUnit = this._snkDataUnit.dataUnit;
41
68
  this._dataState = this._snkDataUnit.dataState;
42
- if (!this._dataUnit) {
69
+ if (this._dataUnit) {
70
+ this.loadInsertionConfig();
71
+ }
72
+ else {
43
73
  this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
44
74
  this._dataUnit = evt.detail;
75
+ this.loadInsertionConfig();
45
76
  });
46
77
  }
47
78
  this._snkDataUnit.addEventListener("dataStateChange", (evt) => {
@@ -52,24 +83,6 @@ export class SnkForm {
52
83
  parent = parent.parentElement;
53
84
  }
54
85
  }
55
- componentWillRender() {
56
- if (this._dataUnit && !this._configLoaded) {
57
- const snkApplication = ApplicationContext.getContextValue("__SNK__APPLICATION__");
58
- if (snkApplication) {
59
- snkApplication.loadFormConfig(this.configName).then(cfg => {
60
- this._configLoaded = true;
61
- this._editionFormConfig = cfg;
62
- this._insertionFormConfig = cfg.filter(fieldCfg => {
63
- const def = this._dataUnit.getField(fieldCfg.name);
64
- if (def === null || def === void 0 ? void 0 : def.readOnly) {
65
- return false;
66
- }
67
- return true;
68
- });
69
- });
70
- }
71
- }
72
- }
73
86
  render() {
74
87
  if (!this._configLoaded || !this._dataUnit || !this._dataState) {
75
88
  return undefined;
@@ -77,7 +90,7 @@ export class SnkForm {
77
90
  return (h("section", { class: "ez-padding--large" },
78
91
  h("div", { class: "ez-row ez-padding-bottom--medium" },
79
92
  h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6", key: "formHeader" },
80
- h("ez-button", { mode: "icon", iconName: "arrow_back", class: "ez-padding-right--medium", size: "small", onClick: () => this.exitForm() }),
93
+ h("ez-button", { title: this.i18n("components.back"), mode: "icon", iconName: "arrow_back", class: "ez-padding-right--medium", size: "small", onClick: () => this.exitForm() }),
81
94
  h("h1", { class: "ez-title ez-title--primary ez-title--xlarge ez-align--middle" }, this.formTitle)),
82
95
  h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6 ez-align--right" },
83
96
  h("snk-taskbar", { key: "formTaskbar", buttons: this._dataState.isDirty ? "CANCEL,SAVE" : "PREVIOUS,NEXT,DIVIDER,CLONE,REMOVE,MORE_OPTIONS,DIVIDER,GRID_MODE,INSERT", primaryButton: this._dataState.isDirty ? "SAVE" : "INSERT", disabledButtons: this.getDisabledButtons(), actionsList: this.actionsList, dataUnit: this._dataUnit }))),
@@ -85,7 +98,7 @@ export class SnkForm {
85
98
  h("section", null,
86
99
  h("div", { class: "ez-row" },
87
100
  h("div", { class: "ez-col ez-col--sd-12" },
88
- h("ez-form", { key: "ezForm" + this._snkDataUnit.entityName, dataUnit: this._dataUnit, config: this.getFormConfig() }))))));
101
+ h("ez-form", { key: "ezForm" + this._snkDataUnit.entityName, dataUnit: this._dataUnit, config: this.getFormConfig(), recordsValidator: this.recordsValidator }))))));
89
102
  }
90
103
  static get is() { return "snk-form"; }
91
104
  static get encapsulation() { return "scoped"; }
@@ -130,6 +143,28 @@ export class SnkForm {
130
143
  "attribute": "config-name",
131
144
  "reflect": false
132
145
  },
146
+ "recordsValidator": {
147
+ "type": "any",
148
+ "mutable": false,
149
+ "complexType": {
150
+ "original": "RecordValidator",
151
+ "resolved": "RecordValidator",
152
+ "references": {
153
+ "RecordValidator": {
154
+ "location": "import",
155
+ "path": "@sankhyalabs/ezui/dist/types/components/ez-form/ez-form"
156
+ }
157
+ }
158
+ },
159
+ "required": false,
160
+ "optional": false,
161
+ "docs": {
162
+ "tags": [],
163
+ "text": "Validador respons\u00E1vel por checar a integridade das informa\u00E7\u00F5es do registro"
164
+ },
165
+ "attribute": "records-validator",
166
+ "reflect": false
167
+ },
133
168
  "actionsList": {
134
169
  "type": "unknown",
135
170
  "mutable": false,
@@ -157,7 +192,9 @@ export class SnkForm {
157
192
  static get states() { return {
158
193
  "_dataUnit": {},
159
194
  "_configLoaded": {},
160
- "_dataState": {}
195
+ "_dataState": {},
196
+ "_editionFormConfig": {},
197
+ "_insertionFormConfig": {}
161
198
  }; }
162
199
  static get events() { return [{
163
200
  "method": "exit",
@@ -10,7 +10,22 @@ export class SnkGrid {
10
10
  this._grid.openGridConfig();
11
11
  }
12
12
  }
13
+ saveConfig(config) {
14
+ const snkApplication = ApplicationContext.getContextValue("__SNK__APPLICATION__");
15
+ if (snkApplication) {
16
+ snkApplication.saveGridConfig(config);
17
+ }
18
+ }
13
19
  componentWillLoad() {
20
+ const snkApplication = ApplicationContext.getContextValue("__SNK__APPLICATION__");
21
+ if (snkApplication) {
22
+ snkApplication.loadGridConfig(this.configName).then(cfg => {
23
+ this._gridConfig = cfg;
24
+ this._configLoaded = true;
25
+ });
26
+ //Forçamos a carga dos acessos pra aproveitar a request inicial.
27
+ snkApplication.getAllAccess();
28
+ }
14
29
  let parent = this._element.parentElement;
15
30
  while (parent) {
16
31
  if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
@@ -29,17 +44,6 @@ export class SnkGrid {
29
44
  parent = parent.parentElement;
30
45
  }
31
46
  }
32
- componentWillRender() {
33
- if (this._dataUnit && !this._configLoaded) {
34
- const snkApplication = ApplicationContext.getContextValue("__SNK__APPLICATION__");
35
- if (snkApplication) {
36
- snkApplication.loadGridConfig(this.configName).then(cfg => {
37
- this._gridConfig = cfg;
38
- this._configLoaded = true;
39
- });
40
- }
41
- }
42
- }
43
47
  render() {
44
48
  if (!this._configLoaded || !this._dataUnit) {
45
49
  return undefined;
@@ -50,7 +54,7 @@ export class SnkGrid {
50
54
  h("slot", null)),
51
55
  h("div", { class: "ez-col ez-col--sd-3 ez-col--tb-3 ez-align--right" },
52
56
  h("snk-taskbar", { onActionClick: evt => this.actionClickHandler(evt), key: "topTaskbar", dataUnit: this._dataUnit, buttons: "FORM_MODE,CONFIG_GRID,INSERT", primaryButton: "INSERT" }))),
53
- h("ez-grid", { ref: ref => this._grid = ref, dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig },
57
+ h("ez-grid", { ref: ref => this._grid = ref, dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig, onConfigChange: evt => { this.saveConfig(evt.detail); }, onEzDoubleClick: () => this.gridDoubleClick.emit() },
54
58
  h("snk-taskbar", { dataUnit: this._dataUnit, buttons: this.getHeaderButtons(), slot: "leftButtons", actionsList: this.actionsList }))));
55
59
  }
56
60
  static get is() { return "snk-grid"; }
@@ -106,7 +110,8 @@ export class SnkGrid {
106
110
  static get states() { return {
107
111
  "_dataUnit": {},
108
112
  "_configLoaded": {},
109
- "_dataState": {}
113
+ "_dataState": {},
114
+ "_gridConfig": {}
110
115
  }; }
111
116
  static get events() { return [{
112
117
  "method": "actionClick",
@@ -123,6 +128,21 @@ export class SnkGrid {
123
128
  "resolved": "string",
124
129
  "references": {}
125
130
  }
131
+ }, {
132
+ "method": "gridDoubleClick",
133
+ "name": "gridDoubleClick",
134
+ "bubbles": true,
135
+ "cancelable": true,
136
+ "composed": true,
137
+ "docs": {
138
+ "tags": [],
139
+ "text": "Emitido sempre que houver duplo click na grade"
140
+ },
141
+ "complexType": {
142
+ "original": "void",
143
+ "resolved": "void",
144
+ "references": {}
145
+ }
126
146
  }]; }
127
147
  static get elementRef() { return "_element"; }
128
148
  }
@@ -51,7 +51,7 @@ export const buildElem = (element, className, getTitle, action, isEnabled, actio
51
51
  case TaskbarElement.CONFIG_GRID:
52
52
  return iconButton("settings-inverted", element, className, getTitle, action, isEnabled);
53
53
  case TaskbarElement.MORE_OPTIONS:
54
- return h("ez-actions-button", { size: "small", class: className, enabled: isEnabled(element), onEzAction: (evt) => action(evt.detail.value), actions: actions });
54
+ return actions && actions.length > 0 ? h("ez-actions-button", { title: getTitle(element), size: "small", class: className, enabled: isEnabled(element), onEzAction: (evt) => action(evt.detail.value), actions: actions }) : undefined;
55
55
  case TaskbarElement.DIVIDER:
56
56
  return h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-horizontal--medium" });
57
57
  }