Commit 529702add06c3a7f12f65066e2b40322f6034939
1 parent
91b8a715
Exists in
master
and in
29 other branches
ActionItem152: adjusting profile design editor
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1205 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
11 changed files
with
30 additions
and
25 deletions
Show diff stats
app/controllers/application.rb
@@ -4,10 +4,6 @@ class ApplicationController < ActionController::Base | @@ -4,10 +4,6 @@ class ApplicationController < ActionController::Base | ||
4 | 4 | ||
5 | helper :document | 5 | helper :document |
6 | helper :language | 6 | helper :language |
7 | - | ||
8 | - def boxes_holder | ||
9 | - environment | ||
10 | - end | ||
11 | 7 | ||
12 | def boxes_editor? | 8 | def boxes_editor? |
13 | false | 9 | false |
app/controllers/box_organizer_controller.rb
@@ -13,7 +13,7 @@ class BoxOrganizerController < ApplicationController | @@ -13,7 +13,7 @@ class BoxOrganizerController < ApplicationController | ||
13 | 13 | ||
14 | @target_box = block_before.box | 14 | @target_box = block_before.box |
15 | else | 15 | else |
16 | - (params[:target] =~ /end-of-box-([0-9])+/) | 16 | + (params[:target] =~ /end-of-box-([0-9]+)/) |
17 | 17 | ||
18 | @target_box = boxes_holder.boxes.find($1) | 18 | @target_box = boxes_holder.boxes.find($1) |
19 | end | 19 | end |
app/controllers/my_profile/profile_design_controller.rb
@@ -3,7 +3,7 @@ class ProfileDesignController < BoxOrganizerController | @@ -3,7 +3,7 @@ class ProfileDesignController < BoxOrganizerController | ||
3 | needs_profile | 3 | needs_profile |
4 | 4 | ||
5 | def index | 5 | def index |
6 | - render :text => '...', :layout => true | 6 | + render :action => 'index', :layout => true |
7 | end | 7 | end |
8 | 8 | ||
9 | def boxes_editor? | 9 | def boxes_editor? |
app/helpers/boxes_helper.rb
@@ -26,7 +26,7 @@ module BoxesHelper | @@ -26,7 +26,7 @@ module BoxesHelper | ||
26 | end | 26 | end |
27 | 27 | ||
28 | def display_box(box, main_content) | 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 | end | 30 | end |
31 | 31 | ||
32 | def display_updated_box(box) | 32 | def display_updated_box(box) |
@@ -53,7 +53,7 @@ module BoxesHelper | @@ -53,7 +53,7 @@ module BoxesHelper | ||
53 | end | 53 | end |
54 | end | 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 | 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) | 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 | end | 59 | end |
app/models/main_block.rb
app/models/profile.rb
@@ -81,11 +81,17 @@ class Profile < ActiveRecord::Base | @@ -81,11 +81,17 @@ class Profile < ActiveRecord::Base | ||
81 | self.environment ||= Environment.default | 81 | self.environment ||= Environment.default |
82 | end | 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 | 3.times do | 91 | 3.times do |
86 | - profile.boxes << Box.new | 92 | + self.boxes << Box.new |
87 | end | 93 | end |
88 | - profile.boxes.first.blocks << MainBlock.new | 94 | + self.boxes.first.blocks << MainBlock.new |
89 | end | 95 | end |
90 | 96 | ||
91 | # Returns information about the profile's owner that was made public by | 97 | # Returns information about the profile's owner that was made public by |
app/views/box_organizer/index.rhtml
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 | page.replace_html(from, display_updated_box(@source_box)) | 4 | page.replace_html(from, display_updated_box(@source_box)) |
5 | page.replace_html(to, display_updated_box(@target_box)) | 5 | page.replace_html(to, display_updated_box(@target_box)) |
app/views/profile_editor/index.rhtml
@@ -9,7 +9,7 @@ | @@ -9,7 +9,7 @@ | ||
9 | 9 | ||
10 | <%= file_manager_button(_('Edit Profile'), 'icons-app/edit-profile.png', :controller => 'profile_editor', :action => 'edit') %> | 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 | <%= file_manager_button(_('Manage Content'), 'icons-app/cms.png', :controller => 'cms') %> | 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,9 +3,6 @@ module NeedsProfile | ||
3 | module ClassMethods | 3 | module ClassMethods |
4 | def needs_profile | 4 | def needs_profile |
5 | before_filter :load_profile | 5 | before_filter :load_profile |
6 | - def boxes_holder | ||
7 | - profile | ||
8 | - end | ||
9 | end | 6 | end |
10 | end | 7 | end |
11 | 8 | ||
@@ -13,6 +10,10 @@ module NeedsProfile | @@ -13,6 +10,10 @@ module NeedsProfile | ||
13 | including.send(:extend, NeedsProfile::ClassMethods) | 10 | including.send(:extend, NeedsProfile::ClassMethods) |
14 | end | 11 | end |
15 | 12 | ||
13 | + def boxes_holder | ||
14 | + profile || environment # prefers profile, but defaults to environment | ||
15 | + end | ||
16 | + | ||
16 | protected | 17 | protected |
17 | 18 | ||
18 | def profile | 19 | def profile |
public/stylesheets/blocks.css
1 | 1 | ||
2 | /* main box */ | 2 | /* main box */ |
3 | -#box-1 { | 3 | +div.box-1 { |
4 | margin-left: 210px; | 4 | margin-left: 210px; |
5 | margin-right: 210px; | 5 | margin-right: 210px; |
6 | } | 6 | } |
7 | 7 | ||
8 | -#box-2 { | 8 | +div.box-2 { |
9 | float: left; | 9 | float: left; |
10 | width: 200px; | 10 | width: 200px; |
11 | } | 11 | } |
12 | 12 | ||
13 | -#box-3 { | 13 | +div.box-3 { |
14 | float: right; | 14 | float: right; |
15 | width: 200px; | 15 | width: 200px; |
16 | } | 16 | } |
@@ -47,12 +47,12 @@ | @@ -47,12 +47,12 @@ | ||
47 | border: 1px solid #ccc; | 47 | border: 1px solid #ccc; |
48 | } | 48 | } |
49 | 49 | ||
50 | -#box-organizer #box-1 .block { | 50 | +#box-organizer div.box-1 .block { |
51 | border: 2px dashed green; | 51 | border: 2px dashed green; |
52 | } | 52 | } |
53 | -#box-organizer #box-2 .block { | 53 | +#box-organizer div.box-2 .block { |
54 | border: 2px dashed red; | 54 | border: 2px dashed red; |
55 | } | 55 | } |
56 | -#box-organizer #box-3 .block { | 56 | +#box-organizer div.box-3 .block { |
57 | border: 2px dashed blue; | 57 | border: 2px dashed blue; |
58 | } | 58 | } |