Fiexed a bug
This commit is contained in:
@@ -7,9 +7,9 @@ import { normalizeCourseName, WEEK_DAYS } from '../../utils.jsx'
|
||||
export const Course = ({ events, selection, setSelection, hideOtherCourses }) => {
|
||||
const selectionSet = new Set(selection)
|
||||
|
||||
const visibleEvents = !hideOtherCourses ? events : events.filter(e => selectionSet.has(e.name))
|
||||
const visibleEvents = !hideOtherCourses ? events : events.filter(e => selectionSet.has(e.id))
|
||||
|
||||
const eventsByCourse = _.groupBy(_.sortBy(visibleEvents, 'name'), 'name')
|
||||
const eventsByCourse = _.groupBy(_.sortBy(visibleEvents, 'id'), 'id')
|
||||
|
||||
const [currentlyHovered, setCurrentlyHovered] = useState(null)
|
||||
const element = useRef()
|
||||
@@ -38,20 +38,20 @@ export const Course = ({ events, selection, setSelection, hideOtherCourses }) =>
|
||||
return (
|
||||
<div class="course-view" ref={element}>
|
||||
<div class="wrap-container">
|
||||
{Object.entries(eventsByCourse).map(([name, courseEvents]) => (
|
||||
{Object.entries(eventsByCourse).map(([id, courseEvents]) => (
|
||||
<div
|
||||
class={
|
||||
'course' +
|
||||
(currentlyHovered === name ? ' highlight' : '') +
|
||||
(selectionSet.has(name) ? ' selected' : '')
|
||||
(currentlyHovered === id ? ' highlight' : '') +
|
||||
(selectionSet.has(id) ? ' selected' : '')
|
||||
}
|
||||
data-course-id={name}
|
||||
data-course-id={id}
|
||||
onClick={() => {
|
||||
if (!selectionSet.has(name)) setSelection([...selection, name])
|
||||
else setSelection(selection.filter(n => n !== name))
|
||||
if (!selectionSet.has(id)) setSelection([...selection, id])
|
||||
else setSelection(selection.filter(selId => selId !== id))
|
||||
}}
|
||||
>
|
||||
<div class="title">{normalizeCourseName(name)}</div>
|
||||
<div class="title">{normalizeCourseName(courseEvents[0].name)}</div>
|
||||
<div class="docenti">{courseEvents[0].docenti.join(', ')}</div>
|
||||
<div class="events">
|
||||
{courseEvents.map(course => (
|
||||
|
||||
@@ -9,16 +9,8 @@ import { layoutIntervals } from '../../interval-layout.js'
|
||||
export const WorkWeek = ({ events, selection, setSelection, hideOtherCourses }) => {
|
||||
const selectionSet = new Set(selection)
|
||||
|
||||
// const base = {
|
||||
// 1: [],
|
||||
// 2: [],
|
||||
// 3: [],
|
||||
// 4: [],
|
||||
// 5: [],
|
||||
// }
|
||||
|
||||
const eventsByWeekday = _.groupBy(
|
||||
!hideOtherCourses ? events : events.filter(e => selectionSet.has(e.name)),
|
||||
!hideOtherCourses ? events : events.filter(e => selectionSet.has(e.id)),
|
||||
event => event.start.getDay()
|
||||
)
|
||||
|
||||
@@ -110,29 +102,27 @@ export const WorkWeek = ({ events, selection, setSelection, hideOtherCourses })
|
||||
<div
|
||||
class={
|
||||
'event' +
|
||||
(currentlyHovered === event.data.name
|
||||
(currentlyHovered === event.data.id
|
||||
? ' highlight'
|
||||
: '') +
|
||||
(selectionSet.has(event.data.name) ? ' selected' : '')
|
||||
(selectionSet.has(event.data.id) ? ' selected' : '')
|
||||
}
|
||||
data-event-id={event.data.name}
|
||||
data-event-id={event.data.id}
|
||||
style={{
|
||||
'--start': event.start / 60 - 7,
|
||||
'--stack': stackIndex + 1,
|
||||
'--size': (event.end - event.start) / 60,
|
||||
'--hue':
|
||||
(Math.abs(hashString('seed3' + event.data.name)) %
|
||||
(Math.abs(hashString('seed3' + event.data.id)) %
|
||||
360) +
|
||||
'deg',
|
||||
}}
|
||||
onClick={() => {
|
||||
if (!selectionSet.has(event.data.name))
|
||||
setSelection([...selection, event.data.name])
|
||||
if (!selectionSet.has(event.data.id))
|
||||
setSelection([...selection, event.data.id])
|
||||
else
|
||||
setSelection(
|
||||
selection.filter(
|
||||
name => event.data.name !== name
|
||||
)
|
||||
selection.filter(id => event.data.id !== id)
|
||||
)
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -80,7 +80,7 @@ export const WorkWeekTranspose = ({ events }) => {
|
||||
'--size': (event.end - event.start) / 60,
|
||||
'--hue':
|
||||
(Math.abs(
|
||||
hashString('seed3' + event.data.name)
|
||||
hashString('seed3' + event.data.id)
|
||||
) %
|
||||
360) +
|
||||
'deg',
|
||||
|
||||
Reference in New Issue
Block a user