Merge pull request #1377 from frappe/state-enhancement

fix: misc
This commit is contained in:
Md Hussain Nagaria
2025-03-12 14:48:54 +05:30
committed by GitHub
2 changed files with 19 additions and 31 deletions

View File

@@ -105,6 +105,7 @@ import {
Select,
TabButtons,
} from 'frappe-ui'
import { useRouteQuery } from '@vueuse/router'
import { computed, inject, onMounted, ref, watch } from 'vue'
import { BookOpen, Plus } from 'lucide-vue-next'
import { updateDocumentTitle } from '@/utils'
@@ -119,7 +120,10 @@ const currentCategory = ref(null)
const title = ref('')
const certification = ref(false)
const filters = ref({})
const currentTab = ref(user.data?.is_student ? 'All' : 'Upcoming')
const currentTab = useRouteQuery(
'tab',
user.data?.is_student ? 'All' : 'Upcoming'
)
const orderBy = ref('start_date')
onMounted(() => {
@@ -250,7 +254,12 @@ const setQueryParams = () => {
}
})
history.replaceState({}, '', `${location.pathname}?${queries.toString()}`)
let queryString = ''
if (queries.toString()) {
queryString = `?${queries.toString()}`
}
history.replaceState({}, '', `${location.pathname}${queryString}`)
}
const updateCategories = (data) => {
@@ -270,18 +279,6 @@ watch(currentTab, () => {
updateBatches()
})
const batchType = computed(() => {
let types = [
{ label: __(''), value: null },
{ label: __('Upcoming'), value: 'Upcoming' },
{ label: __('Archived'), value: 'Archived' },
]
if (user.data?.is_moderator) {
types.push({ label: __('Unpublished'), value: 'Unpublished' })
}
return types
})
const batchTabs = computed(() => {
let tabs = [
{

View File

@@ -105,6 +105,7 @@ import {
Select,
TabButtons,
} from 'frappe-ui'
import { useRouteQuery } from '@vueuse/router'
import { computed, inject, onMounted, ref, watch } from 'vue'
import { BookOpen, Plus } from 'lucide-vue-next'
import { updateDocumentTitle } from '@/utils'
@@ -119,7 +120,7 @@ const currentCategory = ref(null)
const title = ref('')
const certification = ref(false)
const filters = ref({})
const currentTab = ref('Live')
const currentTab = useRouteQuery('tab', 'Live')
onMounted(() => {
setFiltersFromQuery()
@@ -255,7 +256,12 @@ const setQueryParams = () => {
}
})
history.replaceState({}, '', `${location.pathname}?${queries.toString()}`)
let queryString = ''
if (queries.toString()) {
queryString = `?${queries.toString()}`
}
history.replaceState({}, '', `${location.pathname}${queryString}`)
}
const updateCategories = (data) => {
@@ -275,21 +281,6 @@ watch(currentTab, () => {
updateCourses()
})
const courseType = computed(() => {
let types = [
{ label: __(''), value: null },
{ label: __('New'), value: 'New' },
{ label: __('Upcoming'), value: 'Upcoming' },
]
if (user.data?.is_student) {
types.push({ label: __('Enrolled'), value: 'Enrolled' })
}
if (user.data?.is_moderator || user.data?.is_instructor) {
types.push({ label: __('Created'), value: 'Created' })
}
return types
})
const courseTabs = computed(() => {
let tabs = [
{