Description:
change problem toggle to ajax git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@286 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r147:b29d8a0527ac - - 3 files changed: 11 inserted, 8 deleted

@@ -0,0 +1,5
1 + if @problem.available
2 + page["prob-#{@problem.id}"].className = "available"
3 + else
4 + page["prob-#{@problem.id}"].className = "not-available"
5 + end No newline at end of file
@@ -81,11 +81,10
81 redirect_to :action => 'list'
81 redirect_to :action => 'list'
82 end
82 end
83
83
84 - def toggle_avail
84 + def toggle
85 - problem = Problem.find(params[:id])
85 + @problem = Problem.find(params[:id])
86 - problem.available = !(problem.available)
86 + @problem.available = !(@problem.available)
87 - problem.save
87 + @problem.save
88 - redirect_to :action => 'list'
89 end
88 end
90
89
91 def turn_all_off
90 def turn_all_off
@@ -23,7 +23,7
23 </tr>
23 </tr>
24
24
25 <% for problem in @problems %>
25 <% for problem in @problems %>
26 - <tr class="<%= (problem.available) ? "available" : "not-available" %>">
26 + <tr id="prob-<%= problem.id %>" name="prob-<%= problem.id %>" class="<%= (problem.available) ? "available" : "not-available" %>">
27 <% @problem=problem %>
27 <% @problem=problem %>
28 <td><%= in_place_editor_field :problem, :name, {}, :rows=>1 %></td>
28 <td><%= in_place_editor_field :problem, :name, {}, :rows=>1 %></td>
29 <td><%= in_place_editor_field :problem, :full_name, {}, :rows=>1 %></td>
29 <td><%= in_place_editor_field :problem, :full_name, {}, :rows=>1 %></td>
@@ -32,7 +32,7
32 <td><%= problem.available %></td>
32 <td><%= problem.available %></td>
33 <td><%= problem.test_allowed %></td>
33 <td><%= problem.test_allowed %></td>
34
34
35 - <td><%= link_to '[Toggle]', :action => 'toggle_avail', :id => problem.id %></td>
35 + <td><%= link_to_remote '[Toggle]', :url => {:action => 'toggle', :id => problem.id } %></td>
36 <td><%= link_to '[Stat]', :action => 'stat', :id => problem.id %></td>
36 <td><%= link_to '[Stat]', :action => 'stat', :id => problem.id %></td>
37 <td><%= link_to '[Show]', :action => 'show', :id => problem %></td>
37 <td><%= link_to '[Show]', :action => 'show', :id => problem %></td>
38 <td><%= link_to '[Edit]', :action => 'edit', :id => problem %></td>
38 <td><%= link_to '[Edit]', :action => 'edit', :id => problem %></td>
@@ -41,7 +41,6
41 <% end %>
41 <% end %>
42 </table>
42 </table>
43
43
44 -
45 <br />
44 <br />
46
45
47 <%= link_to 'New problem', :action => 'new' %>
46 <%= link_to 'New problem', :action => 'new' %>
You need to be logged in to leave comments. Login now