Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

refactoring tasks views

  • Loading branch information...
commit 5a3b587239293f62ce5e3c72feff32f31fe74fac 1 parent 15f08e3
Francis authored
View
7 app/helpers/tasks_helper.rb
@@ -32,4 +32,11 @@ def time_ago_or_since_in_words(datetime)
"In #{difference}"
end
end
+
+ def task_class(task)
+ [
+ task.done? ? "done" : "todo",
+ task.delayed? && "delayed"
+ ].compact.join(" ")
+ end
end
View
8 app/views/tasks/_task.html.erb
@@ -1,7 +1,9 @@
-<tr id="task_<%= task.id %>" class="task <%= task.done? ? "done" : "todo" %> <%= "delayed" if task.delayed? %>">
- <td class="name"><%= link_to truncate(task.name, :length => 60), task %></td>
+<%= content_tag_for :tr, task, :class => task_class(task) do %>
+ <td class="name">
+ <%= link_to truncate(task.name, :length => 60), task %>
+ </td>
<td class="due_at_and_actions">
<span class="due_at"><%= task.due_at.to_s(:time) %></span>
<%= link_to_destroy_task task %>
</td>
-</tr>
+<% end %>
View
7 app/views/tasks/destroy.js.erb
@@ -1,9 +1,4 @@
-$("#task_<%= @task.id %>").html($("<%= j render @task %>").html())
- .removeClass("todo").removeClass("done").removeClass("delayed")
- <% if @task.delayed? %>
- .addClass("delayed")
- <% end %>
- .addClass("<%= @task.done? ? "done" : "todo" %>");
+$("#task_<%= @task.id %>").replaceWith($("<%= j render @task %>"));
<% Task::SCOPES.each do |show, text| %>
$(".nav.nav-pills.nav-stacked .<%= show %>").html("<%= j render "layouts/link_pill", :show => show, :text => text %>");
Please sign in to comment.
Something went wrong with that request. Please try again.