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",
|
||||
"feather-icons": "^4.28.0",
|
||||
"frappe-ui": "^0.1.56",
|
||||
"lucide-vue-next": "^0.309.0",
|
||||
"lucide-vue-next": "^0.383.0",
|
||||
"markdown-it": "^14.0.0",
|
||||
"pinia": "^2.0.33",
|
||||
"socket.io-client": "^4.7.2",
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
:class="isSidebarCollapsed ? 'items-center' : ''"
|
||||
>
|
||||
<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
|
||||
v-for="link in sidebarLinks"
|
||||
:link="link"
|
||||
@@ -16,6 +16,38 @@
|
||||
class="mx-2 my-0.5"
|
||||
/>
|
||||
</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>
|
||||
<SidebarLink
|
||||
:link="{
|
||||
@@ -35,6 +67,11 @@
|
||||
</template>
|
||||
</SidebarLink>
|
||||
</div>
|
||||
<PageModal
|
||||
v-model="showPageModal"
|
||||
v-model:reloadSidebar="sidebarSettings"
|
||||
:page="pageToEdit"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -42,20 +79,28 @@ import UserDropdown from '@/components/UserDropdown.vue'
|
||||
import CollapseSidebar from '@/components/Icons/CollapseSidebar.vue'
|
||||
import SidebarLink from '@/components/SidebarLink.vue'
|
||||
import { useStorage } from '@vueuse/core'
|
||||
import { ref, onMounted, inject, computed } from 'vue'
|
||||
import { ref, onMounted, inject, watch } from 'vue'
|
||||
import { getSidebarLinks } from '../utils'
|
||||
import { usersStore } from '@/stores/user'
|
||||
import { sessionStore } from '@/stores/session'
|
||||
import { Bell } from 'lucide-vue-next'
|
||||
import { createResource } from 'frappe-ui'
|
||||
import { Plus } from 'lucide-vue-next'
|
||||
import { createResource, Button } from 'frappe-ui'
|
||||
import PageModal from '@/components/Modals/PageModal.vue'
|
||||
|
||||
const { user } = sessionStore()
|
||||
const { userResource } = usersStore()
|
||||
const socket = inject('$socket')
|
||||
const unreadCount = ref(0)
|
||||
const sidebarLinks = ref(getSidebarLinks())
|
||||
const showPageModal = ref(false)
|
||||
const isModerator = ref(false)
|
||||
const pageToEdit = ref(null)
|
||||
|
||||
onMounted(() => {
|
||||
socket.on('publish_lms_notifications', (data) => {
|
||||
unreadNotifications.reload()
|
||||
})
|
||||
addNotifications()
|
||||
})
|
||||
|
||||
const unreadNotifications = createResource({
|
||||
@@ -72,27 +117,75 @@ const unreadNotifications = createResource({
|
||||
},
|
||||
onSuccess(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 links = getSidebarLinks()
|
||||
const addNotifications = () => {
|
||||
if (user) {
|
||||
links.push({
|
||||
sidebarLinks.value.push({
|
||||
label: 'Notifications',
|
||||
icon: Bell,
|
||||
icon: 'Bell',
|
||||
to: 'Notifications',
|
||||
activeFor: ['Notifications'],
|
||||
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 = () => {
|
||||
return useStorage('sidebar_is_collapsed', false)
|
||||
}
|
||||
|
||||
watch(userResource, () => {
|
||||
if (userResource.data) {
|
||||
isModerator.value = userResource.data.is_moderator
|
||||
}
|
||||
})
|
||||
|
||||
let isSidebarCollapsed = ref(getSidebarFromStorage())
|
||||
</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"
|
||||
>
|
||||
<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'"
|
||||
>
|
||||
<Tooltip :text="link.label" placement="right">
|
||||
<slot name="icon">
|
||||
<span class="grid h-5 w-6 flex-shrink-0 place-items-center">
|
||||
<component
|
||||
:is="link.icon"
|
||||
class="h-5 w-5 stroke-1.5 text-gray-800"
|
||||
:is="icons[link.icon]"
|
||||
class="h-4 w-4 stroke-1.5 text-gray-800"
|
||||
/>
|
||||
</span>
|
||||
</slot>
|
||||
@@ -32,16 +32,32 @@
|
||||
<span v-if="link.count" class="!ml-auto block text-xs text-gray-600">
|
||||
{{ link.count }}
|
||||
</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>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { Tooltip } from 'frappe-ui'
|
||||
import { Tooltip, Button } from 'frappe-ui'
|
||||
import { computed } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import * as icons from 'lucide-vue-next'
|
||||
|
||||
const router = useRouter()
|
||||
const emit = defineEmits(['openModal', 'deletePage'])
|
||||
|
||||
const props = defineProps({
|
||||
link: {
|
||||
@@ -52,13 +68,29 @@ const props = defineProps({
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
showControls: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
})
|
||||
|
||||
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)
|
||||
})
|
||||
|
||||
const openModal = (link) => {
|
||||
emit('openModal', link)
|
||||
}
|
||||
|
||||
const deletePage = (link) => {
|
||||
emit('deletePage', link)
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
import { toast } from 'frappe-ui'
|
||||
import { useTimeAgo } from '@vueuse/core'
|
||||
import {
|
||||
BookOpen,
|
||||
Users,
|
||||
TrendingUp,
|
||||
Briefcase,
|
||||
GraduationCap,
|
||||
Bell,
|
||||
} from 'lucide-vue-next'
|
||||
import { Quiz } from '@/utils/quiz'
|
||||
import { Upload } from '@/utils/upload'
|
||||
import Header from '@editorjs/header'
|
||||
@@ -331,31 +323,31 @@ export function getSidebarLinks() {
|
||||
return [
|
||||
{
|
||||
label: 'Courses',
|
||||
icon: BookOpen,
|
||||
icon: 'BookOpen',
|
||||
to: 'Courses',
|
||||
activeFor: ['Courses', 'CourseDetail', 'Lesson'],
|
||||
},
|
||||
{
|
||||
label: 'Batches',
|
||||
icon: Users,
|
||||
icon: 'Users',
|
||||
to: 'Batches',
|
||||
activeFor: ['Batches', 'BatchDetail', 'Batch'],
|
||||
},
|
||||
{
|
||||
label: 'Certified Participants',
|
||||
icon: GraduationCap,
|
||||
icon: 'GraduationCap',
|
||||
to: 'CertifiedParticipants',
|
||||
activeFor: ['CertifiedParticipants'],
|
||||
},
|
||||
{
|
||||
label: 'Jobs',
|
||||
icon: Briefcase,
|
||||
icon: 'Briefcase',
|
||||
to: 'Jobs',
|
||||
activeFor: ['Jobs', 'JobDetail'],
|
||||
},
|
||||
{
|
||||
label: 'Statistics',
|
||||
icon: TrendingUp,
|
||||
icon: 'TrendingUp',
|
||||
to: '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:
|
||||
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",
|
||||
"cookie_policy",
|
||||
"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_section",
|
||||
"mentor_request_creation",
|
||||
@@ -349,18 +360,78 @@
|
||||
"default": "0",
|
||||
"fieldname": "show_day_view",
|
||||
"fieldtype": "Check",
|
||||
"label": "Show Day View in Timetable"
|
||||
"label": "Show day view in timetable"
|
||||
},
|
||||
{
|
||||
"fieldname": "unsplash_access_key",
|
||||
"fieldtype": "Data",
|
||||
"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,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2024-04-16 12:18:14.670978",
|
||||
"modified": "2024-05-31 20:17:07.362088",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"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):
|
||||
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_title = frappe.db.get_value("LMS Course", course, "title")
|
||||
instructors = frappe.db.get_all(
|
||||
"Course Instructor", {"parent": course}, pluck="instructor"
|
||||
)
|
||||
users.append(topic.owner)
|
||||
|
||||
if doc.owner != topic.owner:
|
||||
users.append(topic.owner)
|
||||
|
||||
users += instructors
|
||||
subject = _("New reply on the topic {0} in course {1}").format(
|
||||
topic.title, course_title
|
||||
@@ -689,7 +692,7 @@ def notify_mentions_on_portal(doc, topic):
|
||||
|
||||
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")
|
||||
subject = _("{0} mentioned you in a comment in {1}").format(
|
||||
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.set_published_on
|
||||
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:image" content="{{ meta.image }}" />
|
||||
<meta name="twitter:description" content="{{ meta.description }}" />
|
||||
<script type="module" crossorigin src="/assets/lms/frontend/assets/index-BCIMZEe3.js"></script>
|
||||
<link rel="modulepreload" crossorigin href="/assets/lms/frontend/assets/frappe-ui-D-bJ8Xgf.js">
|
||||
<link rel="stylesheet" crossorigin href="/assets/lms/frontend/assets/frappe-ui-B1gEXx4C.css">
|
||||
<link rel="stylesheet" crossorigin href="/assets/lms/frontend/assets/index-B_uDyhcC.css">
|
||||
<script type="module" crossorigin src="/assets/lms/frontend/assets/index-Cn4HoVlw.js"></script>
|
||||
<link rel="modulepreload" crossorigin href="/assets/lms/frontend/assets/frappe-ui-C28JHUMc.js">
|
||||
<link rel="stylesheet" crossorigin href="/assets/lms/frontend/assets/frappe-ui-DzKBfka9.css">
|
||||
<link rel="stylesheet" crossorigin href="/assets/lms/frontend/assets/index-BUt7GESC.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
|
||||
Reference in New Issue
Block a user