Merge pull request #849 from pateljannat/sidebar-edit
feat: configure sidebar items
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
"dayjs": "^1.11.6",
|
"dayjs": "^1.11.6",
|
||||||
"feather-icons": "^4.28.0",
|
"feather-icons": "^4.28.0",
|
||||||
"frappe-ui": "^0.1.56",
|
"frappe-ui": "^0.1.56",
|
||||||
"lucide-vue-next": "^0.309.0",
|
"lucide-vue-next": "^0.383.0",
|
||||||
"markdown-it": "^14.0.0",
|
"markdown-it": "^14.0.0",
|
||||||
"pinia": "^2.0.33",
|
"pinia": "^2.0.33",
|
||||||
"socket.io-client": "^4.7.2",
|
"socket.io-client": "^4.7.2",
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
:class="isSidebarCollapsed ? 'items-center' : ''"
|
:class="isSidebarCollapsed ? 'items-center' : ''"
|
||||||
>
|
>
|
||||||
<UserDropdown class="p-2" :isCollapsed="isSidebarCollapsed" />
|
<UserDropdown class="p-2" :isCollapsed="isSidebarCollapsed" />
|
||||||
<div class="flex flex-col overflow-y-auto">
|
<div class="flex flex-col overflow-y-auto" v-if="sidebarSettings.data">
|
||||||
<SidebarLink
|
<SidebarLink
|
||||||
v-for="link in sidebarLinks"
|
v-for="link in sidebarLinks"
|
||||||
:link="link"
|
:link="link"
|
||||||
@@ -16,6 +16,38 @@
|
|||||||
class="mx-2 my-0.5"
|
class="mx-2 my-0.5"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="sidebarSettings.data?.web_pages?.length || isModerator"
|
||||||
|
class="mt-4 pt-1 border-t border-gray-200"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-if="isModerator"
|
||||||
|
class="flex items-center justify-between pl-4 pr-2"
|
||||||
|
>
|
||||||
|
<span class="text-sm font-medium text-gray-600">
|
||||||
|
{{ __('Web Pages') }}
|
||||||
|
</span>
|
||||||
|
<Button variant="ghost" @click="openPageModal()">
|
||||||
|
<template #icon>
|
||||||
|
<Plus class="h-4 w-4 text-gray-700 stroke-1.5" />
|
||||||
|
</template>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="sidebarSettings.data?.web_pages?.length"
|
||||||
|
class="flex flex-col overflow-y-auto"
|
||||||
|
>
|
||||||
|
<SidebarLink
|
||||||
|
v-for="link in sidebarSettings.data.web_pages"
|
||||||
|
:link="link"
|
||||||
|
:isCollapsed="isSidebarCollapsed"
|
||||||
|
class="mx-2 my-0.5"
|
||||||
|
:showControls="isModerator ? true : false"
|
||||||
|
@openModal="openPageModal"
|
||||||
|
@deletePage="deletePage"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<SidebarLink
|
<SidebarLink
|
||||||
:link="{
|
:link="{
|
||||||
@@ -35,6 +67,11 @@
|
|||||||
</template>
|
</template>
|
||||||
</SidebarLink>
|
</SidebarLink>
|
||||||
</div>
|
</div>
|
||||||
|
<PageModal
|
||||||
|
v-model="showPageModal"
|
||||||
|
v-model:reloadSidebar="sidebarSettings"
|
||||||
|
:page="pageToEdit"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
@@ -42,20 +79,28 @@ import UserDropdown from '@/components/UserDropdown.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 { useStorage } from '@vueuse/core'
|
import { useStorage } from '@vueuse/core'
|
||||||
import { ref, onMounted, inject, computed } from 'vue'
|
import { ref, onMounted, inject, watch } from 'vue'
|
||||||
import { getSidebarLinks } from '../utils'
|
import { getSidebarLinks } from '../utils'
|
||||||
|
import { usersStore } from '@/stores/user'
|
||||||
import { sessionStore } from '@/stores/session'
|
import { sessionStore } from '@/stores/session'
|
||||||
import { Bell } from 'lucide-vue-next'
|
import { Plus } from 'lucide-vue-next'
|
||||||
import { createResource } from 'frappe-ui'
|
import { createResource, Button } from 'frappe-ui'
|
||||||
|
import PageModal from '@/components/Modals/PageModal.vue'
|
||||||
|
|
||||||
const { user } = sessionStore()
|
const { user } = sessionStore()
|
||||||
|
const { userResource } = usersStore()
|
||||||
const socket = inject('$socket')
|
const socket = inject('$socket')
|
||||||
const unreadCount = ref(0)
|
const unreadCount = ref(0)
|
||||||
|
const sidebarLinks = ref(getSidebarLinks())
|
||||||
|
const showPageModal = ref(false)
|
||||||
|
const isModerator = ref(false)
|
||||||
|
const pageToEdit = ref(null)
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
socket.on('publish_lms_notifications', (data) => {
|
socket.on('publish_lms_notifications', (data) => {
|
||||||
unreadNotifications.reload()
|
unreadNotifications.reload()
|
||||||
})
|
})
|
||||||
|
addNotifications()
|
||||||
})
|
})
|
||||||
|
|
||||||
const unreadNotifications = createResource({
|
const unreadNotifications = createResource({
|
||||||
@@ -72,27 +117,75 @@ const unreadNotifications = createResource({
|
|||||||
},
|
},
|
||||||
onSuccess(data) {
|
onSuccess(data) {
|
||||||
unreadCount.value = data
|
unreadCount.value = data
|
||||||
|
sidebarLinks.value = sidebarLinks.value.map((link) => {
|
||||||
|
if (link.label === 'Notifications') {
|
||||||
|
link.count = data
|
||||||
|
}
|
||||||
|
return link
|
||||||
|
})
|
||||||
},
|
},
|
||||||
auto: true,
|
auto: user ? true : false,
|
||||||
})
|
})
|
||||||
|
|
||||||
const sidebarLinks = computed(() => {
|
const addNotifications = () => {
|
||||||
const links = getSidebarLinks()
|
|
||||||
if (user) {
|
if (user) {
|
||||||
links.push({
|
sidebarLinks.value.push({
|
||||||
label: 'Notifications',
|
label: 'Notifications',
|
||||||
icon: Bell,
|
icon: 'Bell',
|
||||||
to: 'Notifications',
|
to: 'Notifications',
|
||||||
activeFor: ['Notifications'],
|
activeFor: ['Notifications'],
|
||||||
count: unreadCount.value,
|
count: unreadCount.value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return links
|
}
|
||||||
|
|
||||||
|
const sidebarSettings = createResource({
|
||||||
|
url: 'lms.lms.api.get_sidebar_settings',
|
||||||
|
cache: 'Sidebar Settings',
|
||||||
|
auto: true,
|
||||||
|
onSuccess(data) {
|
||||||
|
Object.keys(data).forEach((key) => {
|
||||||
|
if (!parseInt(data[key])) {
|
||||||
|
sidebarLinks.value = sidebarLinks.value.filter(
|
||||||
|
(link) => link.label.toLowerCase() !== key
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const openPageModal = (link) => {
|
||||||
|
showPageModal.value = true
|
||||||
|
pageToEdit.value = link
|
||||||
|
}
|
||||||
|
|
||||||
|
const deletePage = (link) => {
|
||||||
|
createResource({
|
||||||
|
url: 'lms.lms.api.delete_sidebar_item',
|
||||||
|
makeParams(values) {
|
||||||
|
return {
|
||||||
|
webpage: link.web_page,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}).submit(
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
onSuccess() {
|
||||||
|
sidebarSettings.reload()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const getSidebarFromStorage = () => {
|
const getSidebarFromStorage = () => {
|
||||||
return useStorage('sidebar_is_collapsed', false)
|
return useStorage('sidebar_is_collapsed', false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(userResource, () => {
|
||||||
|
if (userResource.data) {
|
||||||
|
isModerator.value = userResource.data.is_moderator
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
let isSidebarCollapsed = ref(getSidebarFromStorage())
|
let isSidebarCollapsed = ref(getSidebarFromStorage())
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
119
frontend/src/components/Controls/IconPicker.vue
Normal file
119
frontend/src/components/Controls/IconPicker.vue
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
<template>
|
||||||
|
<div class="space-y-1.5">
|
||||||
|
<label class="block text-xs text-gray-600">
|
||||||
|
{{ label }}
|
||||||
|
</label>
|
||||||
|
<div class="w-full">
|
||||||
|
<Popover>
|
||||||
|
<template #target="{ togglePopover }">
|
||||||
|
<button
|
||||||
|
@click="openPopover(togglePopover)"
|
||||||
|
class="flex w-full items-center space-x-2 focus:outline-none bg-gray-100 rounded h-7 py-1.5 px-2 hover:bg-gray-200 focus:bg-white border border-gray-100 hover:border-gray-200 focus:border-gray-500"
|
||||||
|
>
|
||||||
|
<component
|
||||||
|
v-if="selectedIcon"
|
||||||
|
class="w-4 h-4 text-gray-700 stroke-1.5"
|
||||||
|
:is="icons[selectedIcon]"
|
||||||
|
/>
|
||||||
|
<component
|
||||||
|
v-else
|
||||||
|
class="w-4 h-4 text-gray-700 stroke-1.5"
|
||||||
|
:is="icons.Folder"
|
||||||
|
/>
|
||||||
|
<span v-if="selectedIcon">
|
||||||
|
{{ selectedIcon }}
|
||||||
|
</span>
|
||||||
|
<span v-else class="text-gray-600">
|
||||||
|
{{ __('Choose an icon') }}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
<template #body-main="{ close, isOpen }" class="w-full">
|
||||||
|
<div class="p-3 max-h-56 overflow-auto w-full">
|
||||||
|
<FormControl
|
||||||
|
ref="search"
|
||||||
|
v-model="iconQuery"
|
||||||
|
:placeholder="__('Search for an icon')"
|
||||||
|
autocomplete="off"
|
||||||
|
/>
|
||||||
|
<div class="grid grid-cols-10 gap-4 mt-4">
|
||||||
|
<div v-for="(iconComponent, iconName) in filteredIcons">
|
||||||
|
<component
|
||||||
|
:is="iconComponent"
|
||||||
|
class="h-4 w-4 stroke-1.5 text-gray-700 cursor-pointer"
|
||||||
|
@click="setIcon(iconName, close)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</Popover>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script setup>
|
||||||
|
import { FormControl, Popover } from 'frappe-ui'
|
||||||
|
import * as icons from 'lucide-vue-next'
|
||||||
|
import { ref, computed, onMounted, nextTick } from 'vue'
|
||||||
|
|
||||||
|
const iconQuery = ref('')
|
||||||
|
const selectedIcon = ref('')
|
||||||
|
const search = ref(null)
|
||||||
|
const emit = defineEmits(['update:modelValue', 'change'])
|
||||||
|
console.log(icons)
|
||||||
|
const iconArray = ref(
|
||||||
|
Object.keys(icons)
|
||||||
|
.sort(() => 0.5 - Math.random())
|
||||||
|
.slice(0, 100)
|
||||||
|
.reduce((result, key) => {
|
||||||
|
result[key] = icons[key]
|
||||||
|
return result
|
||||||
|
}, {})
|
||||||
|
)
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
label: {
|
||||||
|
type: String,
|
||||||
|
default: 'Icon',
|
||||||
|
},
|
||||||
|
modelValue: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
selectedIcon.value = props.modelValue
|
||||||
|
console.log(search.value)
|
||||||
|
})
|
||||||
|
|
||||||
|
const setIcon = (icon, close) => {
|
||||||
|
emit('update:modelValue', icon)
|
||||||
|
selectedIcon.value = icon
|
||||||
|
iconQuery.value = ''
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
|
||||||
|
const filteredIcons = computed(() => {
|
||||||
|
if (!iconQuery.value) {
|
||||||
|
return iconArray.value
|
||||||
|
}
|
||||||
|
|
||||||
|
return Object.keys(icons)
|
||||||
|
.filter((icon) =>
|
||||||
|
icon.toLowerCase().includes(iconQuery.value.toLowerCase())
|
||||||
|
)
|
||||||
|
.reduce((result, key) => {
|
||||||
|
result[key] = icons[key]
|
||||||
|
return result
|
||||||
|
}, {})
|
||||||
|
})
|
||||||
|
|
||||||
|
const openPopover = (togglePopover) => {
|
||||||
|
togglePopover()
|
||||||
|
nextTick(() => {
|
||||||
|
/* search.value.focus() */
|
||||||
|
console.log(search.value.children)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
90
frontend/src/components/Modals/PageModal.vue
Normal file
90
frontend/src/components/Modals/PageModal.vue
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
<template>
|
||||||
|
<Dialog
|
||||||
|
v-model="show"
|
||||||
|
class="text-base"
|
||||||
|
:options="{
|
||||||
|
title: __('Add web page to sidebar'),
|
||||||
|
size: 'lg',
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
label: 'Add',
|
||||||
|
variant: 'solid',
|
||||||
|
onClick: (close) => {
|
||||||
|
addWebPage(close)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<template #body-content>
|
||||||
|
<Link
|
||||||
|
v-model="page.webpage"
|
||||||
|
doctype="Web Page"
|
||||||
|
:label="__('Web Page')"
|
||||||
|
:filters="{
|
||||||
|
published: 1,
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
<IconPicker v-model="page.icon" :label="__('Icon')" class="mt-4" />
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
|
</template>
|
||||||
|
<script setup>
|
||||||
|
import { Dialog, createResource } from 'frappe-ui'
|
||||||
|
import Link from '@/components/Controls/Link.vue'
|
||||||
|
import { reactive, watch } from 'vue'
|
||||||
|
import IconPicker from '@/components/Controls/IconPicker.vue'
|
||||||
|
import { showToast } from '@/utils'
|
||||||
|
|
||||||
|
const sidebar = defineModel('reloadSidebar')
|
||||||
|
const show = defineModel()
|
||||||
|
const page = reactive({
|
||||||
|
icon: '',
|
||||||
|
webpage: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
page: {
|
||||||
|
type: Object,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const webPage = createResource({
|
||||||
|
url: 'lms.lms.api.update_sidebar_item',
|
||||||
|
makeParams(values) {
|
||||||
|
return {
|
||||||
|
webpage: page.webpage,
|
||||||
|
icon: page.icon,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.page,
|
||||||
|
(newPage) => {
|
||||||
|
if (newPage) {
|
||||||
|
page.icon = newPage.icon
|
||||||
|
page.webpage = newPage.web_page
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
|
|
||||||
|
const addWebPage = (close) => {
|
||||||
|
webPage.submit(
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
onSuccess() {
|
||||||
|
sidebar.value.reload()
|
||||||
|
close()
|
||||||
|
showToast('Success', 'Web page added to sidebar', 'check')
|
||||||
|
},
|
||||||
|
onError(err) {
|
||||||
|
showToast('Error', err.message[0] || err, 'x')
|
||||||
|
close()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -6,15 +6,15 @@
|
|||||||
@click="handleClick"
|
@click="handleClick"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="flex items-center w-full duration-300 ease-in-out"
|
class="flex items-center w-full duration-300 ease-in-out group"
|
||||||
:class="isCollapsed ? 'p-1' : 'px-2 py-1'"
|
:class="isCollapsed ? 'p-1' : 'px-2 py-1'"
|
||||||
>
|
>
|
||||||
<Tooltip :text="link.label" placement="right">
|
<Tooltip :text="link.label" placement="right">
|
||||||
<slot name="icon">
|
<slot name="icon">
|
||||||
<span class="grid h-5 w-6 flex-shrink-0 place-items-center">
|
<span class="grid h-5 w-6 flex-shrink-0 place-items-center">
|
||||||
<component
|
<component
|
||||||
:is="link.icon"
|
:is="icons[link.icon]"
|
||||||
class="h-5 w-5 stroke-1.5 text-gray-800"
|
class="h-4 w-4 stroke-1.5 text-gray-800"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
</slot>
|
</slot>
|
||||||
@@ -32,16 +32,32 @@
|
|||||||
<span v-if="link.count" class="!ml-auto block text-xs text-gray-600">
|
<span v-if="link.count" class="!ml-auto block text-xs text-gray-600">
|
||||||
{{ link.count }}
|
{{ link.count }}
|
||||||
</span>
|
</span>
|
||||||
|
<div
|
||||||
|
v-if="showControls"
|
||||||
|
class="flex items-center space-x-2 !ml-auto block text-xs text-gray-600 group-hover:visible invisible"
|
||||||
|
>
|
||||||
|
<component
|
||||||
|
:is="icons['Edit']"
|
||||||
|
class="h-3 w-3 stroke-1.5 text-gray-800"
|
||||||
|
@click.stop="openModal(link)"
|
||||||
|
/>
|
||||||
|
<component
|
||||||
|
:is="icons['X']"
|
||||||
|
class="h-3 w-3 stroke-1.5 text-gray-800"
|
||||||
|
@click.stop="deletePage(link)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { Tooltip } from 'frappe-ui'
|
import { Tooltip, Button } from 'frappe-ui'
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
import * as icons from 'lucide-vue-next'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const emit = defineEmits(['openModal', 'deletePage'])
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
link: {
|
link: {
|
||||||
@@ -52,13 +68,29 @@ const props = defineProps({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
showControls: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleClick() {
|
function handleClick() {
|
||||||
router.push({ name: props.link.to })
|
if (router.hasRoute(props.link.to)) {
|
||||||
|
router.push({ name: props.link.to })
|
||||||
|
} else {
|
||||||
|
window.location.href = `/${props.link.to}`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let isActive = computed(() => {
|
const isActive = computed(() => {
|
||||||
return props.link?.activeFor?.includes(router.currentRoute.value.name)
|
return props.link?.activeFor?.includes(router.currentRoute.value.name)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const openModal = (link) => {
|
||||||
|
emit('openModal', link)
|
||||||
|
}
|
||||||
|
|
||||||
|
const deletePage = (link) => {
|
||||||
|
emit('deletePage', link)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,13 +1,5 @@
|
|||||||
import { toast } from 'frappe-ui'
|
import { toast } from 'frappe-ui'
|
||||||
import { useTimeAgo } from '@vueuse/core'
|
import { useTimeAgo } from '@vueuse/core'
|
||||||
import {
|
|
||||||
BookOpen,
|
|
||||||
Users,
|
|
||||||
TrendingUp,
|
|
||||||
Briefcase,
|
|
||||||
GraduationCap,
|
|
||||||
Bell,
|
|
||||||
} from 'lucide-vue-next'
|
|
||||||
import { Quiz } from '@/utils/quiz'
|
import { Quiz } from '@/utils/quiz'
|
||||||
import { Upload } from '@/utils/upload'
|
import { Upload } from '@/utils/upload'
|
||||||
import Header from '@editorjs/header'
|
import Header from '@editorjs/header'
|
||||||
@@ -331,31 +323,31 @@ export function getSidebarLinks() {
|
|||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
label: 'Courses',
|
label: 'Courses',
|
||||||
icon: BookOpen,
|
icon: 'BookOpen',
|
||||||
to: 'Courses',
|
to: 'Courses',
|
||||||
activeFor: ['Courses', 'CourseDetail', 'Lesson'],
|
activeFor: ['Courses', 'CourseDetail', 'Lesson'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Batches',
|
label: 'Batches',
|
||||||
icon: Users,
|
icon: 'Users',
|
||||||
to: 'Batches',
|
to: 'Batches',
|
||||||
activeFor: ['Batches', 'BatchDetail', 'Batch'],
|
activeFor: ['Batches', 'BatchDetail', 'Batch'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Certified Participants',
|
label: 'Certified Participants',
|
||||||
icon: GraduationCap,
|
icon: 'GraduationCap',
|
||||||
to: 'CertifiedParticipants',
|
to: 'CertifiedParticipants',
|
||||||
activeFor: ['CertifiedParticipants'],
|
activeFor: ['CertifiedParticipants'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Jobs',
|
label: 'Jobs',
|
||||||
icon: Briefcase,
|
icon: 'Briefcase',
|
||||||
to: 'Jobs',
|
to: 'Jobs',
|
||||||
activeFor: ['Jobs', 'JobDetail'],
|
activeFor: ['Jobs', 'JobDetail'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Statistics',
|
label: 'Statistics',
|
||||||
icon: TrendingUp,
|
icon: 'TrendingUp',
|
||||||
to: 'Statistics',
|
to: 'Statistics',
|
||||||
activeFor: ['Statistics'],
|
activeFor: ['Statistics'],
|
||||||
},
|
},
|
||||||
|
|||||||
2089
frontend/yarn.lock
Normal file
2089
frontend/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
@@ -416,3 +416,64 @@ def mark_all_as_read():
|
|||||||
|
|
||||||
for notification in notifications:
|
for notification in notifications:
|
||||||
mark_as_read(notification)
|
mark_as_read(notification)
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist(allow_guest=True)
|
||||||
|
def get_sidebar_settings():
|
||||||
|
lms_settings = frappe.get_single("LMS Settings")
|
||||||
|
sidebar_items = frappe._dict()
|
||||||
|
|
||||||
|
items = [
|
||||||
|
"courses",
|
||||||
|
"batches",
|
||||||
|
"certified_participants",
|
||||||
|
"jobs",
|
||||||
|
"statistics",
|
||||||
|
"notifications",
|
||||||
|
]
|
||||||
|
for item in items:
|
||||||
|
sidebar_items[item] = lms_settings.get(item)
|
||||||
|
|
||||||
|
if len(lms_settings.sidebar_items):
|
||||||
|
web_pages = frappe.get_all(
|
||||||
|
"LMS Sidebar Item",
|
||||||
|
{"parenttype": "LMS Settings", "parentfield": "sidebar_items"},
|
||||||
|
["web_page", "route", "title as label", "icon"],
|
||||||
|
)
|
||||||
|
for page in web_pages:
|
||||||
|
page.to = page.route
|
||||||
|
|
||||||
|
sidebar_items.web_pages = web_pages
|
||||||
|
|
||||||
|
return sidebar_items
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def update_sidebar_item(webpage, icon):
|
||||||
|
filters = {
|
||||||
|
"web_page": webpage,
|
||||||
|
"parenttype": "LMS Settings",
|
||||||
|
"parentfield": "sidebar_items",
|
||||||
|
"parent": "LMS Settings",
|
||||||
|
}
|
||||||
|
|
||||||
|
if frappe.db.exists("LMS Sidebar Item", filters):
|
||||||
|
frappe.db.set_value("LMS Sidebar Item", filters, "icon", icon)
|
||||||
|
else:
|
||||||
|
doc = frappe.new_doc("LMS Sidebar Item")
|
||||||
|
doc.update(filters)
|
||||||
|
doc.icon = icon
|
||||||
|
doc.insert()
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def delete_sidebar_item(webpage):
|
||||||
|
return frappe.db.delete(
|
||||||
|
"LMS Sidebar Item",
|
||||||
|
{
|
||||||
|
"web_page": webpage,
|
||||||
|
"parenttype": "LMS Settings",
|
||||||
|
"parentfield": "sidebar_items",
|
||||||
|
"parent": "LMS Settings",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|||||||
@@ -38,6 +38,17 @@
|
|||||||
"column_break_12",
|
"column_break_12",
|
||||||
"cookie_policy",
|
"cookie_policy",
|
||||||
"cookie_policy_page",
|
"cookie_policy_page",
|
||||||
|
"sidebar_tab",
|
||||||
|
"items_in_sidebar_section",
|
||||||
|
"courses",
|
||||||
|
"batches",
|
||||||
|
"certified_participants",
|
||||||
|
"column_break_exdz",
|
||||||
|
"jobs",
|
||||||
|
"statistics",
|
||||||
|
"notifications",
|
||||||
|
"section_break_qlss",
|
||||||
|
"sidebar_items",
|
||||||
"mentor_request_tab",
|
"mentor_request_tab",
|
||||||
"mentor_request_section",
|
"mentor_request_section",
|
||||||
"mentor_request_creation",
|
"mentor_request_creation",
|
||||||
@@ -349,18 +360,78 @@
|
|||||||
"default": "0",
|
"default": "0",
|
||||||
"fieldname": "show_day_view",
|
"fieldname": "show_day_view",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Show Day View in Timetable"
|
"label": "Show day view in timetable"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "unsplash_access_key",
|
"fieldname": "unsplash_access_key",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"label": "Unsplash Access Key"
|
"label": "Unsplash Access Key"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "sidebar_tab",
|
||||||
|
"fieldtype": "Tab Break",
|
||||||
|
"label": "Sidebar"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "1",
|
||||||
|
"fieldname": "courses",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Courses"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "1",
|
||||||
|
"fieldname": "batches",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Batches"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "1",
|
||||||
|
"fieldname": "certified_participants",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Certified Participants"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "1",
|
||||||
|
"fieldname": "jobs",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Jobs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "1",
|
||||||
|
"fieldname": "statistics",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Statistics"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "1",
|
||||||
|
"fieldname": "notifications",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Notifications"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "items_in_sidebar_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Items in Sidebar"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_exdz",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_qlss",
|
||||||
|
"fieldtype": "Section Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "sidebar_items",
|
||||||
|
"fieldtype": "Table",
|
||||||
|
"label": "Sidebar Items",
|
||||||
|
"options": "LMS Sidebar Item"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-04-16 12:18:14.670978",
|
"modified": "2024-05-31 20:17:07.362088",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Settings",
|
"name": "LMS Settings",
|
||||||
|
|||||||
0
lms/lms/doctype/lms_sidebar_item/__init__.py
Normal file
0
lms/lms/doctype/lms_sidebar_item/__init__.py
Normal file
8
lms/lms/doctype/lms_sidebar_item/lms_sidebar_item.js
Normal file
8
lms/lms/doctype/lms_sidebar_item/lms_sidebar_item.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// Copyright (c) 2024, Frappe and contributors
|
||||||
|
// For license information, please see license.txt
|
||||||
|
|
||||||
|
// frappe.ui.form.on("LMS Sidebar Item", {
|
||||||
|
// refresh(frm) {
|
||||||
|
|
||||||
|
// },
|
||||||
|
// });
|
||||||
62
lms/lms/doctype/lms_sidebar_item/lms_sidebar_item.json
Normal file
62
lms/lms/doctype/lms_sidebar_item/lms_sidebar_item.json
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"allow_rename": 1,
|
||||||
|
"creation": "2024-05-29 16:44:43.778291",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"web_page",
|
||||||
|
"title",
|
||||||
|
"column_break_glmh",
|
||||||
|
"icon",
|
||||||
|
"route"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_glmh",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "icon",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Icon",
|
||||||
|
"read_only": 1,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "web_page",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Web Page",
|
||||||
|
"options": "Web Page",
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fetch_from": "web_page.route",
|
||||||
|
"fieldname": "route",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Route"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fetch_from": "web_page.title",
|
||||||
|
"fieldname": "title",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Title"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"istable": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2024-05-31 20:19:14.629097",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "LMS",
|
||||||
|
"name": "LMS Sidebar Item",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [],
|
||||||
|
"sort_field": "creation",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"states": []
|
||||||
|
}
|
||||||
9
lms/lms/doctype/lms_sidebar_item/lms_sidebar_item.py
Normal file
9
lms/lms/doctype/lms_sidebar_item/lms_sidebar_item.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Copyright (c) 2024, Frappe and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
|
||||||
|
class LMSSidebarItem(Document):
|
||||||
|
pass
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# Copyright (c) 2024, Frappe and Contributors
|
||||||
|
# See license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.tests.utils import FrappeTestCase
|
||||||
|
|
||||||
|
|
||||||
|
class TestLMSSidebarItem(FrappeTestCase):
|
||||||
|
pass
|
||||||
@@ -646,13 +646,16 @@ def handle_notifications(doc, method):
|
|||||||
|
|
||||||
def create_notification_log(doc, topic):
|
def create_notification_log(doc, topic):
|
||||||
users = []
|
users = []
|
||||||
if topic.reference_doctype == "LMS Course":
|
if topic.reference_doctype == "Course Lesson":
|
||||||
course = frappe.db.get_value("Course Lesson", topic.reference_docname, "course")
|
course = frappe.db.get_value("Course Lesson", topic.reference_docname, "course")
|
||||||
course_title = frappe.db.get_value("LMS Course", course, "title")
|
course_title = frappe.db.get_value("LMS Course", course, "title")
|
||||||
instructors = frappe.db.get_all(
|
instructors = frappe.db.get_all(
|
||||||
"Course Instructor", {"parent": course}, pluck="instructor"
|
"Course Instructor", {"parent": course}, pluck="instructor"
|
||||||
)
|
)
|
||||||
users.append(topic.owner)
|
|
||||||
|
if doc.owner != topic.owner:
|
||||||
|
users.append(topic.owner)
|
||||||
|
|
||||||
users += instructors
|
users += instructors
|
||||||
subject = _("New reply on the topic {0} in course {1}").format(
|
subject = _("New reply on the topic {0} in course {1}").format(
|
||||||
topic.title, course_title
|
topic.title, course_title
|
||||||
@@ -689,7 +692,7 @@ def notify_mentions_on_portal(doc, topic):
|
|||||||
|
|
||||||
from_user_name = get_fullname(doc.owner)
|
from_user_name = get_fullname(doc.owner)
|
||||||
|
|
||||||
if topic.reference_doctype == "LMS Course":
|
if topic.reference_doctype == "Course Lesson":
|
||||||
course = frappe.db.get_value("Course Lesson", topic.reference_docname, "course")
|
course = frappe.db.get_value("Course Lesson", topic.reference_docname, "course")
|
||||||
subject = _("{0} mentioned you in a comment in {1}").format(
|
subject = _("{0} mentioned you in a comment in {1}").format(
|
||||||
from_user_name, topic.title
|
from_user_name, topic.title
|
||||||
|
|||||||
@@ -88,4 +88,5 @@ lms.patches.v1_0.rename_evaluator_role
|
|||||||
lms.patches.v1_0.change_navbar_urls
|
lms.patches.v1_0.change_navbar_urls
|
||||||
lms.patches.v1_0.set_published_on
|
lms.patches.v1_0.set_published_on
|
||||||
lms.patches.v2_0.fix_progress_percentage
|
lms.patches.v2_0.fix_progress_percentage
|
||||||
lms.patches.v2_0.add_discussion_topic_titles
|
lms.patches.v2_0.add_discussion_topic_titles
|
||||||
|
lms.patches.v2_0.sidebar_settings
|
||||||
15
lms/patches/v2_0/sidebar_settings.py
Normal file
15
lms/patches/v2_0/sidebar_settings.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
fields = [
|
||||||
|
"courses",
|
||||||
|
"batches",
|
||||||
|
"certified_participants",
|
||||||
|
"jobs",
|
||||||
|
"statistics",
|
||||||
|
"notifications",
|
||||||
|
]
|
||||||
|
|
||||||
|
for field in fields:
|
||||||
|
frappe.db.set_single_value("LMS Settings", field, 1)
|
||||||
@@ -15,10 +15,10 @@
|
|||||||
<meta name="twitter:title" content="{{ meta.title }}" />
|
<meta name="twitter:title" content="{{ meta.title }}" />
|
||||||
<meta name="twitter:image" content="{{ meta.image }}" />
|
<meta name="twitter:image" content="{{ meta.image }}" />
|
||||||
<meta name="twitter:description" content="{{ meta.description }}" />
|
<meta name="twitter:description" content="{{ meta.description }}" />
|
||||||
<script type="module" crossorigin src="/assets/lms/frontend/assets/index-BCIMZEe3.js"></script>
|
<script type="module" crossorigin src="/assets/lms/frontend/assets/index-Cn4HoVlw.js"></script>
|
||||||
<link rel="modulepreload" crossorigin href="/assets/lms/frontend/assets/frappe-ui-D-bJ8Xgf.js">
|
<link rel="modulepreload" crossorigin href="/assets/lms/frontend/assets/frappe-ui-C28JHUMc.js">
|
||||||
<link rel="stylesheet" crossorigin href="/assets/lms/frontend/assets/frappe-ui-B1gEXx4C.css">
|
<link rel="stylesheet" crossorigin href="/assets/lms/frontend/assets/frappe-ui-DzKBfka9.css">
|
||||||
<link rel="stylesheet" crossorigin href="/assets/lms/frontend/assets/index-B_uDyhcC.css">
|
<link rel="stylesheet" crossorigin href="/assets/lms/frontend/assets/index-BUt7GESC.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
|
|||||||
Reference in New Issue
Block a user