Commit 529702add06c3a7f12f65066e2b40322f6034939

Authored by AntonioTerceiro
1 parent 91b8a715

ActionItem152: adjusting profile design editor


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1205 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/application.rb
... ... @@ -4,10 +4,6 @@ class ApplicationController < ActionController::Base
4 4  
5 5 helper :document
6 6 helper :language
7   -
8   - def boxes_holder
9   - environment
10   - end
11 7  
12 8 def boxes_editor?
13 9 false
... ...
app/controllers/box_organizer_controller.rb
... ... @@ -13,7 +13,7 @@ class BoxOrganizerController < ApplicationController
13 13  
14 14 @target_box = block_before.box
15 15 else
16   - (params[:target] =~ /end-of-box-([0-9])+/)
  16 + (params[:target] =~ /end-of-box-([0-9]+)/)
17 17  
18 18 @target_box = boxes_holder.boxes.find($1)
19 19 end
... ...
app/controllers/my_profile/profile_design_controller.rb
... ... @@ -3,7 +3,7 @@ class ProfileDesignController < BoxOrganizerController
3 3 needs_profile
4 4  
5 5 def index
6   - render :text => '...', :layout => true
  6 + render :action => 'index', :layout => true
7 7 end
8 8  
9 9 def boxes_editor?
... ...
app/helpers/boxes_helper.rb
... ... @@ -26,7 +26,7 @@ module BoxesHelper
26 26 end
27 27  
28 28 def display_box(box, main_content)
29   - content_tag('div', content_tag('div', display_box_content(box, main_content), :class => 'blocks'), :class => 'box', :id => "box-#{box.position}" )
  29 + content_tag('div', content_tag('div', display_box_content(box, main_content), :class => 'blocks'), :class => "box box-#{box.position}", :id => "box-#{box.id}" )
30 30 end
31 31  
32 32 def display_updated_box(box)
... ... @@ -53,7 +53,7 @@ module BoxesHelper
53 53 end
54 54 end
55 55  
56   - classes = ['block', block.class.name.underscore.gsub('_', '-') ].uniq.join(' ')
  56 + classes = 'block' # ['block', block.class.name.underscore.gsub('_', '-') ].uniq.join(' ')
57 57  
58 58 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)
59 59 end
... ...
app/models/main_block.rb
1 1 class MainBlock < Block
2 2  
3 3 def content(main_content = nil)
4   - main_content
  4 + main_content + "(id: ##{self.id})"
5 5 end
6 6  
7 7 end
... ...
app/models/profile.rb
... ... @@ -81,11 +81,17 @@ class Profile &lt; ActiveRecord::Base
81 81 self.environment ||= Environment.default
82 82 end
83 83  
84   - after_create do |profile|
  84 + # registar callback for creating boxes after the object is created.
  85 + after_create :create_boxes
  86 +
  87 + # creates the initial set of boxes when the profile is created. Can be
  88 + # overriden for each subclass to create a custom set of boxes for its
  89 + # instances.
  90 + def create_boxes
85 91 3.times do
86   - profile.boxes << Box.new
  92 + self.boxes << Box.new
87 93 end
88   - profile.boxes.first.blocks << MainBlock.new
  94 + self.boxes.first.blocks << MainBlock.new
89 95 end
90 96  
91 97 # Returns information about the profile's owner that was made public by
... ...
app/views/box_organizer/index.rhtml
1   -<h1>testing</h1>
  1 +<h2><%= _('Organizing visual design')%></h2>
2 2  
3 3 This is a test ... and this is a sample text.
  4 +
  5 +<%= @controller.boxes_holder.class %>
... ...
app/views/box_organizer/move_block.rjs
1   -from = "box-#{@source_box.position}"
2   -to = "box-#{@target_box.position}"
  1 +from = "box-#{@source_box.id}"
  2 +to = "box-#{@target_box.id}"
3 3  
4 4 page.replace_html(from, display_updated_box(@source_box))
5 5 page.replace_html(to, display_updated_box(@target_box))
... ...
app/views/profile_editor/index.rhtml
... ... @@ -9,7 +9,7 @@
9 9  
10 10 <%= file_manager_button(_('Edit Profile'), 'icons-app/edit-profile.png', :controller => 'profile_editor', :action => 'edit') %>
11 11  
12   - <%= file_manager_button(_('Edit Visual Design'), 'icons-app/design-editor.png', :controller => 'profile_editor', :action => 'design_editor') %>
  12 + <%= file_manager_button(_('Edit Visual Design'), 'icons-app/design-editor.png', :controller => 'profile_design', :action => 'index') %>
13 13  
14 14 <%= file_manager_button(_('Manage Content'), 'icons-app/cms.png', :controller => 'cms') %>
15 15  
... ...
lib/needs_profile.rb
... ... @@ -3,9 +3,6 @@ module NeedsProfile
3 3 module ClassMethods
4 4 def needs_profile
5 5 before_filter :load_profile
6   - def boxes_holder
7   - profile
8   - end
9 6 end
10 7 end
11 8  
... ... @@ -13,6 +10,10 @@ module NeedsProfile
13 10 including.send(:extend, NeedsProfile::ClassMethods)
14 11 end
15 12  
  13 + def boxes_holder
  14 + profile || environment # prefers profile, but defaults to environment
  15 + end
  16 +
16 17 protected
17 18  
18 19 def profile
... ...
public/stylesheets/blocks.css
1 1  
2 2 /* main box */
3   -#box-1 {
  3 +div.box-1 {
4 4 margin-left: 210px;
5 5 margin-right: 210px;
6 6 }
7 7  
8   -#box-2 {
  8 +div.box-2 {
9 9 float: left;
10 10 width: 200px;
11 11 }
12 12  
13   -#box-3 {
  13 +div.box-3 {
14 14 float: right;
15 15 width: 200px;
16 16 }
... ... @@ -47,12 +47,12 @@
47 47 border: 1px solid #ccc;
48 48 }
49 49  
50   -#box-organizer #box-1 .block {
  50 +#box-organizer div.box-1 .block {
51 51 border: 2px dashed green;
52 52 }
53   -#box-organizer #box-2 .block {
  53 +#box-organizer div.box-2 .block {
54 54 border: 2px dashed red;
55 55 }
56   -#box-organizer #box-3 .block {
  56 +#box-organizer div.box-3 .block {
57 57 border: 2px dashed blue;
58 58 }
... ...