From af411775615a368db7ae1e629434020daaa8d343 Mon Sep 17 00:00:00 2001
From: Francesco Baldino
Date: Sat, 7 Oct 2023 22:49:03 +0200
Subject: [PATCH] reintrodotta visualizzazione lista rimossa nel commit
precedente
---
src/components/Help.jsx | 8 +++-
src/components/OptionBar.jsx | 5 +++
src/components/Toolbar.jsx | 1 +
src/components/view/Courses.jsx | 42 +++++++++++++++---
src/components/view/Schedule.jsx | 2 +-
src/main.jsx | 75 ++++++++++++++++----------------
src/styles/main.scss | 17 ++++++++
7 files changed, 104 insertions(+), 46 deletions(-)
diff --git a/src/components/Help.jsx b/src/components/Help.jsx
index e746b38..97f9e52 100644
--- a/src/components/Help.jsx
+++ b/src/components/Help.jsx
@@ -12,7 +12,8 @@ export const Help = ({}) => (
Una volta compiuta la selezione, è possibile vedere la tabella delle
- lezioni andando nella visualizzazione Orario
+ lezioni andando nella visualizzazione Orario (
+ )
Per via di eventuali preferenze personali, è possibile cambiare
@@ -20,6 +21,11 @@ export const Help = ({}) => (
pulsante Trasponi (
)
+
+ È anche possibile visualizzare in uno specchietto riassuntivo
+ soltanto i corsi selezionati, andando nella visualizzazione Lista (
+ )
+
Stampa
Da desktop puoi stampare l'orario attualmente visibile con il
diff --git a/src/components/OptionBar.jsx b/src/components/OptionBar.jsx
index b2eab56..62747cb 100644
--- a/src/components/OptionBar.jsx
+++ b/src/components/OptionBar.jsx
@@ -25,6 +25,11 @@ export const OptionBar = ({ source, setSource }) => {
label: ,
icon: true,
},
+ {
+ value: 'lista',
+ label: ,
+ icon: true,
+ },
]}
value={source}
setValue={setSource}
diff --git a/src/components/Toolbar.jsx b/src/components/Toolbar.jsx
index 4ad5402..1ab5a85 100644
--- a/src/components/Toolbar.jsx
+++ b/src/components/Toolbar.jsx
@@ -38,6 +38,7 @@ export const Toolbar = ({
{
+export const Courses = ({
+ source,
+ timetables,
+ selection,
+ setSelection,
+ hideOtherCourses,
+}) => {
const events = timetables[source]
const selectionSet = new Set(selection)
- const eventsByCourse = _.groupBy(_.sortBy(events, 'id'), 'id')
+ const visibleEvents = hideOtherCourses
+ ? events.filter(e => selectionSet.has(e.id))
+ : events
+
+ const eventsByCourse = _.groupBy(_.sortBy(visibleEvents, 'id'), 'id')
const profsPerCourse = _.mapValues(eventsByCourse, events =>
_.uniq(events.flatMap(event => event.docenti))
@@ -42,6 +52,15 @@ export const Courses = ({ source, timetables, selection, setSelection }) => {
return (
+ {hideOtherCourses && selection.length === 0 && (
+
+
Non hai ancora selezionato nessun corso.
+
+ Clicca sui corsi nelle altre visuali per selezionarli e
+ visualizzarli nella lista
+
+
+ )}
{Object.entries(eventsByCourse).map(([id, courseEvents]) => (
{
}
data-course-id={id}
onClick={() => {
- if (!selectionSet.has(id)) setSelection([...selection, id])
- else setSelection(selection.filter(selId => selId !== id))
+ if (!selectionSet.has(id))
+ setSelection([...selection, id])
+ else
+ setSelection(
+ selection.filter(selId => selId !== id)
+ )
}}
>
-
{prettyCourseName(courseEvents[0].name)}
-
{profsPerCourse[id].join(', ')}
+
+ {prettyCourseName(courseEvents[0].name)}
+
+
+ {profsPerCourse[id].join(', ')}
+
{courseEvents.map(course => (
{WEEK_DAYS[course.start.getDay()]}{' '}
{format(course.start, 'H:mm')}–
- {format(course.end, 'H:mm')} {course.aule.join(', ')}
+ {format(course.end, 'H:mm')}{' '}
+ {course.aule.join(', ')}
))}
diff --git a/src/components/view/Schedule.jsx b/src/components/view/Schedule.jsx
index fc0d32a..32ab004 100644
--- a/src/components/view/Schedule.jsx
+++ b/src/components/view/Schedule.jsx
@@ -211,7 +211,7 @@ const ScheduleCard = ({
)
}
-export const Schedule = ({ timetables, selection, setSelection }) => {
+export const Schedule = ({ timetables, selection }) => {
const [hasSeenTranspose, setHasSeenTranspose] = usePersistentState(
'transpose_info',
'false'
diff --git a/src/main.jsx b/src/main.jsx
index 6da396f..5b985d5 100644
--- a/src/main.jsx
+++ b/src/main.jsx
@@ -130,16 +130,41 @@ async function loadCalendari() {
}
}
+const View = ({ view, selection, setSelection, timetables }) => {
+ if (view === 'orario') {
+ return
+ } else if (view === 'lista') {
+ return (
+
+ )
+ } else {
+ return (
+
+ )
+ }
+}
const App = ({}) => {
// Clear persistent states unless state_token corresponds to the one passed
// as the argument. Useful with breaking updates. Change this token if your
// (breaking) update needs a reset of persistent states to avoid crashes.
//
// Use any random string of your choice
- clearOldPersistentStates('e73cba02')
+ // clearOldPersistentStates('e73cba02')
// Data Sources
- const [source, setSource] = usePersistentState('source', 'magistrale')
+ const [view, setView] = usePersistentState('view', 'magistrale')
const [timetables, setTimetables] = useState(null)
useEffect(async () => {
setTimetables(await loadCalendari())
@@ -175,8 +200,8 @@ const App = ({}) => {
<>
setShowMobileMenu(true),
onHelp: () => setHelpVisible(true),
theme,
@@ -185,8 +210,8 @@ const App = ({}) => {
/>
setHelpVisible(true),
}}
orizzontale
@@ -194,39 +219,15 @@ const App = ({}) => {
{timetables && (
- {source === 'orario' ? (
-
- ) : (
-
- )}
+
)}
- {/* toolOverlayVisible && (
-
- setMode(
- mode === MODE_COURSES ? MODE_SCHEDULE : MODE_COURSES
- )
- }
- onClose={() => {
- setSelectedCourses([])
- setMode(MODE_COURSES)
- }}
- />
- ) */}
+
{showMobileMenu && (