emit selected trade event and sorting by date

This commit is contained in:
me 2022-08-01 03:57:50 +03:00
parent 63910f19f1
commit 12b2e3aad9

View File

@ -1,13 +1,13 @@
<template> <template>
<b-list-group> <b-list-group>
<b-list-group-item <b-list-group-item
v-for="trade in trades" v-for="trade in trades.sort((a,b) => a.open_timestamp < b.open_timestamp)"
:key="trade.open_timestamp" :key="trade.open_timestamp"
button button
class="d-flex justify-content-between align-items-center py-1" class="d-flex justify-content-between align-items-center py-1"
:title="`${trade.pair}`" :title="`${trade.pair}`"
:active="trade.open_timestamp === selectedTrade" :active="trade.open_timestamp === selectedTrade.open_timestamp"
@click="tradeSelect(trade)" @click="selectedTrade = trade; $emit('trade-select',trade);"
> >
<div> <div>
<DateTimeTZ :date="trade.open_timestamp" /> <DateTimeTZ :date="trade.open_timestamp" />
@ -20,6 +20,7 @@
:stake-currency="botStore.activeBot.stakeCurrency" :stake-currency="botStore.activeBot.stakeCurrency"
/> />
</b-list-group-item> </b-list-group-item>
<b-list-group-item v-if="trades.length === 0">No trades to show...</b-list-group-item>
</b-list-group> </b-list-group>
</template> </template>
@ -36,21 +37,15 @@ export default defineComponent({
components: { TradeProfit, ProfitPill, DateTimeTZ }, components: { TradeProfit, ProfitPill, DateTimeTZ },
props: { props: {
trades: { required: true, type: Array as () => Trade[] }, trades: { required: true, type: Array as () => Trade[] },
sortMethod: { default: 'normal', type: String }, backtestMode: { required: false, default: false, type: Boolean }
backtestMode: { required: false, default: false, type: Boolean },
}, },
setup(props) { setup(props) {
const botStore = useBotStore(); const botStore = useBotStore();
const selectedTrade = ref(0) const selectedTrade = ref(0)
const tradeSelect = (trade: Trade) => {
selectedTrade.value = trade.open_timestamp;
}
return { return {
botStore, botStore,
tradeSelect,
selectedTrade selectedTrade
}; };
}, },