fix: ui issues

This commit is contained in:
Jannat Patel
2024-01-25 15:24:52 +05:30
parent f4e581f6cb
commit 8f317d2f44
9 changed files with 254 additions and 89 deletions

View File

@@ -4,7 +4,7 @@
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" />
<Button @click="openAnnouncementModal()">
<Button v-if="user.data?.is_moderator" @click="openAnnouncementModal()">
<span>
{{ __('Make an Announcement') }}
</span>

View File

@@ -1,93 +1,112 @@
<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="[{ label: __('All Batches'), route: { name: 'Batches' } }]"/>
<div class="flex">
<Button variant="solid">
<template #prefix>
<Plus class="h-4 w-4" />
</template>
{{ __("New Batch") }}
</Button>
</div>
</header>
<div class="mx-5 py-5">
<Tabs class="overflow-hidden" v-model="tabIndex" :tabs="tabs">
<template #tab="{ tab, selected }">
<div>
<button
class="group -mb-px flex items-center gap-2 border-b border-transparent py-2.5 text-base text-gray-600 duration-300 ease-in-out hover:border-gray-400 hover:text-gray-900"
:class="{ 'text-gray-900': selected }">
<component v-if="tab.icon" :is="tab.icon" class="h-5" />
{{ __(tab.label) }}
<Badge :class="{ 'text-gray-900 border border-gray-900': selected }" variant="subtle" theme="gray"
size="sm">
{{ tab.count }}
</Badge>
</button>
</div>
</template>
<template #default="{ tab }">
<div v-if="tab.batches && tab.batches.value.length" class="grid grid-cols-1 sm:grid-cols-3 md:grid-cols-4 gap-8 mt-5">
<router-link v-for="batch in tab.batches.value"
:to="{ name: 'BatchDetail', params: { batchName: batch.name } }">
<BatchCard :batch="batch" />
</router-link>
</div>
<div v-else class="grid flex-1 place-items-center text-xl font-medium text-gray-500">
<div class="flex flex-col items-center justify-center mt-4">
<div>
{{ __("No {0} batches found").format(tab.label.toLowerCase()) }}
</div>
</div>
</div>
</template>
</Tabs>
</div>
</div>
<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="[{ label: __('All Batches'), route: { name: 'Batches' } }]"
/>
<div class="flex">
<Button variant="solid">
<template #prefix>
<Plus class="h-4 w-4" />
</template>
{{ __('New Batch') }}
</Button>
</div>
</header>
<div class="pb-5">
<Tabs v-model="tabIndex" :tabs="tabs" tablistClass="overflow-x-visible">
<template #tab="{ tab, selected }">
<div>
<button
class="group -mb-px flex items-center gap-2 border-b border-transparent py-2.5 text-base text-gray-600 duration-300 ease-in-out hover:border-gray-400 hover:text-gray-900"
:class="{ 'text-gray-900': selected }"
>
<component v-if="tab.icon" :is="tab.icon" class="h-5" />
{{ __(tab.label) }}
<Badge
:class="
selected
? 'text-gray-800 border border-gray-800'
: 'border border-gray-500'
"
variant="subtle"
theme="gray"
size="sm"
>
{{ tab.count }}
</Badge>
</button>
</div>
</template>
<template #default="{ tab }">
<div
v-if="tab.batches && tab.batches.value.length"
class="grid grid-cols-1 sm:grid-cols-3 md:grid-cols-4 gap-5 mt-5 mx-5"
>
<router-link
v-for="batch in tab.batches.value"
:to="{ name: 'BatchDetail', params: { batchName: batch.name } }"
>
<BatchCard :batch="batch" />
</router-link>
</div>
<div
v-else
class="grid flex-1 place-items-center text-xl font-medium text-gray-500"
>
<div class="flex flex-col items-center justify-center mt-4">
<div>
{{ __('No {0} batches found').format(tab.label.toLowerCase()) }}
</div>
</div>
</div>
</template>
</Tabs>
</div>
</div>
</template>
<script setup>
import { createResource, 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 { createResource, 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'
const user = inject("$user")
const user = inject('$user')
const batches = createResource({
url: "lms.lms.utils.get_batches",
cache: ["batches", user?.data?.email],
auto: true,
});
url: 'lms.lms.utils.get_batches',
cache: ['batches', user?.data?.email],
auto: true,
})
const tabIndex = ref(0)
const tabs = [
{
label: "Upcoming",
batches: computed(() => batches.data?.upcoming || []),
count: computed(() => batches.data?.upcoming?.length),
},
];
{
label: 'Upcoming',
batches: computed(() => batches.data?.upcoming || []),
count: computed(() => batches.data?.upcoming?.length),
},
]
if (user.data?.is_moderator) {
tabs.push({
label: "Archived",
batches: computed(() => batches.data?.archived),
count: computed(() => batches.data?.archived?.length),
});
tabs.push({
label: "Private",
batches: computed(() => batches.data?.private),
count: computed(() => batches.data?.private?.length),
})
tabs.push({
label: 'Archived',
batches: computed(() => batches.data?.archived),
count: computed(() => batches.data?.archived?.length),
})
tabs.push({
label: 'Private',
batches: computed(() => batches.data?.private),
count: computed(() => batches.data?.private?.length),
})
}
if (user.data) {
tabs.push({
label: "Enrolled",
batches: computed(() => batches.data?.enrolled),
count: computed(() => batches.data?.enrolled?.length)
})
tabs.push({
label: 'Enrolled',
batches: computed(() => batches.data?.enrolled),
count: computed(() => batches.data?.enrolled?.length),
})
}
</script>
</script>

