@znap/components-vue2 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -9
- package/dist/index.common.js +18 -8
- package/dist/index.common.js.map +1 -1
- package/dist/index.umd.js +18 -8
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/utils/views/generateCrudViewConfigs.d.ts +6 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ import * as ZnapComponents from '@znap/components-vue2';
|
|
|
64
64
|
@update:row="updateRow"
|
|
65
65
|
>
|
|
66
66
|
<template v-slot:footer-prepend>
|
|
67
|
-
|
|
67
|
+
Slot para adicionar elementos do lado esquerdo dos componentes de paginaçao.
|
|
68
68
|
</template>
|
|
69
69
|
</ZnapBaseCrudView>
|
|
70
70
|
</template>
|
|
@@ -190,8 +190,8 @@ export default {
|
|
|
190
190
|
// Modelo inicial do formulario
|
|
191
191
|
});
|
|
192
192
|
|
|
193
|
-
this.viewSettings = crudViewConfigs.viewConfigs;
|
|
194
|
-
this.viewMethods = crudViewConfigs.viewMethods;
|
|
193
|
+
this.viewSettings = crudViewConfigs.viewConfigs; // Retorna o objeto de configuraçoes da classe (Se tornara o state do componente)
|
|
194
|
+
this.viewMethods = crudViewConfigs.viewMethods; // Retorna os metodos pre prontos disponiveis da classe.
|
|
195
195
|
|
|
196
196
|
|
|
197
197
|
// Pode usar os metodos das classe CrudViewConfigs ou entao criar os proprios de acordo com a necessidade.
|
|
@@ -211,10 +211,10 @@ export default {
|
|
|
211
211
|
},
|
|
212
212
|
methods: {
|
|
213
213
|
updateRowsChanged() {
|
|
214
|
-
this.viewSettings.rowsChanged = new Set(this.viewSettings.rowsChanged);
|
|
214
|
+
this.viewSettings.rowsChanged = new Set(this.viewSettings.rowsChanged); // Importante para o Vue detectar que o rowsChanged alterou e exibir o elemento em destaque na tabela.
|
|
215
215
|
}
|
|
216
216
|
updateRow() {
|
|
217
|
-
this.$set(this.viewSettings.apiData, rowIndex, data);
|
|
217
|
+
this.$set(this.viewSettings.apiData, rowIndex, data); // Importante para o vue detectar que teve alteraçao no elemento da tabela.
|
|
218
218
|
}
|
|
219
219
|
async onReload() {
|
|
220
220
|
// Logica de como sera tratado o evento de reload.
|
|
@@ -222,15 +222,21 @@ export default {
|
|
|
222
222
|
async onExportFile() {
|
|
223
223
|
// Logica de como sera tratado o evento de exportaçao de arquivo.
|
|
224
224
|
}
|
|
225
|
-
async onImportFile(
|
|
225
|
+
async onImportFile(
|
|
226
|
+
event // evento contendo o elemento do input de arquivo
|
|
227
|
+
) {
|
|
226
228
|
// Logica de como sera tratado o evento de importaçao de arquivo.
|
|
227
229
|
}
|
|
228
|
-
async onSave(
|
|
230
|
+
async onSave({
|
|
231
|
+
reload = true, // variavel retornada do comoponente para verificar se deve ou nao realizar o reload (Fica a cargo do desenvolvedor)
|
|
232
|
+
itemData = null // Se for um item proveniente da modal (Criaçao/Ediçao) os dados virão aqui
|
|
233
|
+
}) {
|
|
229
234
|
// Logica de como sera tratado o evento de salvamento de registro(s)
|
|
230
235
|
}
|
|
231
|
-
async onDelete(
|
|
236
|
+
async onDelete(
|
|
237
|
+
rows // Array com as linhas que devem ser excluidas
|
|
238
|
+
) {
|
|
232
239
|
// Logica de como sera tratado o evento de exclusao de registro(s)
|
|
233
|
-
|
|
234
240
|
}
|
|
235
241
|
async fetchData() {
|
|
236
242
|
// Logica de busca de dados principais
|
|
@@ -242,3 +248,10 @@ export default {
|
|
|
242
248
|
```
|
|
243
249
|
|
|
244
250
|
|
|
251
|
+
### Utilizaçao da Classe Auxiliar **CrudViewConfigs**
|
|
252
|
+
|
|
253
|
+
O intuito dessa classe é fornecer ao desenvolvedor uma interface padronizada de criaçao de telas, tornando o processo padronizado e de facil aprendizado.
|
|
254
|
+
|
|
255
|
+
A classe retorna metodos e um objeto padrao de estado para ser utilizado para manipular o componente **ZnapBaseCrudView** por meio dos getters **viewConfigs** e **viewMethods**, alem disso, pussui diversos metodos/interfaces para o desenvolvedor adicionar elementos na tela de maneira padronizada evitando refazer a roda toda vez que for construir uma nova tela.
|
|
256
|
+
|
|
257
|
+
|
package/dist/index.common.js
CHANGED
|
@@ -49191,6 +49191,7 @@ class CrudViewConfigs {
|
|
|
49191
49191
|
const optionsPromises = [];
|
|
49192
49192
|
tableOptions.forEach(option => {
|
|
49193
49193
|
if (!option?.endpoint[0]) return optionsPromises.push(null);
|
|
49194
|
+
if (option?.ignoreOnFetchFunction) return optionsPromises.push(null);
|
|
49194
49195
|
optionsPromises.push(httpFetcher.post(option.endpoint[0], option.endpoint[1] ?? null));
|
|
49195
49196
|
});
|
|
49196
49197
|
const optionsData = await Promise.all(optionsPromises);
|
|
@@ -49202,6 +49203,7 @@ class CrudViewConfigs {
|
|
|
49202
49203
|
const optionsPromises = [];
|
|
49203
49204
|
formOptions.forEach(option => {
|
|
49204
49205
|
option.loading = true;
|
|
49206
|
+
if (option?.ignoreOnFetchFunction) return optionsPromises.push(null);
|
|
49205
49207
|
optionsPromises.push(httpFetcher.post(option.endpoint[0], option.endpoint[1] ?? null));
|
|
49206
49208
|
});
|
|
49207
49209
|
const optionsData = await Promise.all(optionsPromises);
|
|
@@ -49213,14 +49215,16 @@ class CrudViewConfigs {
|
|
|
49213
49215
|
async fetchFiltersData(filters, httpFetcher) {
|
|
49214
49216
|
const primaryFiltersPromises = filters?.primary.flatMap(async (filter, index) => {
|
|
49215
49217
|
if (!filter.endpoint?.length || !filter.endpoint[0]) return [index, null];
|
|
49218
|
+
if (filter.ignoreOnFetchFunction) return [index, null];
|
|
49216
49219
|
filter.props.loading = true;
|
|
49217
|
-
const response = await httpFetcher.post(
|
|
49220
|
+
const response = await httpFetcher.post(filter.endpoint[0], filter.endpoint[1] ?? {});
|
|
49218
49221
|
return [index, response?.data];
|
|
49219
49222
|
}) ?? [];
|
|
49220
49223
|
const secondaryFiltersPromises = filters?.secondary?.flatMap(async (filter, index) => {
|
|
49221
49224
|
if (!filter.endpoint?.length || !filter.endpoint[0]) return [index, null];
|
|
49225
|
+
if (filter.ignoreOnFetchFunction) return [index, null];
|
|
49222
49226
|
filter.props.loading = true;
|
|
49223
|
-
const response = await httpFetcher.post(
|
|
49227
|
+
const response = await httpFetcher.post(filter.endpoint[0], filter.endpoint[1] ?? {});
|
|
49224
49228
|
return [index, response?.data];
|
|
49225
49229
|
}) ?? [];
|
|
49226
49230
|
const [primaryFiltersData, secondaryFiltersData] = await Promise.all([Promise.all(primaryFiltersPromises), Promise.all(secondaryFiltersPromises)]);
|
|
@@ -49271,7 +49275,8 @@ class CrudViewConfigs {
|
|
|
49271
49275
|
endpoint = [],
|
|
49272
49276
|
componentProps = {},
|
|
49273
49277
|
hooks = {},
|
|
49274
|
-
dependsOn = ""
|
|
49278
|
+
dependsOn = "",
|
|
49279
|
+
ignoreOnFetchFunction = false
|
|
49275
49280
|
} = {}) {
|
|
49276
49281
|
if (!this.avalibleFilterComponents.has(filterComponent)) throw new Error("O componente escolhido para o filtro não é um componente valido!");
|
|
49277
49282
|
const hooksKeys = Object.keys(hooks);
|
|
@@ -49291,7 +49296,8 @@ class CrudViewConfigs {
|
|
|
49291
49296
|
returnObject: false,
|
|
49292
49297
|
...componentProps
|
|
49293
49298
|
},
|
|
49294
|
-
hooks
|
|
49299
|
+
hooks,
|
|
49300
|
+
ignoreOnFetchFunction
|
|
49295
49301
|
});
|
|
49296
49302
|
return this;
|
|
49297
49303
|
}
|
|
@@ -49315,7 +49321,8 @@ class CrudViewConfigs {
|
|
|
49315
49321
|
endpoint = [],
|
|
49316
49322
|
componentProps = {},
|
|
49317
49323
|
hooks = {},
|
|
49318
|
-
dependsOn = ""
|
|
49324
|
+
dependsOn = "",
|
|
49325
|
+
ignoreOnFetchFunction = false
|
|
49319
49326
|
} = {}) {
|
|
49320
49327
|
if (!this.avalibleFilterComponents.has(filterComponent)) throw new Error("O componente escolhido para o filtro não é um componente valido!");
|
|
49321
49328
|
const hooksKeys = Object.keys(hooks);
|
|
@@ -49335,7 +49342,8 @@ class CrudViewConfigs {
|
|
|
49335
49342
|
...componentProps
|
|
49336
49343
|
},
|
|
49337
49344
|
dependsOn,
|
|
49338
|
-
hooks
|
|
49345
|
+
hooks,
|
|
49346
|
+
ignoreOnFetchFunction
|
|
49339
49347
|
});
|
|
49340
49348
|
return this;
|
|
49341
49349
|
}
|
|
@@ -49348,14 +49356,16 @@ class CrudViewConfigs {
|
|
|
49348
49356
|
itemsArray = [],
|
|
49349
49357
|
endpoint = [],
|
|
49350
49358
|
formatter = null,
|
|
49351
|
-
filterFunction = null
|
|
49359
|
+
filterFunction = null,
|
|
49360
|
+
ignoreOnFetchFunction = false
|
|
49352
49361
|
} = {}) {
|
|
49353
49362
|
this.tableOptions.push({
|
|
49354
49363
|
column: this.isValidColumn(column) ? column : "",
|
|
49355
49364
|
endpoint: this.isValidEndpoint(endpoint) ? endpoint : CrudViewConfigs.generateEndpoint(),
|
|
49356
49365
|
items: this.isValidItemsArray(itemsArray) ? itemsArray : [],
|
|
49357
49366
|
formatter,
|
|
49358
|
-
filterFunction
|
|
49367
|
+
filterFunction,
|
|
49368
|
+
ignoreOnFetchFunction
|
|
49359
49369
|
});
|
|
49360
49370
|
return this;
|
|
49361
49371
|
}
|