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 {
box-shadow: 0 0 5px rgba(0,0,0,0.2);
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 {
display: flex;
flex-direction: column;
}
.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 */
......
......@@ -47,12 +47,11 @@ module SearchHelper
subj = nil
query_string.scan(/(?<= |^)([a-zA-Z]{2,4})(?=$| )/).each do |a|
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
base_query = Course.from_subject(base_query, subj)
query_string.remove!(s)
end
end
query_string.scan(/(?<= |^)(\d{3})(?=$| )/).each do |a|
s = a[0]
......@@ -64,17 +63,16 @@ module SearchHelper
stripped_query_string = query_string.gsub(/ +/, " ").strip
# There's more to parse
if stripped_query_string.length.positive?
base_query = Course.from_title(base_query, stripped_query_string)
base_query = if stripped_query_string.length.positive?
Course.from_title(base_query, stripped_query_string)
.order("section_count DESC")
else
base_query = base_query.order("courses.course_number ASC")
base_query.order("courses.course_number ASC")
end
base_query.all
end
# Given a set of models, create a list of GenericItems for each model's data
def self.build_list(models)
list = []
......@@ -90,7 +88,7 @@ module SearchHelper
ActiveRecord::Base.connection.execute("SELECT COUNT(*) AS count FROM (#{base_query.to_sql})")[0]["count"]
end
def to_s()
def to_s
@type
end
end
......
......@@ -2,16 +2,15 @@
<div class="card" id="course-<%= course.id %>" onclick="toggleSections(this)">
<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>
</div>
<div class="card-body">
<div>
<ul class="attr-list">
<li><i class="fa fa-book"></i></li>
</ul>
<div class="attr-list">
<div class="attr"><i class="fa fa-book"></i> 3 credits</div>
<div class="attr"><i class="fa fa-bars"></i> 3 sections</div>
</div>
<p class="description"><%= course.description %>...</p>
<p class="description"><%= course.description %></p>
<% unless course.prereqs.nil? || course.prereqs.empty? %>
<% first, rest = course.prereqs.split(':') %>
......
<div class="card">
<div class="card-header">
<h4><%= "#{instructor.name}" %></h4>
</div>
<div class="card-body">
<h3><%= "#{instructor.name}" %></h3>
<ul class="attr-list">
<li><i class="fa fa-user"></i> Instructor</li>
<li><i class="fa fa-bars"></i> <%= "#{instructor.section_count}" %> sections</li>
</ul>
<div class="attr-list">
<div class="attr"><i class="fa fa-user"></i> Instructor</div>
<div class="attr"><i class="fa fa-bars"></i> <%= "#{instructor.section_count}" %> sections</div>
</div>
</div>
</div>
\ No newline at end of file
......@@ -17,12 +17,24 @@
class="list-group-item section-item <%= "selected" if @cart.include? section %>"
data-crn="<%= section.crn %>"
onclick="addOrRemoveFromSchedule(event, this)">
<ul class="attr-list">
<li><b class="subj"><%= "#{section.name}" %></b>: <%= section.title %></li>
<li><i class="fas fa-map-marker-alt"></i> <%= section.location %></li>
<li><i class="fas fa-chalkboard-teacher"></i> <%= link_to section.instructor.name, instructor_path(section.instructor) %> </li>
<li><i class="fas fa-clock"></i> <%= "#{section.days}, #{section.start_time}-#{section.end_time}" %></li>
</ul>
<div class="unpadded container">
<div class="row">
<div class="col">
<b class="subj"><%= "#{section.name}" %></b>: <%= section.title %>
</div>
<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>
<% 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