Skip to content

Commit

Permalink
Start working on the planner
Browse files Browse the repository at this point in the history
  • Loading branch information
JaciBrunning committed Jul 19, 2019
1 parent aff3c1e commit 393eb4f
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 2 deletions.
8 changes: 8 additions & 0 deletions app/controllers/planner_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class PlannerController < ApplicationController
def index
end

def show
@course = Course.find_by_code(params[:course_code])
end
end
2 changes: 2 additions & 0 deletions app/helpers/planner_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module PlannerHelper
end
7 changes: 7 additions & 0 deletions app/javascript/components/Planner.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';

class Planner extends React.Component {

}

export default Planner;
2 changes: 1 addition & 1 deletion app/javascript/components/Search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Search extends React.Component {

select = (e) => {
let selection = e[0]
let url = `${this.props.baseUrl.replace(/\/+$/, '')}/${selection.type}/${selection.code}`
let url = this.props.selectUrl.replace(':type', selection.type).replace(':code', selection.code)
window.location.href = url
}

Expand Down
2 changes: 2 additions & 0 deletions app/views/courses/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<% end %>
</ul>
<% end %>
<br />
<i class="fas fa-tasks">&nbsp;</i> <a href="<%= planner_path(@course.code) %>"> Go to planner </a> </i>
</p>

<%=
Expand Down
10 changes: 9 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<li class="nav-item">
<a class="nav-link" href="<%= info_path %>"> API & Info </a>
</li>
<li class="nav-item">
<a class="nav-link" href="<%= planner_index_path %>"> Planner </a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/JacisNonsense/curtin-courses"> Github <i class="fab fa-github"> &nbsp; </i> </a>
</li>
Expand All @@ -38,7 +41,12 @@
</div>

<ul class="navbar-nav ml-auto">
<li class="nav-item" style="width: 500px;"> <%= react_component("Search", { baseUrl: root_path, searchUrl: api_search_path }) %> </li>
<li class="nav-item" style="width: 500px;">
<%=
react_component("Search", {
selectUrl: File.join(root_path, ':type/:code'),
searchUrl: api_search_path
}) %> </li>
</ul>
</header>

Expand Down
10 changes: 10 additions & 0 deletions app/views/planner/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<h1> Course Planner </h1>

<h4> Please select the course you would like to plan: </h4>
<br />
<%=
react_component("Search", {
searchUrl: api_search_courses_path,
selectUrl: planner_path(':code')
})
%>
27 changes: 27 additions & 0 deletions app/views/planner/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<h1> Course Planner </h1>
<h5> <%= @course.name %> </h5>

<% if @course.streams.count > 0 %>
<br />
<h4> This course has streams. Please select which stream you wish to plan </h4>
<ul class="list-group">
<li class="list-group-item"> <span class="tip" data-toggle="tooltip" data-placement="top" title="Select a stream to see its unit breakdown."><strong>Streams</strong></span> </li>
<% @course.streams.each do |stream| %>
<li class="list-group-item"> <a href="<%= planner_path(stream.code) %>"> <%= stream.code %> - <%= stream.name %> </a> </li>
<% end %>
</ul>
<% else %>

<p>

<i class="fas fa-book">&nbsp;</i> <a href="<%= @course.url %>" target="_blank"> Handbook </a> <br />
<% if @course.stream_parent %>
<i class="fas fa-stream">&nbsp;</i> Stream of <%= @course.stream_parent.code %> - <%= @course.stream_parent.name %><br />
<% end %>
<br />

<i class="fas fa-project-diagram">&nbsp;</i> <a href="<%= course_path(@course.code) %>"> Go to course page </a>
</p>


<% end %>
4 changes: 4 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
get 'legend', to: 'home#legend'
get 'info', to: 'home#info'

resources :planner, only: [:index, :show], param: :course_code do

end

get 'course/:code', to: 'courses#show', as: 'course'
get 'unit/:code', to: 'units#show', as: 'unit'
get 'unit/:code/courses', to: 'units#courses', as: 'unit_courses'
Expand Down
1 change: 1 addition & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
t.string "location"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["unit_id", "year", "period", "location"], name: "unit_avails_idx", unique: true
t.index ["unit_id"], name: "index_unit_availabilities_on_unit_id"
end

Expand Down
7 changes: 7 additions & 0 deletions test/controllers/planner_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'test_helper'

class PlannerControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end

0 comments on commit 393eb4f

Please sign in to comment.