Add Item list interface, but acts_as_list can not used
This commit is contained in:
parent
f9b1618ac7
commit
93169b1098
|
@ -9,6 +9,18 @@ class Admin::ItemsController < ApplicationController
|
||||||
@items.unshift Item.find_by_name("root") if @parent_item.name == 'root'
|
@items.unshift Item.find_by_name("root") if @parent_item.name == 'root'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def up
|
||||||
|
@item = Item.find(params[:id])
|
||||||
|
@item.move_higher
|
||||||
|
redirect_to admin_items_url( :parent_name => @item.parent_name )
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
@item = Item.find(params[:id])
|
||||||
|
@item.move_lower
|
||||||
|
redirect_to admin_items_url( :parent_name => @item.parent_name )
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def find_snippets
|
def find_snippets
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<tr>
|
|
||||||
<td><%= item.class %></td>
|
<td><%= item.class %></td>
|
||||||
<td><%= link_to item.name, admin_items_path(:parent_name => item.name) %></td>
|
<td><%= link_to item.name, admin_items_path(:parent_name => item.name) %></td>
|
||||||
<td><%=h item.title %>
|
<td><%=h item.title %>
|
||||||
<td><%= item.position %></td>
|
<td><%= item.position %></td>
|
||||||
|
@ -9,4 +9,3 @@
|
||||||
<%= link_to t(:edit), edit_admin_component_path(item) %> |
|
<%= link_to t(:edit), edit_admin_component_path(item) %> |
|
||||||
<%= link_to t(:delete), admin_component_path(item), :confirm => 'Are you sure?', :method => :delete %>
|
<%= link_to t(:delete), admin_component_path(item), :confirm => 'Are you sure?', :method => :delete %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
|
|
@ -1,4 +1,4 @@
|
||||||
<tr>
|
|
||||||
<td><%= item.class %></td>
|
<td><%= item.class %></td>
|
||||||
<td><%= link_to item.name, admin_items_path(:parent_name => item.name) %></td>
|
<td><%= link_to item.name, admin_items_path(:parent_name => item.name) %></td>
|
||||||
<td><%=h item.title %>
|
<td><%=h item.title %>
|
||||||
|
@ -9,4 +9,3 @@
|
||||||
<%= link_to t(:edit), edit_admin_link_path(item) %> |
|
<%= link_to t(:edit), edit_admin_link_path(item) %> |
|
||||||
<%= link_to t(:delete), admin_link_path(item), :confirm => 'Are you sure?', :method => :delete %>
|
<%= link_to t(:delete), admin_link_path(item), :confirm => 'Are you sure?', :method => :delete %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
|
|
@ -1,5 +1,5 @@
|
||||||
<tr>
|
|
||||||
<td><%= item.class %></td>
|
<td><%= item.class %></td>
|
||||||
<td><%= link_to item.name, admin_items_path(:parent_name => item.name) %></td>
|
<td><%= link_to item.name, admin_items_path(:parent_name => item.name) %></td>
|
||||||
<td><%=h item.title %>
|
<td><%=h item.title %>
|
||||||
<td><%= item.position %></td>
|
<td><%= item.position %></td>
|
||||||
|
@ -9,4 +9,3 @@
|
||||||
<%= link_to t(:edit), edit_admin_page_path(item) %> |
|
<%= link_to t(:edit), edit_admin_page_path(item) %> |
|
||||||
<%= link_to t(:delete), admin_page_path(item), :confirm => 'Are you sure?', :method => :delete %>
|
<%= link_to t(:delete), admin_page_path(item), :confirm => 'Are you sure?', :method => :delete %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
|
|
@ -17,10 +17,15 @@
|
||||||
<th>Position</th>
|
<th>Position</th>
|
||||||
<th>Published?</th>
|
<th>Published?</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<% @items.each do |item| %>
|
<% @items.each do |item| %>
|
||||||
|
<tr>
|
||||||
<%= render :partial => item.class.to_s.downcase, :locals => { :item => item } %>
|
<%= render :partial => item.class.to_s.downcase, :locals => { :item => item } %>
|
||||||
|
<!--<td><%= link_to t(:move_up, :scope => :admin), up_admin_item_path(item), :method => :put %> |
|
||||||
|
<%= link_to t(:move_down, :scope => :admin), down_admin_item_path(item), :method => :put %></td>-->
|
||||||
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
|
@ -16,3 +16,5 @@ zh_tw:
|
||||||
announcement: 公告管理
|
announcement: 公告管理
|
||||||
asset: 資產管理
|
asset: 資產管理
|
||||||
new_asset: 新增資產
|
new_asset: 新增資產
|
||||||
|
move_up: 往上移
|
||||||
|
move_down: 往下移
|
|
@ -3,7 +3,7 @@ ActionController::Routing::Routes.draw do |map|
|
||||||
map.resources :announcements
|
map.resources :announcements
|
||||||
|
|
||||||
map.namespace :admin do |admin|
|
map.namespace :admin do |admin|
|
||||||
admin.resources :items
|
admin.resources :items, :member => { :up => :put, :down => :put }
|
||||||
admin.resources :pages
|
admin.resources :pages
|
||||||
admin.resources :links
|
admin.resources :links
|
||||||
admin.resources :components
|
admin.resources :components
|
||||||
|
|
Reference in New Issue