Add "toggle all bots" button

This commit is contained in:
Matthias 2023-10-12 19:40:52 +02:00
parent 0972f95314
commit a01cf00e0a

View File

@ -8,16 +8,21 @@
:items="tableItems" :items="tableItems"
:fields="tableFields" :fields="tableFields"
> >
<template #cell(botName)="row"> <template #cell(botName)="{ item, value }">
<div class="d-flex flex-row"> <div class="d-flex flex-row">
<b-form-checkbox <b-form-checkbox
v-if="row.item.botId && botStore.botCount > 1" v-if="item.botId && botStore.botCount > 1"
v-model=" v-model="
botStore.botStores[(row.item as unknown as ComparisonTableItems).botId ?? ''].isSelected botStore.botStores[(item as unknown as ComparisonTableItems).botId ?? ''].isSelected
" "
title="Show this bot in Dashboard" title="Show this bot in Dashboard"
/> />
<span>{{ row.value }}</span> <b-form-checkbox
v-if="!item.botId && botStore.botCount > 1"
v-model="allToggled"
title="Toggle all bots"
/>
<span>{{ value }}</span>
</div> </div>
</template> </template>
<template #cell(profitOpen)="{ item }"> <template #cell(profitOpen)="{ item }">
@ -71,6 +76,15 @@ import { TableField, TableItem } from 'bootstrap-vue-next';
const botStore = useBotStore(); const botStore = useBotStore();
const allToggled = computed<boolean>({
get: () => Object.values(botStore.botStores).every((i) => i.isSelected),
set: (val) => {
for (const botId in botStore.botStores) {
botStore.botStores[botId].isSelected = val;
}
},
});
const tableFields: TableField[] = [ const tableFields: TableField[] = [
{ key: 'botName', label: 'Bot' }, { key: 'botName', label: 'Bot' },
{ key: 'trades', label: 'Trades' }, { key: 'trades', label: 'Trades' },