feat: delete lessons
This commit is contained in:
@@ -40,7 +40,7 @@
|
|||||||
</DisclosureButton>
|
</DisclosureButton>
|
||||||
<DisclosurePanel>
|
<DisclosurePanel>
|
||||||
<div v-for="lesson in chapter.lessons" :key="lesson.name">
|
<div v-for="lesson in chapter.lessons" :key="lesson.name">
|
||||||
<div class="outline-lesson pl-8 py-2">
|
<div class="outline-lesson pl-8 py-2 pr-4">
|
||||||
<router-link
|
<router-link
|
||||||
:to="{
|
:to="{
|
||||||
name: allowEdit ? 'CreateLesson' : 'Lesson',
|
name: allowEdit ? 'CreateLesson' : 'Lesson',
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
},
|
},
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<div class="flex items-center text-sm leading-5">
|
<div class="flex items-center text-sm leading-5 group">
|
||||||
<MonitorPlay
|
<MonitorPlay
|
||||||
v-if="lesson.icon === 'icon-youtube'"
|
v-if="lesson.icon === 'icon-youtube'"
|
||||||
class="h-4 w-4 text-gray-900 stroke-1 mr-2"
|
class="h-4 w-4 text-gray-900 stroke-1 mr-2"
|
||||||
@@ -65,6 +65,11 @@
|
|||||||
class="h-4 w-4 text-gray-900 stroke-1 mr-2"
|
class="h-4 w-4 text-gray-900 stroke-1 mr-2"
|
||||||
/>
|
/>
|
||||||
{{ lesson.title }}
|
{{ lesson.title }}
|
||||||
|
<Trash2
|
||||||
|
v-if="allowEdit"
|
||||||
|
@click.prevent="trashLesson(lesson.name, chapter.name)"
|
||||||
|
class="h-4 w-4 stroke-1.5 text-gray-700 ml-auto invisible group-hover:visible"
|
||||||
|
/>
|
||||||
<Check
|
<Check
|
||||||
v-if="lesson.is_complete"
|
v-if="lesson.is_complete"
|
||||||
class="h-4 w-4 text-green-700 ml-2"
|
class="h-4 w-4 text-green-700 ml-2"
|
||||||
@@ -105,7 +110,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { Button, createResource } from 'frappe-ui'
|
import { Button, createResource } from 'frappe-ui'
|
||||||
import { ref, computed } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { Disclosure, DisclosureButton, DisclosurePanel } from '@headlessui/vue'
|
import { Disclosure, DisclosureButton, DisclosurePanel } from '@headlessui/vue'
|
||||||
import {
|
import {
|
||||||
ChevronRight,
|
ChevronRight,
|
||||||
@@ -113,9 +118,11 @@ import {
|
|||||||
HelpCircle,
|
HelpCircle,
|
||||||
FileText,
|
FileText,
|
||||||
Check,
|
Check,
|
||||||
|
Trash2,
|
||||||
} from 'lucide-vue-next'
|
} from 'lucide-vue-next'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import ChapterModal from '@/components/Modals/ChapterModal.vue'
|
import ChapterModal from '@/components/Modals/ChapterModal.vue'
|
||||||
|
import { showToast } from '@/utils'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const expandAll = ref(true)
|
const expandAll = ref(true)
|
||||||
@@ -155,6 +162,27 @@ const outline = createResource({
|
|||||||
auto: true,
|
auto: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const deleteLesson = createResource({
|
||||||
|
url: 'lms.lms.api.delete_lesson',
|
||||||
|
makeParams(values) {
|
||||||
|
return {
|
||||||
|
lesson: values.lesson,
|
||||||
|
chapter: values.chapter,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onSuccess() {
|
||||||
|
outline.reload()
|
||||||
|
showToast('Success', 'Lesson deleted', 'check')
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const trashLesson = (lessonName, chapterName) => {
|
||||||
|
deleteLesson.submit({
|
||||||
|
lesson: lessonName,
|
||||||
|
chapter: chapterName,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const openChapterDetail = (index) => {
|
const openChapterDetail = (index) => {
|
||||||
return index == route.params.chapterNumber || index == 1
|
return index == route.params.chapterNumber || index == 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -344,6 +344,7 @@ const courseResource = createResource({
|
|||||||
'upcoming',
|
'upcoming',
|
||||||
'disable_self_learning',
|
'disable_self_learning',
|
||||||
'paid_course',
|
'paid_course',
|
||||||
|
'featured',
|
||||||
]
|
]
|
||||||
for (let idx in checkboxes) {
|
for (let idx in checkboxes) {
|
||||||
let key = checkboxes[idx]
|
let key = checkboxes[idx]
|
||||||
|
|||||||
@@ -477,3 +477,9 @@ def delete_sidebar_item(webpage):
|
|||||||
"parent": "LMS Settings",
|
"parent": "LMS Settings",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def delete_lesson(lesson, chapter):
|
||||||
|
frappe.db.delete("Lesson Reference", {"parent": chapter, "lesson": lesson})
|
||||||
|
frappe.db.delete("Course Lesson", lesson)
|
||||||
|
|||||||
Reference in New Issue
Block a user