Skip to content

Commit 36bb3c1

Browse files
authored
Merge pull request #849 from dodona-edu/fix/search-pairs
Fix search in file pairs table
2 parents 3f4071a + ee8480e commit 36bb3c1

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

web/src/components/PairsTable.vue

+7-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
:sort-by="'similarity'"
77
:sort-desc="true"
88
:items-per-page="15"
9-
:search="search"
9+
:search="searchValue"
1010
:footer-props="footerProps"
1111
:hide-default-footer="props.pairs.length <= props.itemsPerPage"
1212
@click:row="rowClicked"
@@ -20,20 +20,24 @@
2020
<script lang="ts" setup>
2121
import { shallowRef, onMounted } from "vue";
2222
import { useRouter, useRoute } from "@/composables";
23+
import { useVModel } from "@vueuse/core";
2324
import { Pair } from "@/api/models";
2425
import { DataTableHeader } from "vuetify";
2526
import SimilarityDisplay from "@/components/pair/SimilarityDisplay.vue";
2627
2728
interface Props {
2829
pairs: Pair[];
29-
itemsPerPage: number;
30+
itemsPerPage?: number;
31+
search?: string;
3032
}
3133
3234
const props = withDefaults(defineProps<Props>(), {
3335
itemsPerPage: 15,
3436
});
37+
const emit = defineEmits(["update:search"]);
3538
const router = useRouter();
3639
const route = useRoute();
40+
const searchValue = useVModel(props, "search", emit);
3741
3842
// Table headers
3943
const headers: DataTableHeader[] = [
@@ -51,17 +55,14 @@ const footerProps = {
5155
showFirstLastPage: true,
5256
};
5357
54-
// Search value.
55-
const search = shallowRef("");
56-
5758
// Items in the format for the the data-table.
5859
const items = shallowRef<any[]>([]);
5960
6061
// Calculate the items for the table.
6162
const calculateItems = (): void => {
6263
const str = route.value.query.showIds as string | null;
6364
64-
items.value = Object.values(props.pairs)
65+
items.value = props.pairs
6566
.map((pair) => ({
6667
pair,
6768
left: pair.leftFile.shortPath,

web/src/views/Pairs.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,16 @@
2525
</v-row>
2626

2727
<v-card>
28-
<PairsTable :pairs="pairStore.pairs" />
28+
<PairsTable :search.sync="search" :pairs="pairStore.pairsList" />
2929
</v-card>
3030
</v-container>
3131
</template>
3232

3333
<script lang="ts" setup>
34+
import { shallowRef } from "vue";
3435
import { usePairStore } from "@/api/stores";
3536
import PairsTable from "@/components/PairsTable.vue";
3637
3738
const pairStore = usePairStore();
39+
const search = shallowRef("");
3840
</script>

0 commit comments

Comments
 (0)