diff --git a/app/controllers/admin/environment_design_controller.rb b/app/controllers/admin/environment_design_controller.rb index 31c8868..99804f8 100644 --- a/app/controllers/admin/environment_design_controller.rb +++ b/app/controllers/admin/environment_design_controller.rb @@ -4,7 +4,7 @@ class EnvironmentDesignController < BoxOrganizerController def filtered_available_blocks(blocks=nil) filtered_available_blocks = [] - blocks.each { |block| filtered_available_blocks << block if @environment.enabled_blocks.include?(block.name) } + blocks.each { |block| filtered_available_blocks << block unless @environment.disabled_blocks.include?(block.name) } filtered_available_blocks end diff --git a/app/controllers/admin/features_controller.rb b/app/controllers/admin/features_controller.rb index f69e13b..2d21473 100644 --- a/app/controllers/admin/features_controller.rb +++ b/app/controllers/admin/features_controller.rb @@ -46,6 +46,7 @@ class FeaturesController < AdminController post_only :update_blocks def update_blocks + params[:environment].delete(:available_blocks) if @environment.update_attributes(params[:environment]) session[:notice] = _('Blocks updated successfully.') redirect_to :action => 'manage_blocks' diff --git a/app/controllers/my_profile/profile_design_controller.rb b/app/controllers/my_profile/profile_design_controller.rb index 41952fb..c6cb014 100644 --- a/app/controllers/my_profile/profile_design_controller.rb +++ b/app/controllers/my_profile/profile_design_controller.rb @@ -6,7 +6,7 @@ class ProfileDesignController < BoxOrganizerController def filtered_available_blocks(blocks=nil) filtered_available_blocks = [] - blocks.each { |block| filtered_available_blocks << block if @environment.enabled_blocks.include?(block.name) } + blocks.each { |block| filtered_available_blocks << block unless @environment.disabled_blocks.include?(block.name) } filtered_available_blocks end diff --git a/app/models/environment.rb b/app/models/environment.rb index cdab09c..8bf76a8 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -3,7 +3,7 @@ # domains. class Environment < ActiveRecord::Base - attr_accessible :name, :is_default, :signup_welcome_text_subject, :signup_welcome_text_body, :terms_of_use, :message_for_disabled_enterprise, :news_amount_by_folder, :default_language, :languages, :description, :organization_approval_method, :enabled_plugins, :enabled_features, :enabled_blocks, :redirection_after_login, :redirection_after_signup, :contact_email, :theme, :reports_lower_bound + attr_accessible :name, :is_default, :signup_welcome_text_subject, :signup_welcome_text_body, :terms_of_use, :message_for_disabled_enterprise, :news_amount_by_folder, :default_language, :languages, :description, :organization_approval_method, :enabled_plugins, :enabled_features, :disabled_blocks, :redirection_after_login, :redirection_after_signup, :contact_email, :theme, :reports_lower_bound has_many :users @@ -289,7 +289,7 @@ class Environment < ActiveRecord::Base settings_items :enabled_plugins, :type => Array, :default => [] - settings_items :enabled_blocks, :type => Array, :default => [] + settings_items :disabled_blocks, :type => Array, :default => [] settings_items :search_hints, :type => Hash, :default => {} @@ -339,8 +339,8 @@ class Environment < ActiveRecord::Base enabled_plugins.include?(plugin.to_s) end - def block_enabled?(block) - enabled_blocks.include?(block.to_s) + def block_disabled?(block) + disabled_blocks.include?(block.to_s) end # enables the features identified by features, which is expected to diff --git a/app/views/features/manage_blocks.html.erb b/app/views/features/manage_blocks.html.erb index 78883ce..b1ea408 100644 --- a/app/views/features/manage_blocks.html.erb +++ b/app/views/features/manage_blocks.html.erb @@ -24,7 +24,10 @@ <%= _(block.description) %> - <%= check_box_tag "environment[enabled_blocks][]", block, @environment.block_enabled?(block) %> + <%= check_box_tag "environment[available_blocks][]", block, !@environment.block_disabled?(block), :id => "environment_available_blocks_#{block.name}", :onclick => "toogle_hidden_field(this, '#{block.name}');" %> + <% if @environment.block_disabled?(block) %> + <%= hidden_field_tag "environment[disabled_blocks][]", block.name %> + <% end %> <% end %> @@ -42,6 +45,22 @@ // --> + +
<% button_bar do %> <%= submit_button('save', _('Save changes'), :id=>"save_blocks") %> -- libgit2 0.21.2