Switching enterprise relationships form around

This commit is contained in:
Rob H
2014-09-05 17:11:57 +10:00
parent 0fd496aa97
commit 20bfcd6e48
5 changed files with 27 additions and 23 deletions

View File

@@ -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"

View File

@@ -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)'}

View File

@@ -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 }}

View File

@@ -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'

View File

@@ -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