Module: PermissionHelper
- Defined in:
- app/helpers/permission_helper.rb
Instance Method Summary collapse
- #grant_permission_user_picker(item, perm) ⇒ Object
- #grant_url(item, perm) ⇒ Object
- #jquery_grant_callback(item, perm) ⇒ Object
- #prototype_grant_callback(item, perm) ⇒ Object
Instance Method Details
#grant_permission_user_picker(item, perm) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'app/helpers/permission_helper.rb', line 34 def (item, perm) callback = case AeUsers.js_framework when "prototype" prototype_grant_callback(item, perm) when "jquery" jquery_grant_callback(item, perm) end user_picker "#{perm}_grantee", :roles => true, :callback => callback end |
#grant_url(item, perm) ⇒ Object
2 3 4 5 |
# File 'app/helpers/permission_helper.rb', line 2 def grant_url(item, perm) url_for(:controller => 'permission', :action => 'grant', :perm => (item, perm), :item_klass => item.class.name, :item_id => item.id, :escape => false) end |
#jquery_grant_callback(item, perm) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/helpers/permission_helper.rb', line 22 def jquery_grant_callback(item, perm) return <<-EOF $('##{perm}_nobody').remove(); $.get('#{grant_url(item, perm)}', { 'klass': klass, 'id': id }, function(data) { $('##{perm}_insert_grants_here').append(data); } ); EOF end |
#prototype_grant_callback(item, perm) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/helpers/permission_helper.rb', line 7 def prototype_grant_callback(item, perm) return <<-EOF nobody = $('#{perm}_nobody'); if (nobody) { nobody.remove(); } new Ajax.Updater('#{perm}_insert_grants_here', '#{grant_url(item, perm)}', { parameters: { 'klass': klass, 'id': id }, insertion: Insertion.Bottom, } ); EOF end |