@drax/crud-vue 0.14.3 → 0.14.4
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.14.
|
|
6
|
+
"version": "0.14.4",
|
|
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.1.10",
|
|
65
65
|
"vuetify": "^3.7.1"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "d16e928bedeaaedf04229ec2db917e67d0eb117c"
|
|
68
68
|
}
|
package/src/components/Crud.vue
CHANGED
|
@@ -13,7 +13,7 @@ const {entity} = defineProps({
|
|
|
13
13
|
|
|
14
14
|
const {
|
|
15
15
|
onView, onCreate, onEdit, onDelete, resetCrudStore,
|
|
16
|
-
operation, dialog,
|
|
16
|
+
operation, dialog, notify, error, message, doExport,
|
|
17
17
|
prepareFilters
|
|
18
18
|
} = useCrud(entity);
|
|
19
19
|
|
|
@@ -71,10 +71,7 @@ const emit = defineEmits(['created', 'updated', 'deleted', 'viewed','canceled'])
|
|
|
71
71
|
|
|
72
72
|
<slot name="form">
|
|
73
73
|
<crud-form
|
|
74
|
-
v-model="form"
|
|
75
74
|
:entity="entity"
|
|
76
|
-
:error="error"
|
|
77
|
-
:readonly="operation === 'delete'"
|
|
78
75
|
@created="item => emit('created', item)"
|
|
79
76
|
@updated="item => emit('updated', item)"
|
|
80
77
|
@deleted="emit('deleted')"
|
|
@@ -4,7 +4,7 @@ import type {IEntityCrud, IEntityCrudField} from "@drax/crud-share";
|
|
|
4
4
|
import {useFormUtils} from "../composables/UseFormUtils";
|
|
5
5
|
import {getItemId} from "../helpers/getItemId";
|
|
6
6
|
import CrudFormField from "./CrudFormField.vue";
|
|
7
|
-
import {computed, defineEmits,
|
|
7
|
+
import {computed, defineEmits, defineProps, ref} from "vue";
|
|
8
8
|
import type {PropType} from "vue";
|
|
9
9
|
import {useCrudStore} from "../stores/UseCrudStore";
|
|
10
10
|
import {useCrud} from "../composables/UseCrud";
|
|
@@ -13,14 +13,12 @@ import {useAuth} from '@drax/identity-vue'
|
|
|
13
13
|
const {hasPermission} = useAuth()
|
|
14
14
|
const {t, te} = useI18n()
|
|
15
15
|
|
|
16
|
-
const valueModel = defineModel({type: [Object]})
|
|
17
16
|
|
|
18
17
|
const {entity} = defineProps({
|
|
19
18
|
entity: {type: Object as PropType<IEntityCrud>, required: true},
|
|
20
|
-
readonly: {type: Boolean, default: false}
|
|
21
19
|
})
|
|
22
20
|
|
|
23
|
-
const {onSubmit, onCancel, operation, error} = useCrud(entity)
|
|
21
|
+
const {onSubmit, onCancel, operation, error, form} = useCrud(entity)
|
|
24
22
|
|
|
25
23
|
const emit = defineEmits(['created', 'updated', 'deleted', 'viewed', 'canceled'])
|
|
26
24
|
|
|
@@ -57,7 +55,7 @@ async function submit() {
|
|
|
57
55
|
}
|
|
58
56
|
}
|
|
59
57
|
|
|
60
|
-
let result = await onSubmit(
|
|
58
|
+
let result = await onSubmit(form.value)
|
|
61
59
|
|
|
62
60
|
switch (result.status) {
|
|
63
61
|
case "created":
|
|
@@ -92,13 +90,14 @@ const {
|
|
|
92
90
|
<v-form ref="formRef" @submit.prevent>
|
|
93
91
|
<v-card flat>
|
|
94
92
|
|
|
95
|
-
<v-card-subtitle v-if="getItemId(
|
|
93
|
+
<v-card-subtitle v-if="getItemId(form)">ID: {{ getItemId(form) }}</v-card-subtitle>
|
|
96
94
|
|
|
97
95
|
<v-card-text v-if="error">
|
|
98
96
|
<v-alert color="error">{{ te(error) ? t(error) : error }}</v-alert>
|
|
99
97
|
</v-card-text>
|
|
100
98
|
|
|
101
99
|
<v-card-text>
|
|
100
|
+
|
|
102
101
|
<v-row>
|
|
103
102
|
<v-col
|
|
104
103
|
v-for="field in aFields"
|
|
@@ -113,9 +112,9 @@ const {
|
|
|
113
112
|
<crud-form-field
|
|
114
113
|
:field="field"
|
|
115
114
|
:entity="entity"
|
|
116
|
-
v-model="
|
|
115
|
+
v-model="form[field.name]"
|
|
117
116
|
:clearable="false"
|
|
118
|
-
:readonly="
|
|
117
|
+
:readonly="['delete','view'].includes(operation) || field.readonly"
|
|
119
118
|
:variant="variant"
|
|
120
119
|
:prepend-inner-icon="field?.prependInnerIcon"
|
|
121
120
|
:prepend-icon="field?.prependIcon"
|
|
@@ -224,20 +224,20 @@ export function useCrud(entity: IEntityCrud) {
|
|
|
224
224
|
|
|
225
225
|
|
|
226
226
|
function onCreate() {
|
|
227
|
-
store.setOperation("create")
|
|
228
227
|
store.setForm(entity.form)
|
|
228
|
+
store.setOperation("create")
|
|
229
229
|
openDialog()
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
function onEdit(item: object) {
|
|
233
|
-
store.setOperation("edit")
|
|
234
233
|
store.setForm(cast({...item}))
|
|
234
|
+
store.setOperation("edit")
|
|
235
235
|
openDialog()
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
function onDelete(item: object) {
|
|
239
|
-
store.setOperation("delete")
|
|
240
239
|
store.setForm(cast({...item}))
|
|
240
|
+
store.setOperation("delete")
|
|
241
241
|
openDialog()
|
|
242
242
|
}
|
|
243
243
|
|