From 20bfcd6e48adeaa6de0cac2c6f968c0fcc1859e4 Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 5 Sep 2014 17:11:57 +1000 Subject: [PATCH] Switching enterprise relationships form around --- .../enterprise_relationships.js.coffee | 4 ++-- .../_enterprise_relationship.html.haml | 18 ++++++++++-------- .../enterprise_relationships/_form.html.haml | 7 +++++-- .../enterprise_relationships/index.html.haml | 3 +-- .../admin/enterprise_relationships_spec.rb | 18 +++++++++--------- 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/app/assets/javascripts/admin/services/enterprise_relationships.js.coffee b/app/assets/javascripts/admin/services/enterprise_relationships.js.coffee index cad556efd8..16c9c38fea 100644 --- a/app/assets/javascripts/admin/services/enterprise_relationships.js.coffee +++ b/app/assets/javascripts/admin/services/enterprise_relationships.js.coffee @@ -24,5 +24,5 @@ angular.module("ofn.admin").factory 'EnterpriseRelationships', ($http, enterpris permission_presentation: (permission) -> switch permission - when "add_to_order_cycle" then "can add to order cycle" - when "manage_products" then "can manage the products of" + when "add_to_order_cycle" then "to add to order cycle" + when "manage_products" then "to manage products" diff --git a/app/views/admin/enterprise_relationships/_enterprise_relationship.html.haml b/app/views/admin/enterprise_relationships/_enterprise_relationship.html.haml index 6a7dcdc7f4..45e79b1877 100644 --- a/app/views/admin/enterprise_relationships/_enterprise_relationship.html.haml +++ b/app/views/admin/enterprise_relationships/_enterprise_relationship.html.haml @@ -1,8 +1,10 @@ -%td {{ enterprise_relationship.child_name }} -%td - %ul - %li{"ng-repeat" => "permission in enterprise_relationship.permissions"} - {{ EnterpriseRelationships.permission_presentation(permission.name) }} -%td {{ enterprise_relationship.parent_name }} -%td.actions - %a.delete-enterprise-relationship.icon-trash.no-text{'ng-click' => 'delete(enterprise_relationship)'} +%tr{"ng-repeat" => "enterprise_relationship in EnterpriseRelationships.enterprise_relationships | filter:query"} + %td {{ enterprise_relationship.parent_name }} + %td permits + %td {{ enterprise_relationship.child_name }} + %td + %ul + %li{"ng-repeat" => "permission in enterprise_relationship.permissions"} + {{ EnterpriseRelationships.permission_presentation(permission.name) }} + %td.actions + %a.delete-enterprise-relationship.icon-trash.no-text{'ng-click' => 'delete(enterprise_relationship)'} diff --git a/app/views/admin/enterprise_relationships/_form.html.haml b/app/views/admin/enterprise_relationships/_form.html.haml index 86086c8781..9d031a57c5 100644 --- a/app/views/admin/enterprise_relationships/_form.html.haml +++ b/app/views/admin/enterprise_relationships/_form.html.haml @@ -1,4 +1,9 @@ %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"} + + %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"} %td @@ -6,8 +11,6 @@ %label %input{type: "checkbox", "ng-model" => "permissions[permission]"} {{ EnterpriseRelationships.permission_presentation(permission) }} - %td - %select{name: "enterprise_relationship_parent_id", "ng-model" => "parent_id", "ng-options" => "e.id as e.name for e in Enterprises.my_enterprises"} %td.actions %input{type: "button", value: "Create", "ng-click" => "create()"} .errors {{ EnterpriseRelationships.create_errors }} diff --git a/app/views/admin/enterprise_relationships/index.html.haml b/app/views/admin/enterprise_relationships/index.html.haml index e0e289efcf..0807a37825 100644 --- a/app/views/admin/enterprise_relationships/index.html.haml +++ b/app/views/admin/enterprise_relationships/index.html.haml @@ -11,5 +11,4 @@ %table#enterprise-relationships %tbody = render 'form' - %tr{"ng-repeat" => "enterprise_relationship in EnterpriseRelationships.enterprise_relationships | filter:query"} - = render 'enterprise_relationship' + = render 'enterprise_relationship' diff --git a/spec/features/admin/enterprise_relationships_spec.rb b/spec/features/admin/enterprise_relationships_spec.rb index 7317f44066..007f663db0 100644 --- a/spec/features/admin/enterprise_relationships_spec.rb +++ b/spec/features/admin/enterprise_relationships_spec.rb @@ -24,10 +24,10 @@ feature %q{ # Then I should see the relationships within('table#enterprise-relationships') do - page.should have_relationship e1, e2, ['can add to order cycle'] - page.should have_relationship e2, e3, ['can manage the products of'] + page.should have_relationship e1, e2, ['to add to order cycle'] + page.should have_relationship e2, e3, ['to manage products'] page.should have_relationship e3, e4, - ['can add to order cycle', 'can manage the products of'] + ['to add to order cycle', 'to manage products'] end end @@ -39,13 +39,13 @@ feature %q{ visit admin_enterprise_relationships_path select 'One', from: 'enterprise_relationship_parent_id' - check 'can add to order cycle' - check 'can manage the products of' - uncheck 'can manage the products of' + check 'to add to order cycle' + check 'to manage products' + uncheck 'to manage products' select 'Two', from: 'enterprise_relationship_child_id' click_button 'Create' - page.should have_relationship e1, e2, ['can add to order cycle'] + page.should have_relationship e1, e2, ['to add to order cycle'] er = EnterpriseRelationship.where(parent_id: e1, child_id: e2).first er.should be_present er.permissions.map(&:name).should == ['add_to_order_cycle'] @@ -118,8 +118,8 @@ feature %q{ private def have_relationship(parent, child, perms=[]) - perms = perms.join(' ') || 'permits' + perms = perms.join(' ') - have_table_row [child.name, perms, parent.name, ''] + have_table_row [parent.name, 'permits', child.name, perms, ''] end end