From 529702add06c3a7f12f65066e2b40322f6034939 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Fri, 18 Jan 2008 18:24:49 +0000 Subject: [PATCH] ActionItem152: adjusting profile design editor --- app/controllers/application.rb | 4 ---- app/controllers/box_organizer_controller.rb | 2 +- app/controllers/my_profile/profile_design_controller.rb | 2 +- app/helpers/boxes_helper.rb | 4 ++-- app/models/main_block.rb | 2 +- app/models/profile.rb | 12 +++++++++--- app/views/box_organizer/index.rhtml | 4 +++- app/views/box_organizer/move_block.rjs | 4 ++-- app/views/profile_editor/index.rhtml | 2 +- lib/needs_profile.rb | 7 ++++--- public/stylesheets/blocks.css | 12 ++++++------ 11 files changed, 30 insertions(+), 25 deletions(-) diff --git a/app/controllers/application.rb b/app/controllers/application.rb index d2e67da..2b467f7 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -4,10 +4,6 @@ class ApplicationController < ActionController::Base helper :document helper :language - - def boxes_holder - environment - end def boxes_editor? false diff --git a/app/controllers/box_organizer_controller.rb b/app/controllers/box_organizer_controller.rb index df7cdb5..595809d 100644 --- a/app/controllers/box_organizer_controller.rb +++ b/app/controllers/box_organizer_controller.rb @@ -13,7 +13,7 @@ class BoxOrganizerController < ApplicationController @target_box = block_before.box else - (params[:target] =~ /end-of-box-([0-9])+/) + (params[:target] =~ /end-of-box-([0-9]+)/) @target_box = boxes_holder.boxes.find($1) end diff --git a/app/controllers/my_profile/profile_design_controller.rb b/app/controllers/my_profile/profile_design_controller.rb index 7b32e4a..666399a 100644 --- a/app/controllers/my_profile/profile_design_controller.rb +++ b/app/controllers/my_profile/profile_design_controller.rb @@ -3,7 +3,7 @@ class ProfileDesignController < BoxOrganizerController needs_profile def index - render :text => '...', :layout => true + render :action => 'index', :layout => true end def boxes_editor? diff --git a/app/helpers/boxes_helper.rb b/app/helpers/boxes_helper.rb index 4217295..8ffd08b 100644 --- a/app/helpers/boxes_helper.rb +++ b/app/helpers/boxes_helper.rb @@ -26,7 +26,7 @@ module BoxesHelper end def display_box(box, main_content) - content_tag('div', content_tag('div', display_box_content(box, main_content), :class => 'blocks'), :class => 'box', :id => "box-#{box.position}" ) + content_tag('div', content_tag('div', display_box_content(box, main_content), :class => 'blocks'), :class => "box box-#{box.position}", :id => "box-#{box.id}" ) end def display_updated_box(box) @@ -53,7 +53,7 @@ module BoxesHelper end end - classes = ['block', block.class.name.underscore.gsub('_', '-') ].uniq.join(' ') + classes = 'block' # ['block', block.class.name.underscore.gsub('_', '-') ].uniq.join(' ') box_decorator.block_target(block.box, block) + content_tag('div', result + box_decorator.block_move_buttons(block), :class => classes, :id => "block-#{block.id}") + box_decorator.block_handle(block) end diff --git a/app/models/main_block.rb b/app/models/main_block.rb index d4ed3d3..49901ab 100644 --- a/app/models/main_block.rb +++ b/app/models/main_block.rb @@ -1,7 +1,7 @@ class MainBlock < Block def content(main_content = nil) - main_content + main_content + "(id: ##{self.id})" end end diff --git a/app/models/profile.rb b/app/models/profile.rb index 14e0fee..dde7a2f 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -81,11 +81,17 @@ class Profile < ActiveRecord::Base self.environment ||= Environment.default end - after_create do |profile| + # registar callback for creating boxes after the object is created. + after_create :create_boxes + + # creates the initial set of boxes when the profile is created. Can be + # overriden for each subclass to create a custom set of boxes for its + # instances. + def create_boxes 3.times do - profile.boxes << Box.new + self.boxes << Box.new end - profile.boxes.first.blocks << MainBlock.new + self.boxes.first.blocks << MainBlock.new end # Returns information about the profile's owner that was made public by diff --git a/app/views/box_organizer/index.rhtml b/app/views/box_organizer/index.rhtml index a7f937f..5c6bdf9 100644 --- a/app/views/box_organizer/index.rhtml +++ b/app/views/box_organizer/index.rhtml @@ -1,3 +1,5 @@ -

testing

+

<%= _('Organizing visual design')%>

This is a test ... and this is a sample text. + +<%= @controller.boxes_holder.class %> diff --git a/app/views/box_organizer/move_block.rjs b/app/views/box_organizer/move_block.rjs index 86c00ec..c023142 100644 --- a/app/views/box_organizer/move_block.rjs +++ b/app/views/box_organizer/move_block.rjs @@ -1,5 +1,5 @@ -from = "box-#{@source_box.position}" -to = "box-#{@target_box.position}" +from = "box-#{@source_box.id}" +to = "box-#{@target_box.id}" page.replace_html(from, display_updated_box(@source_box)) page.replace_html(to, display_updated_box(@target_box)) diff --git a/app/views/profile_editor/index.rhtml b/app/views/profile_editor/index.rhtml index e7b88b9..df32cc2 100644 --- a/app/views/profile_editor/index.rhtml +++ b/app/views/profile_editor/index.rhtml @@ -9,7 +9,7 @@ <%= file_manager_button(_('Edit Profile'), 'icons-app/edit-profile.png', :controller => 'profile_editor', :action => 'edit') %> - <%= file_manager_button(_('Edit Visual Design'), 'icons-app/design-editor.png', :controller => 'profile_editor', :action => 'design_editor') %> + <%= file_manager_button(_('Edit Visual Design'), 'icons-app/design-editor.png', :controller => 'profile_design', :action => 'index') %> <%= file_manager_button(_('Manage Content'), 'icons-app/cms.png', :controller => 'cms') %> diff --git a/lib/needs_profile.rb b/lib/needs_profile.rb index 0c0d658..d339662 100644 --- a/lib/needs_profile.rb +++ b/lib/needs_profile.rb @@ -3,9 +3,6 @@ module NeedsProfile module ClassMethods def needs_profile before_filter :load_profile - def boxes_holder - profile - end end end @@ -13,6 +10,10 @@ module NeedsProfile including.send(:extend, NeedsProfile::ClassMethods) end + def boxes_holder + profile || environment # prefers profile, but defaults to environment + end + protected def profile diff --git a/public/stylesheets/blocks.css b/public/stylesheets/blocks.css index 0993881..ab9cbc3 100644 --- a/public/stylesheets/blocks.css +++ b/public/stylesheets/blocks.css @@ -1,16 +1,16 @@ /* main box */ -#box-1 { +div.box-1 { margin-left: 210px; margin-right: 210px; } -#box-2 { +div.box-2 { float: left; width: 200px; } -#box-3 { +div.box-3 { float: right; width: 200px; } @@ -47,12 +47,12 @@ border: 1px solid #ccc; } -#box-organizer #box-1 .block { +#box-organizer div.box-1 .block { border: 2px dashed green; } -#box-organizer #box-2 .block { +#box-organizer div.box-2 .block { border: 2px dashed red; } -#box-organizer #box-3 .block { +#box-organizer div.box-3 .block { border: 2px dashed blue; } -- libgit2 0.21.2