Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions web/src/components/DandisetSearchField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,23 @@ function performSearch(evt: Event) {
// nothing has changed, do nothing
return;
}
if (route.name !== 'searchDandisets') {
router.push({
name: 'searchDandisets',
query: {
search: currentSearch.value,
},
});
} else {
if (route.name === 'searchDandisets' || route.name === 'myDandisets') {
// Stay on the current page so the search keeps its context. On "My Dandisets"
// this scopes the search to the user's own dandisets (including embargoed).
router.replace({
...route,
query: {
...route.query,
search: currentSearch.value,
},
} as RouteLocationRaw);
} else {
router.push({
name: 'searchDandisets',
query: {
search: currentSearch.value,
},
});
}
}
</script>
Expand Down
9 changes: 6 additions & 3 deletions web/src/components/DandisetsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
</v-btn>
</v-toolbar>
<v-alert
v-if="props.search && searchError"
v-if="searchActive && searchError"
type="error"
variant="tonal"
class="mx-4 mx-md-8 mt-4"
Expand All @@ -151,7 +151,7 @@
{{ searchError }}
</v-alert>
<div
v-else-if="props.search && djangoDandisetRequest"
v-else-if="searchActive && djangoDandisetRequest"
class="mx-4 mx-md-8 mt-4 text-h6"
>
{{ djangoDandisetRequest.count }} {{ djangoDandisetRequest.count === 1 ? 'result' : 'results' }} found
Expand Down Expand Up @@ -232,6 +232,9 @@ const sortDir = ref(Number(route.query.sortDir || -1));
const page = ref(Number(route.query.page) || 1);

const pageTitle = computed(() => ((props.search) ? route.query.search as string : props.title));
// A search is active either on the dedicated search page, or whenever a search
// query is present on another listing page (e.g. "My Dandisets").
const searchActive = computed(() => props.search || !!route.query.search);
const sortField = computed(() => sortingOptions[sortOption.value].djangoField);

// Django dandiset listing
Expand All @@ -246,7 +249,7 @@ watchEffect(async () => {
page_size: DANDISETS_PER_PAGE,
ordering,
user: props.user ? 'me' : null,
search: props.search ? route.query.search : null,
search: searchActive.value ? route.query.search : null,
starred: props.starred ? true : null,
draft: props.user ? true : showDrafts.value,
empty: props.user ? true : showEmpty.value,
Expand Down
8 changes: 7 additions & 1 deletion web/src/views/MyDandisetsView/MyDandisetsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@
user
>
<template #no-content>
<div>
<div v-if="route.query.search">
No results found in your dandisets.
</div>
<div v-else>
You haven't created any dandisets yet
</div>
</template>
</DandisetsPage>
</template>

<script setup lang="ts">
import { useRoute } from 'vue-router';
import DandisetsPage from '@/components/DandisetsPage.vue';

const route = useRoute();
</script>
Loading