Improve editing and creating of transactions
This commit is contained in:
@ -8,6 +8,8 @@ const props = defineProps<{
|
||||
transactionid: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits(["save"]);
|
||||
|
||||
const accountStore = useAccountStore();
|
||||
const TX = accountStore.Transactions.get(props.transactionid)!;
|
||||
const payeeType = ref<string|undefined>(undefined);
|
||||
@ -28,6 +30,7 @@ const payload = computed(() => JSON.stringify({
|
||||
function saveTransaction(e: MouseEvent) {
|
||||
e.preventDefault();
|
||||
accountStore.editTransaction(TX.ID, payload.value);
|
||||
emit('save');
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -44,7 +44,7 @@ const Reconciling = computed(() => useAccountStore().Reconciling);
|
||||
<input type="checkbox" v-model="transaction.Reconciled" />
|
||||
</td>
|
||||
</tr>
|
||||
<TransactionEditRow v-if="edit" :transactionid="transaction.ID" />
|
||||
<TransactionEditRow v-if="edit" :transactionid="transaction.ID" @save="edit = false" />
|
||||
</template>
|
||||
|
||||
<style>
|
||||
|
@ -206,12 +206,13 @@ export const useAccountStore = defineStore("budget/account", {
|
||||
async saveTransaction(payload: string) {
|
||||
const result = await POST("/transaction/new", payload);
|
||||
const response = await result.json();
|
||||
this.CurrentAccount?.Transactions.unshift(response);
|
||||
this.AddTransaction(this.CurrentAccount!, response);
|
||||
this.CurrentAccount?.Transactions.unshift(response.ID);
|
||||
},
|
||||
async editTransaction(transactionid: string, payload: string) {
|
||||
const result = await POST("/transaction/" + transactionid, payload);
|
||||
const response = await result.json();
|
||||
this.CurrentAccount?.Transactions.unshift(response);
|
||||
this.AddTransaction(this.CurrentAccount!, response);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user