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
90617364
Commit
90617364
authored
Sep 23, 2018
by
Zac Wood
Browse files
Merge branch 'dev-v2' into 26-model-filters
parents
fc66554a
ea5409e8
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
schedules/app/assets/javascripts/search.js
View file @
90617364
...
...
@@ -4,7 +4,7 @@
class
Schedule
{
constructor
()
{
this
.
isOpen
=
false
;
this
.
_ids
=
Array
.
from
(
document
.
getElementById
(
'
schedule
'
).
children
).
map
(
e
=>
Number
(
e
.
id
.
split
(
'
-
'
)[
1
])
);
this
.
_ids
=
Array
.
from
(
document
.
getElementById
(
'
schedule
'
).
children
).
map
(
e
=>
e
.
dataset
.
crn
);
}
get
ids
()
{
...
...
@@ -51,7 +51,7 @@ class Schedule {
const
section
=
cart
.
querySelector
(
`#section-
${
id
}
`
);
cart
.
removeChild
(
section
);
this
.
ids
=
this
.
ids
.
filter
(
_id
=>
_id
!=
Number
(
id
)
)
;
this
.
ids
=
this
.
ids
.
filter
(
_id
=>
_id
!=
id
);
}
_constructSectionCard
(
section
)
{
...
...
@@ -70,8 +70,8 @@ class Schedule {
}
class
Search
{
sectionWith
Id
(
sectionId
)
{
return
document
.
getElementById
(
'
search-list
'
).
querySelector
(
`
#
${
sectionId
}
`
);
sectionWith
Crn
(
crn
)
{
return
document
.
getElementById
(
'
search-list
'
).
querySelector
(
`
[data-crn="
${
crn
}
"]
`
);
}
}
...
...
@@ -80,14 +80,13 @@ const toggleSchedule = () => this.schedule.toggle();
const
addToSchedule
=
(
event
,
section
)
=>
{
section
.
classList
.
add
(
'
selected
'
);
// this.schedule.addToSchedule(JSON.parse(section.dataset.section));
this
.
schedule
.
addToSchedule
(
section
.
cloneNode
(
true
));
event
.
stopPropagation
();
};
const
removeFromSchedule
=
section
=>
{
this
.
search
.
sectionWith
Id
(
section
.
i
d
).
classList
.
remove
(
'
selected
'
);
this
.
search
.
sectionWith
Crn
(
section
.
d
ataset
.
crn
).
classList
.
remove
(
'
selected
'
);
this
.
schedule
.
removeFromSchedule
(
section
.
id
.
split
(
'
-
'
)[
1
]);
};
...
...
@@ -115,8 +114,3 @@ const addToSystemCalendar = async () => {
const
url
=
`webcal://
${
window
.
location
.
hostname
}
/api/schedule?crns=
${
this
.
schedule
.
ids
.
join
(
'
,
'
)}
`
;
window
.
open
(
url
,
'
_self
'
);
};
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
this
.
schedule
=
new
Schedule
();
this
.
search
=
new
Search
();
});
schedules/app/controllers/search_controller.rb
View file @
90617364
...
...
@@ -6,7 +6,6 @@ class SearchController < ApplicationController
end
def
update
puts
params
[
:ids
]
cookies
[
:ids
]
=
params
[
:ids
]
end
end
schedules/app/views/home/index.html.erb
View file @
90617364
<%=
render
partial:
'shared/navbar'
%>
<h1>
Home#index
</h1>
<p>
Find me in app/views/home/index.html.erb
</p>
schedules/app/views/layouts/application.html.erb
View file @
90617364
<!DOCTYPE html>
<html>
<head>
<title>
Schedules
</title>
<%=
csrf_meta_tags
%>
<link
href=
"https://srct.gmu.io/masonstrap/css/masonstrap.min.css"
rel=
"stylesheet"
>
<script
src=
"https://srct.gmu.io/masonstrap/js/masonstrap.min.js"
></script>
<head>
<title>
Schedules
</title>
<%=
csrf_meta_tags
%>
<link
href=
"https://srct.gmu.io/masonstrap/css/masonstrap.min.css"
rel=
"stylesheet"
>
<script
src=
"https://srct.gmu.io/masonstrap/js/masonstrap.min.js"
></script>
<%=
stylesheet_link_tag
'application'
,
media:
'all'
,
'data-turbolinks-track'
:
'reload'
%>
<%=
javascript_include_tag
'application'
,
'data-turbolinks-track'
:
'reload'
%>
</head>
<%=
stylesheet_link_tag
'application'
,
media:
'all'
,
'data-turbolinks-track'
:
'reload'
%>
<%=
javascript_include_tag
'application'
,
'data-turbolinks-track'
:
'reload'
%>
</head>
<body>
<%=
yield
%>
</body>
<body>
<%=
render
partial:
'shared/navbar'
%>
<%=
yield
%>
<%=
render
partial:
'shared/cart'
%>
</body>
</html>
schedules/app/views/search/index.html.erb
View file @
90617364
<%=
render
partial:
'shared/navbar'
%>
<div
class=
"container-fluid"
>
<!-- The main screen consists of a row with two columns: the search results, and the cart -->
<div
class=
"row"
>
<!-- Search result, List of Courses -->
<div
class=
"col-lg-7 col-md-10 mx-auto order-2 order-lg-0"
id=
"search-list"
>
<%
if
@courses
.
any?
%>
<%=
render
partial:
'shared/course'
,
collection:
@courses
%>
<%
else
%>
<h1>
Sorry, we couldn't find anything matching your search.
</h1>
<p>
Please try again!
</p>
<%
end
%>
</div>
<!-- List of sections in the cart -->
<div
class=
"col order-1 order-lg-1"
id=
"cart"
>
<div
class=
"card"
>
<div
class=
"card-body"
>
<h3
class=
"card-title"
>
Your Schedule
</h3>
</div>
<ul
class=
"list-group list-group-flush"
id=
"schedule"
>
<%=
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=
"#exampleModal"
onclick=
"setUrlInModal()"
>
Export schedule
</button>
</div>
</div>
</div>
</div>
</div>
<%
if
@courses
.
any?
%>
<%=
render
partial:
'shared/course'
,
collection:
@courses
%>
<%
else
%>
<h1>
Sorry, we couldn't find anything matching your search.
</h1>
<p>
Please try again!
</p>
<%
end
%>
<!-- Export Modal -->
<div
class=
"modal fade"
id=
"exampleModal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"exampleModalLabel"
aria-hidden=
"true"
>
...
...
@@ -71,3 +43,10 @@
</div>
</div>
</div>
<%=
javascript_tag
do
%>
document.addEventListener('DOMContentLoaded', () => {
this.schedule = new Schedule();
this.search = new Search();
});
<%
end
%>
schedules/app/views/shared/_cart.html.erb
0 → 100644
View file @
90617364
</div>
<!-- List of sections in the cart -->
<div
class=
"col order-1 order-lg-1"
id=
"cart"
>
<div
class=
"card"
>
<div
class=
"card-body"
>
<h3
class=
"card-title"
>
Your Schedule
</h3>
</div>
<ul
class=
"list-group list-group-flush"
id=
"schedule"
>
<%=
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=
"#exampleModal"
onclick=
"setUrlInModal()"
>
Export schedule
</button>
</div>
</div>
</div>
</div>
</div>
schedules/app/views/shared/_navbar.html.erb
View file @
90617364
<div
class=
"container-fluid"
>
<div
class=
"row align-left align-sm-center align-md-right"
id=
"navbar"
>
<div
class=
"col-8 col-sm align-center"
>
<a
href=
"/
search
"
id=
"logo"
>
<a
href=
"/"
id=
"logo"
>
<i
class=
"fas fa-calendar-alt"
></i>
Schedules
</a>
...
...
@@ -9,7 +9,6 @@
<div
class=
"col-4 col-sm align-center order-0 order-sm-1"
onclick=
"toggleSchedule()"
>
<h1
style=
"margin-top:24px"
>
<!-- <h2><i class="fas fa-shopping-cart" id="schedule-icon"></i></h2> -->
<span
class=
"fa-layers fa-fw"
id=
"schedule-icon"
>
<i
class=
"fas fa-shopping-cart"
></i>
<span
class=
"fa-layers fa-fw"
>
...
...
@@ -38,3 +37,10 @@
</div>
</div>
</div>
<div
class=
"container-fluid"
>
<!-- The main screen consists of a row with two columns: the search results, and the cart -->
<div
class=
"row"
>
<!-- Search result, List of Courses -->
<div
class=
"col-lg-7 col-md-10 mx-auto order-2 order-lg-0"
id=
"search-list"
>
schedules/yarn.lock
View file @
90617364
This diff is collapsed.
Click to expand it.
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