Sha256: 4c14c9dbd21d5e071514e4a599b073b3c63ff887123e74233e39b01eaa650e99
Contents?: true
Size: 1.17 KB
Versions: 10
Compression:
Stored size: 1.17 KB
Contents
module PermissionHelper def grant_url(item, perm) url_for(:controller => 'permission', :action => 'grant', :perm => full_permission_name(item, perm), :item_klass => item.class.name, :item_id => item.id, :escape => false) end 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 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 def grant_permission_user_picker(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 end
Version data entries
10 entries across 10 versions & 1 rubygems