Skip to content

Commit 6b2e326

Browse files
committed
Publication sorting fix and basic features
1 parent 7f9cbc1 commit 6b2e326

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

pages/publications.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ const sorting = ref({
1717
ascending: false
1818
})
1919

20+
const previousSort = ref("author")
21+
2022
// helper
2123
function sortByAuthor(a, b, order) {
2224
const aFirstAuthor = a.authors.split(',')[0]
@@ -55,17 +57,12 @@ const sortedPublications = computed(() => {
5557
})
5658

5759
function handleSortToggle(v) {
58-
// console.log(sorting.value.sort, v)
59-
// if (sorting.value.sort == v) {
60-
// sorting.value.ascending = !sorting.value.ascending
61-
// }
62-
// else {
63-
// sorting.value.ascending = false
64-
// }
65-
}
66-
67-
function handleSortOptionChange(v, e) {
68-
console.log(v,e)
60+
if (previousSort.value === v) {
61+
sorting.value.ascending = !sorting.value.ascending
62+
} else {
63+
previousSort.value = v
64+
sorting.value.ascending = false
65+
}
6966
}
7067

7168
onMounted(async () => {
@@ -102,6 +99,12 @@ onMounted(async () => {
10299
margin-bottom: 10px;
103100
}
104101
}
102+
103+
.v-icon-placeholder {
104+
width: 16px; /* Width of the icon */
105+
height: 16px; /* Height of the icon */
106+
display: inline-block;
107+
}
105108
</style>
106109

107110
<v-row
@@ -112,28 +115,30 @@ onMounted(async () => {
112115
# Publications
113116

114117
<v-btn-toggle
115-
:value="sorting.sort"
116-
@change="handleSortOptionChange(sorting, $event)"
118+
v-model="sorting.sort"
117119
mandatory
118120
group
119121
>
120-
<v-btn value="year" @click="() => handleSortToggle('year')">
122+
<v-btn value="year" @click="() => sorting.sort === 'year' && handleSortToggle('year')">
121123
Year
122124
<v-icon v-if="sorting.sort === 'year'" class="opacity-60">
123125
{{ (sorting.ascending) ? "mdi-arrow-up" : "mdi-arrow-down" }}
124126
</v-icon>
127+
<span v-else class="v-icon-placeholder"></span>
125128
</v-btn>
126-
<v-btn value="author" @click="() => handleSortToggle('author')">
129+
<v-btn value="author" @click="handleSortToggle('author')">
127130
Author
128131
<v-icon v-if="sorting.sort === 'author'" class="opacity-60">
129132
{{ (sorting.ascending) ? "mdi-arrow-up" : "mdi-arrow-down" }}
130133
</v-icon>
134+
<span v-else class="v-icon-placeholder"></span>
131135
</v-btn>
132-
<v-btn value="title" @click="() => handleSortToggle('title')">
136+
<v-btn value="title" @click="handleSortToggle('title')">
133137
Title
134138
<v-icon v-if="sorting.sort === 'title'" class="opacity-60">
135139
{{ (sorting.ascending) ? "mdi-arrow-up" : "mdi-arrow-down" }}
136140
</v-icon>
141+
<span v-else class="v-icon-placeholder"></span>
137142
</v-btn>
138143
</v-btn-toggle>
139144
</v-row>

0 commit comments

Comments
 (0)