Permalink
Browse files

Bootstrapping tasks views

  • Loading branch information...
1 parent 766af26 commit 7ef4971d7118a52c7ffa5e9f1ea5d756c3ab3b12 @zmcartor committed Nov 12, 2012
View
49 app/views/tasks/_form.html.erb
@@ -1,29 +1,32 @@
-<%= form_for(@task) do |f| %>
- <% if @task.errors.any? %>
- <div id="error_explanation">
- <h2><%= pluralize(@task.errors.count, "error") %> prohibited this task from being saved:</h2>
-
- <ul>
- <% @task.errors.full_messages.each do |msg| %>
- <li><%= msg %></li>
- <% end %>
- </ul>
+<%= form_for @task, :html => { :class => 'form-horizontal' } do |f| %>
+ <div class="control-group">
+ <%= f.label :body, :class => 'control-label' %>
+ <div class="controls">
+ <%= f.text_area :body, :class => 'text_area' %>
</div>
- <% end %>
-
- <div class="field">
- <%= f.label :body %><br />
- <%= f.text_area :body %>
</div>
- <div class="field">
- <%= f.label :due %><br />
- <%= f.datetime_select :due %>
+ <div class="control-group">
+ <%= f.label :due, :class => 'control-label' %>
+ <div class="controls">
+ <%= f.datetime_select :due, :class => 'datetime_select' %>
+ </div>
</div>
- <div class="field">
- <%= f.label :completed %><br />
- <%= f.datetime_select :completed %>
+ <div class="control-group">
+ <%= f.label :completed, :class => 'control-label' %>
+ <div class="controls">
+ <%= f.datetime_select :completed, :class => 'datetime_select' %>
+ </div>
</div>
- <div class="actions">
- <%= f.submit %>
+ <div class="control-group">
+ <%= f.label :user_id, :class => 'control-label' %>
+ <div class="controls">
+ <%= f.number_field :user_id, :class => 'number_field' %>
+ </div>
+ </div>
+
+ <div class="form-actions">
+ <%= f.submit nil, :class => 'btn btn-primary' %>
+ <%= link_to t('.cancel', :default => t("helpers.links.cancel")),
+ tasks_path, :class => 'btn' %>
</div>
<% end %>
View
10 app/views/tasks/edit.html.erb
@@ -1,6 +1,4 @@
-<h1>Editing task</h1>
-
-<%= render 'form' %>
-
-<%= link_to 'Show', @task %> |
-<%= link_to 'Back', tasks_path %>
+<%- model_class = @task.class -%>
+<h1><%=t '.title', :default => t('helpers.titles.edit', :model => model_class.model_name.human,
+ :default => "Edit #{model_class.model_name.human}") %></h1>
+<%= render :partial => 'form' %>
View
63 app/views/tasks/index.html.erb
@@ -1,27 +1,40 @@
-<h1>Listing tasks</h1>
-
-<table>
- <tr>
- <th>Body</th>
- <th>Due</th>
- <th>Completed</th>
- <th></th>
- <th></th>
- <th></th>
- </tr>
-
-<% @tasks.each do |task| %>
- <tr>
- <td><%= task.body %></td>
- <td><%= task.due %></td>
- <td><%= task.completed %></td>
- <td><%= link_to 'Show', task %></td>
- <td><%= link_to 'Edit', edit_task_path(task) %></td>
- <td><%= link_to 'Destroy', task, confirm: 'Are you sure?', method: :delete %></td>
- </tr>
-<% end %>
+<%- model_class = Task.new.class -%>
+<h1><%=t '.title', :default => model_class.model_name.human.pluralize %></h1>
+<table class="table table-striped">
+ <thead>
+ <tr>
+ <th><%= model_class.human_attribute_name(:id) %></th>
+ <th><%= model_class.human_attribute_name(:body) %></th>
+ <th><%= model_class.human_attribute_name(:due) %></th>
+ <th><%= model_class.human_attribute_name(:completed) %></th>
+ <th><%= model_class.human_attribute_name(:user_id) %></th>
+ <th><%= model_class.human_attribute_name(:created_at) %></th>
+ <th><%=t '.actions', :default => t("helpers.actions") %></th>
+ </tr>
+ </thead>
+ <tbody>
+ <% @tasks.each do |task| %>
+ <tr>
+ <td><%= link_to task.id, task_path(task) %></td>
+ <td><%= task.body %></td>
+ <td><%= task.due %></td>
+ <td><%= task.completed %></td>
+ <td><%= task.user_id %></td>
+ <td><%=l task.created_at %></td>
+ <td>
+ <%= link_to t('.edit', :default => t("helpers.links.edit")),
+ edit_task_path(task), :class => 'btn btn-mini' %>
+ <%= link_to t('.destroy', :default => t("helpers.links.destroy")),
+ task_path(task),
+ :method => :delete,
+ :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')),
+ :class => 'btn btn-mini btn-danger' %>
+ </td>
+ </tr>
+ <% end %>
+ </tbody>
</table>
-<br />
-
-<%= link_to 'New Task', new_task_path %>
+<%= link_to t('.new', :default => t("helpers.links.new")),
+ new_task_path,
+ :class => 'btn btn-primary' %>
View
9 app/views/tasks/new.html.erb
@@ -1,5 +1,4 @@
-<h1>New task</h1>
-
-<%= render 'form' %>
-
-<%= link_to 'Back', tasks_path %>
+<%- model_class = @task.class -%>
+<h1><%=t '.title', :default => t('helpers.titles.new', :model => model_class.model_name.human,
+ :default => "New #{model_class.model_name.human}") %></h1>
+<%= render :partial => 'form' %>
View
29 app/views/tasks/show.html.erb
@@ -1,20 +1,31 @@
-<p id="notice"><%= notice %></p>
+<%- model_class = @task.class -%>
+<h1><%=t '.title', :default => model_class.model_name.human %></h1>
<p>
- <b>Body:</b>
+ <strong><%= model_class.human_attribute_name(:body) %>:</strong><br>
<%= @task.body %>
</p>
-
<p>
- <b>Due:</b>
+ <strong><%= model_class.human_attribute_name(:due) %>:</strong><br>
<%= @task.due %>
</p>
-
<p>
- <b>Completed:</b>
+ <strong><%= model_class.human_attribute_name(:completed) %>:</strong><br>
<%= @task.completed %>
</p>
+<p>
+ <strong><%= model_class.human_attribute_name(:user_id) %>:</strong><br>
+ <%= @task.user_id %>
+</p>
-
-<%= link_to 'Edit', edit_task_path(@task) %> |
-<%= link_to 'Back', tasks_path %>
+<div class="form-actions">
+ <%= link_to t('.back', :default => t("helpers.links.back")),
+ tasks_path, :class => 'btn' %>
+ <%= link_to t('.edit', :default => t("helpers.links.edit")),
+ edit_task_path(@task), :class => 'btn' %>
+ <%= link_to t('.destroy', :default => t("helpers.links.destroy")),
+ task_path(@task),
+ :method => 'delete',
+ :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')),
+ :class => 'btn btn-danger' %>
+</div>

0 comments on commit 7ef4971

Please sign in to comment.