mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
Merge pull request #339 from gradido/update-transactions
feat: Update Transactions When GddTable Is Rendered
This commit is contained in:
commit
aefbbeaab1
@ -32,6 +32,7 @@
|
|||||||
:balance="balance"
|
:balance="balance"
|
||||||
:gdt-balance="GdtBalance"
|
:gdt-balance="GdtBalance"
|
||||||
:transactions="transactions"
|
:transactions="transactions"
|
||||||
|
:transactionCount="transactionCount"
|
||||||
@update-balance="updateBalance"
|
@update-balance="updateBalance"
|
||||||
@update-transactions="updateTransactions"
|
@update-transactions="updateTransactions"
|
||||||
></router-view>
|
></router-view>
|
||||||
@ -80,6 +81,7 @@ export default {
|
|||||||
GdtBalance: 0,
|
GdtBalance: 0,
|
||||||
transactions: [],
|
transactions: [],
|
||||||
bookedBalance: 0,
|
bookedBalance: 0,
|
||||||
|
transactionCount: 0,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -102,6 +104,7 @@ export default {
|
|||||||
this.transactions = result.result.data.transactions
|
this.transactions = result.result.data.transactions
|
||||||
this.balance = Number(result.result.data.decay)
|
this.balance = Number(result.result.data.decay)
|
||||||
this.bookedBalance = Number(result.result.data.balance)
|
this.bookedBalance = Number(result.result.data.balance)
|
||||||
|
this.transactionCount = result.result.data.count
|
||||||
} else {
|
} else {
|
||||||
// what to do when loading balance fails?
|
// what to do when loading balance fails?
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,8 @@
|
|||||||
v-if="showTransactionList"
|
v-if="showTransactionList"
|
||||||
:transactions="transactions"
|
:transactions="transactions"
|
||||||
:max="5"
|
:max="5"
|
||||||
|
:timestamp="timestamp"
|
||||||
|
:transactionCount="transactionCount"
|
||||||
@update-transactions="updateTransactions"
|
@update-transactions="updateTransactions"
|
||||||
/>
|
/>
|
||||||
</b-container>
|
</b-container>
|
||||||
@ -30,6 +32,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
showTransactionList: true,
|
showTransactionList: true,
|
||||||
|
timestamp: Date.now(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
@ -38,6 +41,7 @@ export default {
|
|||||||
transactions: {
|
transactions: {
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
|
transactionCount: { type: Number, default: 0 },
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
GddStatus,
|
GddStatus,
|
||||||
|
|||||||
@ -95,7 +95,7 @@
|
|||||||
<router-link
|
<router-link
|
||||||
v-else-if="transactions.length > 5"
|
v-else-if="transactions.length > 5"
|
||||||
to="/transactions"
|
to="/transactions"
|
||||||
v-html="$t('transaction.show_all', { count: count })"
|
v-html="$t('transaction.show_all', { count: transactionCount })"
|
||||||
></router-link>
|
></router-link>
|
||||||
</b-list-group-item>
|
</b-list-group-item>
|
||||||
</b-list-group>
|
</b-list-group>
|
||||||
@ -108,37 +108,25 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
transactions: { default: [] },
|
transactions: { default: [] },
|
||||||
max: { type: Number, default: 25 },
|
max: { type: Number, default: 25 },
|
||||||
|
timestamp: { type: Number, default: 0 },
|
||||||
|
transactionCount: { type: Number, default: 0 },
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
form: [],
|
form: [],
|
||||||
fields: ['balance', 'date', 'memo', 'name', 'transaction_id', 'type', 'details'],
|
fields: ['balance', 'date', 'memo', 'name', 'transaction_id', 'type', 'details'],
|
||||||
items: [],
|
items: [],
|
||||||
count: 0,
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
watch: {
|
||||||
this.$emit('change-transactions')
|
timestamp: {
|
||||||
},
|
immediate: true,
|
||||||
computed: {
|
handler: 'updateTransactions',
|
||||||
filteredItems() {
|
|
||||||
return this.ojectToArray(this.items).reverse()
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
ojectToArray(obj) {
|
updateTransactions() {
|
||||||
let result = new Array(Object.keys(obj).length)
|
this.$emit('update-transactions')
|
||||||
Object.entries(obj).forEach((entry) => {
|
|
||||||
const [key, value] = entry
|
|
||||||
result[key] = value
|
|
||||||
})
|
|
||||||
return result
|
|
||||||
},
|
|
||||||
rowClass(item, type) {
|
|
||||||
if (!item || type !== 'row') return
|
|
||||||
if (item.type === 'receive') return 'table-success'
|
|
||||||
if (item.type === 'send') return 'table-warning'
|
|
||||||
if (item.type === 'creation') return 'table-primary'
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,12 @@
|
|||||||
<b-container fluid class="mt--6">
|
<b-container fluid class="mt--6">
|
||||||
<b-row>
|
<b-row>
|
||||||
<b-col class="order-xl-1">
|
<b-col class="order-xl-1">
|
||||||
<gdd-table :transactions="transactions" @update-transactions="updateTransactions" />
|
<gdd-table
|
||||||
|
:timestamp="timestamp"
|
||||||
|
:transactionCount="transactionCount"
|
||||||
|
:transactions="transactions"
|
||||||
|
@update-transactions="updateTransactions"
|
||||||
|
/>
|
||||||
</b-col>
|
</b-col>
|
||||||
</b-row>
|
</b-row>
|
||||||
<b-row class="text-center mb-6" v-if="transactions.length == 0">
|
<b-row class="text-center mb-6" v-if="transactions.length == 0">
|
||||||
@ -27,6 +32,12 @@ export default {
|
|||||||
transactions: {
|
transactions: {
|
||||||
default: [],
|
default: [],
|
||||||
},
|
},
|
||||||
|
transactionCount: { type: Number, default: 0 },
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
timestamp: Date.now(),
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateTransactions() {
|
updateTransactions() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user