Add "clear today" functionality
to move a transaction to today and mark it cleared in one step Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
d101c24b85
commit
00ecb36ab8
1 changed files with 39 additions and 9 deletions
|
@ -109,6 +109,16 @@
|
|||
Move to Today
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button
|
||||
class="dropdown-item"
|
||||
:disabled="selectedTx.length < 1"
|
||||
@click="clearToday"
|
||||
>
|
||||
<i class="fas fa-fw fa-copyright mr-1" />
|
||||
Clear Today
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button
|
||||
v-shortkey="['del']"
|
||||
|
@ -484,6 +494,22 @@ export default {
|
|||
methods: {
|
||||
classFromNumber,
|
||||
|
||||
clearToday() {
|
||||
return this.patchSelected([
|
||||
{
|
||||
op: 'replace',
|
||||
path: '/time',
|
||||
value: new Date(new Date().toISOString()
|
||||
.split('T')[0]),
|
||||
},
|
||||
{
|
||||
op: 'replace',
|
||||
path: '/cleared',
|
||||
value: true,
|
||||
},
|
||||
])
|
||||
},
|
||||
|
||||
deleteSelected() {
|
||||
const actions = []
|
||||
for (const id of this.selectedTx) {
|
||||
|
@ -536,22 +562,26 @@ export default {
|
|||
},
|
||||
|
||||
moveToToday() {
|
||||
return this.patchSelected([
|
||||
{
|
||||
op: 'replace',
|
||||
path: '/time',
|
||||
value: new Date(new Date().toISOString()
|
||||
.split('T')[0]),
|
||||
},
|
||||
])
|
||||
},
|
||||
|
||||
patchSelected(patchset = []) {
|
||||
const actions = []
|
||||
for (const id of this.selectedTx) {
|
||||
actions.push(fetch(`/api/transactions/${id}`, {
|
||||
body: JSON.stringify([
|
||||
{
|
||||
op: 'replace',
|
||||
path: '/time',
|
||||
value: new Date(new Date().toISOString()
|
||||
.split('T')[0]),
|
||||
},
|
||||
]),
|
||||
body: JSON.stringify(patchset),
|
||||
method: 'PATCH',
|
||||
}))
|
||||
}
|
||||
|
||||
Promise.all(actions)
|
||||
return Promise.all(actions)
|
||||
.then(() => {
|
||||
this.$emit('update-accounts')
|
||||
this.fetchTransactions()
|
||||
|
|
Loading…
Reference in a new issue