@drax/crud-vue 0.7.9 → 0.7.13

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.7.9",
6
+ "version": "0.7.13",
7
7
  "type": "module",
8
8
  "main": "./src/index.ts",
9
9
  "module": "./src/index.ts",
@@ -26,7 +26,7 @@
26
26
  "dependencies": {
27
27
  "@drax/common-front": "^0.7.4",
28
28
  "@drax/crud-front": "^0.7.0",
29
- "@drax/crud-share": "^0.7.0",
29
+ "@drax/crud-share": "^0.7.13",
30
30
  "@drax/media-vue": "^0.7.5"
31
31
  },
32
32
  "peerDependencies": {
@@ -64,5 +64,5 @@
64
64
  "vue-tsc": "^2.0.11",
65
65
  "vuetify": "^3.7.1"
66
66
  },
67
- "gitHead": "5bd2bed4505a337ecd69918593ba8d43327ed290"
67
+ "gitHead": "5084879792a4fccc27f7fa0e7ac08950697454b8"
68
68
  }
@@ -1,18 +1,23 @@
1
1
  <script setup lang="ts">
2
- import type {PropType} from "vue";
2
+ import {computed, type PropType} from "vue";
3
3
  import CrudFormField from "./CrudFormField.vue";
4
- import type {IEntityCrud} from "@drax/crud-share";
4
+ import type {IEntityCrud, IEntityCrudFilter} from "@drax/crud-share";
5
5
  import {useI18n} from "vue-i18n";
6
+ import {useAuth} from "@drax/identity-vue";
6
7
 
7
8
  const {t} = useI18n()
8
9
  const valueModel = defineModel({type: [Object]})
9
-
10
+ const {hasPermission} = useAuth()
10
11
 
11
12
  const {entity} = defineProps({
12
13
  entity: {type: Object as PropType<IEntityCrud>, required: true},
13
14
  actions: {type: Boolean, default: false},
14
15
  })
15
16
 
17
+ const aFields = computed(() => {
18
+ return entity.filters.filter((field:IEntityCrudFilter) => !field.permission || hasPermission(field.permission))
19
+ })
20
+
16
21
 
