Skip to content

Commit 546d645

Browse files
committed
vuetify : add edit button on show view
1 parent b6dd40b commit 546d645

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

templates/vue-common/mixins/ShowMixin.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ export default {
2020
.catch(() => {});
2121
});
2222
},
23-
formatDateTime
23+
formatDateTime,
24+
editHandler() {
25+
this.$router.push({
26+
name: `${this.$options.servicePrefix}Update`,
27+
params: { id: this.item['@id'] }
28+
});
29+
}
2430
},
2531
watch: {
2632
error(message) {

templates/vuetify/components/Toolbar.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
<slot name="left"></slot>
44
<v-spacer />
55
<div>
6+
<v-btn
7+
v-if="handleEdit"
8+
:loading="isLoading"
9+
color="primary"
10+
@click="editItem"
11+
>
12+
{{ $t('Edit') }}
13+
</v-btn>
614
<v-btn
715
v-if="handleSubmit"
816
:loading="isLoading"
@@ -55,6 +63,10 @@ export default {
5563
};
5664
},
5765
props: {
66+
handleEdit: {
67+
type: Function,
68+
required: false
69+
},
5870
handleSubmit: {
5971
type: Function,
6072
required: false
@@ -87,6 +99,11 @@ export default {
8799
this.handleAdd();
88100
}
89101
},
102+
editItem() {
103+
if (this.handleEdit) {
104+
this.handleEdit();
105+
}
106+
},
90107
submitItem() {
91108
if (this.handleSubmit) {
92109
this.handleSubmit();

templates/vuetify/views/foo/Show.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div>
3-
<Toolbar :handle-delete="del">
3+
<Toolbar :handle-edit="editHandler" :handle-delete="del">
44
<template slot="left">
55
<v-toolbar-title v-if="item">\{{
66
`${$options.servicePrefix} ${item['@id']}`

0 commit comments

Comments
 (0)