From 3f466e86b62c123930050cd05a2b2f57bfdec6b6 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 26 Feb 2016 00:17:36 +1100 Subject: [PATCH] Renaming 'Override Variant Details' permission to 'Add Products To Inventory' Style changes to make enterprise relationships page more useable --- .../services/enterprise_relationships.js.coffee | 2 +- .../enterprise_relationships/_form.html.haml | 4 ++-- .../enterprise_relationships/index.html.haml | 6 ++++++ .../admin/enterprise_relationships_spec.rb | 16 ++++++++-------- .../enterprise_relationships_spec.js.coffee | 2 +- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/admin/services/enterprise_relationships.js.coffee b/app/assets/javascripts/admin/services/enterprise_relationships.js.coffee index 8c7d798138..0fcd41969c 100644 --- a/app/assets/javascripts/admin/services/enterprise_relationships.js.coffee +++ b/app/assets/javascripts/admin/services/enterprise_relationships.js.coffee @@ -29,4 +29,4 @@ angular.module("ofn.admin").factory 'EnterpriseRelationships', ($http, enterpris when "add_to_order_cycle" then "add to order cycle" when "manage_products" then "manage products" when "edit_profile" then "edit profile" - when "create_variant_overrides" then "override variant details" + when "create_variant_overrides" then "add products to inventory" diff --git a/app/views/admin/enterprise_relationships/_form.html.haml b/app/views/admin/enterprise_relationships/_form.html.haml index 433f9f4ca0..b130faeb1a 100644 --- a/app/views/admin/enterprise_relationships/_form.html.haml +++ b/app/views/admin/enterprise_relationships/_form.html.haml @@ -1,11 +1,11 @@ %tr %td - %select{name: "enterprise_relationship_parent_id", "ng-model" => "parent_id", "ng-options" => "e.id as e.name for e in Enterprises.my_enterprises"} + %select.select2.fullwidth{id: "enterprise_relationship_parent_id", "ng-model" => "parent_id", "ng-options" => "e.id as e.name for e in Enterprises.my_enterprises"} %td permits %td - %select{name: "enterprise_relationship_child_id", "ng-model" => "child_id", "ng-options" => "e.id as e.name for e in Enterprises.all_enterprises"} + %select.select2.fullwidth{id: "enterprise_relationship_child_id", "ng-model" => "child_id", "ng-options" => "e.id as e.name for e in Enterprises.all_enterprises"} %td %label %input{type: "checkbox", ng: {checked: "allPermissionsChecked()", click: "checkAllPermissions()"}} diff --git a/app/views/admin/enterprise_relationships/index.html.haml b/app/views/admin/enterprise_relationships/index.html.haml index 40fbdbc415..163200a0fc 100644 --- a/app/views/admin/enterprise_relationships/index.html.haml +++ b/app/views/admin/enterprise_relationships/index.html.haml @@ -9,6 +9,12 @@ = render 'search_input' %table#enterprise-relationships + %colgroup + %col{ style: "width: 30%" } + %col{ style: "width: 5%" } + %col{ style: "width: 30%" } + %col{ style: "width: 30%" } + %col{ style: "width: 5%" } %tbody = render 'form' = render 'enterprise_relationship' diff --git a/spec/features/admin/enterprise_relationships_spec.rb b/spec/features/admin/enterprise_relationships_spec.rb index ef0f1e5537..85a0a87ee2 100644 --- a/spec/features/admin/enterprise_relationships_spec.rb +++ b/spec/features/admin/enterprise_relationships_spec.rb @@ -37,17 +37,17 @@ feature %q{ e2 = create(:enterprise, name: 'Two') visit admin_enterprise_relationships_path - select 'One', from: 'enterprise_relationship_parent_id' + select2_select 'One', from: 'enterprise_relationship_parent_id' check 'to add to order cycle' check 'to manage products' uncheck 'to manage products' check 'to edit profile' - check 'to override variant details' - select 'Two', from: 'enterprise_relationship_child_id' + check 'to add products to inventory' + select2_select 'Two', from: 'enterprise_relationship_child_id' click_button 'Create' - page.should have_relationship e1, e2, ['to add to order cycle', 'to override variant details', 'to edit profile'] + page.should have_relationship e1, e2, ['to add to order cycle', 'to add products to inventory', 'to edit profile'] er = EnterpriseRelationship.where(parent_id: e1, child_id: e2).first er.should be_present er.permissions.map(&:name).should match_array ['add_to_order_cycle', 'edit_profile', 'create_variant_overrides'] @@ -62,8 +62,8 @@ feature %q{ expect do # When I attempt to create a duplicate relationship visit admin_enterprise_relationships_path - select 'One', from: 'enterprise_relationship_parent_id' - select 'Two', from: 'enterprise_relationship_child_id' + select2_select 'One', from: 'enterprise_relationship_parent_id' + select2_select 'Two', from: 'enterprise_relationship_child_id' click_button 'Create' # Then I should see an error message @@ -110,8 +110,8 @@ feature %q{ scenario "enterprise user can only add their own enterprises as parent" do visit admin_enterprise_relationships_path - page.should have_select 'enterprise_relationship_parent_id', options: ['', d1.name] - page.should have_select 'enterprise_relationship_child_id', options: ['', d1.name, d2.name, d3.name] + page.should have_select2 'enterprise_relationship_parent_id', options: ['', d1.name] + page.should have_select2 'enterprise_relationship_child_id', options: ['', d1.name, d2.name, d3.name] end end diff --git a/spec/javascripts/unit/admin/services/enterprise_relationships_spec.js.coffee b/spec/javascripts/unit/admin/services/enterprise_relationships_spec.js.coffee index 0d0a01215d..96ac4a8905 100644 --- a/spec/javascripts/unit/admin/services/enterprise_relationships_spec.js.coffee +++ b/spec/javascripts/unit/admin/services/enterprise_relationships_spec.js.coffee @@ -15,4 +15,4 @@ describe "enterprise relationships", -> expect(EnterpriseRelationships.permission_presentation("add_to_order_cycle")).toEqual "add to order cycle" expect(EnterpriseRelationships.permission_presentation("manage_products")).toEqual "manage products" expect(EnterpriseRelationships.permission_presentation("edit_profile")).toEqual "edit profile" - expect(EnterpriseRelationships.permission_presentation("create_variant_overrides")).toEqual "override variant details" + expect(EnterpriseRelationships.permission_presentation("create_variant_overrides")).toEqual "add products to inventory"