Commit 8e0b4f45 authored by Zach Perkins's avatar Zach Perkins
Browse files

Finished toying with front-end to make way for filtering

parent 7822496c
...@@ -28,32 +28,27 @@ body { ...@@ -28,32 +28,27 @@ body {
box-shadow: 0 0 5px rgba(0,0,0,0.2); box-shadow: 0 0 5px rgba(0,0,0,0.2);
transition: 0.3s; transition: 0.3s;
ul.attr-list {
list-style-type: none;
margin: 0;
padding: 0;
li {
&:nth-child(odd) {
float: left;
clear: left;
}
&:nth-child(even) {
float: right;
clear: right;
}
}
}
.card-header { .card-header {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.card-body { .card-body {
.attr-list {
display: flex;
flex-direction: row;
justify-content: flex-start;
padding-bottom: 10px;
.attr {
margin-right: 13px;
}
} }
}
}
.unpadded {
padding: 0px;
} }
/* On mouse-over, add a deeper shadow */ /* On mouse-over, add a deeper shadow */
......
module CoursesHelper module CoursesHelper
end end
...@@ -47,12 +47,11 @@ module SearchHelper ...@@ -47,12 +47,11 @@ module SearchHelper
subj = nil subj = nil
query_string.scan(/(?<= |^)([a-zA-Z]{2,4})(?=$| )/).each do |a| query_string.scan(/(?<= |^)([a-zA-Z]{2,4})(?=$| )/).each do |a|
s = a[0] s = a[0]
if get_count(Course.from_subject(base_query, s)).positive? next unless get_count(Course.from_subject(base_query, s)).positive?
subj = s subj = s
base_query = Course.from_subject(base_query, subj) base_query = Course.from_subject(base_query, subj)
query_string.remove!(s) query_string.remove!(s)
end end
end
query_string.scan(/(?<= |^)(\d{3})(?=$| )/).each do |a| query_string.scan(/(?<= |^)(\d{3})(?=$| )/).each do |a|
s = a[0] s = a[0]
...@@ -64,17 +63,16 @@ module SearchHelper ...@@ -64,17 +63,16 @@ module SearchHelper
stripped_query_string = query_string.gsub(/ +/, " ").strip stripped_query_string = query_string.gsub(/ +/, " ").strip
# There's more to parse # There's more to parse
if stripped_query_string.length.positive? base_query = if stripped_query_string.length.positive?
base_query = Course.from_title(base_query, stripped_query_string) Course.from_title(base_query, stripped_query_string)
.order("section_count DESC") .order("section_count DESC")
else else
base_query = base_query.order("courses.course_number ASC") base_query.order("courses.course_number ASC")
end end
base_query.all base_query.all
end end
# Given a set of models, create a list of GenericItems for each model's data # Given a set of models, create a list of GenericItems for each model's data
def self.build_list(models) def self.build_list(models)
list = [] list = []
...@@ -90,7 +88,7 @@ module SearchHelper ...@@ -90,7 +88,7 @@ module SearchHelper
ActiveRecord::Base.connection.execute("SELECT COUNT(*) AS count FROM (#{base_query.to_sql})")[0]["count"] ActiveRecord::Base.connection.execute("SELECT COUNT(*) AS count FROM (#{base_query.to_sql})")[0]["count"]
end end
def to_s() def to_s
@type @type
end end
end end
......
...@@ -2,16 +2,15 @@ ...@@ -2,16 +2,15 @@
<div class="card" id="course-<%= course.id %>" onclick="toggleSections(this)"> <div class="card" id="course-<%= course.id %>" onclick="toggleSections(this)">
<div class="card-header"> <div class="card-header">
<h3><%= "#{course.subject} #{course.course_number}" %></h3> <h4><%= "#{course.subject} #{course.course_number}" %></h4>
<h5><em><%= course.title %></em>. <%= course.credits %> credits.</h5> <h5><em><%= course.title %></em>. <%= course.credits %> credits.</h5>
</div> </div>
<div class="card-body"> <div class="card-body">
<div> <div class="attr-list">
<ul class="attr-list"> <div class="attr"><i class="fa fa-book"></i> 3 credits</div>
<li><i class="fa fa-book"></i></li> <div class="attr"><i class="fa fa-bars"></i> 3 sections</div>
</ul>
</div> </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(':') %>
......
<div class="card"> <div class="card">
<div class="card-header">
<h4><%= "#{instructor.name}" %></h4>
</div>
<div class="card-body"> <div class="card-body">
<h3><%= "#{instructor.name}" %></h3> <div class="attr-list">
<ul class="attr-list"> <div class="attr"><i class="fa fa-user"></i> Instructor</div>
<li><i class="fa fa-user"></i> Instructor</li> <div class="attr"><i class="fa fa-bars"></i> <%= "#{instructor.section_count}" %> sections</div>
<li><i class="fa fa-bars"></i> <%= "#{instructor.section_count}" %> sections</li> </div>
</ul>
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -17,12 +17,24 @@ ...@@ -17,12 +17,24 @@
class="list-group-item section-item <%= "selected" if @cart.include? section %>" class="list-group-item section-item <%= "selected" if @cart.include? section %>"
data-crn="<%= section.crn %>" data-crn="<%= section.crn %>"
onclick="addOrRemoveFromSchedule(event, this)"> onclick="addOrRemoveFromSchedule(event, this)">
<ul class="attr-list"> <div class="unpadded container">
<li><b class="subj"><%= "#{section.name}" %></b>: <%= section.title %></li> <div class="row">
<li><i class="fas fa-map-marker-alt"></i> <%= section.location %></li> <div class="col">
<li><i class="fas fa-chalkboard-teacher"></i> <%= link_to section.instructor.name, instructor_path(section.instructor) %> </li> <b class="subj"><%= "#{section.name}" %></b>: <%= section.title %>
<li><i class="fas fa-clock"></i> <%= "#{section.days}, #{section.start_time}-#{section.end_time}" %></li> </div>
</ul> <div class="col text-right">
<i class="fas fa-map-marker-alt"></i> <%= section.location %>
</div>
</div>
<div class="row">
<div class="col">
<i class="fas fa-chalkboard-teacher"></i> <%= link_to section.instructor.name, instructor_path(section.instructor) %>
</div>
<div class="col text-right">
<i class="fas fa-clock"></i> <%= "#{section.days}, #{section.start_time}-#{section.end_time}" %>
</div>
</div>
</div>
</div> </div>
<% end %> <% end %>
......
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