lighter type info

This commit is contained in:
2024-05-19 16:22:02 +02:00
parent 3a3711b713
commit d82f6b6965
3 changed files with 33 additions and 19 deletions

View File

@@ -26,6 +26,7 @@ interface Props {
items?: AcquiredType[];
infoOnly?: boolean;
showAll?: boolean;
ignoredColums?: string[] | string;
}
interface Emits {
@@ -36,15 +37,25 @@ interface Emits {
const props = withDefaults(defineProps<Props>(), {
items: () => [],
infoOnly: false,
showAll: false
showAll: false,
ignoredColums: () => []
});
defineEmits<Emits>();
const columnsToIgnore = computed(() => {
const ic = typeof props.ignoredColums === 'string' ? [props.ignoredColums] : props.ignoredColums;
if (props.infoOnly && !ic.includes('buttons')) {
return [...ic, 'buttons'];
}
return ic;
});
const marketTaxStore = useMarketTaxStore();
const threshold = useStorage('market-acquisition-threshold', 10);
const filter = ref("");
const { sortedArray, headerProps } = useSort<Result>(computed(() => {
const { sortedArray, headerProps, showColumn } = useSort<Result>(computed(() => {
const filteredItems = props.items.filter(r => r.type.name.toLowerCase().includes(filter.value.toLowerCase()));
if (props.showAll) {
@@ -99,7 +110,8 @@ const { sortedArray, headerProps } = useSort<Result>(computed(() => {
return list;
}), {
defaultSortKey: 'precentProfit',
defaultSortDirection: 'desc'
defaultSortDirection: 'desc',
ignoredColums: columnsToIgnore
})
const getLineColor = (result: Result) => {
if (result.precentProfit >= (threshold.value / 100)) {
@@ -135,24 +147,24 @@ const getLineColor = (result: Result) => {
<SortableHeader v-bind="headerProps" sortKey="remaining">Remaining Amount</SortableHeader>
<SortableHeader v-bind="headerProps" sortKey="precentProfit">Profit (%)</SortableHeader>
<SortableHeader v-bind="headerProps" sortKey="iskProfit">Profit (ISK)</SortableHeader>
<th v-if="!infoOnly" />
<SortableHeader v-bind="headerProps" sortKey="buttons" unsortable />
</tr>
</thead>
<tbody>
<tr v-for="r in sortedArray" :key="r.id" :class="getLineColor(r)">
<td>
<td v-if="showColumn('name')">
<div class="flex">
<MarketTypeLabel :id="r.type.id" :name="r.name" />
<AcquisitionQuantilsTooltip :id="r.type.id" :buy="r.buy" :sell="r.sell" />
</div>
</td>
<td class="text-right">{{ formatIsk(r.buy) }}</td>
<td class="text-right">{{ formatIsk(r.sell) }}</td>
<td class="text-right">{{ formatIsk(r.price) }}</td>
<td class="text-right">{{ r.remaining }}/{{ r.quantity }}</td>
<td class="text-right">{{ percentFormater.format(r.precentProfit) }}</td>
<td class="text-right">{{ formatIsk(r.iskProfit) }}</td>
<td class="text-right" v-if="!infoOnly">
<td v-if="showColumn('buy')" class="text-right">{{ formatIsk(r.buy) }}</td>
<td v-if="showColumn('sell')" class="text-right">{{ formatIsk(r.sell) }}</td>
<td v-if="showColumn('price')" class="text-right">{{ formatIsk(r.price) }}</td>
<td v-if="showColumn('remaining')" class="text-right">{{ r.remaining }}/{{ r.quantity }}</td>
<td v-if="showColumn('precentProfit')" class="text-right">{{ percentFormater.format(r.precentProfit) }}</td>
<td v-if="showColumn('iskProfit')" class="text-right">{{ formatIsk(r.iskProfit) }}</td>
<td v-if="showColumn('buttons')" class="text-right">
<button class="btn-icon me-1" @click="$emit('buy', r.acquisitions, r.price, r.buy, r.sell)"><PlusIcon /></button>
<button class="btn-icon me-1" @click="$emit('sell', r.acquisitions)"><MinusIcon /></button>
</td>