@bildvitta/quasar-ui-asteroid 3.1.0 → 3.2.0-beta.0
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/api/QasTransfer.json +2 -1
- package/dist/api/QasTreeGenerator.json +89 -0
- package/dist/asteroid.cjs.css +1 -1
- package/dist/asteroid.cjs.js +2926 -2153
- package/dist/asteroid.cjs.min.js +2 -2
- package/dist/asteroid.esm.css +1 -1
- package/dist/asteroid.esm.js +2727 -1955
- package/dist/asteroid.esm.min.js +2 -2
- package/dist/asteroid.umd.css +1 -1
- package/dist/asteroid.umd.js +2728 -1956
- package/dist/asteroid.umd.min.js +2 -2
- package/dist/vetur/asteroid-attributes.json +56 -0
- package/dist/vetur/asteroid-tags.json +19 -0
- package/package.json +1 -1
- package/src/components/nested-fields/QasNestedFields.vue +9 -1
- package/src/components/transfer/QasTransfer.yml +1 -0
- package/src/components/tree-generator/QasTreeForm.vue +62 -0
- package/src/components/tree-generator/QasTreeGenerator.vue +488 -0
- package/src/components/tree-generator/QasTreeGenerator.yml +81 -0
- package/src/helpers/destroy-nested-children-by-key.js +33 -0
- package/src/helpers/find-children-by-key.js +14 -0
- package/src/helpers/index.js +4 -0
- package/src/helpers/promise-handler.js +37 -0
- package/src/helpers/rules.js +7 -0
- package/src/vue-plugin.js +3 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
type: component
|
|
2
|
+
|
|
3
|
+
meta:
|
|
4
|
+
desc: Componente de árvore onde é possível adicionar/editar/excluir sem limites de ramos.
|
|
5
|
+
|
|
6
|
+
props:
|
|
7
|
+
form-generator-props:
|
|
8
|
+
desc: Propriedades enviadas para o "QasFormGenerator".
|
|
9
|
+
type: Object
|
|
10
|
+
default: {}
|
|
11
|
+
|
|
12
|
+
form-view-props:
|
|
13
|
+
desc: Propriedades enviadas para o "QasFormView".
|
|
14
|
+
type: Object
|
|
15
|
+
default: {}
|
|
16
|
+
|
|
17
|
+
label-key:
|
|
18
|
+
desc: Chave identificadora da label, por padrão o componente considera label, é possível alterar o valor enviado para API através desta chave.
|
|
19
|
+
type: String
|
|
20
|
+
default: name
|
|
21
|
+
|
|
22
|
+
lazy-nodes:
|
|
23
|
+
desc: Model do lazy, toda vez que é adicionado/editado/excluído um nó este model é atualizado, ele não é um "two way data binding" alterações fora do componente não afetarão o componente.
|
|
24
|
+
type: Array
|
|
25
|
+
default: []
|
|
26
|
+
model: true
|
|
27
|
+
examples: [v-model:lazyNodes="lazyNodes"]
|
|
28
|
+
|
|
29
|
+
nodes:
|
|
30
|
+
desc: Nested de Array de objeto contendo label, uuid, lazy e children, é a propriedade responsável por montar a árvore, precisa ser enviado toda a árvore de uma vez.
|
|
31
|
+
type: Array
|
|
32
|
+
default: []
|
|
33
|
+
|
|
34
|
+
readonly:
|
|
35
|
+
desc: Habilita a árvore para modo de visualização somente, não sendo possível adicionar/editar/remover nenhum ramo.
|
|
36
|
+
type: Boolean
|
|
37
|
+
|
|
38
|
+
resource:
|
|
39
|
+
desc: Usado como endpoint da API para adicionar/remover/excluir, quando não utilizar o QasFormView.
|
|
40
|
+
type: String
|
|
41
|
+
default: ''
|
|
42
|
+
|
|
43
|
+
tree-props:
|
|
44
|
+
desc: Propriedades enviada para o QTree.
|
|
45
|
+
default: {}
|
|
46
|
+
type: Object
|
|
47
|
+
|
|
48
|
+
use-add-button:
|
|
49
|
+
desc: Habilita o botão de adicionar novos ramos.
|
|
50
|
+
default: true
|
|
51
|
+
type: Boolean
|
|
52
|
+
|
|
53
|
+
use-destroy-button:
|
|
54
|
+
desc: Habilita o botão de remover os ramos.
|
|
55
|
+
default: true
|
|
56
|
+
type: Boolean
|
|
57
|
+
|
|
58
|
+
use-destroy-on-first-node:
|
|
59
|
+
desc: Habilita o botão de remover o primeiro ramo da árvore.
|
|
60
|
+
type: Boolean
|
|
61
|
+
|
|
62
|
+
use-edit-button:
|
|
63
|
+
desc: Habilita o botão de editar os ramos.
|
|
64
|
+
default: true
|
|
65
|
+
type: Boolean
|
|
66
|
+
|
|
67
|
+
use-form-view-edit:
|
|
68
|
+
desc: Habilita o form-view como componente a ser renderizado ao abrir o dialog em modo de edição.
|
|
69
|
+
type: Boolean
|
|
70
|
+
|
|
71
|
+
use-form-view-add:
|
|
72
|
+
desc: Habilita o form-view como componente a ser renderizado ao abrir o dialog em modo de adição.
|
|
73
|
+
type: Boolean
|
|
74
|
+
|
|
75
|
+
events:
|
|
76
|
+
'@update:lazy-nodes -> function(value)':
|
|
77
|
+
desc: Dispara toda vez que é adicionado/editado/excluído um nó este model é atualizado, também usado para v-model.
|
|
78
|
+
params:
|
|
79
|
+
value:
|
|
80
|
+
desc: Novo valor do model.
|
|
81
|
+
type: Array
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export default function destroyNestedChildrenByKey (nested = [], destroyedKey = 'destroyed') {
|
|
2
|
+
if (!Array.isArray(nested)) {
|
|
3
|
+
throw new Error('Please provide a valid array.')
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
let index = 0
|
|
7
|
+
|
|
8
|
+
function hasNext () {
|
|
9
|
+
return index < nested.length
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function next () {
|
|
13
|
+
return nested[index++]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
while (hasNext()) {
|
|
17
|
+
const current = next()
|
|
18
|
+
|
|
19
|
+
if (current[destroyedKey]) {
|
|
20
|
+
index--
|
|
21
|
+
nested.splice(index, 1)
|
|
22
|
+
continue
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
for (const key in current) {
|
|
26
|
+
if (Array.isArray(current[key]) && current[key].length) {
|
|
27
|
+
destroyNestedChildrenByKey(nested[index - 1][key])
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return nested
|
|
33
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default (nested = [], key, value) => {
|
|
2
|
+
let response = null
|
|
3
|
+
|
|
4
|
+
nested.some(function findNodes (item) {
|
|
5
|
+
if (item[key] === value) {
|
|
6
|
+
response = item
|
|
7
|
+
return true
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return Array.isArray(item.children) && item.children.some(findNodes)
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
return response
|
|
14
|
+
}
|
package/src/helpers/index.js
CHANGED
|
@@ -11,6 +11,10 @@ export { default as filterListByHandle } from './filter-list-by-handle.js'
|
|
|
11
11
|
export { default as camelizeFieldsName } from './camelize-fields-name.js'
|
|
12
12
|
export { default as getNormalizedOptions } from './get-normalized-options.js'
|
|
13
13
|
export { default as handleProcess } from './handle-process.js'
|
|
14
|
+
export { default as destroyNestedChildrenByKey } from './destroy-nested-children-by-key.js'
|
|
15
|
+
export { default as promiseHandler } from './promise-handler.js'
|
|
16
|
+
export { default as findChildrenByKey } from './find-children-by-key'
|
|
14
17
|
|
|
15
18
|
export * from './filters.js'
|
|
16
19
|
export * from './images.js'
|
|
20
|
+
export * from './rules'
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Loading } from 'quasar'
|
|
2
|
+
import { NotifySuccess, NotifyError } from '../plugins'
|
|
3
|
+
|
|
4
|
+
/** Função para lidar com promises, por exemplo requests.
|
|
5
|
+
*
|
|
6
|
+
* @param {Promise} promise
|
|
7
|
+
* @param {object} config={successMessage, errorMessage, useLoading}
|
|
8
|
+
* @example promiseHandle(new Promise(), { errorMessage: 'Erro', successMessage: 'Sucesso' })
|
|
9
|
+
*/
|
|
10
|
+
export default async function (promise, config = {}) {
|
|
11
|
+
const {
|
|
12
|
+
successMessage,
|
|
13
|
+
errorMessage,
|
|
14
|
+
useLoading = true,
|
|
15
|
+
onLoading
|
|
16
|
+
} = config
|
|
17
|
+
|
|
18
|
+
onLoading && onLoading(true)
|
|
19
|
+
useLoading && Loading.show()
|
|
20
|
+
|
|
21
|
+
const promiseToBeExec = typeof promise === 'function' ? promise() : promise
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
const data = await (Array.isArray(promise) ? Promise.all(promise) : promiseToBeExec)
|
|
25
|
+
|
|
26
|
+
if (successMessage) NotifySuccess(successMessage)
|
|
27
|
+
|
|
28
|
+
return { data, error: null }
|
|
29
|
+
} catch (error) {
|
|
30
|
+
if (errorMessage) NotifyError(errorMessage)
|
|
31
|
+
|
|
32
|
+
return { data: null, error }
|
|
33
|
+
} finally {
|
|
34
|
+
onLoading && onLoading(false)
|
|
35
|
+
Loading.hide()
|
|
36
|
+
}
|
|
37
|
+
}
|
package/src/vue-plugin.js
CHANGED
|
@@ -45,6 +45,7 @@ import QasTableGenerator from './components/table-generator/QasTableGenerator.vu
|
|
|
45
45
|
import QasTabsGenerator from './components/tabs-generator/QasTabsGenerator.vue'
|
|
46
46
|
import QasTextTruncate from './components/text-truncate/QasTextTruncate.vue'
|
|
47
47
|
import QasTransfer from './components/transfer/QasTransfer.vue'
|
|
48
|
+
import QasTreeGenerator from './components/tree-generator/QasTreeGenerator.vue'
|
|
48
49
|
import QasUploader from './components/uploader/QasUploader.vue'
|
|
49
50
|
|
|
50
51
|
import VueGoogleMaps from '@fawmi/vue-google-maps'
|
|
@@ -114,6 +115,7 @@ function install (app) {
|
|
|
114
115
|
app.component('QasTabsGenerator', QasTabsGenerator)
|
|
115
116
|
app.component('QasTextTruncate', QasTextTruncate)
|
|
116
117
|
app.component('QasTransfer', QasTransfer)
|
|
118
|
+
app.component('QasTreeGenerator', QasTreeGenerator)
|
|
117
119
|
app.component('QasUploader', QasUploader)
|
|
118
120
|
|
|
119
121
|
app.use(Quasar, { plugins: { Notify, QuasarDialog, Dialog } })
|
|
@@ -184,6 +186,7 @@ export {
|
|
|
184
186
|
QasTabsGenerator,
|
|
185
187
|
QasTextTruncate,
|
|
186
188
|
QasTransfer,
|
|
189
|
+
QasTreeGenerator,
|
|
187
190
|
QasUploader,
|
|
188
191
|
|
|
189
192
|
// plugins
|