Skip to content

Commit 48e1b52

Browse files
authored
Merge pull request #37 from GoGaucho/feature/courseinfoscreen
Feature/courseinfoscreen
2 parents eed3785 + 7d35951 commit 48e1b52

4 files changed

Lines changed: 118 additions & 27 deletions

File tree

src/components/Course.vue

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,19 @@ import { watch } from 'vue'
33
import { CheckIcon } from '@heroicons/vue/24/outline'
44
import { get } from '../firebase.js'
55
import state from '../model.js'
6-
const props = defineProps(['modelValue'])
7-
const emits = defineEmits(['update:modelValue'])
86
import Wrapper from './Wrapper.vue'
97
import Instructor from './Instructor.vue'
108
import LabelSwitch from './LabelSwitch.vue'
119
10+
const props = defineProps({
11+
modelValue: String,
12+
quarter: {
13+
type: String,
14+
default: () => state.course.quarter,
15+
}
16+
})
17+
const emits = defineEmits(['update:modelValue'])
18+
1219
// control UI
1320
const levels = { U: 'Undergraduate', G: 'Graduate', L: 'Lower Division', S: 'Upper Division' }
1421
const gradings = { null: 'optional', L: 'Letter', P: 'P/NP' }
@@ -21,18 +28,32 @@ function leaveInstructor () {
2128
if (!state.screen.md) instructorName = ''
2229
}
2330
24-
watch(() => props.modelValue, async v => {
25-
if (!v) return
26-
course = {}
27-
course = await get('course/' + state.course.quarter + v)
28-
for (const s in course.sections) {
29-
if (course.sections[s].session) {
30-
isSummer = true
31-
break
31+
watch(
32+
() => [props.modelValue, props.quarter],
33+
async ([v, q]) => {
34+
if (!v) {
35+
course = {}
36+
isSummer = false
37+
return
3238
}
33-
}
34-
setTimeout(() => { course.show = 1 })
35-
})
39+
40+
course = {}
41+
isSummer = false
42+
const quarter = q || state.course.quarter
43+
44+
course = await get('course/' + quarter + v)
45+
46+
for (const s in course.sections) {
47+
if (course.sections[s].session) {
48+
isSummer = true
49+
break
50+
}
51+
}
52+
setTimeout(() => { course.show = 1 })
53+
},
54+
{ immediate: true }
55+
)
56+
3657
3758
function toggleFocus () {
3859
const k = props.modelValue

src/components/Schedule.vue

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { watch } from 'vue'
33
import LabelSwitch from './LabelSwitch.vue'
44
import Toggle from './Toggle.vue'
55
import state from '../model.js'
6-
import { MapPinIcon } from '@heroicons/vue/24/outline'
6+
import { MapPinIcon, BookOpenIcon } from '@heroicons/vue/24/outline'
77
import { useRouter } from 'vue-router'
88
import { classrooms } from '../utils/locations.js'
99
1010
const router = useRouter()
11-
const props = defineProps(['pieces', 'whole'])
11+
const props = defineProps(['pieces', 'whole', 'quarter'])
1212
const ds = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
1313
const days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
1414
const colors = [
@@ -86,6 +86,17 @@ const locate = location => {
8686
if (classrooms[location]) router.push('/map?q=' + location)
8787
}
8888
89+
// Class to courseInfo redirect
90+
const courseInfo = (courseId, quarter) => {
91+
if (courseId)
92+
router.push({
93+
path: '/course',
94+
query: {
95+
courseId,
96+
quarter
97+
}})
98+
}
99+
89100
setInterval(() => { date = new Date() }, 60e3)
90101
document.onvisibilitychange = () => { date = new Date() }
91102
</script>
@@ -115,14 +126,49 @@ document.onvisibilitychange = () => { date = new Date() }
115126
<div class="grid grid-cols-7 gap-px relative w-full overflow-y-hidden all-transition" :style="{ width: state.screen.md || !props.whole ? '140%' : '100%', height: showTime ? '976px' : '736px' }"><!-- body -->
116127
<div v-for="j in 112" class="all-transition bg-gray-100 hover:bg-gray-50 rounded" />
117128
<template v-for="p in props.pieces">
118-
<div v-if="!isHide(p)" :style="pStyle(p)" class="all-transition absolute p-1 text-xs rounded-r-sm overflow-hidden"
119-
@click="locate(p.location)" :class="classrooms[p.location] && 'cursor-pointer group'">
120-
<MapPinIcon :class="colorMap[p.key][1]" class="w-5 h-5 absolute opacity-0 top-1 right-1 group-hover:opacity-100 transition-opacity" />
129+
<div v-if="!isHide(p)" :style="pStyle(p)"
130+
class="all-transition absolute p-1 text-xs rounded-r-sm overflow-hidden z-20"
131+
:class="classrooms[p.location] ? 'group' : 'group'">
132+
133+
<div
134+
class="
135+
absolute
136+
right-1
137+
top-auto bottom-1
138+
xl:top-1 xl:bottom-auto
139+
flex flex-col gap-1
140+
xl:flex-row xl:items-center
141+
"
142+
>
143+
<BookOpenIcon
144+
@click.stop="courseInfo(p.key, props.quarter)"
145+
:class="colorMap[p.key][1]"
146+
class="
147+
w-[clamp(14px,4vw,20px)]
148+
h-[clamp(14px,4vw,20px)]
149+
opacity-0 group-hover:opacity-100
150+
hover:opacity-70
151+
z-30 transition-opacity cursor-pointer
152+
"
153+
/>
154+
<MapPinIcon
155+
v-if="classrooms[p.location]"
156+
@click.stop="locate(p.location)"
157+
:class="colorMap[p.key][1]"
158+
class="
159+
w-[clamp(14px,4vw,20px)]
160+
h-[clamp(14px,4vw,20px)]
161+
opacity-0 group-hover:opacity-100
162+
hover:opacity-70
163+
z-30 transition-opacity cursor-pointer
164+
"
165+
/>
166+
</div>
121167
<div class="font-semibold text-shadow text-[0.7rem] sm:text-xs" :class="colorMap[p.key][1]">{{ p.title || p.key }}</div>
122168
<div class="text-[0.6rem] sm:text-xs opacity-90" :class="colorMap[p.key][1]" v-if="showTime">{{ twelveHour ? twelvify(p.time) : p.time }}</div>
123169
<div class="text-[0.625rem] sm:text-xs opacity-90" :class="colorMap[p.key][1]">{{ p.location }}</div>
124170
<div class="all-transition absolute bottom-0 top-0 left-0 w-0.5" :class="colorMap[p.key][0]" />
125-
<div class="absolute bottom-0 top-0 left-0 right-0" :class="colorMap[p.key][0]" style="opacity: 15%;"/>
171+
<div class="absolute bottom-0 top-0 left-0 right-0 pointer-events-none" :class="colorMap[p.key][0]" style="opacity: 15%;"/>
126172
</div>
127173
</template>
128174
<div class="flex items-center absolute" :style="cStyle">

src/views/Class.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ function removeCustom (i) {
171171
</div>
172172
<div class="w-full flex flex-wrap justify-center items-start" v-if="data" :key="q">
173173
<div class="flex-grow bg-white sm:p-2 sm:pb-4 lg:px-6 pb-4 rounded shadow m-0 sm:m-4 lg:mr-0" v-if="data.schedule"><!-- schedule -->
174-
<Schedule :pieces="pieces" whole="1" />
174+
<Schedule :pieces="pieces" :quarter='q' whole="1" />
175175
</div>
176176
<div class="m-2 w-full lg:w-72 xl:w-80"><!-- side -->
177177
<div :show="1" v-if="data.schedule" class="p-2">

src/views/Course.vue

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import Course from '../components/Course.vue'
1010
import Wrapper from '../components/Wrapper.vue'
1111
import PanelWrapper from '../components/PanelWrapper.vue'
1212
import LabelSwitch from '../components/LabelSwitch.vue'
13-
import { useRouter } from 'vue-router'
13+
import { useRouter, useRoute } from 'vue-router'
1414
const router = useRouter()
15+
const route = useRoute()
1516
log('web/course')
1617
1718
let loading = $ref(true), list = $ref(null), hideList = $ref({}), showSub = $ref({}), subjects = $ref([])
@@ -60,11 +61,24 @@ get('cache/quarter').then(data => {
6061
else state.course.quarter = quarters[0]
6162
})
6263
63-
watch(() => state.course.quarter, v => {
64-
focus = false
65-
state.course.focus = cache.get('course' + v) || {}
66-
fetchList()
67-
})
64+
watch(
65+
() => route.query.courseId,
66+
v => {
67+
focus = v || ''
68+
},
69+
{ immediate: true }
70+
)
71+
72+
watch(
73+
() => state.course.quarter,
74+
(v, old) => {
75+
if (!route.query.quarter || v !== route.query.quarter) {
76+
focus = ''
77+
}
78+
state.course.focus = cache.get('course' + v) || {}
79+
fetchList()
80+
}
81+
)
6882
6983
watch(() => state.course.focus, v => {
7084
const res = {}
@@ -73,6 +87,15 @@ watch(() => state.course.focus, v => {
7387
}
7488
cache.set('course' + state.course.quarter, res)
7589
}, { deep: true })
90+
91+
watch(() => route.query.quarter, v => {
92+
if (typeof v === 'string' && v !== state.course.quarter){
93+
state.course.quarter=v
94+
}
95+
},
96+
{immediate: true}
97+
)
98+
7699
</script>
77100

78101
<template>
@@ -119,7 +142,8 @@ watch(() => state.course.focus, v => {
119142
</PanelWrapper>
120143
</template>
121144
</div>
122-
<Course v-model="focus" />
145+
<Course v-model="focus"
146+
:quarter="state.course.quarter"/>
123147
</div>
124148
</div>
125149
</template>

0 commit comments

Comments
 (0)