@drax/crud-vue 0.8.5 → 0.8.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/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.8.
|
|
6
|
+
"version": "0.8.9",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./src/index.ts",
|
|
9
9
|
"module": "./src/index.ts",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"vue-tsc": "^2.0.11",
|
|
65
65
|
"vuetify": "^3.7.1"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "f2dabb089baefb07ef5ae752acaa142e7cb235c2"
|
|
68
68
|
}
|
package/src/components/Crud.vue
CHANGED
|
@@ -75,7 +75,14 @@ onBeforeMount(() => {
|
|
|
75
75
|
:readonly="operation === 'delete'"
|
|
76
76
|
@submit="onSubmit"
|
|
77
77
|
@cancel="onCancel"
|
|
78
|
-
|
|
78
|
+
>
|
|
79
|
+
|
|
80
|
+
<template v-for="ifield in entity.fields" :key="ifield.name" v-slot:[`field.${ifield.name}`]="{field}">
|
|
81
|
+
<slot :name="`field.${ifield.name}`" v-bind="{field}">
|
|
82
|
+
</slot>
|
|
83
|
+
</template>
|
|
84
|
+
|
|
85
|
+
</crud-form>
|
|
79
86
|
</slot>
|
|
80
87
|
|
|
81
88
|
</crud-dialog>
|
|
@@ -93,18 +93,21 @@ const {
|
|
|
93
93
|
:lg="field.lg ? field.lg : 12"
|
|
94
94
|
:xl="field.xl ? field.xl : 12"
|
|
95
95
|
>
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
96
|
+
<slot :name="`field.${field.name}`" v-bind="{field}">
|
|
97
|
+
<crud-form-field
|
|
98
|
+
:field="field"
|
|
99
|
+
:entity="entity"
|
|
100
|
+
v-model="valueModel[field.name]"
|
|
101
|
+
:clearable="false"
|
|
102
|
+
:readonly="readonly"
|
|
103
|
+
:variant="variant"
|
|
104
|
+
:prepend-inner-icon="field?.prependInnerIcon"
|
|
105
|
+
:prepend-icon="field?.prependIcon"
|
|
106
|
+
:append-icon="field?.appendIcon"
|
|
107
|
+
:append-inner-icon="field?.appendInnerIcon"
|
|
108
|
+
/>
|
|
109
|
+
</slot>
|
|
110
|
+
|
|
108
111
|
</v-col>
|
|
109
112
|
</v-row>
|
|
110
113
|
</v-card-text>
|
|
@@ -13,18 +13,24 @@ const {field} = defineProps({
|
|
|
13
13
|
singleLine: {type: Boolean, default: false},
|
|
14
14
|
clearable: {type: Boolean, default: true},
|
|
15
15
|
density: {type: String as PropType<'comfortable' | 'compact' | 'default'>, default: 'default'},
|
|
16
|
-
variant: {
|
|
16
|
+
variant: {
|
|
17
|
+
type: String as PropType<'underlined' | 'outlined' | 'filled' | 'solo' | 'solo-inverted' | 'solo-filled' | 'plain'>,
|
|
18
|
+
default: 'filled'
|
|
19
|
+
},
|
|
17
20
|
})
|
|
18
21
|
|
|
19
22
|
function newItem() {
|
|
20
|
-
return field.objectFields ? field.objectFields.reduce((acc, field) => ({
|
|
23
|
+
return field.objectFields ? field.objectFields.reduce((acc, field) => ({
|
|
24
|
+
...acc,
|
|
25
|
+
[field.name]: field.default
|
|
26
|
+
}), {}) : []
|
|
21
27
|
}
|
|
22
28
|
|
|
23
|
-
function getField(key: string):IEntityCrudField|undefined {
|
|
29
|
+
function getField(key: string): IEntityCrudField | undefined {
|
|
24
30
|
return field.objectFields ? field.objectFields.find(field => field.name === key) : undefined;
|
|
25
31
|
}
|
|
26
32
|
|
|
27
|
-
function hasField(key: string):boolean {
|
|
33
|
+
function hasField(key: string): boolean {
|
|
28
34
|
return field.objectFields ? field.objectFields.some(field => field.name === key) : false;
|
|
29
35
|
}
|
|
30
36
|
|
|
@@ -43,45 +49,50 @@ defineEmits(['updateValue'])
|
|
|
43
49
|
<template>
|
|
44
50
|
<v-card class="mt-3" variant="flat" border>
|
|
45
51
|
|
|
46
|
-
<v-card-title class="text-h5">{{field.label}}</v-card-title>
|
|
52
|
+
<v-card-title class="text-h5">{{ field.label }}</v-card-title>
|
|
47
53
|
<v-card-text>
|
|
48
|
-
<v-
|
|
49
|
-
<v-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
:readonly="readonly"
|
|
59
|
-
:parentField="field.name"
|
|
60
|
-
:index="index"
|
|
61
|
-
:density="density"
|
|
62
|
-
:variant="variant"
|
|
63
|
-
:clearable="clearable"
|
|
64
|
-
:hide-details="hideDetails"
|
|
65
|
-
:single-line="singleLine"
|
|
66
|
-
@updateValue="$emit('updateValue')"
|
|
67
|
-
/>
|
|
68
|
-
</template>
|
|
69
|
-
|
|
70
|
-
</v-col>
|
|
71
|
-
<v-col cols="1">
|
|
72
|
-
<v-btn v-if="!readonly" icon @click="removeItem(index)" small class="text-red text--darken-3">
|
|
54
|
+
<v-expansion-panels>
|
|
55
|
+
<v-expansion-panel v-for="(item,index) in valueModel" :key="index">
|
|
56
|
+
|
|
57
|
+
<v-expansion-panel-title>
|
|
58
|
+
{{ index }} - {{valueModel[index][Object.keys(valueModel[index] as any)[0]]}}
|
|
59
|
+
|
|
60
|
+
<template v-slot:actions="{expanded}">
|
|
61
|
+
<v-icon>{{expanded ? "mdi-menu-down" : "mdi-menu-up"}}</v-icon>
|
|
62
|
+
|
|
63
|
+
<v-btn v-if="!readonly" variant="text" @click="removeItem(index)" density="compact" class="text-red text--darken-3">
|
|
73
64
|
<v-icon>mdi-close</v-icon>
|
|
74
65
|
</v-btn>
|
|
75
|
-
</
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
66
|
+
</template>
|
|
67
|
+
|
|
68
|
+
</v-expansion-panel-title>
|
|
69
|
+
|
|
70
|
+
<v-expansion-panel-text>
|
|
71
|
+
<template v-for="key in Object.keys(item as Record<string, any>)" :key="key">
|
|
72
|
+
<crud-form-field
|
|
73
|
+
v-if="hasField(key)"
|
|
74
|
+
:entity="entity"
|
|
75
|
+
:field="getField(key)"
|
|
76
|
+
v-model="(valueModel[index] as any)[key]"
|
|
77
|
+
:readonly="readonly"
|
|
78
|
+
:parentField="field.name"
|
|
79
|
+
:index="index"
|
|
80
|
+
:density="density"
|
|
81
|
+
:variant="variant"
|
|
82
|
+
:clearable="clearable"
|
|
83
|
+
:hide-details="hideDetails"
|
|
84
|
+
:single-line="singleLine"
|
|
85
|
+
@updateValue="$emit('updateValue')"
|
|
86
|
+
/>
|
|
87
|
+
</template>
|
|
88
|
+
</v-expansion-panel-text>
|
|
89
|
+
|
|
90
|
+
</v-expansion-panel>
|
|
91
|
+
<v-btn icon @click="addItem" class="text-blue text--darken-3">
|
|
81
92
|
<v-icon>mdi-plus</v-icon>
|
|
82
93
|
</v-btn>
|
|
83
94
|
|
|
84
|
-
</v-
|
|
95
|
+
</v-expansion-panels>
|
|
85
96
|
</v-card-text>
|
|
86
97
|
|
|
87
98
|
|