@bildvitta/quasar-ui-asteroid 3.0.0-beta.13 → 3.0.0-beta.14
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/QasFormView.json +8 -0
- package/dist/asteroid.cjs.css +1 -1
- package/dist/asteroid.cjs.js +31 -13
- package/dist/asteroid.cjs.min.js +2 -2
- package/dist/asteroid.esm.css +1 -1
- package/dist/asteroid.esm.js +31 -13
- package/dist/asteroid.esm.min.js +2 -2
- package/dist/asteroid.umd.css +1 -1
- package/dist/asteroid.umd.js +31 -13
- package/dist/asteroid.umd.min.js +2 -2
- package/dist/vetur/asteroid-attributes.json +4 -0
- package/dist/vetur/asteroid-tags.json +1 -0
- package/package.json +1 -1
- package/src/components/form-view/QasFormView.vue +28 -5
- package/src/components/form-view/QasFormView.yml +6 -0
- package/src/components/nested-fields/QasNestedFields.vue +1 -6
|
@@ -355,6 +355,10 @@
|
|
|
355
355
|
"description": "Altera ordem dos campos.",
|
|
356
356
|
"type": "array"
|
|
357
357
|
},
|
|
358
|
+
"qas-form-view/before-submit": {
|
|
359
|
+
"description": "Callback para controlar como funciona o comportamento do submit.",
|
|
360
|
+
"type": "function"
|
|
361
|
+
},
|
|
358
362
|
"qas-form-view/cancel-button-label": {
|
|
359
363
|
"description": "Rótulo do botão \"cancelar\".",
|
|
360
364
|
"type": "string"
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<slot name="header" />
|
|
5
5
|
</header>
|
|
6
6
|
|
|
7
|
-
<q-form ref="form" @submit="
|
|
7
|
+
<q-form ref="form" @submit="submitHandler">
|
|
8
8
|
<slot />
|
|
9
9
|
|
|
10
10
|
<slot v-if="useActions" name="actions">
|
|
@@ -122,6 +122,11 @@ export default {
|
|
|
122
122
|
useSubmitButton: {
|
|
123
123
|
default: true,
|
|
124
124
|
type: Boolean
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
beforeSubmit: {
|
|
128
|
+
default: null,
|
|
129
|
+
type: Function
|
|
125
130
|
}
|
|
126
131
|
},
|
|
127
132
|
|
|
@@ -369,17 +374,35 @@ export default {
|
|
|
369
374
|
})
|
|
370
375
|
},
|
|
371
376
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
377
|
+
/**
|
|
378
|
+
* Se existe a propriedade com callback "beforeSubmit", então o controle de quando e como chamar o método "submit"
|
|
379
|
+
* está sendo controlado fora do QasFormView, se não existir a propriedade "beforeSubmit", então o controle do método
|
|
380
|
+
* submit é feito pelo próprio QasFormView, chamado pelo evento @submit.
|
|
381
|
+
*/
|
|
382
|
+
submitHandler (event) {
|
|
375
383
|
if (event) {
|
|
376
384
|
event.preventDefault()
|
|
377
385
|
}
|
|
378
386
|
|
|
387
|
+
const hasBeforeSubmit = typeof this.beforeSubmit === 'function'
|
|
388
|
+
|
|
389
|
+
if (hasBeforeSubmit) {
|
|
390
|
+
return this.beforeSubmit({
|
|
391
|
+
payload: { id: this.id, payload: this.modelValue, url: this.url },
|
|
392
|
+
resolve: payload => this.submit(payload)
|
|
393
|
+
})
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
this.submit()
|
|
397
|
+
},
|
|
398
|
+
|
|
399
|
+
async submit (externalPayload = {}) {
|
|
400
|
+
if (this.disable) return null
|
|
401
|
+
|
|
379
402
|
this.isSubmitting = true
|
|
380
403
|
|
|
381
404
|
try {
|
|
382
|
-
const payload = { id: this.id, payload: this.modelValue, url: this.url }
|
|
405
|
+
const payload = { id: this.id, payload: this.modelValue, url: this.url, ...externalPayload }
|
|
383
406
|
|
|
384
407
|
this.$qas.logger.group(
|
|
385
408
|
`QasFormView - submit -> payload do ${this.entity}/${this.mode}`, [payload]
|
|
@@ -4,6 +4,12 @@ meta:
|
|
|
4
4
|
desc: Componente para C.R.U.D. responsável pela pela criação (Create) e edição (Update).
|
|
5
5
|
|
|
6
6
|
props:
|
|
7
|
+
before-submit:
|
|
8
|
+
desc: Callback para controlar como funciona o comportamento do submit.
|
|
9
|
+
default: null
|
|
10
|
+
type: Function
|
|
11
|
+
examples: ['beforeSubmit({ payload, resolve })']
|
|
12
|
+
|
|
7
13
|
cancel-button-label:
|
|
8
14
|
desc: Rótulo do botão "cancelar".
|
|
9
15
|
default: Cancelar
|
|
@@ -261,13 +261,8 @@ export default {
|
|
|
261
261
|
modelValue: {
|
|
262
262
|
handler (value) {
|
|
263
263
|
this.nested = extend(true, [], value)
|
|
264
|
-
},
|
|
265
|
-
immediate: true
|
|
266
|
-
},
|
|
267
264
|
|
|
268
|
-
|
|
269
|
-
handler () {
|
|
270
|
-
!this.modelValue.length && this.setDefaultNestedValue()
|
|
265
|
+
if (!this.nested.length) return this.setDefaultNestedValue()
|
|
271
266
|
},
|
|
272
267
|
immediate: true
|
|
273
268
|
}
|