From 934b51591403968c490843e2b8e3c243c4e3ed45 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Fri, 27 Jul 2012 12:05:17 +0800 Subject: [PATCH] Sitemap with main --- app/assets/stylesheets/style.css.erb | 25 +++++++++++++++-- app/controllers/admin/sites_controller.rb | 6 ++++ app/models/page.rb | 28 ++++++++++--------- app/views/admin/sites/_sitemap_block.html.erb | 13 +++++---- app/views/admin/sites/sitemap.html.erb | 3 ++ 5 files changed, 54 insertions(+), 21 deletions(-) diff --git a/app/assets/stylesheets/style.css.erb b/app/assets/stylesheets/style.css.erb index 7c9d44cb..f45faf9c 100644 --- a/app/assets/stylesheets/style.css.erb +++ b/app/assets/stylesheets/style.css.erb @@ -862,6 +862,12 @@ padding: 5px 15px; border-top: 1px solid #FFF; border-bottom: 1px solid #dedede; + display: table; + width: 100%; +} +.site-map .map-block li span { + width: 170px; + display: block; } .site-map .map-block li:last-child { border-radius: 0 0 4px 4px; @@ -879,8 +885,9 @@ color: #CACACA; } .site-map .map-block h4 { - line-height: 30px; - padding: 0 15px; + line-height: 18px; + min-height: 20px; + padding: 5px 15px; border-radius: 4px 4px 0 0; box-shadow: 0px 1px 2px #A8A8A8; position: relative; @@ -893,6 +900,20 @@ background-repeat: repeat-x; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FCFCFC', endColorstr='#DFDFDF', GradientType=0); } +.site-map .map-block h4 span { + width: 170px; + display: block; +} +.site-map .map-block h4 .onoff { +} +.site-map .disabled h4 { + color: #CACACA; +} +.site-map .disabled h4 .onoff { + box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.5), 0 0 5px rgba(0,0,0,.2) inset; + background-color: #9C9C9C; + color: #CACACA; +} .onoff { display: block; background-color: #5EB92B; diff --git a/app/controllers/admin/sites_controller.rb b/app/controllers/admin/sites_controller.rb index b73d66c3..e926f7ea 100644 --- a/app/controllers/admin/sites_controller.rb +++ b/app/controllers/admin/sites_controller.rb @@ -35,6 +35,12 @@ class Admin::SitesController < ApplicationController @item = Item.find(params[:id]) @item.sitemap_enabled = !@item.sitemap_enabled @item.save + if params[:parent] + @item.children.each do |child| + child.sitemap_enabled = @item.sitemap_enabled + child.save + end + end render :nothing => true end diff --git a/app/models/page.rb b/app/models/page.rb index bddb9872..20a51288 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -25,19 +25,21 @@ class Page < Item protected def create_parts - page_design = self.design - parent = self.parent - menu_part = parent.page_parts.detect{|page_part| page_part.kind.eql?('public_r_tag') && page_part.public_r_tag.eql?('sub_menu') && page_part.public_r_tag_object_id.eql?(parent.id.to_s)} if parent - page_design.layout.layout_parts.each do |layout_part| - current_part = self.page_parts.detect{|page_part| page_part.name.eql?(layout_part.name)} - current_part = self.page_parts.build(:name => layout_part.name) unless current_part - if menu_part && current_part.name.eql?(menu_part.name) - if current_part.new_record? - current_part.kind = menu_part.kind - current_part.public_r_tag = menu_part.public_r_tag - current_part.public_r_tag_object_id = menu_part.public_r_tag_object_id - else - current_part.update_attributes(:kind => menu_part.kind, :public_r_tag => menu_part.public_r_tag, :public_r_tag_object_id => menu_part.public_r_tag_object_id) + if self.new_record? || self.design.changed? + page_design = self.design + parent = self.parent + menu_part = parent.page_parts.detect{|page_part| page_part.kind.eql?('public_r_tag') && page_part.public_r_tag.eql?('sub_menu') && page_part.public_r_tag_object_id.eql?(parent.id.to_s)} if parent + page_design.layout.layout_parts.each do |layout_part| + current_part = self.page_parts.detect{|page_part| page_part.name.eql?(layout_part.name)} + current_part = self.page_parts.build(:name => layout_part.name) unless current_part + if menu_part && current_part.name.eql?(menu_part.name) + if current_part.new_record? + current_part.kind = menu_part.kind + current_part.public_r_tag = menu_part.public_r_tag + current_part.public_r_tag_object_id = menu_part.public_r_tag_object_id + else + current_part.update_attributes(:kind => menu_part.kind, :public_r_tag => menu_part.public_r_tag, :public_r_tag_object_id => menu_part.public_r_tag_object_id) + end end end end diff --git a/app/views/admin/sites/_sitemap_block.html.erb b/app/views/admin/sites/_sitemap_block.html.erb index 37a8dc29..d5e3b2ab 100644 --- a/app/views/admin/sites/_sitemap_block.html.erb +++ b/app/views/admin/sites/_sitemap_block.html.erb @@ -1,12 +1,13 @@ -
-

<%= sitemap_block.i18n_variable[I18n.locale] %>

+
+

+ + <%= sitemap_block.i18n_variable[I18n.locale] %> +

    <% sitemap_block.children.each do |child| %>
  • - <%= child.i18n_variable[I18n.locale] %> - + + <%= child.i18n_variable[I18n.locale] %>
  • <% end if sitemap_block.children %>
diff --git a/app/views/admin/sites/sitemap.html.erb b/app/views/admin/sites/sitemap.html.erb index 6e8d2cbe..453f73f0 100644 --- a/app/views/admin/sites/sitemap.html.erb +++ b/app/views/admin/sites/sitemap.html.erb @@ -32,11 +32,14 @@ $(this).text("<%= t('off_upcase') %>") $(this).parents(".map-block").find('li').addClass('disabled') $(this).parents(".map-block").find('button').text("<%= t('off_upcase') %>") + $(this).parents(".map-block").find('li button').attr('disabled', 'disabled') } else { $(this).text("<%= t('on_upcase') %>") $(this).parents(".map-block").find('li').removeClass('disabled') $(this).parents(".map-block").find('button').text("<%= t('on_upcase') %>") + $(this).parents(".map-block").find('li button').removeAttr("disabled") } + $.getScript('<%= admin_sites_path %>' + '/' + $(this).attr('id') + '/sitemap_toggle?parent=true'); }); <% end %> \ No newline at end of file