Switch to correct grammatical ordering of child/parent enterprise on enterprise relationships page

This commit is contained in:
Rohan Mitchell
2014-08-26 15:42:35 +10:00
parent a5debc19dc
commit 1871d42e68
5 changed files with 10 additions and 10 deletions

View File

@@ -21,7 +21,7 @@ class EnterpriseRelationship < ActiveRecord::Base
where('enterprise_relationship_permissions.name = ?', permission)
}
scope :by_name, with_enterprises.order('parent_enterprises.name, child_enterprises.name')
scope :by_name, with_enterprises.order('child_enterprises.name, parent_enterprises.name')
def permissions_list=(perms)

View File

@@ -1,8 +1,8 @@
%td {{ enterprise_relationship.parent_name }}
%td {{ enterprise_relationship.child_name }}
%td
%ul
%li{"ng-repeat" => "permission in enterprise_relationship.permissions"}
{{ EnterpriseRelationships.permission_presentation(permission.name) }}
%td {{ enterprise_relationship.child_name }}
%td {{ enterprise_relationship.parent_name }}
%td.actions
%a.delete-enterprise-relationship.icon-trash.no-text{'ng-click' => 'delete(enterprise_relationship)'}

View File

@@ -1,6 +1,6 @@
%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{name: "enterprise_relationship_child_id", "ng-model" => "child_id", "ng-options" => "e.id as e.name for e in Enterprises.all_enterprises"}
%td
permits
/ %div{"ng-repeat" => "permission in EnterpriseRelationships.all_permissions"}
@@ -8,7 +8,7 @@
/ %input{type: "checkbox", "ng-model" => "permissions[permission]"}
/ {{ EnterpriseRelationships.permission_presentation(permission) }}
%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{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

@@ -119,6 +119,6 @@ feature %q{
def have_relationship(parent, child, perms=[])
perms = perms.join(' ') || 'permits'
have_table_row [parent.name, perms, child.name, '']
have_table_row [child.name, perms, parent.name, '']
end
end

View File

@@ -6,10 +6,10 @@ describe EnterpriseRelationship do
let(:e2) { create(:enterprise, name: 'B') }
let(:e3) { create(:enterprise, name: 'C') }
it "sorts by parent, child enterprise name" do
er1 = create(:enterprise_relationship, parent: e1, child: e3)
er2 = create(:enterprise_relationship, parent: e2, child: e1)
er3 = create(:enterprise_relationship, parent: e1, child: e2)
it "sorts by child, parent enterprise name" do
er1 = create(:enterprise_relationship, parent: e3, child: e1)
er2 = create(:enterprise_relationship, parent: e1, child: e2)
er3 = create(:enterprise_relationship, parent: e2, child: e1)
EnterpriseRelationship.by_name.should == [er3, er1, er2]
end