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
|
Move to Today
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</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>
|
<li>
|
||||||
<button
|
<button
|
||||||
v-shortkey="['del']"
|
v-shortkey="['del']"
|
||||||
|
@ -484,6 +494,22 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
classFromNumber,
|
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() {
|
deleteSelected() {
|
||||||
const actions = []
|
const actions = []
|
||||||
for (const id of this.selectedTx) {
|
for (const id of this.selectedTx) {
|
||||||
|
@ -536,22 +562,26 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
moveToToday() {
|
moveToToday() {
|
||||||
const actions = []
|
return this.patchSelected([
|
||||||
for (const id of this.selectedTx) {
|
|
||||||
actions.push(fetch(`/api/transactions/${id}`, {
|
|
||||||
body: JSON.stringify([
|
|
||||||
{
|
{
|
||||||
op: 'replace',
|
op: 'replace',
|
||||||
path: '/time',
|
path: '/time',
|
||||||
value: new Date(new Date().toISOString()
|
value: new Date(new Date().toISOString()
|
||||||
.split('T')[0]),
|
.split('T')[0]),
|
||||||
},
|
},
|
||||||
]),
|
])
|
||||||
|
},
|
||||||
|
|
||||||
|
patchSelected(patchset = []) {
|
||||||
|
const actions = []
|
||||||
|
for (const id of this.selectedTx) {
|
||||||
|
actions.push(fetch(`/api/transactions/${id}`, {
|
||||||
|
body: JSON.stringify(patchset),
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
Promise.all(actions)
|
return Promise.all(actions)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.$emit('update-accounts')
|
this.$emit('update-accounts')
|
||||||
this.fetchTransactions()
|
this.fetchTransactions()
|
||||||
|
|
Loading…
Reference in a new issue