diff --git a/app/controllers/box_organizer_controller.rb b/app/controllers/box_organizer_controller.rb index 595809d..2711bf6 100644 --- a/app/controllers/box_organizer_controller.rb +++ b/app/controllers/box_organizer_controller.rb @@ -49,4 +49,36 @@ class BoxOrganizerController < ApplicationController redirect_to :back end + def add_block + type = params[:type] + if ! type.blank? + if available_blocks.map(&:name).include?(type) + boxes_holder.boxes.find(params[:box_id]).blocks << type.constantize.new + redirect_to :action => 'index' + else + raise ArgumentError.new("Type %s is not allowed. Go away." % type) + end + else + @block_types = available_blocks + @boxes = boxes_holder.boxes + render :action => 'add_block', :layout => false + end + end + + def edit + @block = boxes_holder.blocks.find(params[:id]) + render :action => 'edit', :layout => false + end + + def save + @block = boxes_holder.blocks.find(params[:id]) + @block.update_attributes(params[:block]) + redirect_to :action => 'index' + end + + def boxes_editor? + true + end + protected :boxes_editor? + end diff --git a/app/controllers/my_profile/profile_design_controller.rb b/app/controllers/my_profile/profile_design_controller.rb index a87994b..44ce6de 100644 --- a/app/controllers/my_profile/profile_design_controller.rb +++ b/app/controllers/my_profile/profile_design_controller.rb @@ -7,28 +7,7 @@ class ProfileDesignController < BoxOrganizerController end def index - render :action => 'index' end - def add_block - type = params[:type] - if ! type.blank? - if available_blocks.map(&:name).include?(type) - boxes_holder.boxes.find(params[:box_id]).blocks << type.constantize.new - redirect_to :action => 'index' - else - raise ArgumentError.new("Type %s is not allowed. Go away." % type) - end - else - @block_types = available_blocks - @boxes = boxes_holder.boxes - render :action => 'add_block', :layout => false - end - end - - def boxes_editor? - true - end - protected :boxes_editor? end diff --git a/app/views/box_organizer/_article_block.rhtml b/app/views/box_organizer/_article_block.rhtml new file mode 100644 index 0000000..bb54766 --- /dev/null +++ b/app/views/box_organizer/_article_block.rhtml @@ -0,0 +1 @@ +<%= select('block', 'article_id', @block.box.owner.articles.map {|item| [ item.path, item.id]}) %> diff --git a/app/views/box_organizer/edit.rhtml b/app/views/box_organizer/edit.rhtml new file mode 100644 index 0000000..7c2d6d7 --- /dev/null +++ b/app/views/box_organizer/edit.rhtml @@ -0,0 +1,12 @@ +