Commit ea5409e8 authored by Zac Wood's avatar Zac Wood
Browse files

split view into partials

parent cfe2d499
Pipeline #2973 passed with stage
in 2 minutes and 13 seconds
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
class Schedule { class Schedule {
constructor() { constructor() {
this.isOpen = false; this.isOpen = false;
this._ids = Array.from(document.getElementById('schedule').children).map(e => Number(e.dataset.crn)); this._ids = Array.from(document.getElementById('schedule').children).map(e => e.dataset.crn);
} }
get ids() { get ids() {
...@@ -51,7 +51,7 @@ class Schedule { ...@@ -51,7 +51,7 @@ class Schedule {
const section = cart.querySelector(`#section-${id}`); const section = cart.querySelector(`#section-${id}`);
cart.removeChild(section); cart.removeChild(section);
this.ids = this.ids.filter(_id => _id != Number(id)); this.ids = this.ids.filter(_id => _id != id);
} }
_constructSectionCard(section) { _constructSectionCard(section) {
......
...@@ -6,7 +6,6 @@ class SearchController < ApplicationController ...@@ -6,7 +6,6 @@ class SearchController < ApplicationController
end end
def update def update
puts params[:ids]
cookies[:ids] = params[:ids] cookies[:ids] = params[:ids]
end end
end end
<%= render partial: 'shared/navbar' %>
<h1>Home#index</h1> <h1>Home#index</h1>
<p>Find me in app/views/home/index.html.erb</p> <p>Find me in app/views/home/index.html.erb</p>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>Schedules</title> <title>Schedules</title>
<%= csrf_meta_tags %> <%= csrf_meta_tags %>
<link href="https://srct.gmu.io/masonstrap/css/masonstrap.min.css" rel="stylesheet"> <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> <script src="https://srct.gmu.io/masonstrap/js/masonstrap.min.js"></script>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head> </head>
<body> <body>
<%= yield %> <%= render partial: 'shared/navbar' %>
</body> <%= yield %>
<%= render partial: 'shared/cart'%>
</body>
</html> </html>
<%= render partial: 'shared/navbar' %> <% if @courses.any? %>
<%= render partial: 'shared/course', collection: @courses %>
<div class="container-fluid"> <% else %>
<!-- The main screen consists of a row with two columns: the search results, and the cart --> <h1>Sorry, we couldn't find anything matching your search.</h1>
<div class="row"> <p>Please try again!</p>
<% end %>
<!-- 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>
<!-- Export Modal --> <!-- Export Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
......
</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>
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
<div class="col-4 col-sm align-center order-0 order-sm-1" onclick="toggleSchedule()"> <div class="col-4 col-sm align-center order-0 order-sm-1" onclick="toggleSchedule()">
<h1 style="margin-top:24px"> <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"> <span class="fa-layers fa-fw" id="schedule-icon">
<i class="fas fa-shopping-cart"></i> <i class="fas fa-shopping-cart"></i>
<span class="fa-layers fa-fw"> <span class="fa-layers fa-fw">
...@@ -38,3 +37,10 @@ ...@@ -38,3 +37,10 @@
</div> </div>
</div> </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">
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment