diff --git a/app/controllers/admin/enterprise_groups_controller.rb b/app/controllers/admin/enterprise_groups_controller.rb index 32280b7fa3..3f8888edfb 100644 --- a/app/controllers/admin/enterprise_groups_controller.rb +++ b/app/controllers/admin/enterprise_groups_controller.rb @@ -1,6 +1,7 @@ module Admin class EnterpriseGroupsController < ResourceController - before_filter :load_countries, :except => :index + before_filter :load_data, except: :index + before_filter :load_object_data, only: [:new, :edit, :create, :update] def index @enterprise_groups = @enterprise_groups.managed_by(spree_current_user) @@ -34,10 +35,16 @@ module Admin private - def load_countries + def load_data @countries = Spree::Country.order(:name) + @enterprises = Enterprise.activated end + def load_object_data + @owner_email = @enterprise_group.andand.owner.andand.email || "" + end + + def collection EnterpriseGroup.by_position end diff --git a/app/views/admin/enterprise_groups/_inputs.html.haml b/app/views/admin/enterprise_groups/_inputs.html.haml index 02f5aa337c..dbf8606af6 100644 --- a/app/views/admin/enterprise_groups/_inputs.html.haml +++ b/app/views/admin/enterprise_groups/_inputs.html.haml @@ -17,8 +17,7 @@ .with-tip{'data-powertip' => "The primary user responsible for this group."} %a What's this? .eight.columns.omega - - owner_email = @enterprise_group.andand.owner.andand.email || "" - = f.hidden_field :owner_id, class: "select2 fullwidth", 'ofn-user-autocomplete' => true, email: owner_email + = f.hidden_field :owner_id, class: "select2 fullwidth", 'ofn-user-autocomplete' => true, email: @owner_email = f.field_container :on_front_page do = f.label :on_front_page, 'On front page?' @@ -28,7 +27,7 @@ = f.field_container :enterprise_ids do = f.label :enterprise_ids, 'Enterprises' %br/ - = f.collection_select :enterprise_ids, Enterprise.activated, :id, :name, {}, {class: "select2 fullwidth", multiple: true} + = f.collection_select :enterprise_ids, @enterprises, :id, :name, {}, {class: "select2 fullwidth", multiple: true} %fieldset.alpha.no-border-bottom{ ng: { show: "menu.selected.name=='About'" } } %legend About