@drax/crud-vue 3.1.0 → 3.2.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/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "3.
|
|
6
|
+
"version": "3.2.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./src/index.ts",
|
|
9
9
|
"module": "./src/index.ts",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@drax/common-front": "^3.0.0",
|
|
28
28
|
"@drax/crud-front": "^3.0.0",
|
|
29
|
-
"@drax/crud-share": "^3.
|
|
30
|
-
"@drax/media-vue": "^3.
|
|
29
|
+
"@drax/crud-share": "^3.2.0",
|
|
30
|
+
"@drax/media-vue": "^3.2.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"pinia": "^3.0.4",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"vue-tsc": "^3.2.4",
|
|
51
51
|
"vuetify": "^3.11.8"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "8446a621e05bc1f4fd080c814a3ebdd7ae8a626b"
|
|
54
54
|
}
|
package/src/EntityCrud.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
IEntityCrud, IEntityCrudForm, IEntityCrudHeader, IEntityCrudRefs,
|
|
3
3
|
IEntityCrudRules, IEntityCrudField, IEntityCrudPermissions,
|
|
4
|
-
IDraxCrudProvider, IEntityCrudFilter, IEntityCrudFieldVariant, IDraxFieldFilter
|
|
4
|
+
IDraxCrudProvider, IEntityCrudFilter, IEntityCrudFieldVariant, IDraxFieldFilter,
|
|
5
|
+
IEntityCrudOnInput
|
|
5
6
|
} from "@drax/crud-share";
|
|
6
7
|
|
|
7
8
|
|
|
@@ -149,10 +150,20 @@ class EntityCrud implements IEntityCrud {
|
|
|
149
150
|
return {}
|
|
150
151
|
}
|
|
151
152
|
|
|
153
|
+
|
|
154
|
+
|
|
152
155
|
getRule(field: string | undefined): Array<Function> | undefined {
|
|
153
156
|
return field && this.rules[field] && this.rules[field].length > 0 ? this.rules[field] : undefined
|
|
154
157
|
}
|
|
155
158
|
|
|
159
|
+
get onInputs(): IEntityCrudOnInput {
|
|
160
|
+
return {}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
getOnInput(field: string | undefined): Function | undefined {
|
|
164
|
+
return (field && this.onInputs[field] && typeof this.onInputs[field] === 'function') ? this.onInputs[field] : undefined
|
|
165
|
+
}
|
|
166
|
+
|
|
156
167
|
get isViewable() {
|
|
157
168
|
return true
|
|
158
169
|
}
|
|
@@ -132,6 +132,12 @@ const rules = computed(() => {
|
|
|
132
132
|
}
|
|
133
133
|
})
|
|
134
134
|
|
|
135
|
+
const onInput = computed(() => {
|
|
136
|
+
return (fieldName: string) => {
|
|
137
|
+
return entity?.getOnInput(fieldName) as Function || undefined
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
|
|
135
141
|
const onlyView = computed(()=> {
|
|
136
142
|
return ['delete','view'].includes(operation?.value)
|
|
137
143
|
})
|
|
@@ -177,6 +183,7 @@ const onlyView = computed(()=> {
|
|
|
177
183
|
:preview="field?.preview"
|
|
178
184
|
:previewHeight="field?.previewHeight"
|
|
179
185
|
:rules="rules(field.name)"
|
|
186
|
+
:on-input="onInput(field.name)"
|
|
180
187
|
:hint="field.hint"
|
|
181
188
|
:persistent-hint="field.persistentHint"
|
|
182
189
|
:placeholder="field.placeholder"
|
|
@@ -226,6 +233,7 @@ const onlyView = computed(()=> {
|
|
|
226
233
|
:append-icon="field?.appendIcon"
|
|
227
234
|
:append-inner-icon="field?.appendInnerIcon"
|
|
228
235
|
:rules="rules(field.name)"
|
|
236
|
+
:on-input="onInput(field.name)"
|
|
229
237
|
:hint="field.hint"
|
|
230
238
|
:persistent-hint="field.persistentHint"
|
|
231
239
|
:placeholder="field.placeholder"
|
|
@@ -284,6 +292,7 @@ const onlyView = computed(()=> {
|
|
|
284
292
|
:append-icon="field?.appendIcon"
|
|
285
293
|
:append-inner-icon="field?.appendInnerIcon"
|
|
286
294
|
:rules="rules(field.name)"
|
|
295
|
+
:on-input="onInput(field.name)"
|
|
287
296
|
:hint="field.hint"
|
|
288
297
|
:persistent-hint="field.persistentHint"
|
|
289
298
|
:placeholder="field.placeholder"
|
|
@@ -23,7 +23,7 @@ const {hasPermission} = useAuth()
|
|
|
23
23
|
|
|
24
24
|
const valueModel = defineModel<any>({type: [String, Number, Boolean, Object, Array], default: false})
|
|
25
25
|
|
|
26
|
-
const {index, entity, field, parentField, errorMessages, rules, readonly, hideDetails} = defineProps({
|
|
26
|
+
const {index, entity, field, parentField, errorMessages, rules, onInput, readonly, hideDetails} = defineProps({
|
|
27
27
|
entity: {type: Object as PropType<IEntityCrud>, required: true},
|
|
28
28
|
field: {type: Object as PropType<IEntityCrudField | IEntityCrudFilter | undefined>, required: true},
|
|
29
29
|
prependIcon: {type: String, default: ''},
|
|
@@ -43,6 +43,7 @@ const {index, entity, field, parentField, errorMessages, rules, readonly, hideDe
|
|
|
43
43
|
previewHeight: {type: String, default: '100px'},
|
|
44
44
|
parentField: {type: String, default: null, required: false},
|
|
45
45
|
errorMessages: {type: Array as PropType<string[]>, default: null, required: false},
|
|
46
|
+
onInput: {type: Function as PropType<Function>, required: false},
|
|
46
47
|
rules: {type: Array as PropType<ValidationRule[]>, required: false},
|
|
47
48
|
index: {type: Number, default: null, required: false},
|
|
48
49
|
density: {type: String as PropType<'comfortable' | 'compact' | 'default'>, default: 'default'},
|
|
@@ -120,6 +121,7 @@ const hasHideDetails = computed(()=>{
|
|
|
120
121
|
:append-icon="appendIcon"
|
|
121
122
|
:prepend-inner-icon="prependInnerIcon"
|
|
122
123
|
:append-inner-icon="appendInnerIcon"
|
|
124
|
+
@input="onInput"
|
|
123
125
|
@update:modelValue="$emit('updateValue')"
|
|
124
126
|
/>
|
|
125
127
|
|
|
@@ -146,6 +148,7 @@ const hasHideDetails = computed(()=>{
|
|
|
146
148
|
:append-icon="appendIcon"
|
|
147
149
|
:prepend-inner-icon="prependInnerIcon"
|
|
148
150
|
:append-inner-icon="appendInnerIcon"
|
|
151
|
+
@input="onInput"
|
|
149
152
|
@update:modelValue="$emit('updateValue')"
|
|
150
153
|
/>
|
|
151
154
|
|
|
@@ -169,10 +172,11 @@ const hasHideDetails = computed(()=>{
|
|
|
169
172
|
:prepend-icon="prependIcon"
|
|
170
173
|
:append-icon="appendIcon"
|
|
171
174
|
:prepend-inner-icon="prependInnerIcon"
|
|
172
|
-
@update:modelValue="$emit('updateValue')"
|
|
173
175
|
:type="show ? 'text' : 'password'"
|
|
174
176
|
:append-inner-icon="show ? 'mdi-eye' : 'mdi-eye-off'"
|
|
175
177
|
@click:append-inner="show = !show"
|
|
178
|
+
@input="onInput"
|
|
179
|
+
@update:modelValue="$emit('updateValue')"
|
|
176
180
|
/>
|
|
177
181
|
|
|
178
182
|
|
|
@@ -39,6 +39,14 @@ export const useCrudStore = (id: string = 'entity') => defineStore('CrudStore'+i
|
|
|
39
39
|
}
|
|
40
40
|
),
|
|
41
41
|
getters: {
|
|
42
|
+
getFieldValue(state: any) {
|
|
43
|
+
return (fieldName: string) => {
|
|
44
|
+
if (fieldName && state.form[fieldName]) {
|
|
45
|
+
return state.form[fieldName]
|
|
46
|
+
}
|
|
47
|
+
return undefined
|
|
48
|
+
}
|
|
49
|
+
},
|
|
42
50
|
getFieldInputErrors(state: any) {
|
|
43
51
|
return (fieldName: string) => {
|
|
44
52
|
if (state.inputErrors && state.inputErrors[fieldName]) {
|