@drax/dashboard-vue 2.9.0 → 3.0.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": "
|
|
6
|
+
"version": "3.0.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./src/index.ts",
|
|
9
9
|
"module": "./src/index.ts",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"format": "prettier --write src/"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@drax/crud-front": "^
|
|
26
|
-
"@drax/crud-share": "^
|
|
27
|
-
"@drax/dashboard-front": "^
|
|
25
|
+
"@drax/crud-front": "^3.0.0",
|
|
26
|
+
"@drax/crud-share": "^3.0.0",
|
|
27
|
+
"@drax/dashboard-front": "^3.0.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"pinia": "^3.0.4",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"vue-tsc": "^3.2.4",
|
|
47
47
|
"vuetify": "^3.11.8"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "63ae718b24ea25ae80b1a9a5dfb84a3abbb95199"
|
|
50
50
|
}
|
|
@@ -5,19 +5,19 @@ import {useEntityStore} from "@drax/crud-vue";
|
|
|
5
5
|
import type {
|
|
6
6
|
IDraxFieldFilter,
|
|
7
7
|
IEntityCrud,
|
|
8
|
-
IEntityCrudFieldTypes,
|
|
9
8
|
IEntityCrudFilter,
|
|
10
9
|
IEntityCrudFilterOperators
|
|
11
10
|
} from "@drax/crud-share";
|
|
12
11
|
import {useI18n} from "vue-i18n"
|
|
13
12
|
import CrudFormField from "@drax/crud-vue/src/components/CrudFormField.vue";
|
|
14
13
|
import {useFilterIcon} from "@drax/crud-vue";
|
|
14
|
+
import {useDynamicFilters} from "@drax/crud-vue/src/composables/UseDynamicFilters";
|
|
15
15
|
|
|
16
16
|
const props = defineProps({
|
|
17
17
|
modelValue: {type: Object as PropType<IDashboardCard>, required: true}
|
|
18
18
|
});
|
|
19
19
|
const {filterIcon} = useFilterIcon()
|
|
20
|
-
const {t
|
|
20
|
+
const {t} = useI18n()
|
|
21
21
|
|
|
22
22
|
const emit = defineEmits(['update:modelValue', 'save', 'cancel']);
|
|
23
23
|
|
|
@@ -122,92 +122,19 @@ function onEntityChange() {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const dynamicFilter = computed(() => {
|
|
140
|
-
return (index: number) => {
|
|
141
|
-
return filters.value[index]
|
|
142
|
-
}
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
const operations = [
|
|
146
|
-
{title: t('operation.equals'), value: 'eq'},
|
|
147
|
-
{title: t('operation.notEquals'), value: 'ne'},
|
|
148
|
-
{title: t('operation.contains'), value: 'like'},
|
|
149
|
-
{title: t('operation.greaterThan'), value: 'gt'},
|
|
150
|
-
{title: t('operation.lessThan'), value: 'lt'},
|
|
151
|
-
{title: t('operation.greaterThanOrEqual'), value: 'gte'},
|
|
152
|
-
{title: t('operation.lessThanOrEqual'), value: 'lte'},
|
|
153
|
-
]
|
|
154
|
-
|
|
155
|
-
function removeFilter(index: number) {
|
|
156
|
-
if (filters.value) {
|
|
157
|
-
filters.value.splice(index, 1)
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function addFilter() {
|
|
162
|
-
const filter: IEntityCrudFilter = {
|
|
163
|
-
default: undefined,
|
|
164
|
-
label: "",
|
|
165
|
-
name: '',
|
|
166
|
-
operator: 'eq',
|
|
167
|
-
type: 'string',
|
|
168
|
-
permission: '',
|
|
169
|
-
value: ''
|
|
170
|
-
}
|
|
171
|
-
if (filters.value) {
|
|
172
|
-
filters.value.push(filter)
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function normalizeFieldType(type: string): IEntityCrudFieldTypes {
|
|
177
|
-
if (type === 'array.ref') return 'ref';
|
|
178
|
-
if (type === 'array.string') return 'string';
|
|
179
|
-
if (type === 'longString') return 'string';
|
|
180
|
-
if (type === 'array.number') return 'number';
|
|
181
|
-
if (type === 'array.enum') return 'enum';
|
|
182
|
-
return type as IEntityCrudFieldTypes;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function onUpdateField(index: number, val: string) {
|
|
186
|
-
const field = entitySelected.value.fields.find((e: any) => e.name === val)
|
|
187
|
-
let filter = dynamicFilter.value(index)
|
|
188
|
-
if (!filter) {
|
|
189
|
-
return
|
|
190
|
-
}
|
|
191
|
-
filter.value = null
|
|
192
|
-
if (!field) return
|
|
193
|
-
|
|
194
|
-
if (field.ref) {
|
|
195
|
-
filter.ref = field.ref
|
|
196
|
-
}
|
|
197
|
-
if (field.refDisplay) {
|
|
198
|
-
filter.refDisplay = field.refDisplay
|
|
199
|
-
}
|
|
200
|
-
if (field.enum) {
|
|
201
|
-
filter.enum = field.enum
|
|
202
|
-
}
|
|
203
|
-
if (field.type) {
|
|
204
|
-
filter.type = normalizeFieldType(field.type)
|
|
205
|
-
if(field.type === 'boolean'){
|
|
206
|
-
filter.value = false
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
125
|
+
const {
|
|
126
|
+
dynamicFilter,
|
|
127
|
+
selectableFields,
|
|
128
|
+
getOperations,
|
|
129
|
+
isValueRequired,
|
|
130
|
+
onUpdateField,
|
|
131
|
+
addFilter,
|
|
132
|
+
removeFilter
|
|
133
|
+
} = useDynamicFilters(
|
|
134
|
+
computed(() => form.value.entity),
|
|
135
|
+
computed(() => entitySelected.value.fields || []),
|
|
136
|
+
filters
|
|
137
|
+
)
|
|
211
138
|
|
|
212
139
|
</script>
|
|
213
140
|
|
|
@@ -273,22 +200,23 @@ function onUpdateField(index: number, val: string) {
|
|
|
273
200
|
density="compact"
|
|
274
201
|
variant="outlined"
|
|
275
202
|
hide-details
|
|
276
|
-
@update:modelValue="(
|
|
203
|
+
@update:modelValue="() => onUpdateField(index, true)"
|
|
277
204
|
/>
|
|
278
205
|
</v-col>
|
|
279
206
|
<v-col cols="12" sm="3">
|
|
280
207
|
<v-select
|
|
281
|
-
:items="
|
|
208
|
+
:items="getOperations(index)"
|
|
282
209
|
v-model="dynamicFilter(index)!.operator"
|
|
283
210
|
:label="t('crud.operator')"
|
|
284
211
|
density="compact"
|
|
285
212
|
variant="outlined"
|
|
286
213
|
hide-details
|
|
214
|
+
@update:modelValue="() => onUpdateField(index)"
|
|
287
215
|
/>
|
|
288
216
|
</v-col>
|
|
289
217
|
<v-col cols="12" sm="4">
|
|
290
218
|
<crud-form-field
|
|
291
|
-
v-if="entitySelected"
|
|
219
|
+
v-if="entitySelected && isValueRequired(index)"
|
|
292
220
|
:field="filter"
|
|
293
221
|
:entity="entitySelected"
|
|
294
222
|
v-model="dynamicFilter(index)!.value"
|
|
@@ -314,7 +242,7 @@ function onUpdateField(index: number, val: string) {
|
|
|
314
242
|
</v-col>
|
|
315
243
|
|
|
316
244
|
<v-col cols="12">
|
|
317
|
-
<v-btn small variant="outlined" color="primary" @click="addFilter">+ {{ t('action.addFilter') }}</v-btn>
|
|
245
|
+
<v-btn size="small" variant="outlined" color="primary" @click="addFilter">+ {{ t('action.addFilter') }}</v-btn>
|
|
318
246
|
</v-col>
|
|
319
247
|
|
|
320
248
|
</v-row>
|