Added project model; added views for viewing and adding projects
This commit is contained in:
53
views/project/add.erb
Normal file
53
views/project/add.erb
Normal file
@ -0,0 +1,53 @@
|
||||
<div class="grid-x grid-margin-x">
|
||||
<div class="cell small-12">
|
||||
<h1>Add new project</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid-x grid-margin-x">
|
||||
|
||||
<form class="cell small-12" action="/project/add" method="post">
|
||||
<div class="grid-x grid-padding-x">
|
||||
<div class="cell small-12">
|
||||
<label for="project_name">
|
||||
Project name
|
||||
<input id="project_name" type="text" name="project_name" placeholder="Example hardware">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="cell small-12">
|
||||
<label for="project_description">
|
||||
Project description:
|
||||
<textarea id="project_description" cols="30" rows="10" name="project_description"></textarea>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid-x grid-padding-x">
|
||||
<div class="cell small-12 medium-6">
|
||||
<label for="project_hardware">
|
||||
Project hardware:
|
||||
<select id="project_hardware" name="project_hardware[]" multiple>
|
||||
<% hardware.each do |h| %>
|
||||
<option value="<%= h.id %>"><%= h.name %></option>
|
||||
<% end %>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="cell small-12 medium-6">
|
||||
<label for="project_benchmarks">
|
||||
Project benchmarks:
|
||||
<select id="project_benchmarks" name="project_benchmarks[]" multiple>
|
||||
<% benchmarks.each do |b| %>
|
||||
<option value="<%= b.id %>"><%= b.name %></option>
|
||||
<% end %>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="submit" class="button" value="Submit">
|
||||
</form>
|
||||
|
||||
</div>
|
40
views/project/index.erb
Normal file
40
views/project/index.erb
Normal file
@ -0,0 +1,40 @@
|
||||
<div class="grid-x grid-margin-x">
|
||||
<div class="cell small-12">
|
||||
<h1>List of projects</h1>
|
||||
</div>
|
||||
|
||||
<div class="cell small-12">
|
||||
<p>
|
||||
<a href="/project/add">Add new project</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid-x grid-margin-x">
|
||||
<% if projects.length > 0 %>
|
||||
<div class="cell small-12">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Project name</th>
|
||||
<th>Date added</th>
|
||||
<th>Date modified</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% projects.each do |p| %>
|
||||
<tr>
|
||||
<td><a href="/project/<%= p.id %>"><%= p.name %></a></td>
|
||||
<td><%= date_format(p.created_at) %></td>
|
||||
<td><%= date_format(p.updated_at) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="cell small-12">
|
||||
<p>I'm sorry, there doesn't appear to be any projects added yet. Check again later!</p>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
39
views/project/view.erb
Normal file
39
views/project/view.erb
Normal file
@ -0,0 +1,39 @@
|
||||
<div class="grid-x grid-margin-x">
|
||||
<div class="cell small-12">
|
||||
<h1><%= project.name %></h1>
|
||||
</div>
|
||||
|
||||
<div class="cell small-12">
|
||||
<p>
|
||||
<a href="/project/<%= project.id %>/edit/">Edit project</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid-x grid-margin-x">
|
||||
|
||||
<div class="cell small-6">
|
||||
<h3>Hardware:</h3>
|
||||
<ul>
|
||||
<% project.hardware.each do |h| %>
|
||||
<li><%= h.name %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="cell small-6">
|
||||
<h3>Benchmarks:</h3>
|
||||
<ul>
|
||||
<% project.benchmarks.each do |b| %>
|
||||
<li><%= b.name %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="grid-x grid-margin-x">
|
||||
<h3>Project description:</h3>
|
||||
|
||||
<p><%= project.description %></p>
|
||||
</div>
|
Reference in New Issue
Block a user