Skip to content

Commit

Permalink
Small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Dutchman97 committed Dec 10, 2023
1 parent cf8753f commit 0a0d521
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
10 changes: 3 additions & 7 deletions frontend/src/components/DropdownMultiSelectButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<script setup lang="ts">
import type { ResultType, SelectInputOptions } from "@/util/data";
import IdGenerator from "@/util/id-generator";
import _ from "lodash";
import { computed } from "vue";
const props = withDefaults(defineProps<{
Expand All @@ -61,8 +62,8 @@ const emit = defineEmits<{
const dropdownId = IdGenerator.generateUniqueId('dropdownMultiSelect');
const originalModelValues = _.clone(props.modelValue);
const originalModelValues = props.modelValue;
function isNotNil<T>(value: T | null | undefined): value is T {
return value != null;
Expand All @@ -81,12 +82,7 @@ const selectAll = computed<boolean>({
return props.options.length === props.modelValue.length;
},
set(value) {
onSelectionChanged(value ? props.options.map(option => option.value) : originalModelValues);
emit('update:modelValue', value ? props.options.map(option => option.value) : originalModelValues);
},
});
function onSelectionChanged(newSelectedOptionIds: number[]): void {
emit('update:modelValue', newSelectedOptionIds);
}
</script>
14 changes: 7 additions & 7 deletions frontend/src/views/surveyresults/SurveyResultsFull.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
<label class="form-check-label" for="filterBelowPopularityThreshold">Filter away anime below the popularity threshold (2%)</label>
</div>
<h3 class="section-title" id="tableSeries">Anime Series</h3>
<DropdownMultiSelectButton :options="(tableDataOfSeries.columnsAsSelectorItems as SelectInputOptions<ResultType>)" v-model="tableDataOfSeries.visibleColumnTypes">
<DropdownMultiSelectButton :options="(tableDataOfSeries.columnsAsSelectInputOptions as SelectInputOptions<ResultType>)" v-model="tableDataOfSeries.visibleColumnTypes">
Columns
</DropdownMultiSelectButton>
<FullResultsTable :columns="tableDataOfSeries.processedColumns" :entries="tableDataOfSeries.entries" isAnimeSeries/>
<FullResultsTable :columns="tableDataOfSeries.visibleColumns" :entries="tableDataOfSeries.entries" isAnimeSeries/>

<h3 class="section-title" id="tableSpecial">Anime OVAs / ONAs / Movies / Specials</h3>
<DropdownMultiSelectButton :options="(tableDataOfSpecial.columnsAsSelectorItems as SelectInputOptions<ResultType>)" v-model="tableDataOfSpecial.visibleColumnTypes">
<DropdownMultiSelectButton :options="(tableDataOfSpecial.columnsAsSelectInputOptions as SelectInputOptions<ResultType>)" v-model="tableDataOfSpecial.visibleColumnTypes">
Columns
</DropdownMultiSelectButton>
<FullResultsTable :columns="tableDataOfSpecial.processedColumns" :entries="tableDataOfSpecial.entries"/>
<FullResultsTable :columns="tableDataOfSpecial.visibleColumns" :entries="tableDataOfSpecial.entries"/>

<div class="row g-0">
<div class="col-auto pe-1">
Expand Down Expand Up @@ -43,19 +43,19 @@ class TableData {
entries: AnimeTableEntryData[] = [];
isColumnVisible: Partial<Record<ResultType, boolean>> = {};
get processedColumns(): AnimeTableColumnData[] {
get visibleColumns(): AnimeTableColumnData[] {
return this.columns.filter(column => this.isColumnVisible[column.resultType]);
}
get columnsAsSelectorItems(): SelectInputOptions<ResultType> {
get columnsAsSelectInputOptions(): SelectInputOptions<ResultType> {
return new SelectInputOptions<ResultType>(this.columns.map(column => ({
displayName: getResultTypeName(column.resultType, true),
value: column.resultType,
})));
}
get visibleColumnTypes(): ResultType[] {
return this.processedColumns.map(column => column.resultType);
return this.visibleColumns.map(column => column.resultType);
}
set visibleColumnTypes(value: ResultType[]) {
this.columns.forEach(column => this.isColumnVisible[column.resultType] = value.includes(column.resultType));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import type { RouteLocationNormalized } from 'vue-router';
const props = defineProps<{
ranking: { anime: AnimeViewModel, result: number, extraResult?: number }[];
resultTypes: ResultType[]; // Must have either length 1 or 2
resultTypes: [ResultType] | [ResultType, ResultType]; // Must have either length 1 or 2
isAnimeSeries?: boolean;
top: number;
Expand Down

0 comments on commit 0a0d521

Please sign in to comment.