Skip to content

Commit

Permalink
added delete button to front page since I only had it on my show pages
Browse files Browse the repository at this point in the history
  • Loading branch information
add2point71dots committed Mar 26, 2017
1 parent e2264ec commit ff4ebf7
Show file tree
Hide file tree
Showing 7 changed files with 1,006 additions and 13 deletions.
6 changes: 5 additions & 1 deletion app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,14 @@ li a + a {
color: #000;
}

li a + a:hover {
li a:nth-child(2):hover {
color: #808080;
}

li a:last-child:hover {
color: red;
}

/*** forms ***/
form.new_task, form.edit_task {
width: 95%;
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/tasks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def new

def create
task = Task.create task_params
task.deadline ||= Time.now
task.save
redirect_to tasks_path unless task.id == nil
end

Expand Down
12 changes: 7 additions & 5 deletions app/views/tasks/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<main>
<h2>Tasks</h2>

<ul>
<% @tasks.each do |task| %>
<li>
Expand All @@ -9,12 +8,15 @@
<% else %>
<%= link_to raw("&#9744;"), toggle_complete_path(task.id), method: :patch %>
<% end %>

<%= link_to task.name, task_path(task.id) %>
<%=
link_to "[delete]", delete_task_path(task.id),
data: { confirm: "Are you sure you want to delete this task?" },
method: :delete
%>
</li>
<% end %>
</ul>

<p>
<%= link_to "Add New Task", new_task_path %>
</p>
<p><%= link_to "Add New Task", new_task_path %></p>
</main>
4 changes: 2 additions & 2 deletions app/views/tasks/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<h2>Add New Task</h2>

<%= render partial: "form", locals: { action_name: "Add"} %>

<p><%= link_to "Back to tasks", tasks_path %></p>
<p><%= link_to "Back to Tasks", tasks_path %></p>
</main>
9 changes: 4 additions & 5 deletions app/views/tasks/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,28 @@
<main>
<h2>
<%= @task.name %>

<% if @task.completed %>
<%= link_to raw("&#9745;"), toggle_complete_path, method: :patch %>
<% else %>
<%= link_to raw("&#9744;"), toggle_complete_path, method: :patch %>
<% end %>
</h2>

<p><%= @task.description %></p>

<p>
<% if @task.completed %>
<p><%= @task.completed.strftime("Completed on: %m/%d/%Y") %> &check;</p>
<% else %>
<p><%= @task.deadline.strftime("Deadline: %m/%d/%Y") %></p>
<% end %>
</p>

<p>
<%= link_to "Edit Task", edit_task_path %>
<%= link_to "[edit task]", edit_task_path %>
<%=
link_to "Delete Task", delete_task_path,
link_to "[delete task]", delete_task_path,
data: { confirm: "Are you sure you want to delete this task?" },
method: :delete
%>
<%= link_to "Back to Tasks", tasks_path %>
</p>
</main>
Binary file modified db/development.sqlite3
Binary file not shown.
986 changes: 986 additions & 0 deletions log/development.log

Large diffs are not rendered by default.

0 comments on commit ff4ebf7

Please sign in to comment.