Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
schedules
Commits
a4018412
Commit
a4018412
authored
Oct 10, 2018
by
Zac Wood
Browse files
Calendar view
parent
a09028af
Changes
20
Expand all
Hide whitespace changes
Inline
Side-by-side
schedules/app/assets/javascripts/application.js
View file @
a4018412
...
@@ -27,12 +27,12 @@ document.addEventListener('DOMContentLoaded', () => {
...
@@ -27,12 +27,12 @@ document.addEventListener('DOMContentLoaded', () => {
this
.
schedule
=
new
Schedule
();
this
.
schedule
=
new
Schedule
();
});
});
/** Loads FontAwesome icons on load; fixes weird flickering */
document
.
addEventListener
(
'
turbolinks:load
'
,
()
=>
{
FontAwesome
.
dom
.
i2svg
();
});
const
setSemester
=
async
select
=>
{
const
setSemester
=
async
select
=>
{
const
resp
=
await
fetch
(
`/sessions/update?semester_id=
${
select
.
value
}
`
);
const
resp
=
await
fetch
(
`/sessions/update?semester_id=
${
select
.
value
}
`
);
location
.
reload
(
true
);
location
.
reload
(
true
);
};
};
/** Loads FontAwesome icons on load; fixes weird flickering */
document
.
addEventListener
(
'
turbolinks:load
'
,
()
=>
{
FontAwesome
.
dom
.
i2svg
();
});
schedules/app/assets/javascripts/schedule.js
View file @
a4018412
class
Schedule
{
class
Schedule
{
constructor
()
{
constructor
()
{
this
.
isOpen
=
false
;
this
.
isOpen
=
false
;
this
.
_courses
=
{};
// {title, id, sections: {id, crn}}
const
cartData
=
document
.
querySelector
(
'
#cart-data
'
);
const
courses
=
Array
.
from
(
cartData
.
content
.
children
);
for
(
const
course
of
courses
)
{
const
{
id
,
title
}
=
course
.
dataset
;
const
sections
=
Array
.
from
(
course
.
children
).
map
(
node
=>
({
...
node
.
dataset
}));
this
.
_courses
[
id
]
=
{
id
,
title
,
sections
};
}
document
.
getElementById
(
'
course-counter
'
).
innerText
=
Object
.
keys
(
this
.
_courses
).
length
;
this
.
_ids
=
Array
.
from
(
document
.
getElementById
(
'
schedule
'
).
children
).
map
(
e
=>
e
.
dataset
.
crn
);
this
.
_ids
=
Array
.
from
(
document
.
getElementById
(
'
schedule
'
).
children
).
map
(
e
=>
e
.
dataset
.
crn
);
}
}
get
ids
()
{
get
crns
()
{
return
this
.
_ids
;
return
Object
.
keys
(
this
.
_courses
)
.
map
(
cid
=>
this
.
_courses
[
cid
].
sections
.
map
(
s
=>
s
.
crn
))
.
reduce
((
prev
,
curr
)
=>
[...
prev
,
...
curr
],
[]);
}
}
set
ids
(
ids
)
{
get
ids
()
{
this
.
_ids
=
ids
;
return
Object
.
keys
(
this
.
_courses
)
.
map
(
cid
=>
this
.
_courses
[
cid
].
sections
.
map
(
s
=>
s
.
id
))
document
.
getElementById
(
'
course-counter
'
).
innerText
=
ids
.
length
;
.
reduce
((
prev
,
curr
)
=>
[...
prev
,
...
curr
],
[]);
fetch
(
'
/sessions/update?crns=
'
+
ids
.
join
(
'
,
'
),
{
cache
:
'
no-store
'
});
}
}
toggle
()
{
toggle
()
{
...
@@ -30,36 +42,111 @@ class Schedule {
...
@@ -30,36 +42,111 @@ class Schedule {
this
.
isOpen
=
!
this
.
isOpen
;
this
.
isOpen
=
!
this
.
isOpen
;
}
}
addToSchedule
(
section
)
{
addCourse
(
course
)
{
if
(
this
.
ids
.
includes
(
section
.
dataset
.
crn
))
return
;
this
.
_courses
[
course
.
id
]
=
course
;
const
parent
=
document
.
querySelector
(
'
#schedule
'
);
const
current
=
parent
.
querySelector
(
`#schedule-
${
course
.
id
}
`
);
const
newNode
=
this
.
_constructCourseNode
(
course
);
if
(
current
!==
null
)
parent
.
replaceChild
(
newNode
,
current
);
else
parent
.
appendChild
(
newNode
);
document
.
getElementById
(
'
course-counter
'
).
innerText
=
Object
.
keys
(
this
.
_courses
).
length
;
fetch
(
`/sessions/update?section_ids=
${
this
.
ids
.
join
(
'
,
'
)}
`
,
{
cache
:
'
no-store
'
});
}
removeCourse
(
id
)
{
const
sectionIds
=
this
.
_courses
[
id
].
sections
.
map
(
s
=>
s
.
id
);
for
(
const
sectionId
of
sectionIds
)
{
const
sectionCard
=
document
.
querySelector
(
`#section-
${
sectionId
}
`
);
sectionCard
&&
sectionCard
.
classList
.
remove
(
'
selected
'
);
}
delete
this
.
_courses
[
id
];
const
parent
=
document
.
querySelector
(
'
#schedule
'
);
const
current
=
parent
.
querySelector
(
`#schedule-
${
id
}
`
);
parent
.
removeChild
(
current
);
document
.
getElementById
(
'
course-counter
'
).
innerText
=
Object
.
keys
(
this
.
_courses
).
length
;
fetch
(
`/sessions/update?section_ids=
${
this
.
ids
.
join
(
'
,
'
)}
`
,
{
cache
:
'
no-store
'
});
}
courseContainingSection
(
id
)
{
for
(
const
courseId
in
this
.
_courses
)
{
const
course
=
this
.
_courses
[
courseId
];
for
(
const
section
of
course
.
sections
)
{
if
(
section
.
id
==
id
)
return
course
;
}
}
return
undefined
;
}
includesSection
(
id
)
{
return
!!
this
.
courseContainingSection
(
id
);
}
// section: { id, crn }
addSection
(
section
)
{
const
course
=
this
.
_courses
[
section
.
cid
];
if
(
course
)
{
course
.
sections
.
push
(
section
);
this
.
ids
=
[...
this
.
ids
,
section
.
dataset
.
crn
];
const
courseNode
=
document
.
querySelector
(
'
#schedule
'
).
querySelector
(
`#schedule-
${
course
.
id
}
`
);
const
crnList
=
courseNode
.
querySelector
(
'
.crns
'
);
crnList
.
innerText
=
course
.
sections
.
map
(
s
=>
`#
${
s
.
crn
}
`
);
section
.
classList
.
remove
(
'
section-item
'
);
fetch
(
`/sessions/update?section_ids=
${
this
.
ids
.
join
(
'
,
'
)}
`
,
{
cache
:
'
no-store
'
}
);
section
.
classList
.
remove
(
'
selected
'
);
}
else
{
section
.
classList
.
add
(
'
schedule-
section
-card
'
);
const
courseCard
=
document
.
getElementById
(
`course-
${
section
.
cid
}
`
);
section
.
onclick
=
()
=>
removeFromSchedule
(
section
)
;
const
title
=
courseCard
.
querySelector
(
'
#title
'
).
innerText
;
document
.
getElementById
(
'
schedule
'
).
appendChild
(
section
);
this
.
addCourse
({
title
,
id
:
section
.
cid
,
sections
:
[
section
]
});
}
}
}
removeFromSchedule
(
id
)
{
removeSection
(
section
)
{
const
cart
=
document
.
getElementById
(
'
schedule
'
);
const
course
=
this
.
courseContainingSection
(
section
.
id
);
const
section
=
cart
.
querySelector
(
`#section-
${
id
}
`
);
course
.
sections
=
course
.
sections
.
filter
(
s
=>
s
.
id
!==
section
.
id
);
cart
.
removeChild
(
section
);
const
schedule
=
document
.
querySelector
(
'
#schedule
'
);
const
courseNode
=
schedule
.
querySelector
(
`#schedule-
${
course
.
id
}
`
);
const
crnList
=
courseNode
.
querySelector
(
'
.crns
'
);
if
(
course
.
sections
.
length
===
0
)
{
this
.
removeCourse
(
section
.
cid
);
}
else
{
crnList
.
innerText
=
course
.
sections
.
map
(
s
=>
`#
${
s
.
crn
}
`
);
}
this
.
ids
=
this
.
ids
.
filter
(
_id
=>
_id
!=
id
);
fetch
(
`/sessions/update?section_ids=
${
this
.
ids
.
join
(
'
,
'
)}
`
,
{
cache
:
'
no-store
'
}
);
}
}
async
downloadIcs
()
{
async
downloadIcs
()
{
const
cal
=
await
fetch
(
`/api/schedules?crns=
${
this
.
id
s
.
join
(
'
,
'
)}
`
);
const
cal
=
await
fetch
(
`/api/schedules?crns=
${
this
.
crn
s
.
join
(
'
,
'
)}
`
);
const
text
=
await
cal
.
text
();
const
text
=
await
cal
.
text
();
var
blob
=
new
Blob
([
text
],
{
type
:
'
text/calendar;charset=utf-8
'
});
var
blob
=
new
Blob
([
text
],
{
type
:
'
text/calendar;charset=utf-8
'
});
saveAs
(
blob
,
'
test.ics
'
);
saveAs
(
blob
,
'
test.ics
'
);
}
}
async
addToSystemCalendar
()
{
async
addToSystemCalendar
()
{
const
url
=
`webcal://
${
window
.
location
.
hostname
}
/api/schedule?crns=
${
this
.
id
s
.
join
(
'
,
'
)}
`
;
const
url
=
`webcal://
${
window
.
location
.
hostname
}
/api/schedule?crns=
${
this
.
crn
s
.
join
(
'
,
'
)}
`
;
window
.
open
(
url
,
'
_self
'
);
window
.
open
(
url
,
'
_self
'
);
}
}
_constructCourseNode
(
course
)
{
let
html
=
`<li id="schedule-
${
course
.
id
}
" class="list-group-item schedule-section-card" onclick="removeCourse(
${
course
.
id
}
)">`
;
html
+=
`<div style="display: flex; justify-content: space-between;">`
;
html
+=
`<b style="min-width: 15%">
${
course
.
title
}
</b>`
;
html
+=
`<span class="crns" style="color: gray; font-size: 10pt;">`
;
html
+=
course
.
sections
.
map
(
s
=>
`#
${
s
.
crn
}
`
).
join
(
'
,
'
);
html
+=
`</span>`
;
html
+=
`</div>`
;
html
+=
`</li>`
;
return
elementFromString
(
html
);
}
}
}
const
removeCourse
=
id
=>
{
this
.
schedule
.
removeCourse
(
id
);
};
schedules/app/assets/javascripts/search.js
View file @
a4018412
...
@@ -3,17 +3,30 @@
...
@@ -3,17 +3,30 @@
const
sectionWithCrn
=
crn
=>
document
.
getElementById
(
'
search-list
'
).
querySelector
(
`[data-crn="
${
crn
}
"]`
);
const
sectionWithCrn
=
crn
=>
document
.
getElementById
(
'
search-list
'
).
querySelector
(
`[data-crn="
${
crn
}
"]`
);
const
addCourse
=
(
event
,
id
)
=>
{
const
courseCard
=
document
.
getElementById
(
`course-
${
id
}
`
);
const
title
=
courseCard
.
querySelector
(
'
#title
'
).
innerText
;
const
sectionsItems
=
Array
.
from
(
courseCard
.
querySelectorAll
(
'
li
'
));
const
sections
=
sectionsItems
.
map
(
li
=>
({
...
li
.
dataset
}));
this
.
schedule
.
addCourse
({
title
,
id
,
sections
});
sectionsItems
.
forEach
(
s
=>
s
.
classList
.
add
(
'
selected
'
));
event
.
stopPropagation
();
};
/**
/**
* Either adds or removes a section from the schedule depending on
* Either adds or removes a section from the schedule depending on
* if it is currently in the schedule.
* if it is currently in the schedule.
*/
*/
const
addOrRemoveFromSchedule
=
(
event
,
section
)
=>
{
const
addOrRemoveFromSchedule
=
(
event
,
sectionNode
)
=>
{
if
(
this
.
schedule
.
ids
.
includes
(
section
.
dataset
.
crn
))
{
const
section
=
{
...
sectionNode
.
dataset
};
this
.
schedule
.
removeFromSchedule
(
section
.
dataset
.
crn
);
section
.
classList
.
remove
(
'
selected
'
);
if
(
this
.
schedule
.
includesSection
(
section
.
id
))
{
this
.
schedule
.
removeSection
(
section
);
sectionNode
.
classList
.
remove
(
'
selected
'
);
}
else
{
}
else
{
this
.
schedule
.
add
ToSchedule
(
section
.
cloneNode
(
true
)
);
this
.
schedule
.
add
Section
(
section
);
section
.
classList
.
add
(
'
selected
'
);
section
Node
.
classList
.
add
(
'
selected
'
);
}
}
event
.
stopPropagation
();
event
.
stopPropagation
();
...
...
schedules/app/assets/stylesheets/application.scss
View file @
a4018412
...
@@ -99,3 +99,12 @@ body {
...
@@ -99,3 +99,12 @@ body {
margin-bottom
:
16px
;
margin-bottom
:
16px
;
padding
:
12px
;
padding
:
12px
;
}
}
#add-course-btn
:hover
{
background-color
:
rgba
(
0
,
0
,
0
,
0
.2
);
}
#calendar
{
background-color
:
white
;
padding
:
16px
;
}
schedules/app/controllers/application_controller.rb
View file @
a4018412
...
@@ -12,15 +12,17 @@ class ApplicationController < ActionController::Base
...
@@ -12,15 +12,17 @@ class ApplicationController < ActionController::Base
end
end
def
set_cart
def
set_cart
@cart
=
cookies
[
:crns
].
split
(
','
).
map
do
|
crn
|
sections
=
cookies
[
:section_ids
].
split
(
','
).
map
do
|
id
|
s
=
CourseSection
.
find_by_crn
(
crn
)
CourseSection
.
find_by_id
(
id
)
s
if
s
.
course
.
semester
==
@semester
end
end
@cart
.
compact!
@cart
=
sections
.
group_by
do
|
s
|
s
.
course
.
id
end
end
end
def
set_cookies
def
set_cookies
cookies
[
:crns
]
=
""
if
cookies
[
:crns
].
nil?
cookies
[
:crns
]
=
""
if
cookies
[
:crns
].
nil?
cookies
[
:section_ids
]
=
""
if
cookies
[
:section_ids
].
nil?
end
end
end
end
schedules/app/controllers/schedules_controller.rb
View file @
a4018412
...
@@ -15,4 +15,19 @@ class SchedulesController < ApplicationController
...
@@ -15,4 +15,19 @@ class SchedulesController < ApplicationController
@schedule
=
Schedule
.
new
crns
@schedule
=
Schedule
.
new
crns
render
plain:
@schedule
.
to_ical
# render a plaintext iCal file
render
plain:
@schedule
.
to_ical
# render a plaintext iCal file
end
end
def
show
@events
=
@cart
.
map
do
|
_cid
,
sections
|
s
=
sections
.
first
formatted_date
=
Date
.
today
.
to_s
.
tr
(
'-'
,
''
)
formatted_time
=
Time
.
parse
(
s
.
start_time
).
strftime
(
"%H%M%S"
)
formatted_endtime
=
Time
.
parse
(
s
.
end_time
).
strftime
(
"%H%M%S"
)
{
title:
s
.
name
,
start:
"
#{
formatted_date
}
T
#{
formatted_time
}
"
,
end:
"
#{
formatted_date
}
#{
formatted_endtime
}
"
}
end
end
end
end
schedules/app/controllers/sessions_controller.rb
View file @
a4018412
class
SessionsController
<
ApplicationController
class
SessionsController
<
ApplicationController
def
update
def
update
update_cookie
:crns
update_cookie
:crns
update_cookie
:section_ids
update_cookie
:semester_id
update_cookie
:semester_id
head
:ok
head
:ok
...
...
schedules/app/helpers/application_helper.rb
View file @
a4018412
module
ApplicationHelper
module
ApplicationHelper
def
in_cart?
(
id
)
@cart
.
select
{
|
_cid
,
sections
|
sections
.
select
{
|
s
|
s
.
id
==
id
}.
count
.
positive?
}.
count
.
positive?
end
end
end
schedules/app/views/layouts/application.html.erb
View file @
a4018412
...
@@ -5,10 +5,13 @@
...
@@ -5,10 +5,13 @@
<%=
csrf_meta_tags
%>
<%=
csrf_meta_tags
%>
<%=
javascript_include_tag
'masonstrap.min'
%>
<%=
javascript_include_tag
'masonstrap.min'
%>
<%=
javascript_include_tag
'moment.min'
%>
<%=
javascript_include_tag
'fullcalendar.min'
%>
<%=
javascript_include_tag
'FileSaver'
%>
<%=
javascript_include_tag
'FileSaver'
%>
<%=
javascript_include_tag
'application'
%>
<%=
javascript_include_tag
'application'
%>
<%=
stylesheet_link_tag
'masonstrap.min'
%>
<%=
stylesheet_link_tag
'masonstrap.min'
%>
<%=
stylesheet_link_tag
'fullcalendar.min'
%>
<%=
stylesheet_link_tag
'application'
%>
<%=
stylesheet_link_tag
'application'
%>
</head>
</head>
...
...
schedules/app/views/schedules/show.html.erb
0 → 100644
View file @
a4018412
<div
id=
"calendar"
></div>
<template
id=
"events"
data-events=
"
<%=
@events
.
to_json
%>
"
></template>
<script>
/* const cal = document.querySelector('#calendar');
* var calendar = new Calendar(cal, {
* defaultView: 'agendaWeek'
* }); */
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
const
eventsJSON
=
document
.
querySelector
(
'
#events
'
).
dataset
.
events
;
const
events
=
JSON
.
parse
(
eventsJSON
);
console
.
log
(
events
);
$
(
'
#calendar
'
).
fullCalendar
({
defaultView
:
'
agendaWeek
'
,
header
:
{
right
:
'
next
'
},
events
:
events
});
});
</script>
schedules/app/views/search/index.html.erb
View file @
a4018412
...
@@ -5,8 +5,3 @@
...
@@ -5,8 +5,3 @@
<p>
Please try again!
</p>
<p>
Please try again!
</p>
<%
end
%>
<%
end
%>
<%=
javascript_tag
do
%>
document.addEventListener('DOMContentLoaded', () => {
this.search = new Search();
});
<%
end
%>
schedules/app/views/shared/_cart.html.erb
View file @
a4018412
...
@@ -4,10 +4,20 @@
...
@@ -4,10 +4,20 @@
<div
class=
"col order-1 order-lg-1"
id=
"cart"
>
<div
class=
"col order-1 order-lg-1"
id=
"cart"
>
<div
class=
"card"
>
<div
class=
"card"
>
<div
class=
"card-body"
>
<div
class=
"card-body"
>
<h3
class=
"card-title"
>
Your Schedule
</h3>
<h3
class=
"card-title"
>
<%=
link_to
'Your Schedule'
,
schedule_path
%>
</h3>
</div>
</div>
<ul
class=
"list-group list-group-flush"
id=
"schedule"
>
<ul
class=
"list-group list-group-flush"
id=
"schedule"
>
<%=
render
partial:
'shared/section'
,
collection:
@cart
,
locals:
{
in_cart:
true
}
%>
<%
@cart
.
each
do
|
cid
,
sections
|
%>
<%
course
=
Course
.
find_by_id
(
cid
)
%>
<li
id=
"schedule-
<%=
cid
%>
"
class=
"list-group-item schedule-section-card"
onclick=
"removeCourse(
<%=
cid
%>
)"
>
<div
style=
"display: flex; justify-content: space-between;"
>
<b
style=
"min-width: 15%"
>
<%=
"
#{
course
.
subject
}
#{
course
.
course_number
}
"
%>
</b>
<span
class=
"crns"
style=
"color: gray; font-size: 10pt;"
>
<%=
sections
.
map
{
|
s
|
"#
#{
s
.
crn
}
"
}.
join
(
', '
)
%>
</span>
</div>
</li>
<%
end
%>
</ul>
</ul>
<div
class=
"card-body"
>
<div
class=
"card-body"
>
<button
type=
"button"
class=
"btn btn-primary"
data-toggle=
"modal"
data-target=
"#exportModal"
onclick=
"setUrlInModal()"
>
<button
type=
"button"
class=
"btn btn-primary"
data-toggle=
"modal"
data-target=
"#exportModal"
onclick=
"setUrlInModal()"
>
...
@@ -17,6 +27,16 @@
...
@@ -17,6 +27,16 @@
</div>
</div>
</div>
</div>
<template
id=
"cart-data"
>
<%
@cart
.
each
do
|
cid
,
sections
|
%>
<%
course
=
Course
.
find_by_id
cid
%>
<div
data-id=
"
<%=
cid
%>
"
data-title=
"
<%=
"
#{
course
.
subject
}
#{
course
.
course_number
}
"
%>
"
>
<%
sections
.
each
do
|
s
|
%>
<div
data-id=
"
<%=
s
.
id
%>
"
data-crn=
"
<%=
s
.
crn
%>
"
></div>
<%
end
%>
</div>
<%
end
%>
</template>
</div>
</div>
</div>
</div>
...
...
schedules/app/views/shared/_course.html.erb
View file @
a4018412
<%
expanded
=
false
unless
defined?
expanded
%>
<%
expanded
=
false
unless
defined?
expanded
%>
<div
class=
"card"
id=
"course-
<%=
course
.
id
%>
"
onclick=
"toggleSections(this)"
>
<div
class=
"card"
id=
"course-
<%=
course
.
id
%>
"
onclick=
"toggleSections(this)"
>
<div
class=
"card-body"
>
<div
class=
"card-body"
>
<div>
<div
style=
"display: flex; justify-content: space-between"
>
<h3
style=
"float: left"
>
<%=
"
#{
course
.
subject
}
#{
course
.
course_number
}
"
%>
</h3>
<h3
id=
"title"
>
<%=
"
#{
course
.
subject
}
#{
course
.
course_number
}
"
%>
</h3>
<h5
style=
"float: right"
><em>
<%=
course
.
title
%>
</em>
.
<%=
course
.
credits
%>
credits.
</h5>
<div
style=
"display: flex; flex-direction: column; justify-content: center;"
>
</div>
<div
style=
"display: flex"
>
<h5><em>
<%=
course
.
title
%>
</em>
.
<%=
course
.
credits
%>
credits.
</h5>
<h4
id=
"add-course-btn"
onclick=
"addCourse(event, '
<%=
course
.
id
%>
');"
>
<i
class=
"fas fa-plus"
style=
"color: green"
></i>
</h4>
</div>
</div>
</div>
<div
style=
"clear: both"
>
</div>
<div
style=
"clear: both"
>
</div>
<p
class=
"description"
>
<%=
course
.
description
%>
</p>
<p
class=
"description"
>
<%=
course
.
description
%>
</p>
<%
unless
course
.
prereqs
.
nil?
||
course
.
prereqs
.
empty?
%>
<%
unless
course
.
prereqs
.
nil?
||
course
.
prereqs
.
empty?
%>
<%
first
,
rest
=
course
.
prereqs
.
split
(
':'
)
%>
<%
first
,
rest
=
course
.
prereqs
.
split
(
':'
)
%>
<%
prereqs
,
note
=
rest
.
split
(
'.'
)
%>
<%
prereqs
,
note
=
rest
.
split
(
'.'
)
%>
<p><strong>
<%=
first
%>
:
</strong>
<%=
prereqs
%>
<sub>
<%=
note
%>
</sub></p>
<p><strong>
<%=
first
%>
:
</strong>
<%=
prereqs
%>
<sub>
<%=
note
%>
</sub></p>
<%
end
%>
<%
end
%>
<div
class=
"d-block"
style=
"text-align: center"
>
<div
class=
"d-block"
style=
"text-align: center"
>
<p
style=
"margin-bottom:-4px; font-size: 10px;"
>
Expand
</p>
<p
style=
"margin-bottom:-4px; font-size: 10px;"
>
Expand
</p>
<i
class=
"fas fa-chevron-down"
></i>
<i
class=
"fas fa-chevron-down"
></i>
</div>
</div>
<!-- List of Course Sections -->
<!-- List of Course Sections -->
<ul
class=
"list-group list-group-flush"
id=
"sections"
style=
"display:
<%=
expanded
?
"block"
:
"none"
%>
"
>
<ul
class=
"list-group list-group-flush"
id=
"sections"
style=
"display:
<%=
expanded
?
"block"
:
"none"
%>
"
>
<%
if
defined?
(
@instructor
)
%>
<%
if
defined?
(
@instructor
)
%>
<%=
render
partial:
'shared/section'
,
collection:
course
.
course_sections
.
where
(
instructor:
@instructor
),
locals:
{
in_cart:
fal
se
}
%>
<%=
render
partial:
'shared/section'
,
collection:
course
.
course_sections
.
where
(
instructor:
@instructor
),
locals:
{
course:
cour
se
}
%>
<%
else
%>
<%
else
%>
<%=
render
partial:
'shared/section'
,
collection:
course
.
course_sections
,
locals:
{
in_cart:
fal
se
}
%>
<%=
render
partial:
'shared/section'
,
collection:
course
.
course_sections
,
locals:
{
course:
cour
se
}
%>
<%
end
%>
<%
end
%>
</ul>
</ul>
</div>
</div>
</div>
</div>
schedules/app/views/shared/_navbar.html.erb
View file @
a4018412
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
Schedules
Schedules
</a>
</a>
<select
onchange=
"setSemester(this)"
>
<select
onchange=
"setSemester(this)"
>
<%
for
s
emester
in
S
emester
.
all
%>
<%
S
emester
.
all
.
each
do
|
s
emester
|
%>
<option
value=
"
<%=
semester
.
id
%>
"
<%
if
@semester
==
semester
%>
selected
<%
end
%>
>
<option
value=
"
<%=
semester
.
id
%>
"
<%
if
@semester
==
semester
%>
selected
<%
end
%>
>
<%=
"
#{
semester
.
season
}
#{
semester
.
year
}
"
%>
<%=
"
#{
semester
.
season
}
#{
semester
.
year
}
"
%>
</option>
</option>
...
...
schedules/app/views/shared/_section.html.erb
View file @
a4018412
<%
if
in_cart
%>
<li
id=
"section-
<%=
section
.
id
%>
"
<li
id=
"section-
<%=
section
.
crn
%>
"
class=
"list-group-item section-item
<%=
"selected"
if
in_cart?
section
.
id
%>
"
class=
"list-group-item schedule-section-card"
data-crn=
"
<%=
section
.
crn
%>
"
data-crn=
"
<%=
section
.
crn
%>
"
data-id=
"
<%=
section
.
id
%>
"
onclick=
"removeFromSchedule(this)"
data-cid=
"
<%=
course
.
id
%>
"
>
onclick=
"addOrRemoveFromSchedule(event, this)"
<span
style=
"float:left"
><b
class=
"subj"
>
<%=
"
#{
section
.
name
}
"
%>
</b>
:
<%=
section
.
title
%>
</span>
>
<span
style=
"float:right"
><i
class=
"fas fa-map-marker-alt"
></i>
<%=
section
.
location
%>
</span>
<span
style=
"float:left"
><b
class=
"subj"
>
<%=
"
#{
section
.
name
}
"
%>
</b>
:
<%=
section
.
title
%>
</span>
<div
style=
"clear: both"
></div>
<span
style=
"float:right"
><i
class=
"fas fa-map-marker-alt"
></i>
<%=
section
.
location
%>
</span>
<span
style=
"float:left"
><i
class=
"fas fa-chalkboard-teacher"
></i>
<%=
link_to
section
.
instructor
.
name
,
instructor_path
(
section
.
instructor
)
%>
</span>
<div
style=
"clear: both"
></div>
<span
style=
"float:right"
><i
class=
"fas fa-clock"
></i>
<%=
"
#{
section
.
days
}
,
#{
section
.
start_time
}
-
#{
section
.
end_time
}
"
%>
</span>
<span
style=
"float:left"
><i
class=
"fas fa-chalkboard-teacher"
></i>
<%=
link_to
section
.
instructor
.
name
,
instructor_path
(
section
.
instructor
)
%>
</span>
<div
style=
"clear: both"
></div>
<span
style=
"float:right"
><i
class=
"fas fa-clock"
></i>
<%=
"
#{
section
.
days
}
,
#{
section
.
start_time
}
-
#{
section
.
end_time
}
"
%>
</span>
</li>
<div
style=
"clear: both"
></div>
</li>
<%
else
%>
<li
id=
"section-
<%=
section
.
crn
%>
"
class=
"list-group-item section-item
<%=
"selected"
if
@cart
.
include?
section
%>
"
d