mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-19 09:41:22 +00:00
Initial set of pages.
This commit is contained in:
183
frontend/src/pages/recurring/Index.vue
Normal file
183
frontend/src/pages/recurring/Index.vue
Normal file
@@ -0,0 +1,183 @@
|
||||
<template>
|
||||
<q-page>
|
||||
<q-table
|
||||
:title="$t('firefly.recurring')"
|
||||
:rows="rows"
|
||||
:columns="columns"
|
||||
row-key="id"
|
||||
@request="onRequest"
|
||||
v-model:pagination="pagination"
|
||||
:loading="loading"
|
||||
class="q-ma-md"
|
||||
>
|
||||
<template v-slot:header="props">
|
||||
<q-tr :props="props">
|
||||
<q-th
|
||||
v-for="col in props.cols"
|
||||
:key="col.name"
|
||||
:props="props"
|
||||
>
|
||||
{{ col.label }}
|
||||
</q-th>
|
||||
</q-tr>
|
||||
</template>
|
||||
<template v-slot:body="props">
|
||||
<q-tr :props="props">
|
||||
<q-td key="name" :props="props">
|
||||
<router-link :to="{ name: 'recurring.show', params: {id: props.row.id} }" class="text-primary">
|
||||
{{ props.row.name }}
|
||||
</router-link>
|
||||
</q-td>
|
||||
<q-td key="menu" :props="props">
|
||||
<q-btn-dropdown color="primary" label="Actions" size="sm">
|
||||
<q-list>
|
||||
<q-item clickable v-close-popup :to="{name: 'recurring.edit', params: {id: props.row.id}}">
|
||||
<q-item-section>
|
||||
<q-item-label>Edit</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item clickable v-close-popup @click="deleteRecurring(props.row.id, props.row.name)">
|
||||
<q-item-section>
|
||||
<q-item-label>Delete</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-btn-dropdown>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</q-table>
|
||||
<q-page-sticky position="bottom-right" :offset="[18, 18]">
|
||||
<q-fab
|
||||
label="Actions"
|
||||
square
|
||||
vertical-actions-align="right"
|
||||
label-position="left"
|
||||
color="green"
|
||||
icon="fas fa-chevron-up"
|
||||
direction="up"
|
||||
>
|
||||
<q-fab-action color="primary" square :to="{ name: 'recurring.create'}" icon="fas fa-exchange-alt" label="New recurring transaction"/>
|
||||
</q-fab>
|
||||
</q-page-sticky>
|
||||
</q-page>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {mapGetters, useStore} from "vuex";
|
||||
import Destroy from "../../api/recurring/destroy";
|
||||
import List from "../../api/recurring/list";
|
||||
|
||||
export default {
|
||||
name: 'Index',
|
||||
watch: {
|
||||
$route(to) {
|
||||
// react to route changes...
|
||||
if ('recurring.index' === to.name) {
|
||||
this.page = 1;
|
||||
this.updateBreadcrumbs();
|
||||
this.triggerUpdate();
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
rows: [],
|
||||
pagination: {
|
||||
sortBy: 'desc',
|
||||
descending: false,
|
||||
page: 1,
|
||||
rowsPerPage: 5,
|
||||
rowsNumber: 100
|
||||
},
|
||||
loading: false,
|
||||
columns: [
|
||||
{name: 'name', label: 'Name', field: 'name', align: 'left'},
|
||||
{name: 'menu', label: ' ', field: 'menu', align: 'right'},
|
||||
],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters('fireflyiii', ['getRange', 'getCacheKey', 'getListPageSize']),
|
||||
},
|
||||
created() {
|
||||
this.pagination.rowsPerPage = this.getListPageSize;
|
||||
},
|
||||
mounted() {
|
||||
this.type = this.$route.params.type;
|
||||
if (null === this.getRange.start || null === this.getRange.end) {
|
||||
// subscribe, then update:
|
||||
const $store = useStore();
|
||||
$store.subscribe((mutation, state) => {
|
||||
if ('fireflyiii/setRange' === mutation.type) {
|
||||
this.range = {start: mutation.payload.start, end: mutation.payload.end};
|
||||
this.triggerUpdate();
|
||||
}
|
||||
});
|
||||
}
|
||||
if (null !== this.getRange.start && null !== this.getRange.end) {
|
||||
this.range = {start: this.getRange.start, end: this.getRange.end};
|
||||
this.triggerUpdate();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
deleteRecurring: function (id, name) {
|
||||
this.$q.dialog({
|
||||
title: 'Confirm',
|
||||
message: 'Do you want to delete recurring transaction "' + name + '"?',
|
||||
cancel: true,
|
||||
persistent: true
|
||||
}).onOk(() => {
|
||||
this.destroyRecurring(id);
|
||||
});
|
||||
},
|
||||
destroyRecurring: function (id) {
|
||||
let destr = new Destroy;
|
||||
destr.destroy(id).then(() => {
|
||||
this.$store.dispatch('fireflyiii/refreshCacheKey');
|
||||
this.triggerUpdate();
|
||||
});
|
||||
},
|
||||
updateBreadcrumbs: function () {
|
||||
this.$route.meta.pageTitle = 'firefly.Recurring';
|
||||
this.$route.meta.breadcrumbs = [{title: 'Recurring'}];
|
||||
|
||||
},
|
||||
onRequest: function (props) {
|
||||
this.page = props.pagination.page;
|
||||
this.triggerUpdate();
|
||||
},
|
||||
triggerUpdate: function () {
|
||||
if (this.loading) {
|
||||
return;
|
||||
}
|
||||
if (null === this.range.start || null === this.range.end) {
|
||||
return;
|
||||
}
|
||||
this.loading = true;
|
||||
const list = new List();
|
||||
this.rows = [];
|
||||
list.list(this.page, this.getCacheKey).then(
|
||||
(response) => {
|
||||
this.pagination.rowsPerPage = response.data.meta.pagination.per_page;
|
||||
this.pagination.rowsNumber = response.data.meta.pagination.total;
|
||||
this.pagination.page = this.page;
|
||||
|
||||
for (let i in response.data.data) {
|
||||
if (response.data.data.hasOwnProperty(i)) {
|
||||
let current = response.data.data[i];
|
||||
let account = {
|
||||
id: current.id,
|
||||
name: current.attributes.title,
|
||||
};
|
||||
this.rows.push(account);
|
||||
}
|
||||
}
|
||||
this.loading = false;
|
||||
}
|
||||
)
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user