-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: refurbishing gene details page (#229)
- Loading branch information
Showing
28 changed files
with
3,079 additions
and
1,852 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<script setup lang="ts"> | ||
import { onMounted, ref } from 'vue' | ||
import { useBookmarksStore } from '@/stores/bookmarks' | ||
import { StoreState } from '@/stores/misc' | ||
// Import the BookmarksClient | ||
export interface Props { | ||
type: string | ||
id: string | ||
} | ||
const props = withDefaults(defineProps<Props>(), { | ||
type: '', | ||
id: '' | ||
}) | ||
const bookmarksStore = useBookmarksStore() | ||
const isBookmarked = ref(false) | ||
const loadDataToStore = async () => { | ||
await bookmarksStore.loadBookmarks() | ||
} | ||
// Fetch existing bookmark for the given type and id on mount | ||
onMounted(async () => { | ||
loadDataToStore() | ||
bookmarksStore | ||
.fetchBookmark(props.type, props.id) | ||
?.then((bookmark) => { | ||
if (bookmark) { | ||
isBookmarked.value = true | ||
} else { | ||
isBookmarked.value = false | ||
} | ||
}) | ||
.catch((e) => { | ||
isBookmarked.value = false | ||
console.error(e) | ||
}) | ||
}) | ||
// Function to toggle bookmark | ||
const toggleBookmark = async () => { | ||
if (isBookmarked.value) { | ||
await bookmarksStore.deleteBookmark(props.type, props.id) | ||
} else { | ||
await bookmarksStore.createBookmark(props.type, props.id) | ||
} | ||
const retrievedBookmark = await bookmarksStore.fetchBookmark(props.type, props.id) | ||
if (retrievedBookmark) { | ||
isBookmarked.value = true | ||
} else { | ||
isBookmarked.value = false | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<template v-if="bookmarksStore.storeState === StoreState.Error"> | ||
<v-list-item class="text-caption"> Bookmarks available after login </v-list-item> | ||
</template> | ||
<template v-else class="mb-2"> | ||
<v-list-item | ||
:prepend-icon="isBookmarked ? 'mdi-bookmark' : 'mdi-bookmark-outline'" | ||
@click="toggleBookmark()" | ||
> | ||
Bookmark | ||
</v-list-item> | ||
</template> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.