@bildvitta/quasar-ui-asteroid 3.8.0-beta.2 → 3.8.0-beta.3
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/package.json
CHANGED
|
@@ -6,34 +6,32 @@
|
|
|
6
6
|
|
|
7
7
|
<div ref="inputContent">
|
|
8
8
|
<component :is="componentTag" v-bind="componentProps">
|
|
9
|
-
<
|
|
10
|
-
<div :
|
|
11
|
-
<
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
<
|
|
18
|
-
<
|
|
19
|
-
<
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
<
|
|
27
|
-
<qas-actions-menu v-bind="actionsMenuProps" :list="getActionsList(index, row)" />
|
|
28
|
-
</div>
|
|
9
|
+
<template v-for="(row, index) in nested" :key="`row-${index}`">
|
|
10
|
+
<div v-if="!row[destroyKey]" :id="`row-${index}`" class="full-width q-mt-md">
|
|
11
|
+
<header class="flex items-center q-py-md" :class="headerClasses">
|
|
12
|
+
<qas-label v-if="!useSingleLabel" :label="getRowLabel(index)" />
|
|
13
|
+
<qas-actions-menu v-if="hasBlockActions(row)" v-bind="actionsMenuProps" :list="getActionsList(index, row)" />
|
|
14
|
+
</header>
|
|
15
|
+
|
|
16
|
+
<div ref="formGenerator" class="col-12 justify-between q-col-gutter-x-md row">
|
|
17
|
+
<slot :errors="transformedErrors" :fields="children" :index="index" name="fields" :update-value="updateValuesFromInput">
|
|
18
|
+
<qas-form-generator v-model="nested[index]" :class="formClasses" :columns="formColumns" :disable="isDisabledRow(row)" :errors="transformedErrors[index]" :fields="children" :fields-props="fieldsProps" @update:model-value="updateValuesFromInput($event, index)">
|
|
19
|
+
<template v-for="(slot, key) in $slots" #[key]="scope">
|
|
20
|
+
<slot v-bind="scope" :disabled="isDisabledRow(row)" :errors="transformedErrors" :index="index" :name="key" />
|
|
21
|
+
</template>
|
|
22
|
+
</qas-form-generator>
|
|
23
|
+
</slot>
|
|
24
|
+
|
|
25
|
+
<div v-if="hasInlineActions(row)" class="flex items-center qas-nested-fields__actions">
|
|
26
|
+
<qas-actions-menu v-bind="actionsMenuProps" :list="getActionsList(index, row)" />
|
|
29
27
|
</div>
|
|
28
|
+
</div>
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
</div>
|
|
30
|
+
<div class="col-12">
|
|
31
|
+
<slot :fields="children" :index="index" :model="nested[index]" name="custom-fields" :update-value="updateValuesFromInput" />
|
|
34
32
|
</div>
|
|
35
33
|
</div>
|
|
36
|
-
</
|
|
34
|
+
</template>
|
|
37
35
|
</component>
|
|
38
36
|
|
|
39
37
|
<div v-if="useAdd" class="q-mt-md">
|
|
@@ -68,6 +66,7 @@ import QasFormGenerator from '../form-generator/QasFormGenerator.vue'
|
|
|
68
66
|
import QasInput from '../input/QasInput.vue'
|
|
69
67
|
import QasLabel from '../label/QasLabel.vue'
|
|
70
68
|
import { TransitionGroup } from 'vue'
|
|
69
|
+
import { extend } from 'quasar'
|
|
71
70
|
|
|
72
71
|
import { constructObject } from '../../helpers'
|
|
73
72
|
|
|
@@ -241,7 +240,7 @@ export default {
|
|
|
241
240
|
|
|
242
241
|
data () {
|
|
243
242
|
return {
|
|
244
|
-
|
|
243
|
+
nested: [],
|
|
245
244
|
hasDestroyAlways: true
|
|
246
245
|
}
|
|
247
246
|
},
|
|
@@ -293,18 +292,18 @@ export default {
|
|
|
293
292
|
|
|
294
293
|
headerClasses () {
|
|
295
294
|
return this.useSingleLabel ? 'justify-end' : 'justify-between'
|
|
296
|
-
},
|
|
297
|
-
|
|
298
|
-
nested () {
|
|
299
|
-
return this.modelValue.filter(item => !item[this.destroyKey])
|
|
300
|
-
},
|
|
301
|
-
|
|
302
|
-
hasDestroyKeyList () {
|
|
303
|
-
return !!Object.keys(this.destroyKeyList).length
|
|
304
295
|
}
|
|
305
296
|
},
|
|
306
297
|
|
|
307
298
|
watch: {
|
|
299
|
+
modelValue: {
|
|
300
|
+
handler (value) {
|
|
301
|
+
this.nested = extend(true, [], value)
|
|
302
|
+
},
|
|
303
|
+
deep: true,
|
|
304
|
+
immediate: true
|
|
305
|
+
},
|
|
306
|
+
|
|
308
307
|
rowObject: {
|
|
309
308
|
handler () {
|
|
310
309
|
this.setDefaultNestedValue()
|
|
@@ -379,11 +378,9 @@ export default {
|
|
|
379
378
|
* ao invés de adicionar a flag [destroyKey]
|
|
380
379
|
*/
|
|
381
380
|
destroy (index, row) {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
this.destroyKeyList[row[this.identifierItemKey]] = { row: removedRow, index }
|
|
386
|
-
}
|
|
381
|
+
!row[this.identifierItemKey] || this.useRemoveOnDestroy
|
|
382
|
+
? this.nested.splice(index, 1)
|
|
383
|
+
: this.nested.splice(index, 1, { [this.destroyKey]: true, ...row })
|
|
387
384
|
|
|
388
385
|
this.$qas.logger.group('QasNestedFields - destroy', [{ index, row }])
|
|
389
386
|
|
|
@@ -391,23 +388,13 @@ export default {
|
|
|
391
388
|
},
|
|
392
389
|
|
|
393
390
|
updateModelValue () {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
if (this.hasDestroyKeyList) {
|
|
397
|
-
for (const key in this.destroyKeyList) {
|
|
398
|
-
const { row, index } = this.destroyKeyList[key]
|
|
399
|
-
|
|
400
|
-
nested.splice(index, 0, { ...row, [this.destroyKey]: true })
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
this.$emit('update:modelValue', nested)
|
|
391
|
+
this.$emit('update:modelValue', this.nested)
|
|
405
392
|
},
|
|
406
393
|
|
|
407
394
|
updateValuesFromInput (value, index) {
|
|
408
395
|
this.nested.splice(index, 1, value)
|
|
409
396
|
|
|
410
|
-
|
|
397
|
+
this.updateModelValue()
|
|
411
398
|
},
|
|
412
399
|
|
|
413
400
|
setDefaultNestedValue () {
|
|
@@ -436,9 +423,17 @@ export default {
|
|
|
436
423
|
return firstElementToBeFocused?.focus && firstElementToBeFocused.focus()
|
|
437
424
|
},
|
|
438
425
|
|
|
439
|
-
|
|
426
|
+
getRealRowIndex (index) {
|
|
427
|
+
return [...this.nested].splice(0, index).filter(item => !item[this.destroyKey]).length
|
|
428
|
+
},
|
|
429
|
+
|
|
430
|
+
getRowLabel (rowIndex) {
|
|
440
431
|
if (this.rowLabel) {
|
|
441
|
-
|
|
432
|
+
if (!this.useIndexLabel) return this.rowLabel
|
|
433
|
+
|
|
434
|
+
const index = this.useRemoveOnDestroy ? rowIndex : this.getRealRowIndex(rowIndex)
|
|
435
|
+
|
|
436
|
+
return `${this.rowLabel} ${index + 1}`
|
|
442
437
|
}
|
|
443
438
|
|
|
444
439
|
return this.fieldLabel
|