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
9821b71c
Commit
9821b71c
authored
Oct 01, 2018
by
Zac Wood
Browse files
Merge branch 'load-prereqs' into 'dev-v2'
Load prereqs See merge request
!29
parents
5f25e64f
4c21a3ca
Pipeline
#3059
passed with stage
in 2 minutes and 16 seconds
Changes
12
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
schedules/app/assets/javascripts/SectionCard.js
deleted
100644 → 0
View file @
5f25e64f
class
SectionCard
{
constructor
(
section
)
{
this
.
_html
=
`
<li id="section-
${
section
.
crn
}
" class="list-group-item schedule-section-card" onclick="removeFromSchedule(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>
<div style="clear: both"></div>
<span style="float:left"><i class="fas fa-chalkboard-teacher"></i> TODO </span>
<span style="float:right"><i class="fas fa-clock"></i>
${
section
.
days
}
,
${
section
.
start_time
}
-
${
section
.
end_time
}
</span>
<div style="clear: both"></div>
</li>`
;
}
}
schedules/app/assets/javascripts/application.js
View file @
9821b71c
...
...
@@ -27,6 +27,7 @@ document.addEventListener('DOMContentLoaded', () => {
this
.
schedule
=
new
Schedule
();
});
/** Loads FontAwesome icons on load; fixes weird flickering */
document
.
addEventListener
(
'
turbolinks:load
'
,
()
=>
{
FontAwesome
.
dom
.
i2svg
();
});
schedules/app/assets/javascripts/search.js
View file @
9821b71c
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
class
Search
{
sectionWithCrn
(
crn
)
{
return
document
.
getElementById
(
'
search-list
'
).
querySelector
(
`[data-crn="
${
crn
}
"]`
);
const
sectionWithCrn
=
crn
=>
document
.
getElementById
(
'
search-list
'
).
querySelector
(
`[data-crn="
${
crn
}
"]`
);
/**
* Either adds or removes a section from the schedule depending on
* if it is currently in the schedule.
*/
const
addOrRemoveFromSchedule
=
(
event
,
section
)
=>
{
if
(
this
.
schedule
.
ids
.
includes
(
section
.
dataset
.
crn
))
{
this
.
schedule
.
removeFromSchedule
(
section
.
dataset
.
crn
);
section
.
classList
.
remove
(
'
selected
'
);
}
else
{
this
.
schedule
.
addToSchedule
(
section
.
cloneNode
(
true
));
section
.
classList
.
add
(
'
selected
'
);
}
}
const
addToSchedule
=
(
event
,
section
)
=>
{
section
.
classList
.
add
(
'
selected
'
);
this
.
schedule
.
addToSchedule
(
section
.
cloneNode
(
true
));
event
.
stopPropagation
();
};
/**
* Removes a given section from the schedule
* @param {Node} DOM Node of the Section in the schedule
*/
const
removeFromSchedule
=
section
=>
{
const
sectionInSearch
=
this
.
search
.
sectionWithCrn
(
section
.
dataset
.
crn
);
const
sectionInSearch
=
sectionWithCrn
(
section
.
dataset
.
crn
);
if
(
sectionInSearch
)
{
sectionInSearch
.
classList
.
remove
(
'
selected
'
);
}
this
.
schedule
.
removeFromSchedule
(
section
.
dataset
.
crn
);
};
/**
* Toggles the display of the schedule
*/
const
toggleSections
=
course
=>
{
const
sections
=
course
.
querySelector
(
'
#sections
'
);
if
(
sections
.
style
.
display
===
'
block
'
)
{
...
...
@@ -33,6 +43,10 @@ const toggleSections = course => {
}
};
/**
* Generates a webcal:// URL for the current sections in the schedule
* and sets the link in the modal to it.
*/
const
setUrlInModal
=
()
=>
{
document
.
getElementById
(
'
calendar-link
'
).
innerText
=
`https://
${
window
.
location
.
hostname
}
/api/schedule?crns=
${
this
.
schedule
.
ids
.
join
(
'
,
'
)}
`
;
};
schedules/app/assets/stylesheets/application.scss
View file @
9821b71c
...
...
@@ -43,6 +43,11 @@ body {
background-color
:
lightgreen
;
}
.list-group-item.selected
:hover
{
transition
:
0
.15s
;
background-color
:
red
;
}
.schedule-section-card
:hover
{
transition
:
0
.15s
;
background-color
:
red
;
...
...
schedules/app/views/shared/_cart.html.erb
View file @
9821b71c
...
...
@@ -10,7 +10,7 @@
<%=
render
partial:
'shared/section'
,
collection:
@cart
,
locals:
{
in_cart:
true
}
%>
</ul>
<div
class=
"card-body"
>
<button
type=
"button"
class=
"btn btn-primary"
data-toggle=
"modal"
data-target=
"#ex
ample
Modal"
onclick=
"setUrlInModal()"
>
<button
type=
"button"
class=
"btn btn-primary"
data-toggle=
"modal"
data-target=
"#ex
port
Modal"
onclick=
"setUrlInModal()"
>
Export schedule
</button>
</div>
...
...
@@ -23,11 +23,11 @@
<!-- Export Modal -->
<div
class=
"modal fade"
id=
"ex
ample
Modal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"ex
ample
ModalLabel"
aria-hidden=
"true"
>
<div
class=
"modal fade"
id=
"ex
port
Modal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"ex
port
ModalLabel"
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
role=
"document"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<h5
class=
"modal-title"
id=
"ex
ample
ModalLabel"
>
Your calendar has been generated!
</h5>
<h5
class=
"modal-title"
id=
"ex
port
ModalLabel"
>
Your calendar has been generated!
</h5>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
>
<span
aria-hidden=
"true"
>
×
</span>
</button>
...
...
schedules/app/views/shared/_course.html.erb
View file @
9821b71c
...
...
@@ -11,8 +11,15 @@
<p
class=
"description"
>
<%=
course
.
description
%>
</p>
<%
unless
course
.
prereqs
.
nil?
||
course
.
prereqs
.
empty?
%>
<%
first
,
rest
=
course
.
prereqs
.
split
(
':'
)
%>
<%
prereqs
,
note
=
rest
.
split
(
'.'
)
%>
<p><strong>
<%=
first
%>
:
</strong>
<%=
prereqs
%>
<sub>
<%=
note
%>
</sub></p>
<%
end
%>
<div
class=
"d-block"
style=
"text-align: center"
>
<i
class=
"fas fa-chevron-down"
></i>
<p
style=
"margin-bottom:-4px; font-size: 10px;"
>
Expand
</p>
<i
class=
"fas fa-chevron-down"
></i>
</div>
<!-- List of Course Sections -->
...
...
schedules/app/views/shared/_section.html.erb
View file @
9821b71c
...
...
@@ -16,7 +16,7 @@
<li
id=
"section-
<%=
section
.
crn
%>
"
class=
"list-group-item section-item
<%=
"selected"
if
@cart
.
include?
section
%>
"
data-crn=
"
<%=
section
.
crn
%>
"
onclick=
"add
To
Schedule(event, this)"
onclick=
"add
OrRemoveFrom
Schedule(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>
...
...
schedules/db/courses_loader.rb
View file @
9821b71c
...
...
@@ -22,12 +22,15 @@ def get_courses(subj)
description
=
course
.
css
(
'.courseblockdesc'
).
text
prereqs
=
course
.
css
(
'p.prereq'
).
text
{
subject:
subj
,
title:
name
,
course_number:
num
,
credits:
credits_num
,
description:
description
description:
description
,
prereqs:
prereqs
}
end
end
schedules/db/migrate/20180927133105_add_prereqs_to_courses.rb
0 → 100644
View file @
9821b71c
class
AddPrereqsToCourses
<
ActiveRecord
::
Migration
[
5.1
]
def
change
add_column
:courses
,
:prereqs
,
:string
end
end
schedules/db/migrate/20180927140017_remove_columns_from_course.rb
0 → 100644
View file @
9821b71c
class
RemoveColumnsFromCourse
<
ActiveRecord
::
Migration
[
5.1
]
def
change
remove_columns
:courses
,
:prerequisite
,
:restrictions
end
end
schedules/db/schema.rb
View file @
9821b71c
...
...
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201809
14210918
)
do
ActiveRecord
::
Schema
.
define
(
version:
201809
27140017
)
do
create_table
"closures"
,
force: :cascade
do
|
t
|
t
.
date
"date"
...
...
@@ -51,9 +51,8 @@ ActiveRecord::Schema.define(version: 20180914210918) do
t
.
datetime
"updated_at"
,
null:
false
t
.
string
"description"
t
.
string
"credits"
t
.
string
"prerequisite"
t
.
string
"restrictions"
t
.
string
"title"
t
.
string
"prereqs"
t
.
index
[
"semester_id"
],
name:
"index_courses_on_semester_id"
end
...
...
schedules/db/seeds.rb
View file @
9821b71c
...
...
@@ -30,6 +30,7 @@ def load_courses(courses, semester)
course_number:
course
[
:course_number
],
credits:
course
[
:credits
],
description:
course
[
:description
],
prereqs:
course
[
:prereqs
],
semester:
semester
}
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment