From 5e9836f371eb1fd7a6ef5374cbeb93c1efbc2354 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Tue, 22 May 2012 14:45:49 +0800 Subject: [PATCH] Changes for structure --- app/assets/javascripts/side_bar_history.js | 11 +---------- app/assets/stylesheets/sidebar.css.erb | 10 ++++++++-- app/controllers/admin/links_controller.rb | 4 +++- app/controllers/admin/pages_controller.rb | 8 +++++--- app/controllers/application_controller.rb | 2 +- app/helpers/admin/item_helper.rb | 14 +++++++------- app/views/admin/items/_site_map_left_bar.html.erb | 4 +++- app/views/admin/items/index.js.erb | 12 +++++------- app/views/admin/links/delete.js.erb | 4 +++- app/views/admin/pages/_new.html.erb | 2 +- app/views/admin/pages/delete.js.erb | 4 +++- app/views/layouts/site_editor.html.erb | 4 +--- .../back_end/page_contexts/_page_context.html.erb | 2 +- 13 files changed, 42 insertions(+), 39 deletions(-) diff --git a/app/assets/javascripts/side_bar_history.js b/app/assets/javascripts/side_bar_history.js index ad29b497..f23fd6cc 100644 --- a/app/assets/javascripts/side_bar_history.js +++ b/app/assets/javascripts/side_bar_history.js @@ -1,14 +1,5 @@ var history_edited = false; -$('#back_sidebar a, #back_main a.nav').live('click', - function () { - $.getScript(this.href); - history.pushState(null, document.title, this.href); - history_edited = true; - return false; - } -); - $('#back_main a.reload').live('click', function () { $.getScript(this.href); @@ -18,7 +9,7 @@ $('#back_main a.reload').live('click', } ); -$('#back_main .form').live('submit', function () { +$('#back_main form').live('submit', function () { $.post(this.action, $(this).serialize(), null, 'script'); history_edited = true; return false; diff --git a/app/assets/stylesheets/sidebar.css.erb b/app/assets/stylesheets/sidebar.css.erb index 1e4b4010..76d1e4e9 100644 --- a/app/assets/stylesheets/sidebar.css.erb +++ b/app/assets/stylesheets/sidebar.css.erb @@ -18,6 +18,9 @@ padding: 3px 0px; display: block; } +.nav-list>li>ol { + margin-left: 0; +} /* #back_sidebar h1 { background: url(<%= asset_path "h1_bg.png" %>) repeat-x scroll left top transparent; @@ -126,7 +129,7 @@ background: none repeat scroll 0 0 #FFFFFF; border: 1px solid #DDDDDD; border-radius: 5px 5px 5px 5px; - margin: 0 0 0 3px; + margin: 0 0 0 20px; padding: 0; z-index:1; position: absolute; @@ -155,7 +158,7 @@ ol.nav>li>.icons-moves { } .sortable i { position: absolute; - left: -20px; + left: 0px; top: 6px; margin-right: 0; opacity: 0.3; @@ -166,6 +169,9 @@ ol.nav>li>.icons-moves { opacity: 0.7; filter: alpha(opacity=70); } +.with_action { + padding-left: 20px; +} .placeholder { background-color: rgba(0,136,204,.6); border-radius: 3px; diff --git a/app/controllers/admin/links_controller.rb b/app/controllers/admin/links_controller.rb index 533ff829..c233c18f 100644 --- a/app/controllers/admin/links_controller.rb +++ b/app/controllers/admin/links_controller.rb @@ -65,9 +65,11 @@ class Admin::LinksController < ApplicationController end def delete + @item = Link.find(params[:id]) + @item.destroy respond_to do |format| format.html {} - format.js { destroy } + format.js { @item = @item.parent } end end diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index 44bda4aa..5fc6cb77 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -51,7 +51,7 @@ class Admin::PagesController < ApplicationController def create @item = Page.new(params[:page]) - if @item.module_app.key == 'page_content' + if @item.module_app && @item.module_app.key == 'page_content' @item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id ) end @@ -99,14 +99,16 @@ class Admin::PagesController < ApplicationController format.html { redirect_to admin_items_url( :parent_id => @item.parent_id ) } - format.js {} + format.js { redirect_to admin_items_url } end end def delete + @item = Page.find(params[:id]) + @item.destroy respond_to do |format| format.html {} - format.js { destroy } + format.js { @item = @item.parent } end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1455619a..5fd9de5c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -157,7 +157,7 @@ class ApplicationController < ActionController::Base end def get_homepage - Item.first(:conditions => {:parent_id => nil}) + Page.root end def layout_by_resource diff --git a/app/helpers/admin/item_helper.rb b/app/helpers/admin/item_helper.rb index b5ab255e..78e911b9 100644 --- a/app/helpers/admin/item_helper.rb +++ b/app/helpers/admin/item_helper.rb @@ -11,14 +11,14 @@ module Admin::ItemHelper no_nested = 'no-nest' end ret << "
  • " - ret << "" - ret << "
    " - ret << (link_to node.i18n_variable[I18n.locale], dest) + # ret << "" + ret << "
    " + ret << (link_to node.i18n_variable[I18n.locale], dest, :class => 'js_history') ret << "
    " - ret << (link_to t('admin.edit'), eval("edit_admin_#{node._type.downcase}_path(node)")) if node._type.eql?('Page') - ret << (link_to t('admin.new_page'), new_admin_page_path(:parent_id => node.id), :class => 'new_page') if node._type.eql?('Page') - ret << (link_to t('admin.new_link'), new_admin_link_path(:parent_id => node.id), :class => 'new_link') if node._type.eql?('Page') - ret << (link_to t(:delete), eval("delete_admin_#{node._type.downcase}_path(node, :authenticity_token => form_authenticity_token)"), :confirm => t('sure?'), :class => 'delete') + ret << (link_to t('admin.edit'), eval("edit_admin_#{node._type.downcase}_path(node)"), :class => 'js_history') if node._type.eql?('Page') + ret << (link_to t('admin.new_page'), new_admin_page_path(:parent_id => node.id), :class => 'new_page js_history') if node._type.eql?('Page') + ret << (link_to t('admin.new_link'), new_admin_link_path(:parent_id => node.id), :class => 'new_link js_history') if node._type.eql?('Page') + ret << (link_to t(:delete), eval("delete_admin_#{node._type.downcase}_path(node, :authenticity_token => form_authenticity_token)"), :confirm => t('sure?'), :class => 'delete js_history') ret << "
    " ret << "
    " ret << render_children(node) diff --git a/app/views/admin/items/_site_map_left_bar.html.erb b/app/views/admin/items/_site_map_left_bar.html.erb index 8d32365f..a9cf2d91 100644 --- a/app/views/admin/items/_site_map_left_bar.html.erb +++ b/app/views/admin/items/_site_map_left_bar.html.erb @@ -1 +1,3 @@ -<%= render_node_and_children(Item.first(:conditions => {:parent_id => nil})) %> + diff --git a/app/views/admin/items/index.js.erb b/app/views/admin/items/index.js.erb index 8dc86088..1ff6abb5 100644 --- a/app/views/admin/items/index.js.erb +++ b/app/views/admin/items/index.js.erb @@ -1,9 +1,7 @@ $('#back_main').empty(); -switch ("<%= escape_javascript(@item._type)%>") { - case 'Link': - $('#back_main').append("<%= escape_javascript(render(:partial => 'admin/links/show')) %>"); - break; - case 'Page': +<% case @item._type %> + <% when 'Page' %> $('#back_main').append("<%= escape_javascript(render(:partial => 'admin/pages/show')) %>"); - break; -}; \ No newline at end of file + <% when 'Link' %> + $('#back_main').append("<%= escape_javascript(render(:partial => 'admin/links/show')) %>"); +<% end %> \ No newline at end of file diff --git a/app/views/admin/links/delete.js.erb b/app/views/admin/links/delete.js.erb index b1739526..8ea2a642 100644 --- a/app/views/admin/links/delete.js.erb +++ b/app/views/admin/links/delete.js.erb @@ -1 +1,3 @@ -$('#back_sidebar').html("<%= escape_javascript(render(:partial => 'admin/items/site_map_left_bar')) %>"); \ No newline at end of file +$('#back_sidebar').html("<%= escape_javascript(render(:partial => 'admin/items/site_map_left_bar')) %>"); +$('#back_main').html("<%= escape_javascript(render(:partial => 'admin/pages/show')) %>"); +history.pushState(null, document.title, "<%= escape_javascript(admin_items_url) %>"); \ No newline at end of file diff --git a/app/views/admin/pages/_new.html.erb b/app/views/admin/pages/_new.html.erb index ecbda3de..bba5ad50 100644 --- a/app/views/admin/pages/_new.html.erb +++ b/app/views/admin/pages/_new.html.erb @@ -4,7 +4,7 @@ <%= form_for @item, :url => admin_pages_path, :html => { :class => 'form-horizontal edit_page' } do |f| %> <%= render :partial => "form", :locals => { :f => f } %>
    - <%= f.submit t('update'), :class => 'btn btn-primary' %> + <%= f.submit t('create'), :class => 'btn btn-primary' %> <%= link_to t('cancel'), get_go_back, :class=>"btn" %>
    <% end %> diff --git a/app/views/admin/pages/delete.js.erb b/app/views/admin/pages/delete.js.erb index b1739526..8ea2a642 100644 --- a/app/views/admin/pages/delete.js.erb +++ b/app/views/admin/pages/delete.js.erb @@ -1 +1,3 @@ -$('#back_sidebar').html("<%= escape_javascript(render(:partial => 'admin/items/site_map_left_bar')) %>"); \ No newline at end of file +$('#back_sidebar').html("<%= escape_javascript(render(:partial => 'admin/items/site_map_left_bar')) %>"); +$('#back_main').html("<%= escape_javascript(render(:partial => 'admin/pages/show')) %>"); +history.pushState(null, document.title, "<%= escape_javascript(admin_items_url) %>"); \ No newline at end of file diff --git a/app/views/layouts/site_editor.html.erb b/app/views/layouts/site_editor.html.erb index da6efd26..1f66aecc 100644 --- a/app/views/layouts/site_editor.html.erb +++ b/app/views/layouts/site_editor.html.erb @@ -23,9 +23,7 @@
    - + <%= yield :sidebar %>
    diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb index ea8303c2..7e056432 100644 --- a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb +++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb @@ -18,6 +18,6 @@ <%= link_to page_context.version, panel_page_content_back_end_view_path(page_context.page_id) %> <%end -%> - <%= display_date_time(page_context) %> + <%= display_date_time(page_context.updated_at) %> <%= User.find(page_context.create_user_id).name %> \ No newline at end of file