Delete page.
This commit is contained in:
parent
ddc7c74436
commit
7b5ea870a0
|
@ -37,7 +37,7 @@ class Admin::PagesController < ApplicationController
|
|||
flash.now[:notice] = t('admin.create_success_page')
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
redirect_to admin_item_url(@item)
|
||||
redirect_to admin_page_url(@item)
|
||||
}
|
||||
format.js {}
|
||||
end
|
||||
|
@ -64,9 +64,21 @@ class Admin::PagesController < ApplicationController
|
|||
def destroy
|
||||
@item = Page.find(params[:id])
|
||||
@item.destroy
|
||||
@item.destroy_page_parts
|
||||
@item.destroy_i18n_variable
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
redirect_to admin_items_url( :parent_id => @item.parent_id )
|
||||
}
|
||||
format.js {}
|
||||
end
|
||||
end
|
||||
|
||||
redirect_to admin_items_url( :parent_id => @item.parent_id )
|
||||
def delete
|
||||
respond_to do |format|
|
||||
format.html {}
|
||||
format.js { destroy }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ module Admin::ItemHelper
|
|||
ret << (link_to node.name, dest)
|
||||
ret << ' | ' << (link_to t('admin.new_page'), new_admin_page_path(:parent_id => node.id)) if node._type.eql?('Page')
|
||||
ret << ' | ' << (link_to t('admin.new_link'), new_admin_link_path(:parent_id => node.id)) if node._type.eql?('Page')
|
||||
ret << ' | ' << (link_to t(:delete), delete_admin_link_path(node, :authenticity_token => form_authenticity_token), :confirm => t('sure?'), :class => 'delete') if node._type.eql?('Link')
|
||||
ret << ' | ' << (link_to t(:delete), eval("delete_admin_#{node._type.downcase}_path(node, :authenticity_token => form_authenticity_token)"), :confirm => t('sure?'), :class => 'delete')
|
||||
ret << render_children(node)
|
||||
ret << "</li>"
|
||||
end
|
||||
|
|
|
@ -37,11 +37,6 @@ class Item
|
|||
nodes.reverse
|
||||
end
|
||||
|
||||
# Destroy the i18n_variable
|
||||
def destroy_i18n_variable
|
||||
self.i18n_variable.destroy rescue nil
|
||||
end
|
||||
|
||||
# Update or create the i18n_variable record
|
||||
def i18n_variable=(attr)
|
||||
if self.i18n_variable_id
|
||||
|
|
|
@ -18,6 +18,14 @@ class Page < Item
|
|||
end
|
||||
end
|
||||
|
||||
# Destroy the page_parts
|
||||
def destroy_page_parts
|
||||
self.page_parts.each do |part|
|
||||
part.destroy_i18n_variable
|
||||
part.destroy
|
||||
end
|
||||
end
|
||||
|
||||
def get_layout
|
||||
Layout.find(layout_id)
|
||||
end
|
||||
|
|
|
@ -26,6 +26,10 @@ class PagePart
|
|||
end
|
||||
end
|
||||
|
||||
def destroy_i18n_variable
|
||||
self.i18n_variable.destroy rescue nil
|
||||
end
|
||||
|
||||
# Build the content from the i18n_variable
|
||||
def build_content(locales)
|
||||
res = ''
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<% form_for :page, :url => admin_page_path(@page), :html => { :method => :delete } do |f| %>
|
||||
<h2><%= t('sure?') %></h2>
|
||||
<p>
|
||||
<%= submit_tag t(:delete) %>
|
||||
<%= link_back %>
|
||||
</p>
|
||||
<% end %>
|
|
@ -0,0 +1 @@
|
|||
$('#sidebar').html("<%= escape_javascript(render(:partial => 'admin/items/site_map_left_bar')) %>");
|
|
@ -48,7 +48,11 @@ PrototypeR4::Application.routes.draw do
|
|||
get 'delete'
|
||||
end
|
||||
end
|
||||
resources :pages
|
||||
resources :pages do
|
||||
member do
|
||||
get 'delete'
|
||||
end
|
||||
end
|
||||
resources :page_parts
|
||||
resources :homes
|
||||
resources :snippets
|
||||
|
|
Loading…
Reference in New Issue