fix: sidebar improvements
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
placeholder="Search"
|
||||
class="w-full border-none bg-transparent py-3 !pl-2 pr-4.5 text-base text-ink-gray-7 placeholder-ink-gray-4 focus:ring-0"
|
||||
@input="onInput"
|
||||
@keydown="onKeyDown"
|
||||
v-model="query"
|
||||
autocomplete="off"
|
||||
/>
|
||||
@@ -108,7 +107,7 @@ const onInput = () => {
|
||||
|
||||
const generateSearchResults = () => {
|
||||
search.data?.forEach((type: any) => {
|
||||
let result = {}
|
||||
let result: { title: string; items: any[] } = { title: '', items: [] }
|
||||
result.title = type.title
|
||||
type.items.forEach((item: any) => {
|
||||
let paramName = item.doctype === 'LMS Course' ? 'courseName' : 'batchName'
|
||||
@@ -126,7 +125,10 @@ const generateSearchResults = () => {
|
||||
}
|
||||
|
||||
const appendSearchPage = () => {
|
||||
let searchPage = {}
|
||||
let searchPage: { title: string; items: Array<any> } = {
|
||||
title: '',
|
||||
items: [],
|
||||
}
|
||||
searchPage.title = __('Jump to')
|
||||
searchPage.items = [
|
||||
{
|
||||
@@ -212,7 +214,11 @@ const shortcutForEnter = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const navigateTo = (route: string) => {
|
||||
const navigateTo = (route: {
|
||||
name: string
|
||||
params?: Record<string, any>
|
||||
query?: Record<string, any>
|
||||
}) => {
|
||||
show.value = false
|
||||
query.value = ''
|
||||
router.replace({ name: route.name, params: route.params, query: route.query })
|
||||
|
||||
@@ -250,8 +250,7 @@ const showPageModal = ref(false)
|
||||
const isModerator = ref(false)
|
||||
const isInstructor = ref(false)
|
||||
const pageToEdit = ref(null)
|
||||
const { settings, sidebarSettings, activeTab, isSettingsOpen, programs } =
|
||||
useSettings()
|
||||
const { sidebarSettings, activeTab, isSettingsOpen, programs } = useSettings()
|
||||
const settingsStore = useSettings()
|
||||
const showOnboarding = ref(false)
|
||||
const showIntermediateModal = ref(false)
|
||||
@@ -286,9 +285,6 @@ const setSidebarLinks = () => {
|
||||
(item) => item.label.toLowerCase().split(' ').join('_') !== key
|
||||
)
|
||||
})
|
||||
/* sidebarLinks.value = sidebarLinks.value?.items.filter(
|
||||
(link) => link.label.toLowerCase().split(' ').join('_') !== key
|
||||
) */
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -327,32 +323,18 @@ const unreadNotifications = createResource({
|
||||
},
|
||||
onSuccess(data) {
|
||||
unreadCount.value = data
|
||||
/* sidebarLinks.value = sidebarLinks.value.map((link) => {
|
||||
if (link.label === 'Notifications') {
|
||||
link.count = data
|
||||
}
|
||||
return link
|
||||
}) */
|
||||
updateUnreadCount()
|
||||
},
|
||||
auto: user ? true : false,
|
||||
})
|
||||
|
||||
const addPrograms = async () => {
|
||||
const programsLinkExists = sidebarLinks.value.some(
|
||||
(link) => link.label === 'Programs'
|
||||
)
|
||||
if (programsLinkExists) return
|
||||
|
||||
let canAddProgram = await checkIfCanAddProgram()
|
||||
if (!canAddProgram) return
|
||||
let activeFor = ['Programs', 'ProgramDetail']
|
||||
let index = 2
|
||||
|
||||
sidebarLinks.value.splice(index, 0, {
|
||||
label: 'Programs',
|
||||
icon: 'Route',
|
||||
to: 'Programs',
|
||||
activeFor: activeFor,
|
||||
const updateUnreadCount = () => {
|
||||
sidebarLinks.value?.forEach((link) => {
|
||||
link.items.forEach((item) => {
|
||||
if (item.label === 'Notifications') {
|
||||
item.count = unreadCount.value || 0
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -602,15 +584,14 @@ const setUpOnboarding = () => {
|
||||
|
||||
watch(userResource, async () => {
|
||||
await userResource.promise
|
||||
sidebarLinks.value = getSidebarLinks()
|
||||
setSidebarLinks()
|
||||
if (userResource.data) {
|
||||
isModerator.value = userResource.data.is_moderator
|
||||
isInstructor.value = userResource.data.is_instructor
|
||||
await programs.promise
|
||||
sidebarLinks.value = getSidebarLinks()
|
||||
await programs.reload()
|
||||
setUpOnboarding()
|
||||
}
|
||||
sidebarLinks.value = getSidebarLinks()
|
||||
setSidebarLinks()
|
||||
})
|
||||
|
||||
const redirectToWebsite = () => {
|
||||
|
||||
@@ -567,7 +567,6 @@ const checkIfCanAddProgram = () => {
|
||||
if (userResource?.data?.is_moderator || userResource?.data?.is_instructor) {
|
||||
return true
|
||||
}
|
||||
console.log('programs.data', programs.data)
|
||||
return (
|
||||
programs.data?.enrolled.length > 0 ||
|
||||
programs.data?.published.length > 0
|
||||
|
||||
Reference in New Issue
Block a user