fix: empty state conditions
This commit is contained in:
@@ -79,6 +79,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<MultiSelect
|
||||||
|
v-model="instructors"
|
||||||
|
doctype="User"
|
||||||
|
:label="__('Instructors')"
|
||||||
|
/>
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<FormControl
|
<FormControl
|
||||||
v-model="batch.description"
|
v-model="batch.description"
|
||||||
@@ -237,6 +242,7 @@ import { useRouter } from 'vue-router'
|
|||||||
import { showToast } from '../utils'
|
import { showToast } from '../utils'
|
||||||
import { Image } from 'lucide-vue-next'
|
import { Image } from 'lucide-vue-next'
|
||||||
import { capture } from '@/telemetry'
|
import { capture } from '@/telemetry'
|
||||||
|
import MultiSelect from '@/components/Controls/MultiSelect.vue'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const user = inject('$user')
|
const user = inject('$user')
|
||||||
|
|||||||
@@ -87,7 +87,7 @@
|
|||||||
</Tabs>
|
</Tabs>
|
||||||
<div
|
<div
|
||||||
v-else-if="
|
v-else-if="
|
||||||
batches.fetched &&
|
!batches.loading &&
|
||||||
!hasBatches &&
|
!hasBatches &&
|
||||||
(user.data?.is_instructor || user.data?.is_moderator)
|
(user.data?.is_instructor || user.data?.is_moderator)
|
||||||
"
|
"
|
||||||
@@ -117,7 +117,7 @@
|
|||||||
</router-link>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-else-if="batches.fetched && !hasBatches"
|
v-else-if="!batches.loading && !hasBatches"
|
||||||
class="text-center p-5 text-gray-600 mt-52 w-3/4 md:w-1/2 mx-auto space-y-2"
|
class="text-center p-5 text-gray-600 mt-52 w-3/4 md:w-1/2 mx-auto space-y-2"
|
||||||
>
|
>
|
||||||
<BookOpen class="size-10 mx-auto stroke-1 text-gray-500" />
|
<BookOpen class="size-10 mx-auto stroke-1 text-gray-500" />
|
||||||
@@ -165,13 +165,6 @@ const batches = createResource({
|
|||||||
url: 'lms.lms.utils.get_batches',
|
url: 'lms.lms.utils.get_batches',
|
||||||
cache: ['batches', user.data?.email],
|
cache: ['batches', user.data?.email],
|
||||||
auto: true,
|
auto: true,
|
||||||
onSuccess(data) {
|
|
||||||
Object.keys(data).forEach((section) => {
|
|
||||||
if (data[section].length) {
|
|
||||||
hasBatches.value = true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const categories = createResource({
|
const categories = createResource({
|
||||||
@@ -231,6 +224,14 @@ const addToTabs = (label) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(batches, () => {
|
||||||
|
Object.keys(batches.data).forEach((key) => {
|
||||||
|
if (batches.data[key].length) {
|
||||||
|
hasBatches.value = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => currentCategory.value,
|
() => currentCategory.value,
|
||||||
() => {
|
() => {
|
||||||
|
|||||||
@@ -109,7 +109,7 @@
|
|||||||
</Tabs>
|
</Tabs>
|
||||||
<div
|
<div
|
||||||
v-else-if="
|
v-else-if="
|
||||||
courses.fetched &&
|
!courses.loading &&
|
||||||
(user.data?.is_moderator || user.data?.is_instructor)
|
(user.data?.is_moderator || user.data?.is_instructor)
|
||||||
"
|
"
|
||||||
class="grid grid-cols-3 p-5"
|
class="grid grid-cols-3 p-5"
|
||||||
@@ -138,7 +138,7 @@
|
|||||||
</router-link>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-else-if="courses.fetched && !hasCourses"
|
v-else-if="!courses.loading && !hasCourses"
|
||||||
class="text-center p-5 text-gray-600 mt-52 w-3/4 md:w-1/2 mx-auto space-y-2"
|
class="text-center p-5 text-gray-600 mt-52 w-3/4 md:w-1/2 mx-auto space-y-2"
|
||||||
>
|
>
|
||||||
<BookOpen class="size-10 mx-auto stroke-1 text-gray-500" />
|
<BookOpen class="size-10 mx-auto stroke-1 text-gray-500" />
|
||||||
@@ -187,13 +187,6 @@ const courses = createResource({
|
|||||||
url: 'lms.lms.utils.get_courses',
|
url: 'lms.lms.utils.get_courses',
|
||||||
cache: ['courses', user.data?.email],
|
cache: ['courses', user.data?.email],
|
||||||
auto: true,
|
auto: true,
|
||||||
onSuccess(data) {
|
|
||||||
Object.keys(data).forEach((section) => {
|
|
||||||
if (data[section].length) {
|
|
||||||
hasCourses.value = true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const tabIndex = ref(0)
|
const tabIndex = ref(0)
|
||||||
@@ -271,6 +264,16 @@ const categories = createResource({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
watch(courses, () => {
|
||||||
|
if (courses.data) {
|
||||||
|
Object.keys(courses.data).forEach((section) => {
|
||||||
|
if (courses.data[section].length) {
|
||||||
|
hasCourses.value = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => currentCategory.value,
|
() => currentCategory.value,
|
||||||
() => {
|
() => {
|
||||||
|
|||||||
@@ -1101,7 +1101,7 @@ def get_categorized_courses(courses):
|
|||||||
):
|
):
|
||||||
new.append(course)
|
new.append(course)
|
||||||
|
|
||||||
if course.membership and course.published:
|
if course.membership:
|
||||||
enrolled.append(course)
|
enrolled.append(course)
|
||||||
elif course.is_instructor:
|
elif course.is_instructor:
|
||||||
created.append(course)
|
created.append(course)
|
||||||
|
|||||||
Reference in New Issue
Block a user