@drax/crud-vue 0.22.0 → 0.24.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": "0.
|
|
6
|
+
"version": "0.24.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./src/index.ts",
|
|
9
9
|
"module": "./src/index.ts",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"format": "prettier --write src/"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@drax/common-front": "^0.
|
|
28
|
-
"@drax/crud-front": "^0.
|
|
29
|
-
"@drax/crud-share": "^0.
|
|
30
|
-
"@drax/media-vue": "^0.
|
|
27
|
+
"@drax/common-front": "^0.24.0",
|
|
28
|
+
"@drax/crud-front": "^0.24.0",
|
|
29
|
+
"@drax/crud-share": "^0.24.0",
|
|
30
|
+
"@drax/media-vue": "^0.24.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"pinia": "^2.2.2",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"vue-tsc": "^2.1.10",
|
|
65
65
|
"vuetify": "^3.8.2"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "3e6de6c6155a2a0f2e0dae36849dec7db6eb0b09"
|
|
68
68
|
}
|
package/src/EntityCrud.ts
CHANGED
|
@@ -9,9 +9,9 @@ const {t} = useI18n()
|
|
|
9
9
|
const valueModel = defineModel({type: [Object]})
|
|
10
10
|
const {hasPermission} = useAuth()
|
|
11
11
|
|
|
12
|
-
const {entity} = defineProps({
|
|
12
|
+
const {entity, actionButtons} = defineProps({
|
|
13
13
|
entity: {type: Object as PropType<IEntityCrud>, required: true},
|
|
14
|
-
|
|
14
|
+
actionButtons: {type: Boolean, default: false},
|
|
15
15
|
})
|
|
16
16
|
|
|
17
17
|
const aFields = computed(() => {
|
|
@@ -46,16 +46,22 @@ const icon = computed(() => {
|
|
|
46
46
|
})
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
emit('
|
|
49
|
+
function filter() {
|
|
50
|
+
emit('applyFilter')
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
emit('
|
|
53
|
+
function clear() {
|
|
54
|
+
emit('clearFilter')
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function onUpdateValue(){
|
|
58
|
+
if(!actionButtons){
|
|
59
|
+
emit('applyFilter')
|
|
60
|
+
}
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
|
|
58
|
-
const emit = defineEmits(['
|
|
64
|
+
const emit = defineEmits(['applyFilter', 'clearFilter'])
|
|
59
65
|
|
|
60
66
|
</script>
|
|
61
67
|
|
|
@@ -79,13 +85,13 @@ const emit = defineEmits(['filter', 'clear','updateValue'])
|
|
|
79
85
|
variant="outlined"
|
|
80
86
|
:prepend-inner-icon="icon(filter)"
|
|
81
87
|
hide-details disable-rules
|
|
82
|
-
@updateValue="
|
|
88
|
+
@updateValue="onUpdateValue"
|
|
83
89
|
/>
|
|
84
90
|
</v-col>
|
|
85
91
|
|
|
86
92
|
</v-row>
|
|
87
93
|
|
|
88
|
-
<v-card-actions v-if="
|
|
94
|
+
<v-card-actions v-if="actionButtons" class="pb-0">
|
|
89
95
|
<v-spacer />
|
|
90
96
|
<v-btn variant="text" density="compact" color="grey" @click="clear">{{ t('action.clear') }}</v-btn>
|
|
91
97
|
<v-btn variant="flat" density="compact" color="primary" @click="filter">
|
|
@@ -25,7 +25,7 @@ const {entity} = defineProps({
|
|
|
25
25
|
|
|
26
26
|
const {
|
|
27
27
|
loading, itemsPerPage, page, sortBy, search, totalItems, items,
|
|
28
|
-
doPaginate, filters
|
|
28
|
+
doPaginate, filters, applyFilters, clearFilters
|
|
29
29
|
} = useCrud(entity)
|
|
30
30
|
|
|
31
31
|
const actions: IEntityCrudHeader[] = entity.actionHeaders.map(header => ({
|
|
@@ -114,7 +114,9 @@ defineEmits(['import', 'export', 'create', 'update', 'delete', 'view', 'edit'])
|
|
|
114
114
|
v-if="!$slots.filters"
|
|
115
115
|
:entity="entity"
|
|
116
116
|
v-model="filters"
|
|
117
|
-
|
|
117
|
+
:action-buttons="entity.filterButtons"
|
|
118
|
+
@clearFilter="clearFilters()"
|
|
119
|
+
@applyFilter="applyFilters()"
|
|
118
120
|
/>
|
|
119
121
|
</v-card-text>
|
|
120
122
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import {useI18n} from "vue-i18n";
|
|
3
3
|
import {debounce} from "@drax/common-front"
|
|
4
|
-
import {ref, defineModel} from "vue"
|
|
4
|
+
import {ref, defineModel, watch} from "vue"
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
const {t} = useI18n()
|
|
@@ -9,6 +9,10 @@ const model = defineModel<any>()
|
|
|
9
9
|
|
|
10
10
|
let input = ref(model.value)
|
|
11
11
|
|
|
12
|
+
watch(() => model.value, (newValue) => {
|
|
13
|
+
input.value = newValue
|
|
14
|
+
})
|
|
15
|
+
|
|
12
16
|
const debouncedSearch = debounce(updateModel, 500)
|
|
13
17
|
|
|
14
18
|
function updateModel() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {IDraxPaginateResult, IEntityCrud} from "@drax/crud-share";
|
|
2
2
|
import {useCrudStore} from "../stores/UseCrudStore";
|
|
3
|
-
import {computed, toRaw} from "vue";
|
|
3
|
+
import {computed, nextTick, toRaw} from "vue";
|
|
4
4
|
import getItemId from "../helpers/getItemId";
|
|
5
5
|
|
|
6
6
|
export function useCrud(entity: IEntityCrud) {
|
|
@@ -349,12 +349,26 @@ export function useCrud(entity: IEntityCrud) {
|
|
|
349
349
|
store.setFilters(entity.formFilters)
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
+
async function clearFilters(){
|
|
353
|
+
prepareFilters()
|
|
354
|
+
store.setSearch("")
|
|
355
|
+
search.value = ""
|
|
356
|
+
await nextTick(async () => {
|
|
357
|
+
await doPaginate()
|
|
358
|
+
})
|
|
359
|
+
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
async function applyFilters(){
|
|
363
|
+
await doPaginate()
|
|
364
|
+
}
|
|
365
|
+
|
|
352
366
|
|
|
353
367
|
return {
|
|
354
368
|
doPaginate, doExport, onView, onCreate, onEdit, onDelete, onCancel, onSubmit, resetCrudStore,
|
|
355
369
|
operation, dialog, form, notify, error, message, formValid,
|
|
356
370
|
loading, itemsPerPage, page, sortBy, search, totalItems, items,
|
|
357
|
-
prepareFilters, filters,
|
|
371
|
+
prepareFilters, filters, clearFilters, applyFilters,
|
|
358
372
|
exportFiles, exportLoading, exportListVisible
|
|
359
373
|
}
|
|
360
374
|
|