@sankhyalabs/ezui 1.1.120 → 1.1.121

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.
@@ -48,7 +48,7 @@ const buildSearch = ({ name, label, readOnly, required }) => {
48
48
 
49
49
  const buildFile = ({ name, label, readOnly }) => {
50
50
  return (index.h("div", { class: "col col--sd-12 padding-horizontal--small" },
51
- index.h("ez-upload", { enabled: !readOnly, label: label, urlUpload: "", requestHeaders: "", maxFiles: 10, "data-field-name": name, key: name })));
51
+ index.h("ez-upload", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
52
52
  };
53
53
 
54
54
  const buildDate = ({ name, label, readOnly }) => {
@@ -602,30 +602,56 @@ class DataBinder {
602
602
  constructor(dataUnit) {
603
603
  this._fields = new Map();
604
604
  this._dataUnit = dataUnit;
605
- this._dataUnit.subscribe(_action => {
605
+ this._dataUnit.subscribe(action => {
606
606
  var _a;
607
- (_a = this._fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
608
- this.updateValue(field.fieldName, field.field);
609
- });
607
+ switch (action.type) {
608
+ case core.Action.DATA_LOADED:
609
+ case core.Action.DATA_SAVED:
610
+ case core.Action.RECORDS_REMOVED:
611
+ case core.Action.RECORDS_ADDED:
612
+ case core.Action.RECORDS_COPIED:
613
+ case core.Action.DATA_CHANGED:
614
+ case core.Action.EDITION_CANCELED:
615
+ case core.Action.CHANGE_UNDONE:
616
+ case core.Action.CHANGE_REDONE:
617
+ case core.Action.SELECTION_CHANGED:
618
+ case core.Action.NEXT_SELECTED:
619
+ case core.Action.PREVIOUS_SELECTED:
620
+ (_a = this._fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
621
+ this.updateValue(field.fieldName, field.field);
622
+ });
623
+ break;
624
+ }
610
625
  });
611
626
  }
612
627
  bind(fields) {
613
628
  fields.forEach(fieldElement => {
614
629
  const fieldName = fieldElement.dataset.fieldName;
615
630
  this.updateBind(fieldName, fieldElement);
616
- this.updateValue(fieldName, fieldElement);
617
631
  });
618
632
  }
619
633
  updateValue(fieldName, field) {
620
- field["value"] = this._dataUnit.getFieldValue(fieldName);
634
+ const oldValue = field["value"];
635
+ const newValue = this._dataUnit.getFieldValue(fieldName);
636
+ if (oldValue != newValue) {
637
+ field["value"] = newValue;
638
+ }
621
639
  }
622
640
  updateBind(fieldName, field) {
623
641
  const oldBind = this._fields.get(fieldName);
624
642
  if (oldBind) {
625
643
  oldBind.destroy();
626
644
  }
627
- this._fields.set(fieldName, Bind.create(fieldName, field, (fieldName, newValue) => this.setFieldValue(fieldName, newValue)));
645
+ field["value"] = this._dataUnit.getFieldValue(fieldName);
646
+ this._fields.set(fieldName, Bind.create(fieldName, field, (fieldName, waitingChange) => this.changeStarted(fieldName, waitingChange), (fieldName, newValue) => this.setFieldValue(fieldName, newValue)));
628
647
  this.bindSearchOptionsLoader(fieldName, field);
648
+ this.applyEzUploadContext(fieldName, field);
649
+ }
650
+ changeStarted(fieldName, waitingChange) {
651
+ if (this._dataUnit.records.length === 0) {
652
+ this._dataUnit.addRecord();
653
+ }
654
+ this._dataUnit.startChange(fieldName, waitingChange);
629
655
  }
630
656
  setFieldValue(fieldName, newValue) {
631
657
  if (this._dataUnit.records.length === 0) {
@@ -643,19 +669,37 @@ class DataBinder {
643
669
  }
644
670
  }
645
671
  }
672
+ applyEzUploadContext(fieldName, field) {
673
+ var _a, _b;
674
+ if (field.nodeName === "EZ-UPLOAD") {
675
+ field["urlUpload"] = core.ApplicationContext.getContextValue("__EZUI__UPLOAD__ADD__URL__");
676
+ field["urlDelete"] = core.ApplicationContext.getContextValue("__EZUI__UPLOAD__DEL__URL__");
677
+ const descriptor = this._dataUnit.getField(fieldName);
678
+ const destination = (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.DESTINATION;
679
+ if (destination) {
680
+ field["requestHeaders"] = { XTRAINF: `{"destination": "${destination}"}` };
681
+ }
682
+ field["maxFiles"] = ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.MAX_FILES) || 0;
683
+ }
684
+ }
646
685
  }
647
686
  class Bind {
687
+ constructor() {
688
+ this.startChangeEventName = "ezStartChange";
689
+ this.changeEventName = "ezChange";
690
+ }
648
691
  destroy() {
649
- this.field.removeEventListener(this.eventName, this.eventListener);
692
+ this.field.removeEventListener(this.startChangeEventName, this.startChangeListener);
693
+ this.field.removeEventListener(this.changeEventName, this.changeListener);
650
694
  }
651
- static create(fieldName, field, callback) {
695
+ static create(fieldName, field, startChangeCallback, changeCallback) {
652
696
  const b = new Bind();
653
- b.fieldName = fieldName;
654
697
  b.field = field;
655
- //FIXME: Verificar se o field é um EzField
656
- b.eventListener = (evt) => { callback(fieldName, evt.detail); };
657
- b.eventName = "ezChange";
658
- b.field.addEventListener(b.eventName, b.eventListener);
698
+ b.fieldName = fieldName;
699
+ b.startChangeListener = (evt) => { startChangeCallback(fieldName, evt.detail); };
700
+ b.field.addEventListener(b.startChangeEventName, b.startChangeListener);
701
+ b.changeListener = (evt) => { changeCallback(fieldName, evt.detail); };
702
+ b.field.addEventListener(b.changeEventName, b.changeListener);
659
703
  return b;
660
704
  }
661
705
  }
@@ -101,6 +101,7 @@ let EzUpload = class {
101
101
  constructor(hostRef) {
102
102
  index.registerInstance(this, hostRef);
103
103
  this.ezChange = index.createEvent(this, "ezChange", 7);
104
+ this.ezStartChange = index.createEvent(this, "ezStartChange", 7);
104
105
  this._filePointers = new Map();
105
106
  /**
106
107
  * Deixa o campo disponível ou não para digitação.
@@ -108,6 +109,9 @@ let EzUpload = class {
108
109
  this.enabled = true;
109
110
  }
110
111
  changeValue(newValue) {
112
+ //Observamos o mundo externo, se um novo valor foi atribuído,
113
+ //precisamos cancelar a alteração anterior, isso envolve, percorrer
114
+ //a lista de ponteiros e cancelar todos os uploads em andamento.
111
115
  if (newValue !== this._updatingValue) {
112
116
  this._filePointers.forEach(f => {
113
117
  if (this.isRemoteFile(f)) {
@@ -116,8 +120,8 @@ let EzUpload = class {
116
120
  });
117
121
  this._filePointers = new Map();
118
122
  this.updateFilePointers();
123
+ this._updatingValue = undefined;
119
124
  }
120
- this._updatingValue = undefined;
121
125
  }
122
126
  updateFilePointers() {
123
127
  if (this.value) {
@@ -187,6 +191,7 @@ let EzUpload = class {
187
191
  }
188
192
  async doAddFile(file) {
189
193
  if (this.validateFile(file)) {
194
+ this.ezStartChange.emit({ waitmessage: "Há arquivos sendo enviados. Por favor aguarde a conclusão ou cancele o envio." });
190
195
  const uploadingFile = new RemoteFile(file);
191
196
  this._filePointers.set(file.name, uploadingFile);
192
197
  uploadingFile.upload(this.urlUpload, this._requestHeaders, (file) => this.updateFeedback(file))
@@ -206,8 +211,10 @@ let EzUpload = class {
206
211
  this._updatingValue.push(f);
207
212
  }
208
213
  });
209
- this.value = this._updatingValue;
210
- this.ezChange.emit(this.value);
214
+ if (this._filePointers.size === this._updatingValue.length) {
215
+ this.value = this._updatingValue;
216
+ this.ezChange.emit(this.value);
217
+ }
211
218
  }
212
219
  buildProgressId(uploading) {
213
220
  let sanitizedName = uploading.name.replace(/[^a-z0-9_]/gi, "_");
@@ -15,5 +15,5 @@ const patchBrowser = () => {
15
15
  };
16
16
 
17
17
  patchBrowser().then(options => {
18
- return index.bootstrapLazy([["ez-grid.cjs",[[6,"ez-grid",{"multipleSelection":[4,"multiple-selection"],"pageSize":[2,"page-size"],"serverUrl":[1,"server-url"],"dataUnit":[16],"_navigationHasPrevious":[32],"_navigationHasNext":[32],"_navigationFirstRow":[32],"_navigationLastRow":[32],"_navigationTotalRows":[32],"_popUpVisible":[32],"setColumnsDef":[64],"addColumnMenuItem":[64],"setColumnsState":[64],"setData":[64],"getSelection":[64],"getColumnsState":[64],"getColumns":[64],"refresh":[64],"quickFilter":[64]}]]],["ez-dialog.cjs",[[1,"ez-dialog",{"confirm":[1028],"critical":[1028],"message":[1025],"opened":[1540],"personalizedIconPath":[1025,"personalized-icon-path"],"ezTitle":[1025,"ez-title"],"handleButtonClick":[64],"show":[64]}]]],["ez-filter-input.cjs",[[1,"ez-filter-input",{"label":[1],"value":[1537],"enabled":[4],"loading":[516],"errorMessage":[1537,"error-message"],"restrict":[1],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-action-chip.cjs",[[1,"ez-action-chip",{"label":[513],"enabled":[516]}]]],["ez-application.cjs",[[0,"ez-application"]]],["ez-label-chip.cjs",[[1,"ez-label-chip",{"label":[513],"enabled":[516],"removable":[516],"value":[1540],"setFocus":[64],"setBlur":[64]}]]],["ez-popover.cjs",[[1,"ez-popover",{"autoClose":[516,"auto-close"],"top":[1537],"left":[1537],"bottom":[1537],"right":[1537],"boxWidth":[513,"box-width"],"opened":[1540],"innerElement":[1537,"inner-element"],"updatePosition":[64],"show":[64],"hide":[64]}]]],["ez-popup.cjs",[[1,"ez-popup",{"size":[1],"opened":[1540],"useHeader":[1540,"use-header"],"ezTitle":[1,"ez-title"]}]]],["ez-toast.cjs",[[1,"ez-toast",{"message":[1025],"fadeTime":[1026,"fade-time"],"useIcon":[1028,"use-icon"],"canClose":[1028,"can-close"],"show":[64]}]]],["grid-config.cjs",[[2,"grid-config",{"selectedTab":[1025,"selected-tab"],"columns":[1040]}]]],["ez-modal.cjs",[[1,"ez-modal",{"modalSize":[1,"modal-size"],"align":[1],"opened":[1028],"closeEsc":[4,"close-esc"],"closeOutsideClick":[4,"close-outside-click"]}]]],["ez-text-input.cjs",[[1,"ez-text-input",{"label":[513],"value":[1537],"enabled":[516],"loading":[516],"errorMessage":[1537,"error-message"],"mask":[1],"canShowError":[516,"can-show-error"],"restrict":[1],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-date-input.cjs",[[1,"ez-date-input",{"label":[513],"value":[1040],"enabled":[516],"errorMessage":[1537,"error-message"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-date-time-input.cjs",[[1,"ez-date-time-input",{"label":[513],"value":[1040],"enabled":[516],"errorMessage":[1537,"error-message"],"showSeconds":[516,"show-seconds"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-search.cjs",[[1,"ez-search",{"value":[1537],"label":[1537],"enabled":[1540],"errorMessage":[1537,"error-message"],"optionLoader":[16],"showSelectedValue":[4,"show-selected-value"],"showOptionValue":[4,"show-option-value"],"suppressEmptyOption":[4,"suppress-empty-option"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-time-input.cjs",[[1,"ez-time-input",{"label":[513],"viewValue":[1537,"view-value"],"value":[1026],"enabled":[516],"errorMessage":[1537,"error-message"],"showSeconds":[516,"show-seconds"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-number-input.cjs",[[1,"ez-number-input",{"label":[1],"value":[1538],"enabled":[4],"errorMessage":[1537,"error-message"],"precision":[2],"prettyPrecision":[2,"pretty-precision"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-collapsible-box.cjs",[[1,"ez-collapsible-box",{"value":[1540],"label":[513],"headerSize":[513,"header-size"],"iconPlacement":[513,"icon-placement"],"showHide":[64]}]]],["test-du.cjs",[[0,"test-du"]]],["select-box.cjs",[[1,"select-box",{"selectedOption":[1,"selected-option"]}]]],["ez-list.cjs",[[1,"ez-list",{"dataSource":[1040],"useGroups":[1540,"use-groups"],"ezDraggable":[1028,"ez-draggable"],"ezSelectable":[1028,"ez-selectable"],"itemSlotBuilder":[1040],"_listItems":[32],"_listGroupItems":[32],"setSelection":[64],"getSelection":[64],"getList":[64]}]]],["ez-text-area.cjs",[[1,"ez-text-area",{"label":[513],"value":[1537],"enabled":[516],"loading":[516],"errorMessage":[1537,"error-message"],"rows":[1538],"canShowError":[516,"can-show-error"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-upload.cjs",[[1,"ez-upload",{"label":[1],"enabled":[4],"maxFileSize":[2,"max-file-size"],"maxFiles":[2,"max-files"],"requestHeaders":[8,"request-headers"],"urlUpload":[1,"url-upload"],"urlDelete":[1,"url-delete"],"value":[1040],"addFiles":[64],"setFocus":[64],"setBlur":[64]}]]],["ez-button.cjs",[[1,"ez-button",{"label":[513],"enabled":[516],"mode":[513],"image":[513],"iconName":[513,"icon-name"],"size":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-calendar.cjs",[[1,"ez-calendar",{"value":[1040],"floating":[516],"time":[516],"showSeconds":[516,"show-seconds"],"show":[64],"fitVertical":[64],"hide":[64]}]]],["ez-check.cjs",[[1,"ez-check",{"label":[513],"value":[1540],"enabled":[516],"mode":[513],"getMode":[64],"setFocus":[64]}]]],["ez-tabselector.cjs",[[1,"ez-tabselector",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1]}]]],["ez-combo-box.cjs",[[1,"ez-combo-box",{"value":[1537],"label":[513],"enabled":[516],"options":[1040],"errorMessage":[1537,"error-message"],"searchMode":[4,"search-mode"],"showSelectedValue":[4,"show-selected-value"],"showOptionValue":[4,"show-option-value"],"optionLoader":[16],"suppressEmptyOption":[4,"suppress-empty-option"],"canShowError":[516,"can-show-error"],"mode":[513],"_preSelection":[32],"_visibleOptions":[32],"setFocus":[64],"setBlur":[64]}]]],["ez-icon.cjs",[[1,"ez-icon",{"size":[513],"href":[513],"iconName":[513,"icon-name"]}]]],["ez-form.cjs",[[0,"ez-form",{"dataUnit":[1040],"config":[16],"submit":[64],"cancel":[64],"validate":[64]}]]]], options);
18
+ return index.bootstrapLazy([["ez-grid.cjs",[[6,"ez-grid",{"multipleSelection":[4,"multiple-selection"],"pageSize":[2,"page-size"],"serverUrl":[1,"server-url"],"dataUnit":[16],"_navigationHasPrevious":[32],"_navigationHasNext":[32],"_navigationFirstRow":[32],"_navigationLastRow":[32],"_navigationTotalRows":[32],"_popUpVisible":[32],"setColumnsDef":[64],"addColumnMenuItem":[64],"setColumnsState":[64],"setData":[64],"getSelection":[64],"getColumnsState":[64],"getColumns":[64],"refresh":[64],"quickFilter":[64]}]]],["ez-dialog.cjs",[[1,"ez-dialog",{"confirm":[1028],"critical":[1028],"message":[1025],"opened":[1540],"personalizedIconPath":[1025,"personalized-icon-path"],"ezTitle":[1025,"ez-title"],"handleButtonClick":[64],"show":[64]}]]],["ez-filter-input.cjs",[[1,"ez-filter-input",{"label":[1],"value":[1537],"enabled":[4],"loading":[516],"errorMessage":[1537,"error-message"],"restrict":[1],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-action-chip.cjs",[[1,"ez-action-chip",{"label":[513],"enabled":[516]}]]],["ez-application.cjs",[[0,"ez-application"]]],["ez-label-chip.cjs",[[1,"ez-label-chip",{"label":[513],"enabled":[516],"removable":[516],"value":[1540],"setFocus":[64],"setBlur":[64]}]]],["ez-popover.cjs",[[1,"ez-popover",{"autoClose":[516,"auto-close"],"top":[1537],"left":[1537],"bottom":[1537],"right":[1537],"boxWidth":[513,"box-width"],"opened":[1540],"innerElement":[1537,"inner-element"],"updatePosition":[64],"show":[64],"hide":[64]}]]],["ez-popup.cjs",[[1,"ez-popup",{"size":[1],"opened":[1540],"useHeader":[1540,"use-header"],"ezTitle":[1,"ez-title"]}]]],["ez-toast.cjs",[[1,"ez-toast",{"message":[1025],"fadeTime":[1026,"fade-time"],"useIcon":[1028,"use-icon"],"canClose":[1028,"can-close"],"show":[64]}]]],["grid-config.cjs",[[2,"grid-config",{"selectedTab":[1025,"selected-tab"],"columns":[1040]}]]],["ez-modal.cjs",[[1,"ez-modal",{"modalSize":[1,"modal-size"],"align":[1],"opened":[1028],"closeEsc":[4,"close-esc"],"closeOutsideClick":[4,"close-outside-click"]}]]],["ez-text-input.cjs",[[1,"ez-text-input",{"label":[513],"value":[1537],"enabled":[516],"loading":[516],"errorMessage":[1537,"error-message"],"mask":[1],"canShowError":[516,"can-show-error"],"restrict":[1],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-date-input.cjs",[[1,"ez-date-input",{"label":[513],"value":[1040],"enabled":[516],"errorMessage":[1537,"error-message"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-date-time-input.cjs",[[1,"ez-date-time-input",{"label":[513],"value":[1040],"enabled":[516],"errorMessage":[1537,"error-message"],"showSeconds":[516,"show-seconds"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-search.cjs",[[1,"ez-search",{"value":[1537],"label":[1537],"enabled":[1540],"errorMessage":[1537,"error-message"],"optionLoader":[16],"showSelectedValue":[4,"show-selected-value"],"showOptionValue":[4,"show-option-value"],"suppressEmptyOption":[4,"suppress-empty-option"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-time-input.cjs",[[1,"ez-time-input",{"label":[513],"viewValue":[1537,"view-value"],"value":[1026],"enabled":[516],"errorMessage":[1537,"error-message"],"showSeconds":[516,"show-seconds"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-number-input.cjs",[[1,"ez-number-input",{"label":[1],"value":[1538],"enabled":[4],"errorMessage":[1537,"error-message"],"precision":[2],"prettyPrecision":[2,"pretty-precision"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-collapsible-box.cjs",[[1,"ez-collapsible-box",{"value":[1540],"label":[513],"headerSize":[513,"header-size"],"iconPlacement":[513,"icon-placement"],"showHide":[64]}]]],["test-du.cjs",[[0,"test-du",{"isDirty":[32]}]]],["select-box.cjs",[[1,"select-box",{"selectedOption":[1,"selected-option"]}]]],["ez-list.cjs",[[1,"ez-list",{"dataSource":[1040],"useGroups":[1540,"use-groups"],"ezDraggable":[1028,"ez-draggable"],"ezSelectable":[1028,"ez-selectable"],"itemSlotBuilder":[1040],"_listItems":[32],"_listGroupItems":[32],"setSelection":[64],"getSelection":[64],"getList":[64]}]]],["ez-text-area.cjs",[[1,"ez-text-area",{"label":[513],"value":[1537],"enabled":[516],"loading":[516],"errorMessage":[1537,"error-message"],"rows":[1538],"canShowError":[516,"can-show-error"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-upload.cjs",[[1,"ez-upload",{"label":[1],"enabled":[4],"maxFileSize":[2,"max-file-size"],"maxFiles":[2,"max-files"],"requestHeaders":[8,"request-headers"],"urlUpload":[1,"url-upload"],"urlDelete":[1,"url-delete"],"value":[1040],"addFiles":[64],"setFocus":[64],"setBlur":[64]}]]],["ez-button.cjs",[[1,"ez-button",{"label":[513],"enabled":[516],"mode":[513],"image":[513],"iconName":[513,"icon-name"],"size":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-calendar.cjs",[[1,"ez-calendar",{"value":[1040],"floating":[516],"time":[516],"showSeconds":[516,"show-seconds"],"show":[64],"fitVertical":[64],"hide":[64]}]]],["ez-check.cjs",[[1,"ez-check",{"label":[513],"value":[1540],"enabled":[516],"mode":[513],"getMode":[64],"setFocus":[64]}]]],["ez-tabselector.cjs",[[1,"ez-tabselector",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1]}]]],["ez-combo-box.cjs",[[1,"ez-combo-box",{"value":[1537],"label":[513],"enabled":[516],"options":[1040],"errorMessage":[1537,"error-message"],"searchMode":[4,"search-mode"],"showSelectedValue":[4,"show-selected-value"],"showOptionValue":[4,"show-option-value"],"optionLoader":[16],"suppressEmptyOption":[4,"suppress-empty-option"],"canShowError":[516,"can-show-error"],"mode":[513],"_preSelection":[32],"_visibleOptions":[32],"setFocus":[64],"setBlur":[64]}]]],["ez-icon.cjs",[[1,"ez-icon",{"size":[513],"href":[513],"iconName":[513,"icon-name"]}]]],["ez-form.cjs",[[0,"ez-form",{"dataUnit":[1040],"config":[16],"submit":[64],"cancel":[64],"validate":[64]}]]]], options);
19
19
  });
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["ez-grid.cjs",[[6,"ez-grid",{"multipleSelection":[4,"multiple-selection"],"pageSize":[2,"page-size"],"serverUrl":[1,"server-url"],"dataUnit":[16],"_navigationHasPrevious":[32],"_navigationHasNext":[32],"_navigationFirstRow":[32],"_navigationLastRow":[32],"_navigationTotalRows":[32],"_popUpVisible":[32],"setColumnsDef":[64],"addColumnMenuItem":[64],"setColumnsState":[64],"setData":[64],"getSelection":[64],"getColumnsState":[64],"getColumns":[64],"refresh":[64],"quickFilter":[64]}]]],["ez-dialog.cjs",[[1,"ez-dialog",{"confirm":[1028],"critical":[1028],"message":[1025],"opened":[1540],"personalizedIconPath":[1025,"personalized-icon-path"],"ezTitle":[1025,"ez-title"],"handleButtonClick":[64],"show":[64]}]]],["ez-filter-input.cjs",[[1,"ez-filter-input",{"label":[1],"value":[1537],"enabled":[4],"loading":[516],"errorMessage":[1537,"error-message"],"restrict":[1],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-action-chip.cjs",[[1,"ez-action-chip",{"label":[513],"enabled":[516]}]]],["ez-application.cjs",[[0,"ez-application"]]],["ez-label-chip.cjs",[[1,"ez-label-chip",{"label":[513],"enabled":[516],"removable":[516],"value":[1540],"setFocus":[64],"setBlur":[64]}]]],["ez-popover.cjs",[[1,"ez-popover",{"autoClose":[516,"auto-close"],"top":[1537],"left":[1537],"bottom":[1537],"right":[1537],"boxWidth":[513,"box-width"],"opened":[1540],"innerElement":[1537,"inner-element"],"updatePosition":[64],"show":[64],"hide":[64]}]]],["ez-popup.cjs",[[1,"ez-popup",{"size":[1],"opened":[1540],"useHeader":[1540,"use-header"],"ezTitle":[1,"ez-title"]}]]],["ez-toast.cjs",[[1,"ez-toast",{"message":[1025],"fadeTime":[1026,"fade-time"],"useIcon":[1028,"use-icon"],"canClose":[1028,"can-close"],"show":[64]}]]],["grid-config.cjs",[[2,"grid-config",{"selectedTab":[1025,"selected-tab"],"columns":[1040]}]]],["ez-modal.cjs",[[1,"ez-modal",{"modalSize":[1,"modal-size"],"align":[1],"opened":[1028],"closeEsc":[4,"close-esc"],"closeOutsideClick":[4,"close-outside-click"]}]]],["ez-text-input.cjs",[[1,"ez-text-input",{"label":[513],"value":[1537],"enabled":[516],"loading":[516],"errorMessage":[1537,"error-message"],"mask":[1],"canShowError":[516,"can-show-error"],"restrict":[1],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-date-input.cjs",[[1,"ez-date-input",{"label":[513],"value":[1040],"enabled":[516],"errorMessage":[1537,"error-message"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-date-time-input.cjs",[[1,"ez-date-time-input",{"label":[513],"value":[1040],"enabled":[516],"errorMessage":[1537,"error-message"],"showSeconds":[516,"show-seconds"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-search.cjs",[[1,"ez-search",{"value":[1537],"label":[1537],"enabled":[1540],"errorMessage":[1537,"error-message"],"optionLoader":[16],"showSelectedValue":[4,"show-selected-value"],"showOptionValue":[4,"show-option-value"],"suppressEmptyOption":[4,"suppress-empty-option"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-time-input.cjs",[[1,"ez-time-input",{"label":[513],"viewValue":[1537,"view-value"],"value":[1026],"enabled":[516],"errorMessage":[1537,"error-message"],"showSeconds":[516,"show-seconds"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-number-input.cjs",[[1,"ez-number-input",{"label":[1],"value":[1538],"enabled":[4],"errorMessage":[1537,"error-message"],"precision":[2],"prettyPrecision":[2,"pretty-precision"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-collapsible-box.cjs",[[1,"ez-collapsible-box",{"value":[1540],"label":[513],"headerSize":[513,"header-size"],"iconPlacement":[513,"icon-placement"],"showHide":[64]}]]],["test-du.cjs",[[0,"test-du"]]],["select-box.cjs",[[1,"select-box",{"selectedOption":[1,"selected-option"]}]]],["ez-list.cjs",[[1,"ez-list",{"dataSource":[1040],"useGroups":[1540,"use-groups"],"ezDraggable":[1028,"ez-draggable"],"ezSelectable":[1028,"ez-selectable"],"itemSlotBuilder":[1040],"_listItems":[32],"_listGroupItems":[32],"setSelection":[64],"getSelection":[64],"getList":[64]}]]],["ez-text-area.cjs",[[1,"ez-text-area",{"label":[513],"value":[1537],"enabled":[516],"loading":[516],"errorMessage":[1537,"error-message"],"rows":[1538],"canShowError":[516,"can-show-error"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-upload.cjs",[[1,"ez-upload",{"label":[1],"enabled":[4],"maxFileSize":[2,"max-file-size"],"maxFiles":[2,"max-files"],"requestHeaders":[8,"request-headers"],"urlUpload":[1,"url-upload"],"urlDelete":[1,"url-delete"],"value":[1040],"addFiles":[64],"setFocus":[64],"setBlur":[64]}]]],["ez-button.cjs",[[1,"ez-button",{"label":[513],"enabled":[516],"mode":[513],"image":[513],"iconName":[513,"icon-name"],"size":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-calendar.cjs",[[1,"ez-calendar",{"value":[1040],"floating":[516],"time":[516],"showSeconds":[516,"show-seconds"],"show":[64],"fitVertical":[64],"hide":[64]}]]],["ez-check.cjs",[[1,"ez-check",{"label":[513],"value":[1540],"enabled":[516],"mode":[513],"getMode":[64],"setFocus":[64]}]]],["ez-tabselector.cjs",[[1,"ez-tabselector",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1]}]]],["ez-combo-box.cjs",[[1,"ez-combo-box",{"value":[1537],"label":[513],"enabled":[516],"options":[1040],"errorMessage":[1537,"error-message"],"searchMode":[4,"search-mode"],"showSelectedValue":[4,"show-selected-value"],"showOptionValue":[4,"show-option-value"],"optionLoader":[16],"suppressEmptyOption":[4,"suppress-empty-option"],"canShowError":[516,"can-show-error"],"mode":[513],"_preSelection":[32],"_visibleOptions":[32],"setFocus":[64],"setBlur":[64]}]]],["ez-icon.cjs",[[1,"ez-icon",{"size":[513],"href":[513],"iconName":[513,"icon-name"]}]]],["ez-form.cjs",[[0,"ez-form",{"dataUnit":[1040],"config":[16],"submit":[64],"cancel":[64],"validate":[64]}]]]], options);
17
+ return index.bootstrapLazy([["ez-grid.cjs",[[6,"ez-grid",{"multipleSelection":[4,"multiple-selection"],"pageSize":[2,"page-size"],"serverUrl":[1,"server-url"],"dataUnit":[16],"_navigationHasPrevious":[32],"_navigationHasNext":[32],"_navigationFirstRow":[32],"_navigationLastRow":[32],"_navigationTotalRows":[32],"_popUpVisible":[32],"setColumnsDef":[64],"addColumnMenuItem":[64],"setColumnsState":[64],"setData":[64],"getSelection":[64],"getColumnsState":[64],"getColumns":[64],"refresh":[64],"quickFilter":[64]}]]],["ez-dialog.cjs",[[1,"ez-dialog",{"confirm":[1028],"critical":[1028],"message":[1025],"opened":[1540],"personalizedIconPath":[1025,"personalized-icon-path"],"ezTitle":[1025,"ez-title"],"handleButtonClick":[64],"show":[64]}]]],["ez-filter-input.cjs",[[1,"ez-filter-input",{"label":[1],"value":[1537],"enabled":[4],"loading":[516],"errorMessage":[1537,"error-message"],"restrict":[1],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-action-chip.cjs",[[1,"ez-action-chip",{"label":[513],"enabled":[516]}]]],["ez-application.cjs",[[0,"ez-application"]]],["ez-label-chip.cjs",[[1,"ez-label-chip",{"label":[513],"enabled":[516],"removable":[516],"value":[1540],"setFocus":[64],"setBlur":[64]}]]],["ez-popover.cjs",[[1,"ez-popover",{"autoClose":[516,"auto-close"],"top":[1537],"left":[1537],"bottom":[1537],"right":[1537],"boxWidth":[513,"box-width"],"opened":[1540],"innerElement":[1537,"inner-element"],"updatePosition":[64],"show":[64],"hide":[64]}]]],["ez-popup.cjs",[[1,"ez-popup",{"size":[1],"opened":[1540],"useHeader":[1540,"use-header"],"ezTitle":[1,"ez-title"]}]]],["ez-toast.cjs",[[1,"ez-toast",{"message":[1025],"fadeTime":[1026,"fade-time"],"useIcon":[1028,"use-icon"],"canClose":[1028,"can-close"],"show":[64]}]]],["grid-config.cjs",[[2,"grid-config",{"selectedTab":[1025,"selected-tab"],"columns":[1040]}]]],["ez-modal.cjs",[[1,"ez-modal",{"modalSize":[1,"modal-size"],"align":[1],"opened":[1028],"closeEsc":[4,"close-esc"],"closeOutsideClick":[4,"close-outside-click"]}]]],["ez-text-input.cjs",[[1,"ez-text-input",{"label":[513],"value":[1537],"enabled":[516],"loading":[516],"errorMessage":[1537,"error-message"],"mask":[1],"canShowError":[516,"can-show-error"],"restrict":[1],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-date-input.cjs",[[1,"ez-date-input",{"label":[513],"value":[1040],"enabled":[516],"errorMessage":[1537,"error-message"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-date-time-input.cjs",[[1,"ez-date-time-input",{"label":[513],"value":[1040],"enabled":[516],"errorMessage":[1537,"error-message"],"showSeconds":[516,"show-seconds"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-search.cjs",[[1,"ez-search",{"value":[1537],"label":[1537],"enabled":[1540],"errorMessage":[1537,"error-message"],"optionLoader":[16],"showSelectedValue":[4,"show-selected-value"],"showOptionValue":[4,"show-option-value"],"suppressEmptyOption":[4,"suppress-empty-option"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-time-input.cjs",[[1,"ez-time-input",{"label":[513],"viewValue":[1537,"view-value"],"value":[1026],"enabled":[516],"errorMessage":[1537,"error-message"],"showSeconds":[516,"show-seconds"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-number-input.cjs",[[1,"ez-number-input",{"label":[1],"value":[1538],"enabled":[4],"errorMessage":[1537,"error-message"],"precision":[2],"prettyPrecision":[2,"pretty-precision"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-collapsible-box.cjs",[[1,"ez-collapsible-box",{"value":[1540],"label":[513],"headerSize":[513,"header-size"],"iconPlacement":[513,"icon-placement"],"showHide":[64]}]]],["test-du.cjs",[[0,"test-du",{"isDirty":[32]}]]],["select-box.cjs",[[1,"select-box",{"selectedOption":[1,"selected-option"]}]]],["ez-list.cjs",[[1,"ez-list",{"dataSource":[1040],"useGroups":[1540,"use-groups"],"ezDraggable":[1028,"ez-draggable"],"ezSelectable":[1028,"ez-selectable"],"itemSlotBuilder":[1040],"_listItems":[32],"_listGroupItems":[32],"setSelection":[64],"getSelection":[64],"getList":[64]}]]],["ez-text-area.cjs",[[1,"ez-text-area",{"label":[513],"value":[1537],"enabled":[516],"loading":[516],"errorMessage":[1537,"error-message"],"rows":[1538],"canShowError":[516,"can-show-error"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-upload.cjs",[[1,"ez-upload",{"label":[1],"enabled":[4],"maxFileSize":[2,"max-file-size"],"maxFiles":[2,"max-files"],"requestHeaders":[8,"request-headers"],"urlUpload":[1,"url-upload"],"urlDelete":[1,"url-delete"],"value":[1040],"addFiles":[64],"setFocus":[64],"setBlur":[64]}]]],["ez-button.cjs",[[1,"ez-button",{"label":[513],"enabled":[516],"mode":[513],"image":[513],"iconName":[513,"icon-name"],"size":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-calendar.cjs",[[1,"ez-calendar",{"value":[1040],"floating":[516],"time":[516],"showSeconds":[516,"show-seconds"],"show":[64],"fitVertical":[64],"hide":[64]}]]],["ez-check.cjs",[[1,"ez-check",{"label":[513],"value":[1540],"enabled":[516],"mode":[513],"getMode":[64],"setFocus":[64]}]]],["ez-tabselector.cjs",[[1,"ez-tabselector",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1]}]]],["ez-combo-box.cjs",[[1,"ez-combo-box",{"value":[1537],"label":[513],"enabled":[516],"options":[1040],"errorMessage":[1537,"error-message"],"searchMode":[4,"search-mode"],"showSelectedValue":[4,"show-selected-value"],"showOptionValue":[4,"show-option-value"],"optionLoader":[16],"suppressEmptyOption":[4,"suppress-empty-option"],"canShowError":[516,"can-show-error"],"mode":[513],"_preSelection":[32],"_visibleOptions":[32],"setFocus":[64],"setBlur":[64]}]]],["ez-icon.cjs",[[1,"ez-icon",{"size":[513],"href":[513],"iconName":[513,"icon-name"]}]]],["ez-form.cjs",[[0,"ez-form",{"dataUnit":[1040],"config":[16],"submit":[64],"cancel":[64],"validate":[64]}]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-88286449.js');
6
6
  const core = require('@sankhyalabs/core');
7
+ const ApplicationUtils = require('./ApplicationUtils-93721afc.js');
7
8
 
8
9
  const testDuCss = ":host{display:block}";
9
10
 
@@ -11,49 +12,23 @@ let TestDu = class {
11
12
  constructor(hostRef) {
12
13
  index.registerInstance(this, hostRef);
13
14
  }
14
- /*private _ezButton// : HTMLEzButton;
15
- private _ezComboBox// : HTMLEzComboBox;
16
- private _ezDateInput// : HTMLEzDateInput;
17
- private _ezDateTimeInput// : HTMLEzDateTimeInput;
18
- private _ezNumberInput// : HTMLEzNumberInput
19
- private _ezSearch// : HTMLEzSearch
20
- private _ezUpload// : HTMLEzUpload
21
- private _ezFilterInput// : HTMLEzFilterInput*/
22
15
  componentWillLoad() {
16
+ core.ApplicationContext.setContextValue("__EZUI__UPLOAD__ADD__URL__", "http://localhost:8080/mge/ez.uploading");
23
17
  this.dataUnit = new core.DataUnit("testes_com_formulario");
18
+ this.dataUnit.subscribe(() => this.isDirty = this.dataUnit.isDirty());
24
19
  this.dataUnit.metadata = {
25
20
  name: "dd://br.com.sankhya.fin.cad.movimentacaoFinanceira/Financeiro",
26
21
  label: "Parceiro",
27
22
  fields: [
28
23
  {
29
- name: "CODPARC",
30
- label: "Parceiro",
31
- dataType: core.DataType.NUMBER,
32
- userInterface: core.UserInterface.SEARCH,
33
- required: true,
34
- properties: {}
35
- },
36
- {
37
- name: "RECDESP",
38
- label: "Receita/Despesa",
39
- dataType: core.DataType.TEXT,
40
- userInterface: core.UserInterface.OPTIONSELECTOR,
41
- required: true,
42
- properties: { options: `{"-1": "Despesa", "1": "Receita"}` }
43
- },
44
- {
45
- name: "P",
46
- label: "pera",
47
- dataType: core.DataType.TEXT,
48
- userInterface: core.UserInterface.OPTIONSELECTOR,
49
- properties: { options: `{"M": "Madura", "V": "Verde", "P": "Passada"}` }
50
- },
51
- {
52
- name: "ME",
53
- label: "ME",
54
- dataType: core.DataType.NUMBER,
55
- userInterface: core.UserInterface.DECIMALNUMBER,
56
- properties: { precision: 4, prettyPrecision: 1 }
24
+ name: "ANEXO",
25
+ label: "Anexo",
26
+ dataType: core.DataType.OBJECT,
27
+ userInterface: core.UserInterface.FILE,
28
+ properties: {
29
+ DESTINATION: "MULTIFILE",
30
+ MAX_FILES: "2"
31
+ }
57
32
  }
58
33
  ]
59
34
  };
@@ -71,9 +46,23 @@ let TestDu = class {
71
46
  total: 100,
72
47
  hasMore: true
73
48
  }));
49
+ this.dataUnit.saveLoader = (_dataUnit, changes) => {
50
+ const savedRecords = [];
51
+ changes.forEach(change => {
52
+ savedRecords.push(Object.assign(Object.assign({}, change.record), change.updatingFields));
53
+ });
54
+ return Promise.resolve(savedRecords);
55
+ };
56
+ }
57
+ save() {
58
+ this.dataUnit.saveData().catch(e => {
59
+ if (e.kind === "WAITING_CHANGE_ERROR") {
60
+ ApplicationUtils.ApplicationUtils.alert(`Alterando campo ${e.fieldName}`, e.message);
61
+ }
62
+ });
74
63
  }
75
64
  render() {
76
- return (index.h("ez-form", { dataUnit: this.dataUnit }));
65
+ return (index.h("div", null, index.h("button", { onClick: () => this.dataUnit.loadData() }, "Carregar"), index.h("button", { onClick: () => this.save(), disabled: !this.isDirty }, "Salvar"), index.h("ez-form", { dataUnit: this.dataUnit })));
77
66
  }
78
67
  };
79
68
  TestDu.style = testDuCss;
@@ -1,32 +1,58 @@
1
- import { ApplicationContext } from "@sankhyalabs/core";
1
+ import { ApplicationContext, Action } from "@sankhyalabs/core";
2
2
  export default class DataBinder {
3
3
  constructor(dataUnit) {
4
4
  this._fields = new Map();
5
5
  this._dataUnit = dataUnit;
6
- this._dataUnit.subscribe(_action => {
6
+ this._dataUnit.subscribe(action => {
7
7
  var _a;
8
- (_a = this._fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
9
- this.updateValue(field.fieldName, field.field);
10
- });
8
+ switch (action.type) {
9
+ case Action.DATA_LOADED:
10
+ case Action.DATA_SAVED:
11
+ case Action.RECORDS_REMOVED:
12
+ case Action.RECORDS_ADDED:
13
+ case Action.RECORDS_COPIED:
14
+ case Action.DATA_CHANGED:
15
+ case Action.EDITION_CANCELED:
16
+ case Action.CHANGE_UNDONE:
17
+ case Action.CHANGE_REDONE:
18
+ case Action.SELECTION_CHANGED:
19
+ case Action.NEXT_SELECTED:
20
+ case Action.PREVIOUS_SELECTED:
21
+ (_a = this._fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
22
+ this.updateValue(field.fieldName, field.field);
23
+ });
24
+ break;
25
+ }
11
26
  });
12
27
  }
13
28
  bind(fields) {
14
29
  fields.forEach(fieldElement => {
15
30
  const fieldName = fieldElement.dataset.fieldName;
16
31
  this.updateBind(fieldName, fieldElement);
17
- this.updateValue(fieldName, fieldElement);
18
32
  });
19
33
  }
20
34
  updateValue(fieldName, field) {
21
- field["value"] = this._dataUnit.getFieldValue(fieldName);
35
+ const oldValue = field["value"];
36
+ const newValue = this._dataUnit.getFieldValue(fieldName);
37
+ if (oldValue != newValue) {
38
+ field["value"] = newValue;
39
+ }
22
40
  }
23
41
  updateBind(fieldName, field) {
24
42
  const oldBind = this._fields.get(fieldName);
25
43
  if (oldBind) {
26
44
  oldBind.destroy();
27
45
  }
28
- this._fields.set(fieldName, Bind.create(fieldName, field, (fieldName, newValue) => this.setFieldValue(fieldName, newValue)));
46
+ field["value"] = this._dataUnit.getFieldValue(fieldName);
47
+ this._fields.set(fieldName, Bind.create(fieldName, field, (fieldName, waitingChange) => this.changeStarted(fieldName, waitingChange), (fieldName, newValue) => this.setFieldValue(fieldName, newValue)));
29
48
  this.bindSearchOptionsLoader(fieldName, field);
49
+ this.applyEzUploadContext(fieldName, field);
50
+ }
51
+ changeStarted(fieldName, waitingChange) {
52
+ if (this._dataUnit.records.length === 0) {
53
+ this._dataUnit.addRecord();
54
+ }
55
+ this._dataUnit.startChange(fieldName, waitingChange);
30
56
  }
31
57
  setFieldValue(fieldName, newValue) {
32
58
  if (this._dataUnit.records.length === 0) {
@@ -44,19 +70,37 @@ export default class DataBinder {
44
70
  }
45
71
  }
46
72
  }
73
+ applyEzUploadContext(fieldName, field) {
74
+ var _a, _b;
75
+ if (field.nodeName === "EZ-UPLOAD") {
76
+ field["urlUpload"] = ApplicationContext.getContextValue("__EZUI__UPLOAD__ADD__URL__");
77
+ field["urlDelete"] = ApplicationContext.getContextValue("__EZUI__UPLOAD__DEL__URL__");
78
+ const descriptor = this._dataUnit.getField(fieldName);
79
+ const destination = (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.DESTINATION;
80
+ if (destination) {
81
+ field["requestHeaders"] = { XTRAINF: `{"destination": "${destination}"}` };
82
+ }
83
+ field["maxFiles"] = ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.MAX_FILES) || 0;
84
+ }
85
+ }
47
86
  }
48
87
  class Bind {
88
+ constructor() {
89
+ this.startChangeEventName = "ezStartChange";
90
+ this.changeEventName = "ezChange";
91
+ }
49
92
  destroy() {
50
- this.field.removeEventListener(this.eventName, this.eventListener);
93
+ this.field.removeEventListener(this.startChangeEventName, this.startChangeListener);
94
+ this.field.removeEventListener(this.changeEventName, this.changeListener);
51
95
  }
52
- static create(fieldName, field, callback) {
96
+ static create(fieldName, field, startChangeCallback, changeCallback) {
53
97
  const b = new Bind();
54
- b.fieldName = fieldName;
55
98
  b.field = field;
56
- //FIXME: Verificar se o field é um EzField
57
- b.eventListener = (evt) => { callback(fieldName, evt.detail); };
58
- b.eventName = "ezChange";
59
- b.field.addEventListener(b.eventName, b.eventListener);
99
+ b.fieldName = fieldName;
100
+ b.startChangeListener = (evt) => { startChangeCallback(fieldName, evt.detail); };
101
+ b.field.addEventListener(b.startChangeEventName, b.startChangeListener);
102
+ b.changeListener = (evt) => { changeCallback(fieldName, evt.detail); };
103
+ b.field.addEventListener(b.changeEventName, b.changeListener);
60
104
  return b;
61
105
  }
62
106
  }
@@ -1,5 +1,5 @@
1
1
  import { h } from "@stencil/core";
2
2
  export const buildFile = ({ name, label, readOnly }) => {
3
3
  return (h("div", { class: "col col--sd-12 padding-horizontal--small" },
4
- h("ez-upload", { enabled: !readOnly, label: label, urlUpload: "", requestHeaders: "", maxFiles: 10, "data-field-name": name, key: name })));
4
+ h("ez-upload", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
5
5
  };
@@ -10,6 +10,9 @@ export class EzUpload {
10
10
  this.enabled = true;
11
11
  }
12
12
  changeValue(newValue) {
13
+ //Observamos o mundo externo, se um novo valor foi atribuído,
14
+ //precisamos cancelar a alteração anterior, isso envolve, percorrer
15
+ //a lista de ponteiros e cancelar todos os uploads em andamento.
13
16
  if (newValue !== this._updatingValue) {
14
17
  this._filePointers.forEach(f => {
15
18
  if (this.isRemoteFile(f)) {
@@ -18,8 +21,8 @@ export class EzUpload {
18
21
  });
19
22
  this._filePointers = new Map();
20
23
  this.updateFilePointers();
24
+ this._updatingValue = undefined;
21
25
  }
22
- this._updatingValue = undefined;
23
26
  }
24
27
  updateFilePointers() {
25
28
  if (this.value) {
@@ -89,6 +92,7 @@ export class EzUpload {
89
92
  }
90
93
  async doAddFile(file) {
91
94
  if (this.validateFile(file)) {
95
+ this.ezStartChange.emit({ waitmessage: "Há arquivos sendo enviados. Por favor aguarde a conclusão ou cancele o envio." });
92
96
  const uploadingFile = new RemoteFile(file);
93
97
  this._filePointers.set(file.name, uploadingFile);
94
98
  uploadingFile.upload(this.urlUpload, this._requestHeaders, (file) => this.updateFeedback(file))
@@ -108,8 +112,10 @@ export class EzUpload {
108
112
  this._updatingValue.push(f);
109
113
  }
110
114
  });
111
- this.value = this._updatingValue;
112
- this.ezChange.emit(this.value);
115
+ if (this._filePointers.size === this._updatingValue.length) {
116
+ this.value = this._updatingValue;
117
+ this.ezChange.emit(this.value);
118
+ }
113
119
  }
114
120
  buildProgressId(uploading) {
115
121
  let sanitizedName = uploading.name.replace(/[^a-z0-9_]/gi, "_");
@@ -435,6 +441,26 @@ export class EzUpload {
435
441
  }
436
442
  }
437
443
  }
444
+ }, {
445
+ "method": "ezStartChange",
446
+ "name": "ezStartChange",
447
+ "bubbles": true,
448
+ "cancelable": true,
449
+ "composed": true,
450
+ "docs": {
451
+ "tags": [],
452
+ "text": "Evento emitido ao iniciar a altera\u00E7\u00E3o (remover ou adicionar um arquivo)."
453
+ },
454
+ "complexType": {
455
+ "original": "WaitingChange",
456
+ "resolved": "WaitingChange",
457
+ "references": {
458
+ "WaitingChange": {
459
+ "location": "import",
460
+ "path": "@sankhyalabs/core"
461
+ }
462
+ }
463
+ }
438
464
  }]; }
439
465
  static get methods() { return {
440
466
  "addFiles": {
@@ -1,49 +1,24 @@
1
- import { Component, h } from '@stencil/core';
2
- import { DataUnit, DataType, UserInterface } from '@sankhyalabs/core';
1
+ import { Component, h, State } from '@stencil/core';
2
+ import { DataUnit, DataType, UserInterface, ApplicationContext } from '@sankhyalabs/core';
3
+ import { ApplicationUtils } from '../../utils';
3
4
  export class TestDu {
4
- /*private _ezButton// : HTMLEzButton;
5
- private _ezComboBox// : HTMLEzComboBox;
6
- private _ezDateInput// : HTMLEzDateInput;
7
- private _ezDateTimeInput// : HTMLEzDateTimeInput;
8
- private _ezNumberInput// : HTMLEzNumberInput
9
- private _ezSearch// : HTMLEzSearch
10
- private _ezUpload// : HTMLEzUpload
11
- private _ezFilterInput// : HTMLEzFilterInput*/
12
5
  componentWillLoad() {
6
+ ApplicationContext.setContextValue("__EZUI__UPLOAD__ADD__URL__", "http://localhost:8080/mge/ez.uploading");
13
7
  this.dataUnit = new DataUnit("testes_com_formulario");
8
+ this.dataUnit.subscribe(() => this.isDirty = this.dataUnit.isDirty());
14
9
  this.dataUnit.metadata = {
15
10
  name: "dd://br.com.sankhya.fin.cad.movimentacaoFinanceira/Financeiro",
16
11
  label: "Parceiro",
17
12
  fields: [
18
13
  {
19
- name: "CODPARC",
20
- label: "Parceiro",
21
- dataType: DataType.NUMBER,
22
- userInterface: UserInterface.SEARCH,
23
- required: true,
24
- properties: {}
25
- },
26
- {
27
- name: "RECDESP",
28
- label: "Receita/Despesa",
29
- dataType: DataType.TEXT,
30
- userInterface: UserInterface.OPTIONSELECTOR,
31
- required: true,
32
- properties: { options: `{"-1": "Despesa", "1": "Receita"}` }
33
- },
34
- {
35
- name: "P",
36
- label: "pera",
37
- dataType: DataType.TEXT,
38
- userInterface: UserInterface.OPTIONSELECTOR,
39
- properties: { options: `{"M": "Madura", "V": "Verde", "P": "Passada"}` }
40
- },
41
- {
42
- name: "ME",
43
- label: "ME",
44
- dataType: DataType.NUMBER,
45
- userInterface: UserInterface.DECIMALNUMBER,
46
- properties: { precision: 4, prettyPrecision: 1 }
14
+ name: "ANEXO",
15
+ label: "Anexo",
16
+ dataType: DataType.OBJECT,
17
+ userInterface: UserInterface.FILE,
18
+ properties: {
19
+ DESTINATION: "MULTIFILE",
20
+ MAX_FILES: "2"
21
+ }
47
22
  }
48
23
  ]
49
24
  };
@@ -61,9 +36,26 @@ export class TestDu {
61
36
  total: 100,
62
37
  hasMore: true
63
38
  }));
39
+ this.dataUnit.saveLoader = (_dataUnit, changes) => {
40
+ const savedRecords = [];
41
+ changes.forEach(change => {
42
+ savedRecords.push(Object.assign(Object.assign({}, change.record), change.updatingFields));
43
+ });
44
+ return Promise.resolve(savedRecords);
45
+ };
46
+ }
47
+ save() {
48
+ this.dataUnit.saveData().catch(e => {
49
+ if (e.kind === "WAITING_CHANGE_ERROR") {
50
+ ApplicationUtils.alert(`Alterando campo ${e.fieldName}`, e.message);
51
+ }
52
+ });
64
53
  }
65
54
  render() {
66
- return (h("ez-form", { dataUnit: this.dataUnit }));
55
+ return (h("div", null,
56
+ h("button", { onClick: () => this.dataUnit.loadData() }, "Carregar"),
57
+ h("button", { onClick: () => this.save(), disabled: !this.isDirty }, "Salvar"),
58
+ h("ez-form", { dataUnit: this.dataUnit })));
67
59
  }
68
60
  static get is() { return "test-du"; }
69
61
  static get originalStyleUrls() { return {
@@ -72,4 +64,7 @@ export class TestDu {
72
64
  static get styleUrls() { return {
73
65
  "$": ["test-du.css"]
74
66
  }; }
67
+ static get states() { return {
68
+ "isDirty": {}
69
+ }; }
75
70
  }