Improve editing and creating of transactions
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-02-27 21:15:46 +00:00
parent faef975f1a
commit 4c6d21c2b4
7 changed files with 32 additions and 22 deletions

View File

@ -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>

View File

@ -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>

View File

@ -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);
}
}