Commit 899bf4a4 authored by Zac Wood's avatar Zac Wood

temporary fix for courses and semesters

parent 2d45d1b3
Pipeline #3318 passed with stage
in 2 minutes and 14 seconds
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
// vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require FileSaver
//= require cart
// require_tree .
// require jquery3
// require popper
// require bootstrap-sprockets
// require rails-ujs
const elementFromString = string => {
const html = new DOMParser().parseFromString(string, 'text/html');
return html.body.firstChild;
......
/**
* Either adds or removes a section from the cart depending on
* if it is currently in the cart.
*/
const addOrRemoveFromCart = async (event, sectionNode) => {
event && event.stopPropagation();
const section = { ...sectionNode.dataset };
await this.cart.addSection(section);
if (this.cart.includesSection(section)) {
sectionNode.classList.add('selected');
} else {
sectionNode.classList.remove('selected');
}
};
const initListeners = () => {
const items = Array.from(document.querySelectorAll('.section-item'));
items.forEach(item => (item.onclick = e => addOrRemoveFromCart(e, item)));
};
document.addEventListener('DOMContentLoaded', initListeners);
......@@ -2,7 +2,11 @@
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
.section-item.selected {
background-color: lightgreen;
}
#add-course-btn:hover {
background-color: rgba(0,0,0,0.2);
.section-item:hover {
transition: 0.15s;
background-color: lightgray;
}
......@@ -15,8 +15,3 @@
transition: 0.15s;
background-color: red;
}
.section-item:hover {
transition: 0.15s;
background-color: red;
}
class CoursesController < ApplicationController
before_action :set_course
def show; end
def show
@course = Course.find_by subject: @course.subject, course_number: @course.course_number, semester: @semester
end
private
......
......@@ -28,3 +28,7 @@
<%= render partial: 'shared/section', collection: @course.course_sections %>
</div>
</div>
<%= javascript_include_tag 'search' %>
<%= stylesheet_link_tag 'search' %>
......@@ -22,3 +22,6 @@
<% end %>
</div>
</div>
<%= javascript_include_tag 'search' %>
<%= stylesheet_link_tag 'search' %>
......@@ -21,6 +21,9 @@ Rails.application.config.assets.precompile += %w(
cart.js
cart.scss
courses.js
courses.scss
FileSaver.js
masonstrap.min.css
masonstrap.min.js
......
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