@sankhyalabs/sankhyablocks 5.4.1 → 5.4.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-data-exporter.cjs.entry.js +1 -1
- package/dist/cjs/{snk-data-unit-1a9d18aa.js → snk-data-unit-aa613f3b.js} +14 -8
- package/dist/cjs/snk-data-unit.cjs.entry.js +1 -1
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +16 -9
- package/dist/components/snk-data-unit2.js +14 -8
- package/dist/esm/snk-data-exporter.entry.js +1 -1
- package/dist/esm/{snk-data-unit-1ac2b0c3.js → snk-data-unit-5ed93c0e.js} +14 -8
- package/dist/esm/snk-data-unit.entry.js +1 -1
- package/dist/sankhyablocks/p-94e6fc90.entry.js +1 -0
- package/dist/sankhyablocks/{p-968af3c0.entry.js → p-9bfa3cfb.entry.js} +1 -1
- package/dist/sankhyablocks/p-bc281de0.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +2 -0
- package/dist/types/components.d.ts +2 -2
- package/package.json +1 -1
- package/dist/sankhyablocks/p-2da737f2.entry.js +0 -1
- package/dist/sankhyablocks/p-95a80f3f.js +0 -1
@@ -8,7 +8,7 @@ const utils = require('@sankhyalabs/ezui/dist/collection/utils');
|
|
8
8
|
const index = require('./index-f400b1d6.js');
|
9
9
|
const constants = require('./constants-ae0ed870.js');
|
10
10
|
const DataFetcher = require('./DataFetcher-a9d0228f.js');
|
11
|
-
const snkDataUnit = require('./snk-data-unit-
|
11
|
+
const snkDataUnit = require('./snk-data-unit-aa613f3b.js');
|
12
12
|
require('./_commonjsHelpers-537d719a.js');
|
13
13
|
require('./SnkMessageBuilder-115e8a80.js');
|
14
14
|
|
@@ -16,6 +16,7 @@ const SnkDataUnit = class {
|
|
16
16
|
this.insertionMode = index.createEvent(this, "insertionMode", 3);
|
17
17
|
this.cancelEdition = index.createEvent(this, "cancelEdition", 3);
|
18
18
|
this._onDataUnitResolve = [];
|
19
|
+
this._openedAlert = false;
|
19
20
|
this._dataUnitObserver = (action) => {
|
20
21
|
var _a, _b;
|
21
22
|
const duState = this.buildDataState();
|
@@ -180,13 +181,15 @@ const SnkDataUnit = class {
|
|
180
181
|
break;
|
181
182
|
case core.Action.DATA_CHANGED:
|
182
183
|
case core.Action.CHANGING_DATA:
|
183
|
-
if (this.isAllowed("UPDATE"))
|
184
|
-
resolve(action);
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
184
|
+
if (this.isAllowed("UPDATE"))
|
185
|
+
return resolve(action);
|
186
|
+
if (this._openedAlert)
|
187
|
+
return this.dataUnit.cancelEdition();
|
188
|
+
this._openedAlert = true;
|
189
|
+
this.dataUnit.cancelEdition();
|
190
|
+
utils.ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate")).then(() => {
|
191
|
+
this._openedAlert = false;
|
192
|
+
});
|
190
193
|
break;
|
191
194
|
case core.Action.SAVING_DATA:
|
192
195
|
if (this.beforeSave) {
|
@@ -275,8 +278,10 @@ const SnkDataUnit = class {
|
|
275
278
|
}
|
276
279
|
buildDataState() {
|
277
280
|
const selectionInfo = this.dataUnit.getSelectionInfo();
|
281
|
+
const isStartingInsertionMode = (this.dataUnit.hasDirtyRecords() || this.dataUnit.hasWaitingChanges()) && (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isEmpty());
|
278
282
|
return new DataStateImpl({
|
279
283
|
insertionMode: this.dataUnit.hasNewRecord(),
|
284
|
+
isStartingInsertionMode,
|
280
285
|
hasNext: this.dataUnit.hasNext(),
|
281
286
|
hasPrevious: this.dataUnit.hasPrevious(),
|
282
287
|
copyMode: this.dataUnit.hasCopiedRecord(),
|
@@ -308,7 +313,7 @@ const SnkDataUnit = class {
|
|
308
313
|
if (this.dataState.copyMode) {
|
309
314
|
return SnkMessageBuilder.OperationMap.CLONE;
|
310
315
|
}
|
311
|
-
if (this.dataState.insertionMode) {
|
316
|
+
if (this.dataState.insertionMode || this.dataState.isStartingInsertionMode) {
|
312
317
|
return SnkMessageBuilder.OperationMap.INSERT;
|
313
318
|
}
|
314
319
|
if (this.dataState.isDirty) {
|
@@ -415,6 +420,7 @@ class DataStateImpl {
|
|
415
420
|
constructor(datastate) {
|
416
421
|
this.copyMode = datastate.copyMode;
|
417
422
|
this.insertionMode = datastate.insertionMode;
|
423
|
+
this.isStartingInsertionMode = datastate.isStartingInsertionMode;
|
418
424
|
this.isDirty = datastate.isDirty;
|
419
425
|
this.hasDirtyRecords = datastate.hasDirtyRecords;
|
420
426
|
this.hasNext = datastate.hasNext;
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
const snkDataUnit = require('./snk-data-unit-
|
5
|
+
const snkDataUnit = require('./snk-data-unit-aa613f3b.js');
|
6
6
|
require('./index-21bd01e1.js');
|
7
7
|
require('@sankhyalabs/core');
|
8
8
|
require('@sankhyalabs/ezui/dist/collection/utils');
|
@@ -5,6 +5,7 @@ import { OperationMap, SnkMessageBuilder } from '../../lib/message/SnkMessageBui
|
|
5
5
|
export class SnkDataUnit {
|
6
6
|
constructor() {
|
7
7
|
this._onDataUnitResolve = [];
|
8
|
+
this._openedAlert = false;
|
8
9
|
this._dataUnitObserver = (action) => {
|
9
10
|
var _a, _b;
|
10
11
|
const duState = this.buildDataState();
|
@@ -169,13 +170,16 @@ export class SnkDataUnit {
|
|
169
170
|
break;
|
170
171
|
case Action.DATA_CHANGED:
|
171
172
|
case Action.CHANGING_DATA:
|
172
|
-
if (this.isAllowed("UPDATE"))
|
173
|
-
resolve(action);
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
173
|
+
if (this.isAllowed("UPDATE"))
|
174
|
+
return resolve(action);
|
175
|
+
if (this._openedAlert)
|
176
|
+
return this.dataUnit.cancelEdition();
|
177
|
+
;
|
178
|
+
this._openedAlert = true;
|
179
|
+
this.dataUnit.cancelEdition();
|
180
|
+
ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate")).then(() => {
|
181
|
+
this._openedAlert = false;
|
182
|
+
});
|
179
183
|
break;
|
180
184
|
case Action.SAVING_DATA:
|
181
185
|
if (this.beforeSave) {
|
@@ -264,8 +268,10 @@ export class SnkDataUnit {
|
|
264
268
|
}
|
265
269
|
buildDataState() {
|
266
270
|
const selectionInfo = this.dataUnit.getSelectionInfo();
|
271
|
+
const isStartingInsertionMode = (this.dataUnit.hasDirtyRecords() || this.dataUnit.hasWaitingChanges()) && (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isEmpty());
|
267
272
|
return new DataStateImpl({
|
268
273
|
insertionMode: this.dataUnit.hasNewRecord(),
|
274
|
+
isStartingInsertionMode,
|
269
275
|
hasNext: this.dataUnit.hasNext(),
|
270
276
|
hasPrevious: this.dataUnit.hasPrevious(),
|
271
277
|
copyMode: this.dataUnit.hasCopiedRecord(),
|
@@ -297,7 +303,7 @@ export class SnkDataUnit {
|
|
297
303
|
if (this.dataState.copyMode) {
|
298
304
|
return OperationMap.CLONE;
|
299
305
|
}
|
300
|
-
if (this.dataState.insertionMode) {
|
306
|
+
if (this.dataState.insertionMode || this.dataState.isStartingInsertionMode) {
|
301
307
|
return OperationMap.INSERT;
|
302
308
|
}
|
303
309
|
if (this.dataState.isDirty) {
|
@@ -455,7 +461,7 @@ export class SnkDataUnit {
|
|
455
461
|
"optional": false,
|
456
462
|
"docs": {
|
457
463
|
"tags": [],
|
458
|
-
"text": "Usado para criar o dataUnit uma \u00FAnica vez
|
464
|
+
"text": "Usado para criar o dataUnit uma \u00FAnica vez.\nSe omitido, ser\u00E1 usado o pr\u00F3prio nome da entidade."
|
459
465
|
},
|
460
466
|
"attribute": "data-unit-name",
|
461
467
|
"reflect": false
|
@@ -733,6 +739,7 @@ class DataStateImpl {
|
|
733
739
|
constructor(datastate) {
|
734
740
|
this.copyMode = datastate.copyMode;
|
735
741
|
this.insertionMode = datastate.insertionMode;
|
742
|
+
this.isStartingInsertionMode = datastate.isStartingInsertionMode;
|
736
743
|
this.isDirty = datastate.isDirty;
|
737
744
|
this.hasDirtyRecords = datastate.hasDirtyRecords;
|
738
745
|
this.hasNext = datastate.hasNext;
|
@@ -15,6 +15,7 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
15
15
|
this.insertionMode = createEvent(this, "insertionMode", 3);
|
16
16
|
this.cancelEdition = createEvent(this, "cancelEdition", 3);
|
17
17
|
this._onDataUnitResolve = [];
|
18
|
+
this._openedAlert = false;
|
18
19
|
this._dataUnitObserver = (action) => {
|
19
20
|
var _a, _b;
|
20
21
|
const duState = this.buildDataState();
|
@@ -179,13 +180,15 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
179
180
|
break;
|
180
181
|
case Action.DATA_CHANGED:
|
181
182
|
case Action.CHANGING_DATA:
|
182
|
-
if (this.isAllowed("UPDATE"))
|
183
|
-
resolve(action);
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
183
|
+
if (this.isAllowed("UPDATE"))
|
184
|
+
return resolve(action);
|
185
|
+
if (this._openedAlert)
|
186
|
+
return this.dataUnit.cancelEdition();
|
187
|
+
this._openedAlert = true;
|
188
|
+
this.dataUnit.cancelEdition();
|
189
|
+
ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate")).then(() => {
|
190
|
+
this._openedAlert = false;
|
191
|
+
});
|
189
192
|
break;
|
190
193
|
case Action.SAVING_DATA:
|
191
194
|
if (this.beforeSave) {
|
@@ -274,8 +277,10 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
274
277
|
}
|
275
278
|
buildDataState() {
|
276
279
|
const selectionInfo = this.dataUnit.getSelectionInfo();
|
280
|
+
const isStartingInsertionMode = (this.dataUnit.hasDirtyRecords() || this.dataUnit.hasWaitingChanges()) && (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isEmpty());
|
277
281
|
return new DataStateImpl({
|
278
282
|
insertionMode: this.dataUnit.hasNewRecord(),
|
283
|
+
isStartingInsertionMode,
|
279
284
|
hasNext: this.dataUnit.hasNext(),
|
280
285
|
hasPrevious: this.dataUnit.hasPrevious(),
|
281
286
|
copyMode: this.dataUnit.hasCopiedRecord(),
|
@@ -307,7 +312,7 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
307
312
|
if (this.dataState.copyMode) {
|
308
313
|
return OperationMap.CLONE;
|
309
314
|
}
|
310
|
-
if (this.dataState.insertionMode) {
|
315
|
+
if (this.dataState.insertionMode || this.dataState.isStartingInsertionMode) {
|
311
316
|
return OperationMap.INSERT;
|
312
317
|
}
|
313
318
|
if (this.dataState.isDirty) {
|
@@ -426,6 +431,7 @@ class DataStateImpl {
|
|
426
431
|
constructor(datastate) {
|
427
432
|
this.copyMode = datastate.copyMode;
|
428
433
|
this.insertionMode = datastate.insertionMode;
|
434
|
+
this.isStartingInsertionMode = datastate.isStartingInsertionMode;
|
429
435
|
this.isDirty = datastate.isDirty;
|
430
436
|
this.hasDirtyRecords = datastate.hasDirtyRecords;
|
431
437
|
this.hasNext = datastate.hasNext;
|
@@ -4,7 +4,7 @@ import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/
|
|
4
4
|
import { D as DataExporterOption, a as DataExporterFormat, b as DataExporterType } from './index-6519a79e.js';
|
5
5
|
import { d as KEY_PORT_EXPORT, W as WEB_CONNECTION, R as REPORT_LAUNCHER_RESOURCE_ID } from './constants-15617e7d.js';
|
6
6
|
import { D as DataFetcher } from './DataFetcher-b3d8b2d5.js';
|
7
|
-
import { S as SnkDataUnit } from './snk-data-unit-
|
7
|
+
import { S as SnkDataUnit } from './snk-data-unit-5ed93c0e.js';
|
8
8
|
import './_commonjsHelpers-9943807e.js';
|
9
9
|
import './SnkMessageBuilder-a15d22f8.js';
|
10
10
|
|
@@ -14,6 +14,7 @@ const SnkDataUnit = class {
|
|
14
14
|
this.insertionMode = createEvent(this, "insertionMode", 3);
|
15
15
|
this.cancelEdition = createEvent(this, "cancelEdition", 3);
|
16
16
|
this._onDataUnitResolve = [];
|
17
|
+
this._openedAlert = false;
|
17
18
|
this._dataUnitObserver = (action) => {
|
18
19
|
var _a, _b;
|
19
20
|
const duState = this.buildDataState();
|
@@ -178,13 +179,15 @@ const SnkDataUnit = class {
|
|
178
179
|
break;
|
179
180
|
case Action.DATA_CHANGED:
|
180
181
|
case Action.CHANGING_DATA:
|
181
|
-
if (this.isAllowed("UPDATE"))
|
182
|
-
resolve(action);
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
182
|
+
if (this.isAllowed("UPDATE"))
|
183
|
+
return resolve(action);
|
184
|
+
if (this._openedAlert)
|
185
|
+
return this.dataUnit.cancelEdition();
|
186
|
+
this._openedAlert = true;
|
187
|
+
this.dataUnit.cancelEdition();
|
188
|
+
ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate")).then(() => {
|
189
|
+
this._openedAlert = false;
|
190
|
+
});
|
188
191
|
break;
|
189
192
|
case Action.SAVING_DATA:
|
190
193
|
if (this.beforeSave) {
|
@@ -273,8 +276,10 @@ const SnkDataUnit = class {
|
|
273
276
|
}
|
274
277
|
buildDataState() {
|
275
278
|
const selectionInfo = this.dataUnit.getSelectionInfo();
|
279
|
+
const isStartingInsertionMode = (this.dataUnit.hasDirtyRecords() || this.dataUnit.hasWaitingChanges()) && (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isEmpty());
|
276
280
|
return new DataStateImpl({
|
277
281
|
insertionMode: this.dataUnit.hasNewRecord(),
|
282
|
+
isStartingInsertionMode,
|
278
283
|
hasNext: this.dataUnit.hasNext(),
|
279
284
|
hasPrevious: this.dataUnit.hasPrevious(),
|
280
285
|
copyMode: this.dataUnit.hasCopiedRecord(),
|
@@ -306,7 +311,7 @@ const SnkDataUnit = class {
|
|
306
311
|
if (this.dataState.copyMode) {
|
307
312
|
return OperationMap.CLONE;
|
308
313
|
}
|
309
|
-
if (this.dataState.insertionMode) {
|
314
|
+
if (this.dataState.insertionMode || this.dataState.isStartingInsertionMode) {
|
310
315
|
return OperationMap.INSERT;
|
311
316
|
}
|
312
317
|
if (this.dataState.isDirty) {
|
@@ -413,6 +418,7 @@ class DataStateImpl {
|
|
413
418
|
constructor(datastate) {
|
414
419
|
this.copyMode = datastate.copyMode;
|
415
420
|
this.insertionMode = datastate.insertionMode;
|
421
|
+
this.isStartingInsertionMode = datastate.isStartingInsertionMode;
|
416
422
|
this.isDirty = datastate.isDirty;
|
417
423
|
this.hasDirtyRecords = datastate.hasDirtyRecords;
|
418
424
|
this.hasNext = datastate.hasNext;
|
@@ -0,0 +1 @@
|
|
1
|
+
export{S as snk_data_unit}from"./p-bc281de0.js";import"./p-b9667fbe.js";import"@sankhyalabs/core";import"@sankhyalabs/ezui/dist/collection/utils";import"./p-2ecf14ff.js";
|
@@ -1 +1 @@
|
|
1
|
-
import{r as t,h as e,H as i,g as s}from"./p-b9667fbe.js";import{ObjectUtils as o,ApplicationContext as r,ElementIDUtils as n}from"@sankhyalabs/core";import{ApplicationUtils as l,DialogType as a}from"@sankhyalabs/ezui/dist/collection/utils";import{D as d,a as h,b as c}from"./p-f132e371.js";import{d as p,W as u,R as m}from"./p-f587a454.js";import{D as v}from"./p-41d92871.js";import{S as x}from"./p-95a80f3f.js";import"./p-112455b1.js";import"./p-2ecf14ff.js";class f{constructor(t,e){this._selectedNumber=0,this._getMessage=t,this._selectedNumber=e}setExportOption(t,e){const i=this.getExportGroupName();t===d.EXPORT_TO_PDF&&e.push(this.getExportToPDF(i)),t===d.EXPORT_TO_XLS&&e.push(this.getExportToXLS(i)),this.setExportCurrentPage(t,e),this.setExportByEmail(t,e)}setExportCurrentPage(t,e){var i;const s=[d.EXPORT_PAGE_TO_PDF,d.EXPORT_PAGE_TO_XLS];if(t===d.EXPORT_CURRENT_PAGE&&e.push(this.getCurrentPage()),s.includes(t)){let s=e.find((t=>t.id===d.EXPORT_CURRENT_PAGE));null==s&&(e.push(this.getCurrentPage()),s=e.find((t=>t.id===d.EXPORT_CURRENT_PAGE))),(null===(i=null==s?void 0:s.children)||void 0===i?void 0:i.length)||(s.children=[]),t===d.EXPORT_PAGE_TO_PDF&&s.children.push(this.getExportPageToPDF()),t===d.EXPORT_PAGE_TO_XLS&&s.children.push(this.getExportPageToXLS())}}setExportByEmail(t,e){t===d.EXPORT_BY_EMAIL&&e.push(this.getExportByEmail())}getExportToPDF(t){return{id:d.EXPORT_TO_PDF,label:"PDF (.pdf)",group:t}}getExportToXLS(t){return{id:d.EXPORT_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`,group:t}}getCurrentPage(){return{id:d.EXPORT_CURRENT_PAGE,label:this._getMessage("snkDataExporter.label.currentPage"),group:this._getMessage("snkDataExporter.group.custom")}}getExportPageToPDF(){return{id:d.EXPORT_PAGE_TO_PDF,label:"PDF (.pdf)"}}getExportPageToXLS(){return{id:d.EXPORT_PAGE_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`}}getExportByEmail(){return{id:d.EXPORT_BY_EMAIL,label:`${this._getMessage("snkDataExporter.label.sendByEmail")}...`}}getExportGroupName(){return 1===this._selectedNumber?this._getMessage("snkDataExporter.group.export.selectedLine"):this._selectedNumber>1?this._getMessage("snkDataExporter.group.export.multiSelected").replace("{0}",this._selectedNumber.toString()):this._getMessage("snkDataExporter.group.export.default")}}function E(t){var{methodName:e}=t,i=function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(t);o<s.length;o++)e.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(i[s[o]]=t[s[o]])}return i}(t,["methodName"]);const s=`mgefin-bff@DataExporterSPBean.${e}`,r={serviceName:s,requestBody:i};return new Promise(((t,e)=>{v.get().callServiceBroker(s,o.objectToString(r)).then((e=>t(function(t){var e;const i=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.$;if(null!=i)return o.stringToObject(i)}(e)))).catch((t=>e(t)))}))}const b=5e3,k=class{constructor(e){t(this,e),this._selectedNumber=0,this._customPrefix="$custom$",this._items=[],this._showDropdown=!1,this._releasedToExport=[d.EXPORT_TO_PDF,d.EXPORT_TO_XLS,d.EXPORT_BY_EMAIL,d.EXPORT_PDF_TO_EMAIL,d.EXPORT_XLS_TO_EMAIL,d.EXPORT_PAGE_TO_PDF,d.EXPORT_PAGE_TO_XLS],this.provider=null,this.messagesBuilder=void 0}async exportByEmail(){const t=this._selectedNumber;this._snkEmailSender.open({type:t>0?"selection":"all",selectedRows:t,email:{attachments:[{name:this._appLabel}]},resolver:({type:t,format:e,email:{to:i,subject:s,message:o}})=>{var r;const n=null!==(r=h[null==e?void 0:e.toUpperCase()])&&void 0!==r?r:h.PDF;this.resolveExporter({type:t,methodName:n,to:i,subject:s,message:o,fileName:this._appLabel,titleGrid:this._appLabel},(()=>{this._snkEmailSender.close(),l.info(this.getMessage("snkDataExporter.message.emailSuccess"),{iconName:"check"})}))}})}getMessage(t,e){if(null==this.messagesBuilder){const t=x.getNearestInstance(this._element);t&&(this.messagesBuilder=t.messagesBuilder)}return this.messagesBuilder.getMessage(t,e)}positionDropdown(){var t;const e=null===(t=this._ezButton)||void 0===t?void 0:t.getBoundingClientRect();null!=e&&null!=this._dropdownParent&&(this._dropdownParent.style.top=e.y+e.height+5+"px",this._dropdownParent.style.left=e.x+"px")}closeDropdown(t){const e=null==t?void 0:t.target;null!=e&&(e.closest(".snk-data-exporter")||(this._showDropdown=!1))}setEvents(){document.removeEventListener("click",this.closeDropdown.bind(this)),document.addEventListener("click",this.closeDropdown.bind(this)),document.removeEventListener("scroll",this.positionDropdown.bind(this)),document.addEventListener("scroll",this.positionDropdown.bind(this))}controlDropdown(){this._showDropdown=!this._showDropdown}resolveExporter(t,e){if(null==this.provider||null==t||null==e)return;const i=this.provider.getFilters(),s=this.provider.getColumnsMetadata(),o=this.provider.getOrders(),r=this.provider.getResourceURI(),n=this.provider.getSelectedIDs(),a=t.exportOption,h=[d.EXPORT_PAGE_TO_PDF,d.EXPORT_PAGE_TO_XLS];delete t.exportOption;let c=Object.assign({filters:i,columns:s,sort:o,resourceURI:r,selectedIDs:n.slice(0,b)},t);if(h.includes(a)||"page"==t.type){const t=this.provider.getOffset(),e=this.provider.getLimit();c=Object.assign(Object.assign({},c),{offset:t,limit:e,selectedIDs:[]})}else"all"==t.type&&(c=Object.assign(Object.assign({},c),{offset:0,limit:b,selectedIDs:[]}));E(c).then((t=>e(t))).catch((t=>l.error(this.getMessage("snkDataExporter.message.exportError"),t?t.statusMessage:this.getMessage("snkDataExporter.message.exportError"))))}getOptionKey(t){return Object.keys(d).find((e=>d[e]===t))}dispatchExporter(t){var e;const i=this.getOptionKey(t),s=null!==(e=c[i])&&void 0!==e?e:c.EXPORT_TO_PDF,o=c[i]===c.EXPORT_TO_XLS;this.resolveExporter({methodName:d[`EXPORT_TO_${s}`],fileName:this._appLabel,titleGrid:this._appLabel,exportOption:t,limit:b},(t=>{!function({fileSessionKey:t,canPrint:e,canExport:i,useAppPrint:s,isDownload:o}){const n=r.getContextValue("__SNK__APPLICATION__");if(s&&!o)return function(t,e,i,s){null==s||s.webConnection(p,u.methods.PDF_VIEWER,{chaveArquivo:t,permiteImprimir:e?"S":"N",permiteExportar:i?"S":"N",contentType:"S"})}(t,e,i,n);window.open(`${window.location.protocol}//${window.location.hostname}:${window.location.port}/mge/visualizadorArquivos.mge?chaveArquivo=${t}${o?"&download=S":""}`),l.info(function(t){var e;return null===(e=null==t?void 0:t.messagesBuilder)||void 0===e?void 0:e.getMessage("fileViewer.message.exportSuccess",void 0)}(n),{iconName:"check"})}(Object.assign(Object.assign({},t),{fileType:s,isDownload:o}))}))}async processExporter(t){var e,i,s,o;const r=null==t?void 0:t.detail,n=[d.EXPORT_PAGE_TO_PDF,d.EXPORT_PAGE_TO_XLS],h=null===(e=null==r?void 0:r.id)||void 0===e?void 0:e.includes(this._customPrefix);if((null==r?void 0:r.id)===d.EXPORT_CURRENT_PAGE)return;const c=null===(i=this.provider)||void 0===i?void 0:i.getSelectedIDs(),p=null===(s=this.provider)||void 0===s?void 0:s.getTotalRecords(),u=null===(o=this.provider)||void 0===o?void 0:o.getLimit();let m=!1;if(n.includes(null==r?void 0:r.id)&&u<=b||h?m=!1:(null==c?void 0:c.length)?m=c.length>b:p>b&&(m=!0),m){const t=b.toLocaleString("pt-BR",{minimumFractionDigits:0}),e={title:this.getMessage("snkDataExporter.limitExceeded.title"),description:`\n ${this.getMessage("snkDataExporter.limitExceeded.description",{limit:t})}\n <br/><br/>\n <b>\n ${this.getMessage("snkDataExporter.limitExceeded.subdescription")}\n </b>\n `,cancel:this.getMessage("snkDataExporter.limitExceeded.cancel"),confirm:this.getMessage("snkDataExporter.limitExceeded.continue")};if(!await l.confirm(e.title,e.description,null,a.WARN,{labelCancel:e.cancel,labelConfirm:e.confirm}))return}if(h)return this.openPersonalizedReports(r.id),void(this._showDropdown=!1);this._releasedToExport.includes(null==r?void 0:r.id)&&(r.id===d.EXPORT_BY_EMAIL?this.exportByEmail():this.dispatchExporter(r.id),this._showDropdown=!1)}loadItems(){const t=[];this._releasedToExport.forEach((e=>{var i;null===(i=this._itemBuilder)||void 0===i||i.setExportOption(e,t)})),this.loadPersonalizedItems(t)}async loadPersonalizedItems(t){var e;const i=null===(e=this.provider)||void 0===e?void 0:e.getRecordID();if(null==i)return void(this._items=t);const s=await function(t){const e="mgefin-bff@DataExporterSPBean.getPersonalizedReports",i={serviceName:e,requestBody:t};return new Promise(((t,s)=>v.get().callServiceBroker(e,o.objectToString(i)).then((e=>t(function(t){var e;const i=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.$;if(null!=i)return o.stringToObject(i)}(e)))).catch((t=>s(t)))))}({recordID:i});null==s||s.forEach((e=>{t.push({id:`${this._customPrefix}_${e.ID}`,label:e.label,group:this.getMessage("snkDataExporter.group.custom")})})),this._items=t}openPersonalizedReports(t){var e;const i=[],s=(null==t?void 0:t.replace(this._customPrefix,""))||"";null===(e=this.provider)||void 0===e||e.getSelectedIDs().forEach((({name:t,type:e,value:s},o)=>{const r=[];r.fields=[],0===o&&(i[`PK_${t}`]={type:e,value:s},i.pks=[]),r.fields.push({nome:t,tipo:e,valor:s}),i.pks.push(r)})),this._application.openApp(`${m}${s}`,i)}loadDropdown(){var t,e;this._selectedNumber=(null===(e=null===(t=this.provider)||void 0===t?void 0:t.getSelectedIDs())||void 0===e?void 0:e.length)||0,this._itemBuilder=new f(this.getMessage.bind(this),this._selectedNumber),this.loadItems()}getElementID(t){return{[n.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:n.getInternalIDInfo(t)}}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this._items)||void 0===t?void 0:t.length)>0}componentWillLoad(){var t;this._application=r.getContextValue("__SNK__APPLICATION__"),null===(t=this._application)||void 0===t||t.getAppLabel().then((t=>this._appLabel=t)),this.setEvents()}componentDidLoad(){null!=this._element&&(n.addIDInfo(this._element),this.positionDropdown())}componentWillUpdate(){var t;this._showDropdown&&!(null===(t=this._items)||void 0===t?void 0:t.length)&&this.loadDropdown()}componentDidUpdate(){var t;this._showDropdown?this.positionDropdown():(null===(t=this._items)||void 0===t?void 0:t.length)>0&&(this._items=[])}render(){return e(i,null,e("div",{class:`snk-data-exporter\n ${this.canShowDropdown()?" snk-data-exporter--overlap":""}\n `},e("ez-button",Object.assign({ref:t=>this._ezButton=t,iconName:"file-download",size:"small",mode:"icon",title:this.getMessage("snkDataExporter.group.export.title"),onClick:()=>this.controlDropdown()},this.getElementID("button"))),e("div",Object.assign({ref:t=>this._dropdownParent=t,class:`snk-data-exporter__dropdown\n ${this.canShowDropdown()?"snk-data-exporter__dropdown--show":""}\n `},this.getElementID("dropdown")),this.canShowDropdown()&&e("ez-dropdown",Object.assign({items:this._items,onEzClick:t=>this.processExporter(t)},this.getElementID("dropdown"))))),this.canShowDropdown()&&e("div",Object.assign({class:"ez-scrim ez-scrim--light"},this.getElementID("ezScrim"))),e("snk-exporter-email-sender",Object.assign({ref:t=>this._snkEmailSender=t,getMessage:(t,e)=>this.getMessage(t,e)},this.getElementID("snkExporterEmailSender"))))}get _element(){return s(this)}};k.style=".sc-snk-data-exporter-h{--snk-data-exporter--z-index:var(--most-visible, 3);display:flex;width:fit-content;height:fit-content}.snk-data-exporter.sc-snk-data-exporter{display:flex;width:fit-content;height:fit-content}.snk-data-exporter--overlap.sc-snk-data-exporter{z-index:var(--snk-data-exporter--z-index)}.snk-data-exporter__dropdown.sc-snk-data-exporter{display:none}.snk-data-exporter__dropdown--show.sc-snk-data-exporter{display:flex;flex-direction:column;position:fixed}.snk-data-exporter__dropdown.sc-snk-data-exporter>ez-dropdown.sc-snk-data-exporter{position:relative}";export{k as snk_data_exporter}
|
1
|
+
import{r as t,h as e,H as i,g as s}from"./p-b9667fbe.js";import{ObjectUtils as o,ApplicationContext as r,ElementIDUtils as n}from"@sankhyalabs/core";import{ApplicationUtils as l,DialogType as a}from"@sankhyalabs/ezui/dist/collection/utils";import{D as d,a as h,b as c}from"./p-f132e371.js";import{d as p,W as u,R as m}from"./p-f587a454.js";import{D as v}from"./p-41d92871.js";import{S as x}from"./p-bc281de0.js";import"./p-112455b1.js";import"./p-2ecf14ff.js";class f{constructor(t,e){this._selectedNumber=0,this._getMessage=t,this._selectedNumber=e}setExportOption(t,e){const i=this.getExportGroupName();t===d.EXPORT_TO_PDF&&e.push(this.getExportToPDF(i)),t===d.EXPORT_TO_XLS&&e.push(this.getExportToXLS(i)),this.setExportCurrentPage(t,e),this.setExportByEmail(t,e)}setExportCurrentPage(t,e){var i;const s=[d.EXPORT_PAGE_TO_PDF,d.EXPORT_PAGE_TO_XLS];if(t===d.EXPORT_CURRENT_PAGE&&e.push(this.getCurrentPage()),s.includes(t)){let s=e.find((t=>t.id===d.EXPORT_CURRENT_PAGE));null==s&&(e.push(this.getCurrentPage()),s=e.find((t=>t.id===d.EXPORT_CURRENT_PAGE))),(null===(i=null==s?void 0:s.children)||void 0===i?void 0:i.length)||(s.children=[]),t===d.EXPORT_PAGE_TO_PDF&&s.children.push(this.getExportPageToPDF()),t===d.EXPORT_PAGE_TO_XLS&&s.children.push(this.getExportPageToXLS())}}setExportByEmail(t,e){t===d.EXPORT_BY_EMAIL&&e.push(this.getExportByEmail())}getExportToPDF(t){return{id:d.EXPORT_TO_PDF,label:"PDF (.pdf)",group:t}}getExportToXLS(t){return{id:d.EXPORT_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`,group:t}}getCurrentPage(){return{id:d.EXPORT_CURRENT_PAGE,label:this._getMessage("snkDataExporter.label.currentPage"),group:this._getMessage("snkDataExporter.group.custom")}}getExportPageToPDF(){return{id:d.EXPORT_PAGE_TO_PDF,label:"PDF (.pdf)"}}getExportPageToXLS(){return{id:d.EXPORT_PAGE_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`}}getExportByEmail(){return{id:d.EXPORT_BY_EMAIL,label:`${this._getMessage("snkDataExporter.label.sendByEmail")}...`}}getExportGroupName(){return 1===this._selectedNumber?this._getMessage("snkDataExporter.group.export.selectedLine"):this._selectedNumber>1?this._getMessage("snkDataExporter.group.export.multiSelected").replace("{0}",this._selectedNumber.toString()):this._getMessage("snkDataExporter.group.export.default")}}function E(t){var{methodName:e}=t,i=function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(t);o<s.length;o++)e.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(i[s[o]]=t[s[o]])}return i}(t,["methodName"]);const s=`mgefin-bff@DataExporterSPBean.${e}`,r={serviceName:s,requestBody:i};return new Promise(((t,e)=>{v.get().callServiceBroker(s,o.objectToString(r)).then((e=>t(function(t){var e;const i=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.$;if(null!=i)return o.stringToObject(i)}(e)))).catch((t=>e(t)))}))}const b=5e3,k=class{constructor(e){t(this,e),this._selectedNumber=0,this._customPrefix="$custom$",this._items=[],this._showDropdown=!1,this._releasedToExport=[d.EXPORT_TO_PDF,d.EXPORT_TO_XLS,d.EXPORT_BY_EMAIL,d.EXPORT_PDF_TO_EMAIL,d.EXPORT_XLS_TO_EMAIL,d.EXPORT_PAGE_TO_PDF,d.EXPORT_PAGE_TO_XLS],this.provider=null,this.messagesBuilder=void 0}async exportByEmail(){const t=this._selectedNumber;this._snkEmailSender.open({type:t>0?"selection":"all",selectedRows:t,email:{attachments:[{name:this._appLabel}]},resolver:({type:t,format:e,email:{to:i,subject:s,message:o}})=>{var r;const n=null!==(r=h[null==e?void 0:e.toUpperCase()])&&void 0!==r?r:h.PDF;this.resolveExporter({type:t,methodName:n,to:i,subject:s,message:o,fileName:this._appLabel,titleGrid:this._appLabel},(()=>{this._snkEmailSender.close(),l.info(this.getMessage("snkDataExporter.message.emailSuccess"),{iconName:"check"})}))}})}getMessage(t,e){if(null==this.messagesBuilder){const t=x.getNearestInstance(this._element);t&&(this.messagesBuilder=t.messagesBuilder)}return this.messagesBuilder.getMessage(t,e)}positionDropdown(){var t;const e=null===(t=this._ezButton)||void 0===t?void 0:t.getBoundingClientRect();null!=e&&null!=this._dropdownParent&&(this._dropdownParent.style.top=e.y+e.height+5+"px",this._dropdownParent.style.left=e.x+"px")}closeDropdown(t){const e=null==t?void 0:t.target;null!=e&&(e.closest(".snk-data-exporter")||(this._showDropdown=!1))}setEvents(){document.removeEventListener("click",this.closeDropdown.bind(this)),document.addEventListener("click",this.closeDropdown.bind(this)),document.removeEventListener("scroll",this.positionDropdown.bind(this)),document.addEventListener("scroll",this.positionDropdown.bind(this))}controlDropdown(){this._showDropdown=!this._showDropdown}resolveExporter(t,e){if(null==this.provider||null==t||null==e)return;const i=this.provider.getFilters(),s=this.provider.getColumnsMetadata(),o=this.provider.getOrders(),r=this.provider.getResourceURI(),n=this.provider.getSelectedIDs(),a=t.exportOption,h=[d.EXPORT_PAGE_TO_PDF,d.EXPORT_PAGE_TO_XLS];delete t.exportOption;let c=Object.assign({filters:i,columns:s,sort:o,resourceURI:r,selectedIDs:n.slice(0,b)},t);if(h.includes(a)||"page"==t.type){const t=this.provider.getOffset(),e=this.provider.getLimit();c=Object.assign(Object.assign({},c),{offset:t,limit:e,selectedIDs:[]})}else"all"==t.type&&(c=Object.assign(Object.assign({},c),{offset:0,limit:b,selectedIDs:[]}));E(c).then((t=>e(t))).catch((t=>l.error(this.getMessage("snkDataExporter.message.exportError"),t?t.statusMessage:this.getMessage("snkDataExporter.message.exportError"))))}getOptionKey(t){return Object.keys(d).find((e=>d[e]===t))}dispatchExporter(t){var e;const i=this.getOptionKey(t),s=null!==(e=c[i])&&void 0!==e?e:c.EXPORT_TO_PDF,o=c[i]===c.EXPORT_TO_XLS;this.resolveExporter({methodName:d[`EXPORT_TO_${s}`],fileName:this._appLabel,titleGrid:this._appLabel,exportOption:t,limit:b},(t=>{!function({fileSessionKey:t,canPrint:e,canExport:i,useAppPrint:s,isDownload:o}){const n=r.getContextValue("__SNK__APPLICATION__");if(s&&!o)return function(t,e,i,s){null==s||s.webConnection(p,u.methods.PDF_VIEWER,{chaveArquivo:t,permiteImprimir:e?"S":"N",permiteExportar:i?"S":"N",contentType:"S"})}(t,e,i,n);window.open(`${window.location.protocol}//${window.location.hostname}:${window.location.port}/mge/visualizadorArquivos.mge?chaveArquivo=${t}${o?"&download=S":""}`),l.info(function(t){var e;return null===(e=null==t?void 0:t.messagesBuilder)||void 0===e?void 0:e.getMessage("fileViewer.message.exportSuccess",void 0)}(n),{iconName:"check"})}(Object.assign(Object.assign({},t),{fileType:s,isDownload:o}))}))}async processExporter(t){var e,i,s,o;const r=null==t?void 0:t.detail,n=[d.EXPORT_PAGE_TO_PDF,d.EXPORT_PAGE_TO_XLS],h=null===(e=null==r?void 0:r.id)||void 0===e?void 0:e.includes(this._customPrefix);if((null==r?void 0:r.id)===d.EXPORT_CURRENT_PAGE)return;const c=null===(i=this.provider)||void 0===i?void 0:i.getSelectedIDs(),p=null===(s=this.provider)||void 0===s?void 0:s.getTotalRecords(),u=null===(o=this.provider)||void 0===o?void 0:o.getLimit();let m=!1;if(n.includes(null==r?void 0:r.id)&&u<=b||h?m=!1:(null==c?void 0:c.length)?m=c.length>b:p>b&&(m=!0),m){const t=b.toLocaleString("pt-BR",{minimumFractionDigits:0}),e={title:this.getMessage("snkDataExporter.limitExceeded.title"),description:`\n ${this.getMessage("snkDataExporter.limitExceeded.description",{limit:t})}\n <br/><br/>\n <b>\n ${this.getMessage("snkDataExporter.limitExceeded.subdescription")}\n </b>\n `,cancel:this.getMessage("snkDataExporter.limitExceeded.cancel"),confirm:this.getMessage("snkDataExporter.limitExceeded.continue")};if(!await l.confirm(e.title,e.description,null,a.WARN,{labelCancel:e.cancel,labelConfirm:e.confirm}))return}if(h)return this.openPersonalizedReports(r.id),void(this._showDropdown=!1);this._releasedToExport.includes(null==r?void 0:r.id)&&(r.id===d.EXPORT_BY_EMAIL?this.exportByEmail():this.dispatchExporter(r.id),this._showDropdown=!1)}loadItems(){const t=[];this._releasedToExport.forEach((e=>{var i;null===(i=this._itemBuilder)||void 0===i||i.setExportOption(e,t)})),this.loadPersonalizedItems(t)}async loadPersonalizedItems(t){var e;const i=null===(e=this.provider)||void 0===e?void 0:e.getRecordID();if(null==i)return void(this._items=t);const s=await function(t){const e="mgefin-bff@DataExporterSPBean.getPersonalizedReports",i={serviceName:e,requestBody:t};return new Promise(((t,s)=>v.get().callServiceBroker(e,o.objectToString(i)).then((e=>t(function(t){var e;const i=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.$;if(null!=i)return o.stringToObject(i)}(e)))).catch((t=>s(t)))))}({recordID:i});null==s||s.forEach((e=>{t.push({id:`${this._customPrefix}_${e.ID}`,label:e.label,group:this.getMessage("snkDataExporter.group.custom")})})),this._items=t}openPersonalizedReports(t){var e;const i=[],s=(null==t?void 0:t.replace(this._customPrefix,""))||"";null===(e=this.provider)||void 0===e||e.getSelectedIDs().forEach((({name:t,type:e,value:s},o)=>{const r=[];r.fields=[],0===o&&(i[`PK_${t}`]={type:e,value:s},i.pks=[]),r.fields.push({nome:t,tipo:e,valor:s}),i.pks.push(r)})),this._application.openApp(`${m}${s}`,i)}loadDropdown(){var t,e;this._selectedNumber=(null===(e=null===(t=this.provider)||void 0===t?void 0:t.getSelectedIDs())||void 0===e?void 0:e.length)||0,this._itemBuilder=new f(this.getMessage.bind(this),this._selectedNumber),this.loadItems()}getElementID(t){return{[n.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:n.getInternalIDInfo(t)}}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this._items)||void 0===t?void 0:t.length)>0}componentWillLoad(){var t;this._application=r.getContextValue("__SNK__APPLICATION__"),null===(t=this._application)||void 0===t||t.getAppLabel().then((t=>this._appLabel=t)),this.setEvents()}componentDidLoad(){null!=this._element&&(n.addIDInfo(this._element),this.positionDropdown())}componentWillUpdate(){var t;this._showDropdown&&!(null===(t=this._items)||void 0===t?void 0:t.length)&&this.loadDropdown()}componentDidUpdate(){var t;this._showDropdown?this.positionDropdown():(null===(t=this._items)||void 0===t?void 0:t.length)>0&&(this._items=[])}render(){return e(i,null,e("div",{class:`snk-data-exporter\n ${this.canShowDropdown()?" snk-data-exporter--overlap":""}\n `},e("ez-button",Object.assign({ref:t=>this._ezButton=t,iconName:"file-download",size:"small",mode:"icon",title:this.getMessage("snkDataExporter.group.export.title"),onClick:()=>this.controlDropdown()},this.getElementID("button"))),e("div",Object.assign({ref:t=>this._dropdownParent=t,class:`snk-data-exporter__dropdown\n ${this.canShowDropdown()?"snk-data-exporter__dropdown--show":""}\n `},this.getElementID("dropdown")),this.canShowDropdown()&&e("ez-dropdown",Object.assign({items:this._items,onEzClick:t=>this.processExporter(t)},this.getElementID("dropdown"))))),this.canShowDropdown()&&e("div",Object.assign({class:"ez-scrim ez-scrim--light"},this.getElementID("ezScrim"))),e("snk-exporter-email-sender",Object.assign({ref:t=>this._snkEmailSender=t,getMessage:(t,e)=>this.getMessage(t,e)},this.getElementID("snkExporterEmailSender"))))}get _element(){return s(this)}};k.style=".sc-snk-data-exporter-h{--snk-data-exporter--z-index:var(--most-visible, 3);display:flex;width:fit-content;height:fit-content}.snk-data-exporter.sc-snk-data-exporter{display:flex;width:fit-content;height:fit-content}.snk-data-exporter--overlap.sc-snk-data-exporter{z-index:var(--snk-data-exporter--z-index)}.snk-data-exporter__dropdown.sc-snk-data-exporter{display:none}.snk-data-exporter__dropdown--show.sc-snk-data-exporter{display:flex;flex-direction:column;position:fixed}.snk-data-exporter__dropdown.sc-snk-data-exporter>ez-dropdown.sc-snk-data-exporter{position:relative}";export{k as snk_data_exporter}
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as t,c as i,h as s,g as e,H as n}from"./p-b9667fbe.js";import{Action as a,ObjectUtils as o,JSUtils as h,ApplicationContext as r,DataType as l}from"@sankhyalabs/core";import{ApplicationUtils as d,DialogType as c}from"@sankhyalabs/ezui/dist/collection/utils";import{O as v,S as u}from"./p-2ecf14ff.js";const f=class{constructor(s){t(this,s),this.dataStateChange=i(this,"dataStateChange",3),this.dataUnitReady=i(this,"dataUnitReady",3),this.messagesBuilderUpdated=i(this,"messagesBuilderUpdated",3),this.insertionMode=i(this,"insertionMode",3),this.cancelEdition=i(this,"cancelEdition",3),this._onDataUnitResolve=[],this._openedAlert=!1,this._dataUnitObserver=t=>{var i,s;const e=this.buildDataState();if(this.dataState=e,t.type===a.DATA_SAVED){const i=this.getMessage("snkDataUnit.saveInfo",t.payload.records[0]);null!=i&&this.showSuccessMessage(i)}if(t.type!==a.RECORDS_ADDED&&t.type!==a.RECORDS_COPIED||this.insertionMode.emit(),t.type===a.EDITION_CANCELED&&this.cancelEdition.emit(),t.type===a.RECORDS_REMOVED){const e=t.payload.cachedRecords;let n;n=(null==e?void 0:e.length)>1?this.getMessage("snkDataUnit.removeAllInfo",{size:e.length}):this.getMessage("snkDataUnit.removeInfo",t.payload.cachedRecords[0]),null!=n&&this.showSuccessMessage(n);const a=null!==(s=null===(i=this.dataUnit.records)||void 0===i?void 0:i.length)&&void 0!==s?s:0,o=this.dataUnit.getPaginationInfo();o&&this.dataUnit.gotoPage(a>0||o.hasMore?o.currentPage:0)}this.messagesBuilder.currentOperation=this.getMessageOperation()},this.dataState=void 0,this.messagesBuilder=void 0,this.dataUnitName=void 0,this.entityName=void 0,this.pageSize=150,this.dataUnit=void 0,this.beforeSave=void 0,this.afterSave=void 0}observePageSize(){this.dataUnit&&(this.dataUnit.pageSize=this.pageSize)}observeDataUnitName(t,i){i!=t&&(this.dataUnit?this._application.updateDataunitCache(i,this.dataUnitName,this.dataUnit):this.loadDataUnit())}observeEntityName(t,i){i!=t&&(this.dataUnit=void 0,this.entityName=t,this.loadDataUnit())}observeDataState(t,i){o.objectToString(i)!=o.objectToString(t)&&this.dataStateChange.emit(t)}observeDataUnit(){this.handlerLinkFields(),this.dataUnitReady.emit(this.dataUnit)}observeMessagesBuilder(t){t&&this.messagesBuilderUpdated.emit(t)}async getDataUnit(){return new Promise((t=>{this.dataUnit?t(this.dataUnit):this._onDataUnitResolve.push(t)}))}async getSelectedRecordsIDsInfo(){var t;const i=null===(t=this.dataUnit)||void 0===t?void 0:t.getSelectionInfo();if(null==i?void 0:i.isAllRecords())return[];const s=[],e=null==i?void 0:i.records;return(null==e?void 0:e.length)>0&&e.forEach((({__record__id__:t})=>{if(!this.dataUnit.isNewRecord(t)){if(!h.isBase64(t))return void s.push({name:"__record__id__",type:l.TEXT,value:t});const i=JSON.parse(window.atob(t));Object.entries(i).forEach((([t,i])=>{var e;const n=null===(e=this.dataUnit)||void 0===e?void 0:e.getField(t);null!=n&&s.push(Object.assign({name:t,type:n.dataType},i))}))}})),s}async interceptAction(t){return new Promise((i=>{var s,e;switch(t.type){case a.RECORDS_ADDED:this.isAllowed("INSERT")?i(t):d.info(this.getMessage("snkDataUnit.forbiddenInsert"));break;case a.RECORDS_COPIED:this.isAllowed("CLONE")?i(t):d.info(this.getMessage("snkDataUnit.forbiddenClone"));break;case a.DATA_CHANGED:case a.CHANGING_DATA:if(this.isAllowed("UPDATE"))return i(t);if(this._openedAlert)return this.dataUnit.cancelEdition();this._openedAlert=!0,this.dataUnit.cancelEdition(),d.alert(this.getMessage("snkDataUnit.forbidden"),this.getMessage("snkDataUnit.forbiddenUpdate")).then((()=>{this._openedAlert=!1}));break;case a.SAVING_DATA:if(this.beforeSave){const s=this.beforeSave(this.dataUnit);s instanceof Promise?s.then((s=>i(s?t:void 0))):i(s?t:void 0)}else i(t);break;case a.DATA_SAVED:this.afterSave?this.afterSave(this.dataUnit):i(t);break;case a.EDITION_CANCELED:if(this.dataState.hasDirtyRecords){const e=this.getMessage("snkDataUnit.cancelConfirmation");if(null===(s=t.payload)||void 0===s?void 0:s.fromParent)return void i(t);if(null==e)this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo")),i(t);else{const s=this.getMessage("snkDataUnit.cancelConfirmationTitle");d.confirm(s,e).then((s=>{s&&this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo")),i(s?t:void 0)}))}}else i(t);break;case a.REMOVING_RECORDS:if(this.isAllowed("REMOVE")){let s=!1,n=this.getMessage("snkDataUnit.removeConfirmation");const a=null===(e=this.dataUnit)||void 0===e?void 0:e.getSelectionInfo();if((null==a?void 0:a.length)>1&&(n=this.getMessage("snkDataUnit.removeAllConfirmation",{size:a.length}),s=!0),null==n)i(t);else{const e={canClose:!1,labelCancel:this.getMessage("snkDataUnit.confirm."+(s?"no":"cancel")),labelConfirm:this.getMessage("snkDataUnit.confirm."+(s?"yes":"delete")),btnConfirmDanger:!1},a=this.getMessage("snkDataUnit.removeConfirmationTitle");d.confirm(a,n,null,c.WARN,e).then((s=>i(s?t:void 0)))}}else d.info(this.getMessage("snkDataUnit.forbiddenRemove"));break;default:i(t)}}))}showSuccessMessage(t){d.info(t,{iconName:"check"})}isAllowed(t){return!!this._permissions&&(this._permissions.isSup||this._permissions[t])}buildDataState(){const t=this.dataUnit.getSelectionInfo(),i=(this.dataUnit.hasDirtyRecords()||this.dataUnit.hasWaitingChanges())&&(null==t?void 0:t.isEmpty());return new m({insertionMode:this.dataUnit.hasNewRecord(),isStartingInsertionMode:i,hasNext:this.dataUnit.hasNext(),hasPrevious:this.dataUnit.hasPrevious(),copyMode:this.dataUnit.hasCopiedRecord(),isDirty:this.dataUnit.isDirty(),hasDirtyRecords:this.dataUnit.hasDirtyRecords(),selectedRecords:void 0,selectionInfo:t,selectedRecord:this.dataUnit.getSelectedRecord()})}getMessage(t,i){return i||(i=this.getMessageParams()),this.messagesBuilder.getMessage(t,i)}getMessageParams(){return this.dataState.selectedRecord}getMessageOperation(){return this.dataState.copyMode?v.CLONE:this.dataState.insertionMode||this.dataState.isStartingInsertionMode?v.INSERT:this.dataState.isDirty?v.UPDATE:v.CLEAN}async getDataUnitParentOrChild(){var t;const i=this.dataUnitName?this.dataUnitName:this.entityName;return this._parentSnkDataUnit?(this._parentDataUnit=await(null===(t=this._parentSnkDataUnit)||void 0===t?void 0:t.getDataUnit()),await this._application.getDataUnit(this.entityName,i,this._parentDataUnit)):await this._application.getDataUnit(this.entityName,i)}async loadDataUnit(){if(null==this.dataUnit&&this._application&&this.entityName&&(this.dataUnit=await this.getDataUnitParentOrChild()),this.dataUnit){let t;for(this.dataUnit.pageSize=this.pageSize,this.dataUnit.unsubscribe(this._dataUnitObserver),this.dataUnit.addInterceptor(this),this.dataUnit.subscribe(this._dataUnitObserver),this.dataState=this.buildDataState();t=this._onDataUnitResolve.pop();)t(this.dataUnit)}}getParentSnkDataUnit(){let t=this.element;for(;t.parentNode;){if("SNK-DATA-UNIT"===t.parentNode.nodeName)return t.parentNode;t=t.parentNode}}handlerLinkFields(){var t,i;const s=Object.assign({},this.dataUnit.metadata);if(!this._parentDataUnit)return;const e=this._parentDataUnit.getChildInfo(this.entityName);if(!e)return;const n=null===(t=null==e?void 0:e.links)||void 0===t?void 0:t.map((t=>t.target));null===(i=null==s?void 0:s.fields)||void 0===i||i.forEach((t=>{(null==n?void 0:n.includes(t.name))&&(t.visible=!1)})),this.dataUnit.metadata=s}static getNearestInstance(t){let i=t.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase())return i;i=i.parentElement}}componentWillLoad(){this._application=r.getContextValue("__SNK__APPLICATION__"),this._application.getAllAccess().then((t=>this._permissions=t)),this._parentSnkDataUnit=this.getParentSnkDataUnit(),null==this.messagesBuilder&&(this.messagesBuilder=new u(this.entityName))}disconnectedCallback(){this.dataUnit&&(this.dataUnit.unsubscribe(this._dataUnitObserver),this.dataUnit.removeInterceptor(this))}componentDidLoad(){this.loadDataUnit()}render(){return s(n,null)}get element(){return e(this)}static get watchers(){return{pageSize:["observePageSize"],dataUnitName:["observeDataUnitName"],entityName:["observeEntityName"],dataState:["observeDataState"],dataUnit:["observeDataUnit"],messagesBuilder:["observeMessagesBuilder"]}}};class m{constructor(t){this.copyMode=t.copyMode,this.insertionMode=t.insertionMode,this.isStartingInsertionMode=t.isStartingInsertionMode,this.isDirty=t.isDirty,this.hasDirtyRecords=t.hasDirtyRecords,this.hasNext=t.hasNext,this.hasPrevious=t.hasPrevious,this.selectionInfo=t.selectionInfo,this.selectedRecord=t.selectedRecord}get selectedRecords(){var t;if(console.warn("SnkDataUnit: O método `selectedRecords` foi descontinuado. Use o método `selectionInfo`."),null===(t=this.selectionInfo)||void 0===t?void 0:t.isAllRecords())throw new Error("Erro interno: Impossível obter os registros selecionados. A seleção atual é virtual. Use o atributo `selectionInfo`.");return this.selectionInfo.records}}f.style=".sc-snk-data-unit-h{display:flex;flex-direction:column;height:100%;width:100%}";export{f as S}
|
@@ -1 +1 @@
|
|
1
|
-
import{p as e,b as t}from"./p-b9667fbe.js";export{s as setNonce}from"./p-b9667fbe.js";(()=>{const t=import.meta.url,a={};return""!==t&&(a.resourcesUrl=new URL(".",t).href),e(a)})().then((e=>t([["p-81e85890",[[6,"snk-simple-crud",{dataState:[16],dataUnit:[16],mode:[2],taskbarManager:[16],messagesBuilder:[1040],_currentViewMode:[32],_config:[32],goToView:[64],setMetadata:[64],setRecords:[64],getRecords:[64]},[[0,"actionClick","actionClickListener"]]]]],["p-e551b19a",[[1,"teste-pesquisa"]]],["p-86d29b6f",[[0,"snk-filter-binary-select",{value:[1544],config:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-79d22df0",[[2,"snk-filter-field-search",{searchable:[4],breadcrumbItems:[32],linkItems:[32],fieldItems:[32],setDataSource:[64],filterDataSource:[64]}]]],["p-ee82c157",[[0,"snk-filter-multi-select",{value:[1544],config:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-ad51bf1c",[[0,"snk-filter-number",{config:[16],value:[2],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-93d8fe00",[[2,"snk-filter-param-config",{messagesBuilder:[1040],_opened:[32],_configType:[32],_expressionItem:[32],_informedInstance:[32],_canSave:[32],open:[64],close:[64]}]]],["p-5fc55684",[[0,"snk-filter-period",{config:[16],value:[8],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-d5c9c1f8",[[0,"snk-filter-personalized",{config:[16],value:[1040],fix:[16],unfix:[16],show:[64]}]]],["p-5e62a17b",[[0,"snk-filter-search",{config:[16],value:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-c336170d",[[0,"snk-filter-text",{config:[16],value:[1]},[[0,"ezChange","ezChangeListener"]]]]],["p-b3e71248",[[6,"snk-simple-bar",{label:[1],breadcrumbItens:[16]}]]],["p-1393dc00",[[2,"snk-detail-view",{formConfigManager:[1040],dataUnitName:[1,"data-unit-name"],guideItemPath:[16],entityName:[1,"entity-name"],label:[1],dataUnit:[1040],selectedForm:[1025,"selected-form"],dataState:[1040],messagesBuilder:[1040],branchGuide:[16],_disabledButtons:[32],changeViewMode:[64],configGrid:[64],showUp:[64]},[[0,"snkContentCardChanged","onContentCardChanged"]]]]],["p-32599159",[[2,"snk-configurator",{configName:[1,"config-name"],viewMode:[2,"view-mode"],messagesBuilder:[1040],_opened:[32],_permissions:[32],open:[64],close:[64]}]]],["p-e701646c",[[2,"snk-pesquisa",{searchLoader:[16],selectItem:[16],argument:[1025],_itemList:[32],_startLoading:[32]}]]],["p-fac37198",[[2,"snk-filter-bar",{dataUnit:[1040],configName:[1,"config-name"],filterConfig:[1040],messagesBuilder:[1040],allowDefault:[32],scrollerLocked:[32]},[[0,"filterChange","filterChangeListener"]]]]],["p-6516f35a",[[2,"snk-grid-config",{selectedIndex:[1026,"selected-index"],application:[16],columns:[1040],config:[1040],configName:[1,"config-name"]}]]],["p-0a1e7f75",[[2,"snk-config-options",{fieldConfig:[16],idConfig:[513,"id-config"],dataUnit:[16],messagesBuilder:[1040],_defaultType:[32]}]]],["p-
|
1
|
+
import{p as e,b as t}from"./p-b9667fbe.js";export{s as setNonce}from"./p-b9667fbe.js";(()=>{const t=import.meta.url,a={};return""!==t&&(a.resourcesUrl=new URL(".",t).href),e(a)})().then((e=>t([["p-81e85890",[[6,"snk-simple-crud",{dataState:[16],dataUnit:[16],mode:[2],taskbarManager:[16],messagesBuilder:[1040],_currentViewMode:[32],_config:[32],goToView:[64],setMetadata:[64],setRecords:[64],getRecords:[64]},[[0,"actionClick","actionClickListener"]]]]],["p-e551b19a",[[1,"teste-pesquisa"]]],["p-86d29b6f",[[0,"snk-filter-binary-select",{value:[1544],config:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-79d22df0",[[2,"snk-filter-field-search",{searchable:[4],breadcrumbItems:[32],linkItems:[32],fieldItems:[32],setDataSource:[64],filterDataSource:[64]}]]],["p-ee82c157",[[0,"snk-filter-multi-select",{value:[1544],config:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-ad51bf1c",[[0,"snk-filter-number",{config:[16],value:[2],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-93d8fe00",[[2,"snk-filter-param-config",{messagesBuilder:[1040],_opened:[32],_configType:[32],_expressionItem:[32],_informedInstance:[32],_canSave:[32],open:[64],close:[64]}]]],["p-5fc55684",[[0,"snk-filter-period",{config:[16],value:[8],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-d5c9c1f8",[[0,"snk-filter-personalized",{config:[16],value:[1040],fix:[16],unfix:[16],show:[64]}]]],["p-5e62a17b",[[0,"snk-filter-search",{config:[16],value:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-c336170d",[[0,"snk-filter-text",{config:[16],value:[1]},[[0,"ezChange","ezChangeListener"]]]]],["p-b3e71248",[[6,"snk-simple-bar",{label:[1],breadcrumbItens:[16]}]]],["p-1393dc00",[[2,"snk-detail-view",{formConfigManager:[1040],dataUnitName:[1,"data-unit-name"],guideItemPath:[16],entityName:[1,"entity-name"],label:[1],dataUnit:[1040],selectedForm:[1025,"selected-form"],dataState:[1040],messagesBuilder:[1040],branchGuide:[16],_disabledButtons:[32],changeViewMode:[64],configGrid:[64],showUp:[64]},[[0,"snkContentCardChanged","onContentCardChanged"]]]]],["p-32599159",[[2,"snk-configurator",{configName:[1,"config-name"],viewMode:[2,"view-mode"],messagesBuilder:[1040],_opened:[32],_permissions:[32],open:[64],close:[64]}]]],["p-e701646c",[[2,"snk-pesquisa",{searchLoader:[16],selectItem:[16],argument:[1025],_itemList:[32],_startLoading:[32]}]]],["p-fac37198",[[2,"snk-filter-bar",{dataUnit:[1040],configName:[1,"config-name"],filterConfig:[1040],messagesBuilder:[1040],allowDefault:[32],scrollerLocked:[32]},[[0,"filterChange","filterChangeListener"]]]]],["p-6516f35a",[[2,"snk-grid-config",{selectedIndex:[1026,"selected-index"],application:[16],columns:[1040],config:[1040],configName:[1,"config-name"]}]]],["p-0a1e7f75",[[2,"snk-config-options",{fieldConfig:[16],idConfig:[513,"id-config"],dataUnit:[16],messagesBuilder:[1040],_defaultType:[32]}]]],["p-94e6fc90",[[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],getDataUnit:[64],getSelectedRecordsIDsInfo:[64]}]]],["p-f29caa0a",[[2,"snk-field-config",{isConfigActive:[16],fieldConfig:[16],modeInsertion:[516,"mode-insertion"],dataUnit:[16],messagesBuilder:[1040]}]]],["p-b80cf644",[[6,"snk-tab-config",{selectedIndex:[1538,"selected-index"],selectedTab:[1537,"selected-tab"],tabs:[1],messagesBuilder:[1040],_processedTabs:[32],_activeEditText:[32],_activeEditTextIndex:[32],_actionsHide:[32],_actionsShow:[32]}]]],["p-f4d36823",[[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-d65809d5",[[6,"snk-taskbar",{configName:[1,"config-name"],buttons:[1],customButtons:[16],actionsList:[16],primaryButton:[1,"primary-button"],disabledButtons:[16],dataUnit:[16],presentationMode:[1537,"presentation-mode"],messagesBuilder:[1040],_permissions:[32]}]]],["p-3a2ce158",[[0,"snk-filter-item",{config:[1040],getMessage:[16],detailIsVisible:[32],showUp:[64],hideDetail:[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]]]],["p-093febff",[[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-3169584f",[[1,"snk-select-box",{selectedOption:[1,"selected-option"]}]]],["p-22e44b9d",[[0,"snk-exporter-email-sender",{getMessage:[16],_config:[32],_opened:[32],_currentStep:[32],open:[64],close:[64]}]]],["p-9bfa3cfb",[[2,"snk-data-exporter",{provider:[16],messagesBuilder:[1040],_items:[32],_showDropdown:[32],_releasedToExport:[32]}]]],["p-79f01b63",[[2,"snk-guides-viewer",{_guideBuilders:[16],dataUnit:[16],dataState:[16],configName:[1,"config-name"],entityPath:[1,"entity-path"],actionsList:[16],recordsValidator:[16],masterFormConfig:[1040],selectedGuide:[16],taskbarManager:[16],messagesBuilder:[1040],presentationMode:[1,"presentation-mode"],_breadcrumbItems:[32],_guides:[32],_formEditorConfigManager:[32],_formEditorDataUnit:[32],showFormConfig:[64]},[[2,"actionClick","onActionClick"],[0,"snkContentCardChanged","onContentCardChanged"]]]]],["p-1c17eecf",[[6,"snk-crud",{configName:[1025,"config-name"],actionsList:[16],taskbarManager:[16],recordsValidator:[16],statusResolver:[16],multipleSelection:[4,"multiple-selection"],presentationMode:[1,"presentation-mode"],messagesBuilder:[1040],_dataUnit:[32],_dataState:[32],_currentViewMode:[32],goToView:[64]}]]],["p-7621806d",[[2,"snk-form",{configName:[1,"config-name"],recordsValidator:[16],messagesBuilder:[1040],_dataUnit:[32],_dataState:[32],_showFormConfig:[32],_configManager:[32],showConfig:[64],hideConfig:[64]}]]],["p-340d6fb0",[[2,"snk-application",{messagesBuilder:[1040],configName:[1,"config-name"],isUserSup:[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],getResourceID:[64],getUserID:[64],alert:[64],error:[64],success:[64],message:[64],confirm:[64],info:[64],loadGridConfig:[64],loadTotals:[64],executeSearch:[64],executePreparedSearch:[64],isDebugMode:[64],getAppLabel:[64],addSearchListener:[64]}]]],["p-afba9bbe",[[0,"snk-filter-detail",{config:[1040],getMessage:[16],show:[64]}]]],["p-d61759a5",[[6,"snk-grid",{configName:[1,"config-name"],actionsList:[16],isDetail:[4,"is-detail"],taskbarManager:[16],statusResolver:[16],multipleSelection:[4,"multiple-selection"],presentationMode:[1,"presentation-mode"],messagesBuilder:[1040],_dataUnit:[32],_dataState:[32],_gridConfig:[32],_popUpGridConfig:[32],showConfig:[64],hideConfig:[64],setConfig:[64]}]]],["p-900b2889",[[2,"snk-form-summary",{fixed:[1540],contracted:[1540],summary:[16]}]]],["p-71215dc2",[[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-73e830cf",[[0,"snk-filter-modal",{getMessage:[16],items:[1040],modalTitle:[1,"modal-title"],modalSubTitle:[1,"modal-sub-title"],cancelButtonLabel:[1,"cancel-button-label"],okButtonLabel:[1,"ok-button-label"],infoText:[1,"info-text"],useSearch:[4,"use-search"],processModalAction:[16],_filterArgument:[32]}]]]],e)));
|
@@ -9,6 +9,7 @@ export declare class SnkDataUnit implements DUActionInterceptor {
|
|
9
9
|
_permissions: any;
|
10
10
|
_parentSnkDataUnit: HTMLSnkDataUnitElement;
|
11
11
|
_parentDataUnit: DataUnit;
|
12
|
+
_openedAlert: boolean;
|
12
13
|
element: HTMLSnkDataUnitElement;
|
13
14
|
/**
|
14
15
|
* Controla o estado atual dos dados.
|
@@ -106,6 +107,7 @@ export declare class SnkDataUnit implements DUActionInterceptor {
|
|
106
107
|
export interface DataState {
|
107
108
|
copyMode: boolean;
|
108
109
|
insertionMode: boolean;
|
110
|
+
isStartingInsertionMode: boolean;
|
109
111
|
isDirty: boolean;
|
110
112
|
hasDirtyRecords: boolean;
|
111
113
|
hasNext: boolean;
|
@@ -322,7 +322,7 @@ export namespace Components {
|
|
322
322
|
*/
|
323
323
|
"dataUnit": DataUnit;
|
324
324
|
/**
|
325
|
-
* Usado para criar o dataUnit uma única vez.
|
325
|
+
* Usado para criar o dataUnit uma única vez. Se omitido, será usado o próprio nome da entidade.
|
326
326
|
*/
|
327
327
|
"dataUnitName": string;
|
328
328
|
/**
|
@@ -1470,7 +1470,7 @@ declare namespace LocalJSX {
|
|
1470
1470
|
*/
|
1471
1471
|
"dataUnit"?: DataUnit;
|
1472
1472
|
/**
|
1473
|
-
* Usado para criar o dataUnit uma única vez.
|
1473
|
+
* Usado para criar o dataUnit uma única vez. Se omitido, será usado o próprio nome da entidade.
|
1474
1474
|
*/
|
1475
1475
|
"dataUnitName"?: string;
|
1476
1476
|
/**
|
package/package.json
CHANGED
@@ -1 +0,0 @@
|
|
1
|
-
export{S as snk_data_unit}from"./p-95a80f3f.js";import"./p-b9667fbe.js";import"@sankhyalabs/core";import"@sankhyalabs/ezui/dist/collection/utils";import"./p-2ecf14ff.js";
|
@@ -1 +0,0 @@
|
|
1
|
-
import{r as t,c as i,h as s,g as e,H as n}from"./p-b9667fbe.js";import{Action as a,ObjectUtils as o,JSUtils as h,ApplicationContext as r,DataType as l}from"@sankhyalabs/core";import{ApplicationUtils as d,DialogType as c}from"@sankhyalabs/ezui/dist/collection/utils";import{O as v,S as u}from"./p-2ecf14ff.js";const f=class{constructor(s){t(this,s),this.dataStateChange=i(this,"dataStateChange",3),this.dataUnitReady=i(this,"dataUnitReady",3),this.messagesBuilderUpdated=i(this,"messagesBuilderUpdated",3),this.insertionMode=i(this,"insertionMode",3),this.cancelEdition=i(this,"cancelEdition",3),this._onDataUnitResolve=[],this._dataUnitObserver=t=>{var i,s;const e=this.buildDataState();if(this.dataState=e,t.type===a.DATA_SAVED){const i=this.getMessage("snkDataUnit.saveInfo",t.payload.records[0]);null!=i&&this.showSuccessMessage(i)}if(t.type!==a.RECORDS_ADDED&&t.type!==a.RECORDS_COPIED||this.insertionMode.emit(),t.type===a.EDITION_CANCELED&&this.cancelEdition.emit(),t.type===a.RECORDS_REMOVED){const e=t.payload.cachedRecords;let n;n=(null==e?void 0:e.length)>1?this.getMessage("snkDataUnit.removeAllInfo",{size:e.length}):this.getMessage("snkDataUnit.removeInfo",t.payload.cachedRecords[0]),null!=n&&this.showSuccessMessage(n);const a=null!==(s=null===(i=this.dataUnit.records)||void 0===i?void 0:i.length)&&void 0!==s?s:0,o=this.dataUnit.getPaginationInfo();o&&this.dataUnit.gotoPage(a>0||o.hasMore?o.currentPage:0)}this.messagesBuilder.currentOperation=this.getMessageOperation()},this.dataState=void 0,this.messagesBuilder=void 0,this.dataUnitName=void 0,this.entityName=void 0,this.pageSize=150,this.dataUnit=void 0,this.beforeSave=void 0,this.afterSave=void 0}observePageSize(){this.dataUnit&&(this.dataUnit.pageSize=this.pageSize)}observeDataUnitName(t,i){i!=t&&(this.dataUnit?this._application.updateDataunitCache(i,this.dataUnitName,this.dataUnit):this.loadDataUnit())}observeEntityName(t,i){i!=t&&(this.dataUnit=void 0,this.entityName=t,this.loadDataUnit())}observeDataState(t,i){o.objectToString(i)!=o.objectToString(t)&&this.dataStateChange.emit(t)}observeDataUnit(){this.handlerLinkFields(),this.dataUnitReady.emit(this.dataUnit)}observeMessagesBuilder(t){t&&this.messagesBuilderUpdated.emit(t)}async getDataUnit(){return new Promise((t=>{this.dataUnit?t(this.dataUnit):this._onDataUnitResolve.push(t)}))}async getSelectedRecordsIDsInfo(){var t;const i=null===(t=this.dataUnit)||void 0===t?void 0:t.getSelectionInfo();if(null==i?void 0:i.isAllRecords())return[];const s=[],e=null==i?void 0:i.records;return(null==e?void 0:e.length)>0&&e.forEach((({__record__id__:t})=>{if(!this.dataUnit.isNewRecord(t)){if(!h.isBase64(t))return void s.push({name:"__record__id__",type:l.TEXT,value:t});const i=JSON.parse(window.atob(t));Object.entries(i).forEach((([t,i])=>{var e;const n=null===(e=this.dataUnit)||void 0===e?void 0:e.getField(t);null!=n&&s.push(Object.assign({name:t,type:n.dataType},i))}))}})),s}async interceptAction(t){return new Promise((i=>{var s,e;switch(t.type){case a.RECORDS_ADDED:this.isAllowed("INSERT")?i(t):d.info(this.getMessage("snkDataUnit.forbiddenInsert"));break;case a.RECORDS_COPIED:this.isAllowed("CLONE")?i(t):d.info(this.getMessage("snkDataUnit.forbiddenClone"));break;case a.DATA_CHANGED:case a.CHANGING_DATA:this.isAllowed("UPDATE")?i(t):(this.dataUnit.cancelEdition(),d.alert(this.getMessage("snkDataUnit.forbidden"),this.getMessage("snkDataUnit.forbiddenUpdate")));break;case a.SAVING_DATA:if(this.beforeSave){const s=this.beforeSave(this.dataUnit);s instanceof Promise?s.then((s=>i(s?t:void 0))):i(s?t:void 0)}else i(t);break;case a.DATA_SAVED:this.afterSave?this.afterSave(this.dataUnit):i(t);break;case a.EDITION_CANCELED:if(this.dataState.hasDirtyRecords){const e=this.getMessage("snkDataUnit.cancelConfirmation");if(null===(s=t.payload)||void 0===s?void 0:s.fromParent)return void i(t);if(null==e)this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo")),i(t);else{const s=this.getMessage("snkDataUnit.cancelConfirmationTitle");d.confirm(s,e).then((s=>{s&&this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo")),i(s?t:void 0)}))}}else i(t);break;case a.REMOVING_RECORDS:if(this.isAllowed("REMOVE")){let s=!1,n=this.getMessage("snkDataUnit.removeConfirmation");const a=null===(e=this.dataUnit)||void 0===e?void 0:e.getSelectionInfo();if((null==a?void 0:a.length)>1&&(n=this.getMessage("snkDataUnit.removeAllConfirmation",{size:a.length}),s=!0),null==n)i(t);else{const e={canClose:!1,labelCancel:this.getMessage("snkDataUnit.confirm."+(s?"no":"cancel")),labelConfirm:this.getMessage("snkDataUnit.confirm."+(s?"yes":"delete")),btnConfirmDanger:!1},a=this.getMessage("snkDataUnit.removeConfirmationTitle");d.confirm(a,n,null,c.WARN,e).then((s=>i(s?t:void 0)))}}else d.info(this.getMessage("snkDataUnit.forbiddenRemove"));break;default:i(t)}}))}showSuccessMessage(t){d.info(t,{iconName:"check"})}isAllowed(t){return!!this._permissions&&(this._permissions.isSup||this._permissions[t])}buildDataState(){const t=this.dataUnit.getSelectionInfo();return new m({insertionMode:this.dataUnit.hasNewRecord(),hasNext:this.dataUnit.hasNext(),hasPrevious:this.dataUnit.hasPrevious(),copyMode:this.dataUnit.hasCopiedRecord(),isDirty:this.dataUnit.isDirty(),hasDirtyRecords:this.dataUnit.hasDirtyRecords(),selectedRecords:void 0,selectionInfo:t,selectedRecord:this.dataUnit.getSelectedRecord()})}getMessage(t,i){return i||(i=this.getMessageParams()),this.messagesBuilder.getMessage(t,i)}getMessageParams(){return this.dataState.selectedRecord}getMessageOperation(){return this.dataState.copyMode?v.CLONE:this.dataState.insertionMode?v.INSERT:this.dataState.isDirty?v.UPDATE:v.CLEAN}async getDataUnitParentOrChild(){var t;const i=this.dataUnitName?this.dataUnitName:this.entityName;return this._parentSnkDataUnit?(this._parentDataUnit=await(null===(t=this._parentSnkDataUnit)||void 0===t?void 0:t.getDataUnit()),await this._application.getDataUnit(this.entityName,i,this._parentDataUnit)):await this._application.getDataUnit(this.entityName,i)}async loadDataUnit(){if(null==this.dataUnit&&this._application&&this.entityName&&(this.dataUnit=await this.getDataUnitParentOrChild()),this.dataUnit){let t;for(this.dataUnit.pageSize=this.pageSize,this.dataUnit.unsubscribe(this._dataUnitObserver),this.dataUnit.addInterceptor(this),this.dataUnit.subscribe(this._dataUnitObserver),this.dataState=this.buildDataState();t=this._onDataUnitResolve.pop();)t(this.dataUnit)}}getParentSnkDataUnit(){let t=this.element;for(;t.parentNode;){if("SNK-DATA-UNIT"===t.parentNode.nodeName)return t.parentNode;t=t.parentNode}}handlerLinkFields(){var t,i;const s=Object.assign({},this.dataUnit.metadata);if(!this._parentDataUnit)return;const e=this._parentDataUnit.getChildInfo(this.entityName);if(!e)return;const n=null===(t=null==e?void 0:e.links)||void 0===t?void 0:t.map((t=>t.target));null===(i=null==s?void 0:s.fields)||void 0===i||i.forEach((t=>{(null==n?void 0:n.includes(t.name))&&(t.visible=!1)})),this.dataUnit.metadata=s}static getNearestInstance(t){let i=t.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase())return i;i=i.parentElement}}componentWillLoad(){this._application=r.getContextValue("__SNK__APPLICATION__"),this._application.getAllAccess().then((t=>this._permissions=t)),this._parentSnkDataUnit=this.getParentSnkDataUnit(),null==this.messagesBuilder&&(this.messagesBuilder=new u(this.entityName))}disconnectedCallback(){this.dataUnit&&(this.dataUnit.unsubscribe(this._dataUnitObserver),this.dataUnit.removeInterceptor(this))}componentDidLoad(){this.loadDataUnit()}render(){return s(n,null)}get element(){return e(this)}static get watchers(){return{pageSize:["observePageSize"],dataUnitName:["observeDataUnitName"],entityName:["observeEntityName"],dataState:["observeDataState"],dataUnit:["observeDataUnit"],messagesBuilder:["observeMessagesBuilder"]}}};class m{constructor(t){this.copyMode=t.copyMode,this.insertionMode=t.insertionMode,this.isDirty=t.isDirty,this.hasDirtyRecords=t.hasDirtyRecords,this.hasNext=t.hasNext,this.hasPrevious=t.hasPrevious,this.selectionInfo=t.selectionInfo,this.selectedRecord=t.selectedRecord}get selectedRecords(){var t;if(console.warn("SnkDataUnit: O método `selectedRecords` foi descontinuado. Use o método `selectionInfo`."),null===(t=this.selectionInfo)||void 0===t?void 0:t.isAllRecords())throw new Error("Erro interno: Impossível obter os registros selecionados. A seleção atual é virtual. Use o atributo `selectionInfo`.");return this.selectionInfo.records}}f.style=".sc-snk-data-unit-h{display:flex;flex-direction:column;height:100%;width:100%}";export{f as S}
|