fix: lesson editing

This commit is contained in:
Jannat Patel
2024-03-07 10:06:32 +05:30
parent 0ce7c74778
commit 2126b4f657
9 changed files with 87 additions and 28 deletions

View File

@@ -8,12 +8,19 @@
:items="[{ label: __('All Batches'), route: { name: 'Batches' } }]"
/>
<div class="flex">
<Button variant="solid" @click="openBatchModal()">
<template #prefix>
<Plus class="h-4 w-4" />
</template>
{{ __('New Batch') }}
</Button>
<router-link
:to="{
name: 'CreateBatch',
params: { batchName: 'new' },
}"
>
<Button variant="solid">
<template #prefix>
<Plus class="h-4 w-4" />
</template>
{{ __('New Batch') }}
</Button>
</router-link>
</div>
</header>
<div v-if="batches.data" class="pb-5">
@@ -73,14 +80,12 @@
</Tabs>
</div>
</div>
<BatchCreation v-model="showBatchModal" />
</template>
<script setup>
import { createListResource, Breadcrumbs, Button, Tabs, Badge } from 'frappe-ui'
import { Plus } from 'lucide-vue-next'
import BatchCard from '@/components/BatchCard.vue'
import { inject, ref, computed } from 'vue'
import BatchCreation from '@/components/Modals/BatchCreation.vue'
const user = inject('$user')
const showBatchModal = ref(false)
@@ -120,8 +125,4 @@ if (user.data) {
count: computed(() => batches.data?.enrolled?.length),
})
}
const openBatchModal = () => {
showBatchModal.value = true
}
</script>

View File

@@ -0,0 +1,37 @@
<template>
<div class="h-screen text-base">
<header
class="sticky top-0 z-10 flex items-center justify-between border-b bg-white px-3 py-2.5 sm:px-5"
>
<Breadcrumbs class="h-7" :items="breadcrumbs" />
</header>
<div>Batch creation</div>
</div>
</template>
<script setup>
import { computed } from 'vue'
import { Breadcrumbs } from 'frappe-ui'
const props = defineProps({
batchName: {
type: String,
required: true,
},
})
const breadcrumbs = computed(() => {
let crumbs = [
{
label: 'Batches',
route: {
name: 'Batches',
},
},
]
crumbs.push({
label: props.batchName == 'new' ? 'New Batch' : 'Edit Batch',
route: { name: 'CreateBatch', params: { batchName: props.batchName } },
})
return crumbs
})
</script>

View File

@@ -43,7 +43,7 @@ import {
Button,
createDocumentResource,
} from 'frappe-ui'
import { computed, reactive, onMounted, onBeforeMount } from 'vue'
import { computed, reactive, onMounted, inject } from 'vue'
import EditorJS from '@editorjs/editorjs'
import Header from '@editorjs/header'
import Paragraph from '@editorjs/paragraph'
@@ -54,6 +54,7 @@ import { createToast } from '../utils'
let editor
let editLessonResource
const user = inject('$user')
const props = defineProps({
courseName: {
@@ -71,8 +72,10 @@ const props = defineProps({
})
onMounted(() => {
if (!user.data?.is_moderator || !user.data?.is_instructor) {
window.location.href = '/login'
}
editor = renderEditor('content')
/* renderEditor('instructor-notes') */
})
const renderEditor = (holder) => {

View File

@@ -83,6 +83,7 @@
</div>
<JobApplicationModal
v-model="showApplicationModal"
v-model:application="jobApplication"
:job="job.data.name"
/>
</div>
@@ -112,25 +113,26 @@ const job = createResource({
},
cache: ['job', props.job],
auto: true,
onSuccess: (data) => {
if (user.data?.name) {
jobApplication.submit()
}
},
})
const jobApplication = createResource({
url: 'frappe.client.get_list',
params: {
doctype: 'LMS Job Application',
filters: {
job: job.data?.name,
user: user.data?.name,
},
makeParams(values) {
return {
doctype: 'LMS Job Application',
filters: {
job: job.data?.name,
user: user.data?.name,
},
}
},
})
onMounted(() => {
if (user.data?.name) {
jobApplication.submit()
}
})
const openApplicationModal = () => {
showApplicationModal.value = true
}