Added Pinning to Standard Entity
This commit is contained in:
@@ -45,6 +45,7 @@ const router = useRouter()
|
||||
const route = useRoute()
|
||||
const dataStore = useDataStore()
|
||||
const modal = useModal()
|
||||
const auth = useAuthStore()
|
||||
|
||||
const dataType = dataStore.dataTypes[type]
|
||||
|
||||
@@ -97,6 +98,43 @@ const onTabChange = (index) => {
|
||||
router.push(`${router.currentRoute.value.path}?tabIndex=${index}`)
|
||||
}
|
||||
|
||||
const changePinned = async () => {
|
||||
let newPins = []
|
||||
|
||||
if(auth.profile.pinned_on_navigation.find(i => i.datatype === type && i.id === props.item.id)){
|
||||
//Remove Pin
|
||||
|
||||
newPins = auth.profile.pinned_on_navigation.filter(i => !(i.datatype === type && i.id === props.item.id))
|
||||
} else {
|
||||
//Add Pin
|
||||
|
||||
newPins = [
|
||||
...auth.profile.pinned_on_navigation,
|
||||
{
|
||||
id: props.item.id,
|
||||
icon: "i-heroicons-document",
|
||||
type: "standardEntity",
|
||||
datatype: type,
|
||||
label: props.item[dataType.templateColumns.find(i => i.title).key]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
const res = await useNuxtApp().$api(`/api/user/${auth.user.id}/profile`,{
|
||||
method: "PUT",
|
||||
body: {
|
||||
data: {
|
||||
pinned_on_navigation: newPins
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
await auth.fetchMe()
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -147,6 +185,13 @@ const onTabChange = (index) => {
|
||||
>{{item ? `${dataType.labelSingle}${props.item[dataType.templateColumns.find(i => i.title).key] ? ': ' + props.item[dataType.templateColumns.find(i => i.title).key] : ''}`: '' }}</h1>
|
||||
</template>
|
||||
<template #right>
|
||||
<UButton
|
||||
v-if="auth.profile"
|
||||
:variant="auth.profile?.pinned_on_navigation.find(i => i.datatype === type && i.id === props.item.id) ? 'solid' : 'outline'"
|
||||
icon="i-heroicons-star"
|
||||
color="yellow"
|
||||
@click="changePinned"
|
||||
></UButton>
|
||||
<UButton
|
||||
@click="router.push(`/standardEntity/${type}/edit/${item.id}`)"
|
||||
>
|
||||
|
||||
@@ -16,6 +16,13 @@ const links = computed(() => {
|
||||
target: "_blank",
|
||||
pinned: true
|
||||
}
|
||||
}else if(pin.type === "standardEntity") {
|
||||
return {
|
||||
label: pin.label,
|
||||
to: `/standardEntity/${pin.datatype}/show/${pin.id}`,
|
||||
icon: pin.icon,
|
||||
pinned: true
|
||||
}
|
||||
}
|
||||
}),
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export default defineNuxtPlugin(() => {
|
||||
const api = $fetch.create({
|
||||
baseURL: "https://backend.fedeo.io",
|
||||
baseURL: "http://localhost:3100" /*"https://backend.fedeo.io"*/,
|
||||
credentials: "include",
|
||||
onRequest({ options }) {
|
||||
// Token aus Cookie holen
|
||||
|
||||
Reference in New Issue
Block a user