View File

@@ -9,7 +9,7 @@
:items="[{ label: __('All Courses'), route: { name: 'Courses' } }]"
/>
<div class="flex">
<Button variant="solid">
<Button v-if="user.data.is_moderator" variant="solid">
<template #prefix>
<Plus class="h-4 w-4" />
</template>
@@ -17,8 +17,8 @@
</Button>
</div>
</header>
<div class="mx-5 py-5">
<Tabs class="overflow-hidden" v-model="tabIndex" :tabs="tabs">
<div class="pb-5">
<Tabs v-model="tabIndex" :tabs="tabs" tablistClass="overflow-x-visible">
<template #tab="{ tab, selected }">
<div>
<button
@@ -28,7 +28,11 @@
<component v-if="tab.icon" :is="tab.icon" class="h-5" />
{{ __(tab.label) }}
<Badge
:class="{ 'text-gray-900 border border-gray-900': selected }"
:class="
selected
? 'text-gray-800 border border-gray-800'
: 'border border-gray-500'
"
variant="subtle"
theme="gray"
size="sm"
@@ -41,7 +45,7 @@
<template #default="{ tab }">
<div
v-if="tab.courses && tab.courses.value.length"
class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-8 mt-5"
class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-8 mt-5 mx-5"
>
<router-link
v-for="course in tab.courses.value"

View File

@@ -0,0 +1,27 @@
<template>
<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="[{ label: __('Jobs'), route: { name: 'Jobs' } }]"
/>
<div class="flex">
<Button v-if="user.data?.name" variant="solid">
<template #prefix>
<Plus class="h-4 w-4" />
</template>
{{ __('New Job') }}
</Button>
</div>
</header>
<div></div>
</template>
<script setup>
const props = defineProps({
job: {
type: String,
required: true,
},
})
</script>

View File

@@ -0,0 +1,48 @@
<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="[{ label: __('Jobs'), route: { name: 'Jobs' } }]"
/>
<div class="flex">
<Button v-if="user.data?.name" variant="solid">
<template #prefix>
<Plus class="h-4 w-4" />
</template>
{{ __('New Job') }}
</Button>
</div>
</header>
<div v-if="jobs.data">
<div class="grid grid-cols-2 gap-5 p-5">
<div v-if="jobs.data.length" v-for="job in jobs.data">
<router-link
:to="{
name: 'JobDetail',
params: { job: job.name },
}"
>
<JobCard :job="job" />
</router-link>
</div>
</div>
</div>
</div>
</template>
<script setup>
import { Button, Breadcrumbs, createResource } from 'frappe-ui'
import { Plus } from 'lucide-vue-next'
import { inject } from 'vue'
import JobCard from '@/components/JobCard.vue'
const user = inject('$user')
const jobs = createResource({
url: 'lms.lms.utils.get_job_opportunities',
cache: ['jobs'],
auto: true,
})
</script>