2022-08-11 21:56:30 +03:00
|
|
|
import { mapState } from 'vuex'
|
2023-03-17 22:24:22 +03:00
|
|
|
import { routeTo } from 'src/components/navigation/navigation.js'
|
2022-08-31 00:48:38 +03:00
|
|
|
import OptionalRouterLink from 'src/components/optional_router_link/optional_router_link.vue'
|
2022-08-11 21:56:30 +03:00
|
|
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
|
|
|
|
import { faThumbtack } from '@fortawesome/free-solid-svg-icons'
|
2025-03-23 20:03:25 +02:00
|
|
|
import { mapStores, mapState as mapPiniaState } from 'pinia'
|
|
|
|
|
|
2025-02-03 13:02:14 +02:00
|
|
|
import { useAnnouncementsStore } from 'src/stores/announcements'
|
2025-03-23 20:03:25 +02:00
|
|
|
import { useServerSideStorageStore } from 'src/stores/serverSideStorage'
|
2022-08-11 21:56:30 +03:00
|
|
|
|
|
|
|
|
library.add(faThumbtack)
|
|
|
|
|
|
|
|
|
|
const NavigationEntry = {
|
|
|
|
|
props: ['item', 'showPin'],
|
2022-08-31 00:48:38 +03:00
|
|
|
components: {
|
|
|
|
|
OptionalRouterLink
|
|
|
|
|
},
|
2022-08-11 21:56:30 +03:00
|
|
|
methods: {
|
|
|
|
|
isPinned (value) {
|
|
|
|
|
return this.pinnedItems.has(value)
|
|
|
|
|
},
|
|
|
|
|
togglePin (value) {
|
|
|
|
|
if (this.isPinned(value)) {
|
2025-03-23 20:03:25 +02:00
|
|
|
useServerSideStorageStore().removeCollectionPreference({ path: 'collections.pinnedNavItems', value })
|
2022-08-11 21:56:30 +03:00
|
|
|
} else {
|
2025-03-23 20:03:25 +02:00
|
|
|
useServerSideStorageStore().addCollectionPreference({ path: 'collections.pinnedNavItems', value })
|
2022-08-11 21:56:30 +03:00
|
|
|
}
|
2025-03-23 20:03:25 +02:00
|
|
|
useServerSideStorageStore().pushServerSideStorage()
|
2022-08-11 21:56:30 +03:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
2022-08-23 15:36:54 +03:00
|
|
|
routeTo () {
|
2023-03-17 22:24:22 +03:00
|
|
|
return routeTo(this.item, this.currentUser)
|
2022-08-23 15:36:54 +03:00
|
|
|
},
|
2022-08-11 21:56:30 +03:00
|
|
|
getters () {
|
|
|
|
|
return this.$store.getters
|
|
|
|
|
},
|
2023-04-06 16:32:21 -06:00
|
|
|
...mapStores(useAnnouncementsStore),
|
2022-08-11 21:56:30 +03:00
|
|
|
...mapState({
|
2025-03-23 20:03:25 +02:00
|
|
|
currentUser: state => state.users.currentUser
|
|
|
|
|
}),
|
|
|
|
|
...mapPiniaState(useServerSideStorageStore, {
|
|
|
|
|
pinnedItems: store => new Set(store.prefsStorage.collections.pinnedNavItems)
|
|
|
|
|
}),
|
2022-08-11 21:56:30 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default NavigationEntry
|