Permalink
Browse files

Add delete input

  • Loading branch information...
rociopaez committed Sep 27, 2014
1 parent 23bec20 commit f7ded06801a21b5f209c0343871bfff40b1c5703
Showing with 72 additions and 20 deletions.
  1. +6 −0 routes/outputs.rb
  2. +66 −20 views/outputs/index.mote
@@ -17,6 +17,12 @@ class Outputs < Cuba
on get do
render("outputs/edit", title: "Edit Output", output: output)
end

on "delete", post do
output.delete

res.redirect("/outputs")
end
end

on post, param("output") do |params|
@@ -1,25 +1,71 @@
% outputs = params[:outputs]

<h2><a href="/outputs/new">New Output</a></h2>
<div class="forms">
<form action="/outputs" method="POST">
<select name="output[date_month]">
<optgroup label="Month">
% 1.upto(12).each do |i|
<option{{ ' selected="selected"' if Time.now.month == i }}>{{ i }}</option>
% end
</optgroup>
</select>
<select name="output[date_day]">
<optgroup label="Day">
% 1.upto(31).each do |i|
<option{{ ' selected="selected"' if Time.now.day == i }}>{{ i }}</option>
% end
</optgroup>
</select>
<select name="output[date_year]">
<optgroup label="Year">
% this_year = Time.now.year
% start_year = this_year - 2
% start_year.upto(this_year).each do |i|
<option{{ ' selected="selected"' if Time.now.year == i }}>{{ i }}</option>
% end
</optgroup>
</select>
<select name="output[scale]">
<optgroup label="Pain Scale">
% 1.upto(10).each do |i|
<option>{{ i }}</option>
% end
</optgroup>
</select>
<select name="output[duration]">
<optgroup label="Duration">
% Output::DURATIONS.each do |duration, description|
<option value="{{ duration }}">{{ description }}</option>
% end
</optgroup>
</select>
<input type="submit" value="Add Output">
</form>

<h2>Your Output Types record:</h2>
<table class="output">
<thead>
<tr>
<th>Date</th>
<th class="output">Duration minutes</th>
<th>Scale</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
% outputs.each do |output|

<table class="output">
<thead>
<tr>
<td>{{output.date}}</td>
<td>{{output.duration}}</td>
<td>{{output.scale}}</td>
<td><a href="/outputs/{{output.id}}">Edit</a></td>
<th>Date</th>
<th class="output">Duration minutes</th>
<th>Scale</th>
<th>Actions</th>
</tr>
% end
</tbody>
</table>
</thead>
<tbody>
% outputs.each do |output|
<tr>
<th>{{output.date}}</th>
<td>{{output.duration}}</td>
<td>{{output.scale}}</td>
<td class="action">
<a href="/outputs/{{output.id}}">Edit</a>
<form action="/outputs/{{output.id}}/delete" method="POST">
<input type="submit" value="delete">
</form>
</td>
</tr>
% end
</tbody>
</table>
</div>

1 comment on commit f7ded06

@rociopaez

This comment has been minimized.

Copy link
Contributor

rociopaez commented on f7ded06 Sep 29, 2014

This is delete an output not input :)

Please sign in to comment.