fix: show pinned views in sidebar
This commit is contained in:
parent
e0b3fbb5a0
commit
28812b2d8c
@ -15,6 +15,27 @@
|
|||||||
class="mx-2 my-0.5"
|
class="mx-2 my-0.5"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="getPinnedViews().length"
|
||||||
|
class="mt-4 flex flex-col overflow-y-auto"
|
||||||
|
>
|
||||||
|
<div class="h-7 px-3 text-base text-gray-600">Pinned Views</div>
|
||||||
|
<SidebarLink
|
||||||
|
v-for="pinnedView in getPinnedViews()"
|
||||||
|
:icon="
|
||||||
|
h(getIcon(pinnedView.route_name), {
|
||||||
|
class: 'h-4.5 w-4.5 text-gray-700',
|
||||||
|
})
|
||||||
|
"
|
||||||
|
:label="pinnedView.label"
|
||||||
|
:to="{
|
||||||
|
name: pinnedView.route_name,
|
||||||
|
query: { view: pinnedView.name },
|
||||||
|
}"
|
||||||
|
:isCollapsed="isSidebarCollapsed"
|
||||||
|
class="mx-2 my-0.5"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<SidebarLink
|
<SidebarLink
|
||||||
:label="isSidebarCollapsed ? 'Expand' : 'Collapse'"
|
:label="isSidebarCollapsed ? 'Expand' : 'Collapse'"
|
||||||
@ -35,6 +56,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import PinIcon from '@/components/Icons/PinIcon.vue'
|
||||||
import UserDropdown from '@/components/UserDropdown.vue'
|
import UserDropdown from '@/components/UserDropdown.vue'
|
||||||
import LeadsIcon from '@/components/Icons/LeadsIcon.vue'
|
import LeadsIcon from '@/components/Icons/LeadsIcon.vue'
|
||||||
import DealsIcon from '@/components/Icons/DealsIcon.vue'
|
import DealsIcon from '@/components/Icons/DealsIcon.vue'
|
||||||
@ -44,7 +66,11 @@ import NoteIcon from '@/components/Icons/NoteIcon.vue'
|
|||||||
import PhoneIcon from '@/components/Icons/PhoneIcon.vue'
|
import PhoneIcon from '@/components/Icons/PhoneIcon.vue'
|
||||||
import CollapseSidebar from '@/components/Icons/CollapseSidebar.vue'
|
import CollapseSidebar from '@/components/Icons/CollapseSidebar.vue'
|
||||||
import SidebarLink from '@/components/SidebarLink.vue'
|
import SidebarLink from '@/components/SidebarLink.vue'
|
||||||
|
import { viewsStore } from '@/stores/views'
|
||||||
import { useStorage } from '@vueuse/core'
|
import { useStorage } from '@vueuse/core'
|
||||||
|
import { h } from 'vue'
|
||||||
|
|
||||||
|
const { getPinnedViews } = viewsStore()
|
||||||
|
|
||||||
const links = [
|
const links = [
|
||||||
{
|
{
|
||||||
@ -79,5 +105,24 @@ const links = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
function getIcon(routeName) {
|
||||||
|
switch (routeName) {
|
||||||
|
case 'Leads':
|
||||||
|
return LeadsIcon
|
||||||
|
case 'Deals':
|
||||||
|
return DealsIcon
|
||||||
|
case 'Contacts':
|
||||||
|
return ContactsIcon
|
||||||
|
case 'Organizations':
|
||||||
|
return OrganizationsIcon
|
||||||
|
case 'Notes':
|
||||||
|
return NoteIcon
|
||||||
|
case 'Call Logs':
|
||||||
|
return PhoneIcon
|
||||||
|
default:
|
||||||
|
return PinIcon
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const isSidebarCollapsed = useStorage('sidebar_is_collapsed', false)
|
const isSidebarCollapsed = useStorage('sidebar_is_collapsed', false)
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -89,7 +89,7 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const { $dialog } = globalStore()
|
const { $dialog } = globalStore()
|
||||||
const { getView } = viewsStore()
|
const { reload: reloadView, getView } = viewsStore()
|
||||||
|
|
||||||
const list = defineModel()
|
const list = defineModel()
|
||||||
|
|
||||||
@ -132,6 +132,7 @@ function getParams() {
|
|||||||
order_by: _view.order_by,
|
order_by: _view.order_by,
|
||||||
columns: _view.columns,
|
columns: _view.columns,
|
||||||
rows: _view.rows,
|
rows: _view.rows,
|
||||||
|
route_name: _view.route_name,
|
||||||
default_columns: _view.row,
|
default_columns: _view.row,
|
||||||
pinned: _view.pinned,
|
pinned: _view.pinned,
|
||||||
}
|
}
|
||||||
@ -143,6 +144,7 @@ function getParams() {
|
|||||||
order_by: 'modified desc',
|
order_by: 'modified desc',
|
||||||
columns: '',
|
columns: '',
|
||||||
rows: '',
|
rows: '',
|
||||||
|
route_name: '',
|
||||||
default_columns: true,
|
default_columns: true,
|
||||||
pinned: false,
|
pinned: false,
|
||||||
}
|
}
|
||||||
@ -302,6 +304,7 @@ const viewActions = computed(() => {
|
|||||||
value: !view.value.pinned,
|
value: !view.value.pinned,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
view.value.pinned = !view.value.pinned
|
view.value.pinned = !view.value.pinned
|
||||||
|
reloadView()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -332,6 +335,7 @@ const viewActions = computed(() => {
|
|||||||
}
|
}
|
||||||
).then(() => {
|
).then(() => {
|
||||||
router.push({ name: route.name })
|
router.push({ name: route.name })
|
||||||
|
reloadView()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -357,6 +361,7 @@ function saveView() {
|
|||||||
order_by: defaultParams.value.order_by,
|
order_by: defaultParams.value.order_by,
|
||||||
columns: defaultParams.value.columns,
|
columns: defaultParams.value.columns,
|
||||||
rows: defaultParams.value.rows,
|
rows: defaultParams.value.rows,
|
||||||
|
route_name: route.name,
|
||||||
default_columns: view.value.default_columns,
|
default_columns: view.value.default_columns,
|
||||||
}
|
}
|
||||||
showViewModal.value = true
|
showViewModal.value = true
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { createListResource } from 'frappe-ui'
|
import { createListResource } from 'frappe-ui'
|
||||||
import { reactive } from 'vue'
|
import { reactive, ref } from 'vue'
|
||||||
|
|
||||||
export const viewsStore = defineStore('crm-views', () => {
|
export const viewsStore = defineStore('crm-views', () => {
|
||||||
let viewsByName = reactive({})
|
let viewsByName = reactive({})
|
||||||
|
let pinnedViews = ref([])
|
||||||
|
|
||||||
const views = createListResource({
|
const views = createListResource({
|
||||||
doctype: 'CRM View Settings',
|
doctype: 'CRM View Settings',
|
||||||
@ -12,8 +13,12 @@ export const viewsStore = defineStore('crm-views', () => {
|
|||||||
initialData: [],
|
initialData: [],
|
||||||
auto: true,
|
auto: true,
|
||||||
transform(views) {
|
transform(views) {
|
||||||
|
pinnedViews.value = []
|
||||||
for (let view of views) {
|
for (let view of views) {
|
||||||
viewsByName[view.name] = view
|
viewsByName[view.name] = view
|
||||||
|
if (view.pinned) {
|
||||||
|
pinnedViews.value?.push(view)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return views
|
return views
|
||||||
},
|
},
|
||||||
@ -27,8 +32,19 @@ export const viewsStore = defineStore('crm-views', () => {
|
|||||||
return viewsByName[view]
|
return viewsByName[view]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPinnedViews() {
|
||||||
|
if (!pinnedViews.value?.length) return []
|
||||||
|
return pinnedViews.value
|
||||||
|
}
|
||||||
|
|
||||||
|
function reload() {
|
||||||
|
views.reload()
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
views,
|
views,
|
||||||
|
getPinnedViews,
|
||||||
|
reload,
|
||||||
getView,
|
getView,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user