Extract EditAccount Dialog
This commit is contained in:
parent
7435ac3667
commit
1331304639
44
web/src/dialogs/EditAccount.vue
Normal file
44
web/src/dialogs/EditAccount.vue
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
import Modal from '../components/Modal.vue';
|
||||||
|
import { useAccountStore } from '../stores/budget-account';
|
||||||
|
|
||||||
|
const accountStore = useAccountStore();
|
||||||
|
const CurrentAccount = computed(() => accountStore.CurrentAccount);
|
||||||
|
|
||||||
|
const accountName = ref("");
|
||||||
|
const accountOnBudget = ref(true);
|
||||||
|
|
||||||
|
function editAccount(e : any) {
|
||||||
|
accountStore.EditAccount(CurrentAccount.value?.ID ?? "", accountName.value, accountOnBudget.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function openEditAccount(e : any) {
|
||||||
|
accountName.value = CurrentAccount.value?.Name ?? "";
|
||||||
|
accountOnBudget.value = CurrentAccount.value?.OnBudget ?? true;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal button-text="Edit Account" @open="openEditAccount" @submit="editAccount">
|
||||||
|
<template v-slot:placeholder>✎</template>
|
||||||
|
<div class="mt-2 px-7 py-3">
|
||||||
|
<input
|
||||||
|
class="border-2"
|
||||||
|
type="text"
|
||||||
|
v-model="accountName"
|
||||||
|
placeholder="Account name"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="mt-2 px-7 py-3">
|
||||||
|
<input
|
||||||
|
class="border-2"
|
||||||
|
type="checkbox"
|
||||||
|
v-model="accountOnBudget"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<label>On Budget</label>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
@ -4,7 +4,7 @@ import Currency from "../components/Currency.vue";
|
|||||||
import TransactionRow from "../components/TransactionRow.vue";
|
import TransactionRow from "../components/TransactionRow.vue";
|
||||||
import TransactionInputRow from "../components/TransactionInputRow.vue";
|
import TransactionInputRow from "../components/TransactionInputRow.vue";
|
||||||
import { useAccountStore } from "../stores/budget-account";
|
import { useAccountStore } from "../stores/budget-account";
|
||||||
import Modal from "../components/Modal.vue";
|
import EditAccount from "../dialogs/EditAccount.vue";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
budgetid: string
|
budgetid: string
|
||||||
@ -15,42 +15,11 @@ const accountStore = useAccountStore();
|
|||||||
const CurrentAccount = computed(() => accountStore.CurrentAccount);
|
const CurrentAccount = computed(() => accountStore.CurrentAccount);
|
||||||
const TransactionsList = computed(() => accountStore.TransactionsList);
|
const TransactionsList = computed(() => accountStore.TransactionsList);
|
||||||
|
|
||||||
const accountName = ref("");
|
|
||||||
const accountOnBudget = ref(true);
|
|
||||||
|
|
||||||
function editAccount(e : any) {
|
|
||||||
accountStore.EditAccount(CurrentAccount.value?.ID ?? "", accountName.value, accountOnBudget.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
function openEditAccount(e : any) {
|
|
||||||
accountName.value = CurrentAccount.value?.Name ?? "";
|
|
||||||
accountOnBudget.value = CurrentAccount.value?.OnBudget ?? true;
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<h1 class="inline">{{ CurrentAccount?.Name }}</h1>
|
<h1 class="inline">{{ CurrentAccount?.Name }}</h1>
|
||||||
<Modal button-text="Edit Account" @open="openEditAccount" @submit="editAccount">
|
<EditAccount />
|
||||||
<template v-slot:placeholder>✎</template>
|
|
||||||
<div class="mt-2 px-7 py-3">
|
|
||||||
<input
|
|
||||||
class="border-2"
|
|
||||||
type="text"
|
|
||||||
v-model="accountName"
|
|
||||||
placeholder="Account name"
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="mt-2 px-7 py-3">
|
|
||||||
<input
|
|
||||||
class="border-2"
|
|
||||||
type="checkbox"
|
|
||||||
v-model="accountOnBudget"
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
<label>On Budget</label>
|
|
||||||
</div>
|
|
||||||
</Modal>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Current Balance:
|
Current Balance:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user