17
22
  async function filter() {
18
23
  emit('filter')
@@ -29,9 +34,14 @@ const emit = defineEmits(['filter', 'clear','updateValue'])
29
34
 
30
35
  <template>
31
36
  <v-card flat >
32
- <v-row dense class="mt-1" justify="space-between">
33
- <v-col v-for="(filter,index) in entity.filters" :key="filter.name"
34
- cols="12" sm="6" md="4"
37
+ <v-row dense class="mt-1">
38
+ <v-col v-for="(filter,index) in aFields"
39
+ :key="filter.name"
40
+ :cols="filter.cols ? filter.cols : 12"
41
+ :sm="filter.sm ? filter.sm : 6"
42
+ :md="filter.md ? filter.md : 6"
43
+ :lg="filter.lg ? filter.lg : 4"
44
+ :xl="filter.xl ? filter.xl : 3"
35
45
  >
36
46
  <crud-form-field
37
47
  :field="filter"
@@ -4,7 +4,7 @@ import type {IEntityCrud, IEntityCrudField, IEntityCrudOperation} from "@drax/cr
4
4
  import {useFormUtils} from "../composables/UseFormUtils";
5
5
  import CrudFormField from "./CrudFormField.vue";
6
6
  import {computed, defineEmits, defineModel, defineProps, ref} from "vue";
7
- import type { PropType} from "vue";
7
+ import type {PropType} from "vue";
8
8
  import {useCrudStore} from "../stores/UseCrudStore";
9
9
  import {useAuth} from '@drax/identity-vue'
10
10
 
@@ -27,13 +27,13 @@ const store = useCrudStore()
27
27
  const formRef = ref()
28
28
 
29
29
  const fields = computed(() => {
30
- if(operation === 'create') {
30
+ if (operation === 'create') {
31
31
  return entity.createFields
32
- }else if(operation === 'edit') {
32
+ } else if (operation === 'edit') {
33
33
  return entity.updateFields
34
- }else if(operation === 'delete') {
34
+ } else if (operation === 'delete') {
35
35
  return entity.deleteFields
36
- }else if(operation === 'view') {
36
+ } else if (operation === 'view') {
37
37
  return entity.viewFields
38
38
  }
39
39
  return []
@@ -41,22 +41,22 @@ const fields = computed(() => {
41
41
 
42
42
 
43
43
  const aFields = computed(() => {
44
- return fields.value.filter((field:IEntityCrudField) => !field.permission || hasPermission(field.permission))
44
+ return fields.value.filter((field: IEntityCrudField) => !field.permission || hasPermission(field.permission))
45
45
  })
46
46
 
47
47
  async function submit() {
48
48
  store.resetErrors()
49
49
 
50
- if(operation === 'delete') {
51
- emit('submit',valueModel.value)
50
+ if (operation === 'delete') {
51
+ emit('submit', valueModel.value)
52
52
  return
53
53
  }
54
54
 
55
55
  const {valid, errors} = await formRef.value.validate()
56
56
 
57
- if(valid) {
58
- emit('submit',valueModel.value)
59
- }else{
57
+ if (valid) {
58
+ emit('submit', valueModel.value)
59
+ } else {
60
60
  console.log('Invalid form', errors)
61
61
  }
62
62
  }
@@ -65,7 +65,7 @@ function cancel() {
65
65
  emit('cancel')
66
66
  }
67
67
 
68
- const {
68
+ const {
69
69
  variant, submitColor, readonly
70
70
  } = useFormUtils(operation)
71
71
 
@@ -73,30 +73,40 @@ const {
73
73
  </script>
74
74
 
75
75
  <template>
76
- <v-form ref="formRef" @submit.prevent >
76
+ <v-form ref="formRef" @submit.prevent>
77
77
  <v-card flat>
78
78
 
79
- <v-card-subtitle v-if="valueModel._id">ID: {{valueModel._id}}</v-card-subtitle>
79
+ <v-card-subtitle v-if="valueModel._id">ID: {{ valueModel._id }}</v-card-subtitle>
80
80
 
81
81
  <v-card-text v-if="error">
82
82
  <v-alert color="error">{{ te(error) ? t(error) : error }}</v-alert>
83
83
  </v-card-text>
84
84
 
85
85
  <v-card-text>
86
- <template v-for="field in aFields" :key="field.name">
87
- <crud-form-field
88
- :field="field"
89
- :entity="entity"
90
- v-model="valueModel[field.name]"
91
- :clearable="false"
92
- :readonly="readonly"
93
- :variant="variant"
94
- :prepend-inner-icon="field?.prependInnerIcon"
95
- :prepend-icon="field?.prependIcon"
96
- :append-icon="field?.appendIcon"
97
- :append-inner-icon="field?.appendInnerIcon"
98
- />
99
- </template>
86
+ <v-row>
87
+ <v-col
88
+ v-for="field in aFields"
89
+ :key="field.name"
90
+ :cols="field.cols ? field.cols : 12"
91
+ :sm="field.sm ? field.sm : 12"
92
+ :md="field.md ? field.md : 12"
93
+ :lg="field.lg ? field.lg : 12"
94
+ :xl="field.xl ? field.xl : 12"
95
+ >
96
+ <crud-form-field
97
+ :field="field"
98
+ :entity="entity"
99
+ v-model="valueModel[field.name]"
100
+ :clearable="false"
101
+ :readonly="readonly"
102
+ :variant="variant"
103
+ :prepend-inner-icon="field?.prependInnerIcon"
104
+ :prepend-icon="field?.prependIcon"
105
+ :append-icon="field?.appendIcon"
106
+ :append-inner-icon="field?.appendInnerIcon"
107
+ />
108
+ </v-col>
109
+ </v-row>
100
110
  </v-card-text>
101
111
 
102
112
  <v-card-actions>
@@ -91,6 +91,27 @@ defineEmits(['updateValue'])
91
91
  @update:modelValue="$emit('updateValue')"
92
92
  />
93
93
 
94
+ <v-textarea
95
+ v-if="field.type === 'longString'"
96
+ type="text"
97
+ :name="name"
98
+ :label="label"
99
+ v-model="valueModel"
100
+ :readonly="readonly"
101
+ :error-messages="inputErrors"
102
+ :rules="rules"
103
+ :density="density"
104
+ :variant="variant"
105
+ :clearable="clearable"
106
+ :hide-details="hideDetails"
107
+ :single-line="singleLine"
108
+ :prepend-icon="prependIcon"
109
+ :append-icon="appendIcon"
110
+ :prepend-inner-icon="prependInnerIcon"
111
+ :append-inner-icon="appendInnerIcon"
112
+ @update:modelValue="$emit('updateValue')"
113
+ />
114
+
94
115
  <v-text-field
95
116
  v-if="field.type === 'password'"
96
117
  :name="name"