diff --git a/src/components/table/SortableHeader.vue b/src/components/table/SortableHeader.vue index cd5a412..d6f843e 100644 --- a/src/components/table/SortableHeader.vue +++ b/src/components/table/SortableHeader.vue @@ -4,23 +4,29 @@ import { SortDirection } from './sort'; interface Props { currentSortKey: string | null; sortDirection?: SortDirection | null; + showColumn?: (k: string) => boolean; + unsortable?: boolean; sortKey: string; } interface Emit { (e: 'sort', key: string, direction: SortDirection): void; } -defineProps(); +withDefaults(defineProps(), { + showColumn: () => () => true, + unsortable: false +}); const emit = defineEmits(); diff --git a/src/components/table/sort.ts b/src/components/table/sort.ts index 36f6ef1..64b5927 100644 --- a/src/components/table/sort.ts +++ b/src/components/table/sort.ts @@ -4,6 +4,7 @@ export type SortDirection = "asc" | "desc"; export type UseSortOptions = { defaultSortKey?: string; defaultSortDirection?: SortDirection; + ignoredColums?: MaybeRefOrGetter; }; export const useSort = (array: MaybeRefOrGetter, options?: UseSortOptions) => { @@ -13,10 +14,11 @@ export const useSort = (array: MaybeRefOrGetter, options?: UseSortOption sortKey.value = key; sortDirection.value = direction; }; + const showColumn = (sortKey: string) => toValue(options?.ignoredColums)?.includes(sortKey) ?? true; const headerProps = computed(() => ({ - onSort: sortBy, + onSort: sortBy, showColumn, currentSortKey: sortKey.value, - sortDirection: sortDirection.value, + sortDirection: sortDirection.value })); const sortedArray = computed(() => toValue(array).sort((a, b) => { @@ -38,5 +40,5 @@ export const useSort = (array: MaybeRefOrGetter, options?: UseSortOption } })); - return { sortedArray, headerProps }; + return { sortedArray, headerProps, showColumn }; } \ No newline at end of file diff --git a/src/market/scan/ScanResultTable.vue b/src/market/scan/ScanResultTable.vue index 0f31fde..b7eb875 100644 --- a/src/market/scan/ScanResultTable.vue +++ b/src/market/scan/ScanResultTable.vue @@ -24,6 +24,7 @@ type Result = { interface Props { items?: ScanResult[]; infoOnly?: boolean; + ignoredColums?: string[]; } interface Emits { @@ -37,7 +38,8 @@ const scoreFormater = new Intl.NumberFormat("en-US", { const props = withDefaults(defineProps(), { items: () => [], - infoOnly: false + infoOnly: false, + ignoredColums: () => [] }); defineEmits(); @@ -47,7 +49,13 @@ const days = useStorage('market-scan-days', 365); const threshold = useStorage('market-scan-threshold', 10); const filter = ref(""); const onlyCheap = ref(false); -const { sortedArray, headerProps } = useSort(computed(() => props.items +const columnsToIgnore = computed(() => { + if (props.infoOnly && !props.ignoredColums.includes('buttons')) { + return [...props.ignoredColums, 'buttons']; + } + return props.ignoredColums; +}); +const { sortedArray, headerProps, showColumn } = useSort(computed(() => props.items .filter(r => r.type.name.toLowerCase().includes(filter.value.toLowerCase())) .map(r => { const quartils = getHistoryQuartils(r.history, days.value); @@ -68,7 +76,8 @@ const { sortedArray, headerProps } = useSort(computed(() => props.items }; }).filter(r => !onlyCheap.value || (r.buy <= r.q1 && r.profit >= (threshold.value / 100)))), { defaultSortKey: 'score', - defaultSortDirection: 'desc' + defaultSortDirection: 'desc', + ignoredColums: columnsToIgnore }) const getLineColor = (result: Result) => { if (props.infoOnly) { @@ -116,22 +125,22 @@ const getLineColor = (result: Result) => { Q3 Profit Score - + - + - {{ formatIsk(r.buy) }} - {{ formatIsk(r.sell) }} - {{ formatIsk(r.q1) }} - {{ formatIsk(r.median) }} - {{ formatIsk(r.q3) }} - {{ percentFormater.format(r.profit) }} - {{ scoreFormater.format(r.score) }} - + {{ formatIsk(r.buy) }} + {{ formatIsk(r.sell) }} + {{ formatIsk(r.q1) }} + {{ formatIsk(r.median) }} + {{ formatIsk(r.q3) }} + {{ percentFormater.format(r.profit) }} + {{ scoreFormater.format(r.score) }} +