mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Filter relationships by permission
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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
|
||||
@@ -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"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
%tr{"ng-repeat" => "enterprise_relationship in EnterpriseRelationships.enterprise_relationships | filter:query"}
|
||||
%tr{"ng-repeat" => "enterprise_relationship in EnterpriseRelationships.enterprise_relationships | keywords: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) }}
|
||||
to {{ EnterpriseRelationships.permission_presentation(permission.name) }}
|
||||
%td.actions
|
||||
%a.delete-enterprise-relationship.icon-trash.no-text{'ng-click' => 'delete(enterprise_relationship)'}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
%input.search{"ng-model" => "query", "placeholder" => "Search"}
|
||||
|
||||
%label{ng: {repeat: "permission in EnterpriseRelationships.all_permissions"}}
|
||||
%input{type: "checkbox", ng: {click: "$parent.query = toggleKeyword($parent.query, permission)"}}
|
||||
{{ EnterpriseRelationships.permission_presentation(permission) }}
|
||||
@@ -6,7 +6,7 @@
|
||||
%div{"ng-app" => "ofn.admin", "ng-controller" => "AdminEnterpriseRelationshipsCtrl"}
|
||||
= render 'data'
|
||||
|
||||
%input.search{"ng-model" => "query", "placeholder" => "Search"}
|
||||
= render 'search_input'
|
||||
|
||||
%table#enterprise-relationships
|
||||
%tbody
|
||||
|
||||
Reference in New Issue
Block a user