Filter relationships by permission

This commit is contained in:
Maikel Linke
2015-06-12 17:02:40 +10:00
parent 61effc03c1
commit d717c38f6d
6 changed files with 31 additions and 7 deletions

View File

@@ -10,6 +10,18 @@ angular.module("ofn.admin").controller "AdminEnterpriseRelationshipsCtrl", ($sco
if confirm("Are you sure?")
$scope.EnterpriseRelationships.delete enterprise_relationship
$scope.toggleKeyword = (string, key) ->
string = '' unless string
words = string.split ' '
words = words.filter (s) ->
s
index = words.indexOf key
if index > -1
words.splice index, 1
else
words.push key
words.join ' '
$scope.allPermissionsChecked = ->
for i in EnterpriseRelationships.all_permissions
if !$scope.permissions[i]

View File

@@ -0,0 +1,7 @@
angular.module("ofn.admin").filter "keywords", ($filter) ->
return (array, query) ->
return array unless query
keywords = query.split ' '
keywords.forEach (key) ->
array = $filter('filter')(array, key)
array

View File

@@ -26,7 +26,7 @@ angular.module("ofn.admin").factory 'EnterpriseRelationships', ($http, enterpris
permission_presentation: (permission) ->
switch permission
when "add_to_order_cycle" then "to add to order cycle"
when "manage_products" then "to manage products"
when "edit_profile" then "to edit profile"
when "create_variant_overrides" then "to override variant details"
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"