Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to delete fee payments through frontend for system admins #2153

Open
wants to merge 1 commit into
base: stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion src/views/core/bodies/ListFeePaymentsModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@
<b-table-column field="invoice_name" label="Invoice name">
{{ props.row.invoice_name }}
</b-table-column>

<b-table-column label="Delete" centered :visible="canDelete">
<a class="button is-small is-danger" @click="askDeleteMemberPaymentFee(props.row, false)">
<span class="icon"><font-awesome-icon icon="minus" /></span>
<span>Delete</span>
</a>
</b-table-column>
</template>

<template slot="empty">
Expand All @@ -48,14 +55,41 @@
<script>
export default {
name: 'ListFeePaymentsModal',
props: ['member'],
props: [
'member',
'payments',
'canDelete',
'route',
'services',
'root'
],
data () {
return {
}
},
methods: {
askDeleteMemberPaymentFee (fee) {
const message = `Are you sure you want to <b>delete</b> ${fee.id} from ${this.member.user.first_name} ${this.member.user.last_name}? This action cannot be undone.`
this.$buefy.dialog.confirm({
title: 'Deleting a fee',
message,
confirmText: 'Delete fee',
type: 'is-danger',
hasIcon: true,
onConfirm: () => this.deleteFee(fee)
})
},
deleteFee (fee) {
this.axios.delete(this.services['core'] + '/bodies/' + this.route.params.id + '/payments/' + fee.id).then(() => {
this.root.showSuccess('Fee is deleted.')
const updatedPayments = [...this.member.payments]
const index = updatedPayments.findIndex(p => p.id === fee.id)
updatedPayments.splice(index, 1)
this.member.payments = updatedPayments
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should refresh the table as well, to prevent this behaviour after deleting the last fee payment;
chrome_2024-05-17_16 16 37

}).catch((err) => this.root.showError('Could not delete fee', err))
}
}
}
</script>
11 changes: 9 additions & 2 deletions src/views/core/bodies/ViewMembers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ export default {
create: false,
viewMember: false,
viewPayment: false,
createPayment: false
createPayment: false,
deletePayment: false
},
PAST_DATE_PLACEHOLDER: '1900-01-1'
}
Expand All @@ -127,7 +128,12 @@ export default {
component: ListFeePaymentsModal,
hasModalCard: true,
props: {
member
member,
payments: this.payments,
canDelete: this.can.deletePayment,
route: this.$route,
services: this.services,
root: this.$root
}
})
},
Expand Down Expand Up @@ -243,6 +249,7 @@ export default {
this.can.viewMember = this.permissions.some(permission => permission.combined.endsWith('view:member'))
this.can.viewPayment = this.permissions.some(permission => permission.combined.endsWith('view:payment'))
this.can.createPayment = this.permissions.some(permission => permission.combined.endsWith('create:payment'))
this.can.deletePayment = this.permissions.some(permission => permission.combined.endsWith('delete:payment'))
if (!this.can.viewPayment || !this.body.pays_fees) {
this.isLoading = false
Expand Down