@sankhyalabs/sankhyablocks 1.1.19 → 1.1.22

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.
@@ -7,6 +7,8 @@ import ParametersFetcher from "../../lib/http/data-fetcher/fetchers/parameters-f
7
7
  //incluída no pacote. Isso deve ser resolvido nas proximas entregas e então ajustado aqui
8
8
  import ApplicationUtils from "../../temp/ApplicationUtils";
9
9
  import { FormConfigFetcher } from "../../lib/http/data-fetcher/fetchers/form-config-fetcher";
10
+ import { ApplicationContext } from "@sankhyalabs/core";
11
+ import { pesquisaLoadOptions } from "../../lib/utils/pesquisa";
10
12
  export class SnkApplication {
11
13
  get parameters() {
12
14
  if (!this._parameters) {
@@ -110,6 +112,9 @@ export class SnkApplication {
110
112
  }
111
113
  return this._formConfigFetcher;
112
114
  }
115
+ componentWillLoad() {
116
+ ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__", pesquisaLoadOptions);
117
+ }
113
118
  componentDidLoad() {
114
119
  this.applicationLoading.emit(true);
115
120
  window.requestAnimationFrame(() => {
@@ -1,4 +1,4 @@
1
- import { DataUnit, } from "@sankhyalabs/core";
1
+ import { DataUnit, ChangeOperation, } from "@sankhyalabs/core";
2
2
  import { HttpFetcher } from "../DataFetcher";
3
3
  import { gql } from "graphql-request";
4
4
  export default class DataUnitFetcher {
@@ -63,6 +63,7 @@ export default class DataUnitFetcher {
63
63
  dataUnit.metadataLoader = (dataUnit) => this.loadMetadata(dataUnit);
64
64
  dataUnit.dataLoader = (dataUnit, sort, filters) => this.loadData(dataUnit, sort, filters);
65
65
  dataUnit.saveLoader = (dataUnit, changes) => this.saveData(dataUnit, changes);
66
+ dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
66
67
  return dataUnit;
67
68
  }
68
69
  loadMetadata(dataUnit) {
@@ -123,7 +124,12 @@ export default class DataUnitFetcher {
123
124
  const { dataUnit: changeDU, record, updatingFields, operation } = change;
124
125
  const parsedUpdatingFields = Object.entries(updatingFields).map(([fieldName, value]) => {
125
126
  if (value) {
126
- value = value.toString();
127
+ try {
128
+ value = JSON.stringify(value);
129
+ }
130
+ catch (_a) {
131
+ value = value.toString();
132
+ }
127
133
  }
128
134
  return { fieldName, value };
129
135
  });
@@ -154,4 +160,22 @@ export default class DataUnitFetcher {
154
160
  });
155
161
  });
156
162
  }
163
+ removeRecords(dataUnit, recordIds) {
164
+ const changes = recordIds.map((recordId) => {
165
+ return { dataUnit: dataUnit.name, operation: ChangeOperation.DELETE, recordId };
166
+ });
167
+ return new Promise((resolve, reject) => {
168
+ HttpFetcher.get()
169
+ .callGraphQL({
170
+ values: { changes: changes },
171
+ query: this.templateByQuery.get("saveData"),
172
+ })
173
+ .then((_resp) => {
174
+ resolve(recordIds);
175
+ })
176
+ .catch((error) => {
177
+ reject(error);
178
+ });
179
+ });
180
+ }
157
181
  }
@@ -8,7 +8,7 @@ export class FormConfigFetcher extends ResourceFetcher {
8
8
  const config = JSON.parse(configAsString);
9
9
  const { tabs, fields } = config;
10
10
  if (tabs) {
11
- const allTabs = new Map(tabs.map(t => [t.tabKey, t]));
11
+ const allTabs = new Map(tabs.map(t => [t.label, t]));
12
12
  fields.forEach(f => f.tab = allTabs.get(f.tab));
13
13
  }
14
14
  accept(fields);
@@ -0,0 +1,16 @@
1
+ const mockByEntity = {
2
+ "ImplantacaoSaldoConta": [{ "value": 6, "label": "Conta Financeiro" }, { "value": 7, "label": "Conta Banco do Brasil" }],
3
+ "HistoricoBancario": [{ "value": 9, "label": "Lanç. Origem" }, { "value": 8, "label": "Lanç. Origem 2" }],
4
+ "ContaDestino": [{ "value": 10, "label": "Conta BB" }, { "value": 7, "label": "Conta Santander" }],
5
+ "HistoricoBancarioDestino": [{ "value": 11, "label": "Contra Bradesco" }, { "value": 13, "label": "Contra Destino" }],
6
+ "Usuario": [{ "value": 0, "label": "SUP" }],
7
+ "ContaBancaria": [{ "value": 10, "label": "Conta 10" }, { "value": 17, "label": "Conta 17" }],
8
+ "TipoOperacao": [{ "value": 4, "label": "Entrada NFse" }, { "value": 5, "label": "Outra top" }, { "value": 6, "label": "Top 6" }]
9
+ };
10
+ export const pesquisaLoadOptions = (searchArgument, fieldName, dataUnit) => {
11
+ var _a;
12
+ console.log(searchArgument);
13
+ const field = dataUnit.getField(fieldName);
14
+ const entityName = (_a = field.properties) === null || _a === void 0 ? void 0 : _a.ENTITYNAME;
15
+ return (mockByEntity[entityName] || []);
16
+ };