/
index.html.erb
112 lines (87 loc) · 2.8 KB
/
index.html.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<div id='tabs'>
<ul>
<% @count = 1%>
<% @lists.each do |list| %>
<li>
<a href="<%= '#' + 'tabs-' + @count.to_s %>"><%= list.name.capitalize %></a>
</li>
<% @count += 1%>
<% end %>
<li>
<a href="#tabs-new-list">Add List +</a>
</li>
</ul>
<% @count = 1%>
<% @lists.each do |list| %>
<div id='tabs-<%= @count %>' class="tab">
<div class="new-task">
<%= simple_form_for(@task, :url => list_tasks_url(list)) do |f| %>
<%= f.input :done , :as => :hidden, :input_html => {:value => false }%>
<%= f.input :list_id , :as => :hidden, :input_html => {:value => list.id }%>
<div class="split-fields">
<div class="field">
<%= f.input :name , :label => false, :placeholder => "Enter a new task" %>
</div>
<div class="button">
<%= f.button :submit, "Add Task" %>
</div>
</div>
<% end %>
</div>
<% unless list.tasks.empty? %>
<ul class="tasks pending-tasks">
<% list.tasks.each do |task| %>
<% unless task.done %>
<%= simple_form_for(task, :url => list_task_url(list, task)) do |f| %>
<li>
<%= f.input :done , :input_html => { :class => 'box' } , :label => false %>
<%= f.button :submit , :class => 'hidden' %>
<%= raw auto_link( h(task.name), :html => { :target => '_blank' }) %>
<p class="delete-task">
<%= link_to 'X', list_task_url(list, task), :confirm => 'Are you sure?', :method => :delete %>
</p>
</li>
<% end %>
<% end %>
<% end %>
</ul>
<% end %>
<% unless list.done_tasks.empty? %>
<ul class="tasks finished-tasks">
<% list.done_tasks.each do |task| %>
<li class="finished">
<%= raw auto_link( h(task.name), :html => { :target => '_blank' }) %>
<p class="delete-task">
<%= link_to 'X', list_task_url(list, task), :confirm => 'Are you sure?', :method => :delete %>
</p>
</li>
<% end %>
</ul>
<% end %>
<p class="delete-list">
<%= link_to 'Delete this list', list, :confirm => 'Are you sure?', :method => :delete %>
</p>
</div>
<% @count += 1%>
<%end%>
<div id="tabs-new-list">
<h2>Add a New Task List</h2>
<%= render :partial => '/lists/form' %>
</div>
</div>
<% if listid = params[:list_id] %>
<% prevlist = List.find listid %>
<% tabindex = @lists.index(prevlist) %>
<% end %>
<script>
$('.box').click(function(event) {
$(this).parent().next().click();
});
$(function() {
var opts = {};
<% if params[:list_id] %>
opts.selected = <%= tabindex %>
<% end %>
$( "#tabs" ).tabs(opts);
});
</script>