Skip to content

Commit

Permalink
refactor(Proof card): move PriceAdd action to menu
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Aug 16, 2024
1 parent 5dec6b7 commit 20fd8a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
6 changes: 6 additions & 0 deletions src/components/ProofActionMenuButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<v-icon>mdi-dots-vertical</v-icon>
<v-menu activator="parent" scroll-strategy="close" transition="slide-y-transition">
<v-list>
<PriceAddLink :proofId="proof.id" :proofType="proof.type" display="list-item" :disabled="!userCanAddPrice" />
<v-divider />
<v-list-item :slim="true" prepend-icon="mdi-pencil" :disabled="!userCanEditProof" @click="openEditDialog">
{{ $t('Common.Edit') }}
</v-list-item>
Expand Down Expand Up @@ -50,6 +52,7 @@ import { defineAsyncComponent } from 'vue'
export default {
components: {
PriceAddLink: defineAsyncComponent(() => import('../components/PriceAddLink.vue')),
ProofEditDialog: defineAsyncComponent(() => import('../components/ProofEditDialog.vue')),
ProofDeleteConfirmationDialog: defineAsyncComponent(() => import('../components/ProofDeleteConfirmationDialog.vue'))
},
Expand All @@ -73,6 +76,9 @@ export default {
}
},
computed: {
userCanAddPrice() {
return this.proof && (this.proof.type === 'PRICE_TAG' || this.proof.type === 'RECEIPT')
},
userCanEditProof() {
// user must be proof owner
// and proof must not have any prices
Expand Down
12 changes: 0 additions & 12 deletions src/views/ProofDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
</v-col>
</v-row>

<v-row v-if="allowPriceAdd" class="mt-0">
<v-col cols="12">
<PriceAddLink class="mr-2" :proofId="proof.id" :proofType="proof.type" />
</v-col>
</v-row>

<br>

<h2 v-if="proof" class="text-h6 mb-1">
Expand Down Expand Up @@ -42,7 +36,6 @@ import api from '../services/api'
export default {
components: {
PriceAddLink: defineAsyncComponent(() => import('../components/PriceAddLink.vue')),
ProofCard: defineAsyncComponent(() => import('../components/ProofCard.vue')),
PriceCard: defineAsyncComponent(() => import('../components/PriceCard.vue')),
},
Expand All @@ -56,11 +49,6 @@ export default {
loading: false,
}
},
computed: {
allowPriceAdd() {
return this.proof && (this.proof.type === 'PRICE_TAG' || this.proof.type === 'RECEIPT')
}
},
mounted() {
this.getProof()
},
Expand Down

0 comments on commit 20fd8a5

Please sign in to comment.