Permalink
Browse files

system groups - address style comments from pull request 1837 review

Addresses a few minor style comments from 1837:
- spacing around => in controller
- spacing after lambda in controller
- inclusion of () on selector callback function
- indentation in *selector.js
  • Loading branch information...
1 parent ac176ca commit e036360fbae77992d4fd0521ac37a9165189a2c0 @bbuckingham bbuckingham committed Apr 3, 2013
Showing with 197 additions and 196 deletions.
  1. +58 −56 src/app/controllers/system_groups_controller.rb
  2. +139 −140 src/public/javascripts/env_content_view_selector.js
@@ -12,38 +12,38 @@
class SystemGroupsController < ApplicationController
- before_filter :panel_options, :only=>[:index, :items, :create, :copy]
- before_filter :find_group, :only=>[:edit, :update, :destroy, :destroy_systems, :systems,
- :show, :add_systems, :remove_systems, :edit_systems,
- :update_systems, :copy]
+ before_filter :panel_options, :only => [:index, :items, :create, :copy]
+ before_filter :find_group, :only => [:edit, :update, :destroy, :destroy_systems, :systems,
+ :show, :add_systems, :remove_systems, :edit_systems,
+ :update_systems, :copy]
before_filter :authorize
def rules
- any_readable = lambda{current_organization && SystemGroup.any_readable?(current_organization)}
- read_perm = lambda{@group.readable?}
- edit_perm = lambda{@group.editable?}
- create_perm = lambda{SystemGroup.creatable?(current_organization)}
- destroy_perm = lambda{@group.deletable?}
- destroy_systems_perm = lambda{@group.systems_deletable?}
- edit_systems_perm = lambda{@group.systems_editable?}
+ any_readable = lambda {current_organization && SystemGroup.any_readable?(current_organization)}
+ read_perm = lambda {@group.readable?}
+ edit_perm = lambda {@group.editable?}
+ create_perm = lambda {SystemGroup.creatable?(current_organization)}
+ destroy_perm = lambda {@group.deletable?}
+ destroy_systems_perm = lambda {@group.systems_deletable?}
+ edit_systems_perm = lambda {@group.systems_editable?}
{
- :index=>any_readable,
- :items=>any_readable,
+ :index => any_readable,
+ :items => any_readable,
:new => create_perm,
- :create=>create_perm,
- :copy=>create_perm,
- :edit=>read_perm,
+ :create => create_perm,
+ :copy => create_perm,
+ :edit => read_perm,
:systems => read_perm,
- :update=>edit_perm,
- :destroy=>destroy_perm,
- :destroy_systems=>destroy_systems_perm,
- :show=>read_perm,
- :auto_complete=>any_readable,
- :add_systems=> edit_perm,
- :remove_systems=>edit_perm,
- :edit_systems=>edit_systems_perm,
- :update_systems=>edit_systems_perm,
- :validate_name=>any_readable
+ :update => edit_perm,
+ :destroy => destroy_perm,
+ :destroy_systems => destroy_systems_perm,
+ :show => read_perm,
+ :auto_complete => any_readable,
+ :add_systems => edit_perm,
+ :remove_systems => edit_perm,
+ :edit_systems => edit_systems_perm,
+ :update_systems => edit_systems_perm,
+ :validate_name => any_readable
}
end
@@ -71,15 +71,15 @@ def new
end
def create
- @group = SystemGroup.create!(params[:system_group].merge({:organization_id=>current_organization.id}))
+ @group = SystemGroup.create!(params[:system_group].merge({:organization_id => current_organization.id}))
notify.success _("System Group %s created successfully.") % @group.name
if !search_validate(SystemGroup, @group.id, params[:search])
notify.message _("'%s' did not meet the current search criteria and is not being shown.") % @group.name
render :json => { :no_match => true }
else
respond_to do |format|
- format.html {render :partial => "system_groups/list_group", :locals=>{:item=>@group, :accessor=>"id",
- :name=>controller_display_name}}
+ format.html {render :partial => "system_groups/list_group", :locals => {:item => @group, :accessor => "id",
+ :name => controller_display_name}}
format.json {render :json => @group}
end
end
@@ -98,17 +98,18 @@ def copy
notify.success _("System Group %{new_group} created successfully as a copy of system group %{group}.") % {:new_group => new_group.name, :group => @group.name}
- render :partial => "system_groups/list_group", :locals=>{:item=>new_group, :accessor=>"id", :name=>controller_display_name}
+ render :partial => "system_groups/list_group", :locals=> {:item => new_group, :accessor => "id",
+ :name => controller_display_name}
end
def edit
- render :partial => "edit", :locals => {:filter => @group, :name=>controller_display_name,
- :editable=>@group.editable?
- }
+ render :partial => "edit", :locals => {:filter => @group, :name => controller_display_name,
+ :editable => @group.editable?
+ }
end
def show
- render :partial => "system_groups/list_group", :locals=>{:item=>@group, :accessor=>"id", :name=>controller_display_name}
+ render :partial => "system_groups/list_group", :locals => {:item => @group, :accessor => "id", :name => controller_display_name}
end
def update
@@ -133,13 +134,13 @@ def update
:asynchronous => false
end
- render :text=>to_ret
+ render :text => to_ret
end
def destroy
@group.destroy
notify.success _("System Group %s deleted.") % @group.name
- render :partial => "common/list_remove", :locals => {:id=>params[:id], :name=>controller_display_name}
+ render :partial => "common/list_remove", :locals => {:id => params[:id], :name => controller_display_name}
end
def destroy_systems
@@ -154,14 +155,15 @@ def destroy_systems
notify.success _("Deleted System Group %{group} and it's %{count} systems.") % {:group => @group.name, :count => system_names.length.to_s},
:details => system_names.join("\n")
- render :partial => "common/list_remove.js", :locals => {:id=>params[:id], :name=>controller_display_name}
+ render :partial => "common/list_remove.js", :locals => {:id => params[:id], :name => controller_display_name}
end
def items
ids = SystemGroup.readable(current_organization).collect{|s| s.id}
render_panel_direct(SystemGroup, @panel_options, params[:search], params[:offset], [:name_sort, :asc],
- {:default_field => :name, :load=>true, :filter=>[{:id=>ids},{:organization_id=>[current_organization.id]}]})
+ {:default_field => :name, :load => true, :filter => [{:id => ids},
+ {:organization_id => [current_organization.id]}]})
end
def panel_options
@@ -171,43 +173,43 @@ def panel_options
:titles => [_('Name')],
:create => _('System Group'),
:name => controller_display_name,
- :ajax_scroll=>items_system_groups_path(),
- :enable_create=> SystemGroup.creatable?(current_organization),
- :initial_action=>:systems,
+ :ajax_scroll => items_system_groups_path(),
+ :enable_create => SystemGroup.creatable?(current_organization),
+ :initial_action =>:systems,
:list_partial => 'system_groups/list_groups',
- :ajax_load=>true,
- :search_class=>SystemGroup
+ :ajax_load => true,
+ :search_class => SystemGroup
}
end
def systems
@system_joins = @group.system_system_groups.sort_by{|a| a.system.name}
render :partial => "systems",
- :locals => {:filter => @group, :name=>controller_display_name, :editable=>@group.editable?,
- :systems_deletable=>@group.systems_deletable?}
+ :locals => {:filter => @group, :name => controller_display_name, :editable => @group.editable?,
+ :systems_deletable => @group.systems_deletable?}
end
def add_systems
ids = params[:system_ids].collect{|s| s.to_i} - @group.system_ids #ignore dups
- systems = System.readable(current_organization).where(:id=>ids)
+ systems = System.readable(current_organization).where(:id => ids)
@group.system_ids = (@group.system_ids + systems.collect{|s| s.id}).uniq
@group.save!
- system_joins = @group.system_system_groups.where(:system_id=>ids)
+ system_joins = @group.system_system_groups.where(:system_id => ids)
notify.success _("Successfully added system[s] to group '%s'.") % @group.name
- render :partial=>'system_item', :collection=>system_joins, :as=>:system,
- :locals=>{:editable=>@group.editable?}
+ render :partial => 'system_item', :collection => system_joins, :as => :system,
+ :locals => {:editable => @group.editable?}
end
def remove_systems
- systems = System.readable(current_organization).where(:id=>params[:system_ids]).collect{|s| s.id}
+ systems = System.readable(current_organization).where(:id => params[:system_ids]).collect{|s| s.id}
@group.system_ids = (@group.system_ids - systems).uniq
@group.save!
notify.success _("Successfully removed system[s] from group '%s'.") % @group.name
- render :text=>''
+ render :text => ''
end
def edit_systems
@@ -230,7 +232,7 @@ def update_systems
notify.success _("Successfully updated environment and content view for all systems in group %{group}") %
{:group => @group.name}
- render :text=>''
+ render :text => ''
end
def auto_complete
@@ -242,11 +244,11 @@ def auto_complete
string query
end
filter :term, {:organization_id => org.id}
- filter :terms, {:id=>SystemGroup.editable(org).collect{|g| g.id}}
+ filter :terms, {:id => SystemGroup.editable(org).collect{|g| g.id}}
end
- render :json=>groups.map{|s| {:label=>s.name, :value=>s.name, :id=>s.id}}
+ render :json => groups.map{|s| {:label => s.name, :value => s.name, :id => s.id}}
rescue Tire::Search::SearchRequestFailed => e
- render :json=>Util::Support.array_with_total
+ render :json => Util::Support.array_with_total
end
def controller_display_name
@@ -255,7 +257,7 @@ def controller_display_name
def validate_name
name = params[:term]
- render :json=>SystemGroup.search("name:#{name}").count
+ render :json => SystemGroup.search("name:#{name}").count
end
def find_group
Oops, something went wrong.

0 comments on commit e036360

Please sign in to comment.