mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Switching enterprise relationships form around
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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)'}
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user