Sha256: 484c8c4d7cfbe90f10e166ba4eb84b3f5f558e989c579ac0894d33d0081efdbf

Contents?: true

Size: 1.43 KB

Versions: 19

Compression:

Stored size: 1.43 KB

Contents

module ErpApp
	module Desktop
		module UserManagement
			class RoleManagementController < ErpApp::Desktop::UserManagement::BaseController

			  def available_roles
          user_id = params[:user_id]
          roles = SecurityRole.order('description ASC').all

          unless user_id.empty?
            current_role_ids = User.find(user_id).roles.collect{|r| r.id}
            roles.delete_if{|r| current_role_ids.include?(r.id)}
          end

          render :json => roles.map{|role| {:text => role.description, :iconCls => 'icon-user', :leaf => true, :role_id => role.id}}
        end

        def current_roles
          user_id = params[:user_id]
          roles = []

          unless user_id.empty?
            roles = User.find(user_id).roles.order('description ASC')
          end

          render :json => roles.map{|role| {:text => role.description, :iconCls => 'icon-user', :leaf => true, :role_id => role.id}}
        end

			  def save_roles
          role_ids = params[:role_ids]
          user_id  = params[:user_id]

          user = User.find(user_id)
          user.party.remove_all_roles
          unless role_ids.blank?
            roles = SecurityRole.where("id in (#{role_ids.join(',')})").all
            user.party.add_roles(roles)
          end
          user.party.save

          render :json => {:success => true, :message => 'Roles Saved'}
			  end
			  
			end
		end
	end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
erp_app-4.2.0 app/controllers/erp_app/desktop/user_management/role_management_controller.rb
erp_app-4.0.0 app/controllers/erp_app/desktop/user_management/role_management_controller.rb
erp_app-3.1.16 app/controllers/erp_app/desktop/user_management/role_management_controller.rb
erp_app-3.1.15 app/controllers/erp_app/desktop/user_management/role_management_controller.rb
erp_app-3.1.14 app/controllers/erp_app/desktop/user_management/role_management_controller.rb
erp_app-3.1.13 app/controllers/erp_app/desktop/user_management/role_management_controller.rb
erp_app-3.1.12 app/controllers/erp_app/desktop/user_management/role_management_controller.rb
erp_app-3.1.11 app/controllers/erp_app/desktop/user_management/role_management_controller.rb
erp_app-3.1.10 app/controllers/erp_app/desktop/user_management/role_management_controller.rb
erp_app-3.1.9 app/controllers/erp_app/desktop/user_management/role_management_controller.rb
erp_app-3.1.8 app/controllers/erp_app/desktop/user_management/role_management_controller.rb
erp_app-3.1.7 app/controllers/erp_app/desktop/user_management/role_management_controller.rb
erp_app-3.1.6 app/controllers/erp_app/desktop/user_management/role_management_controller.rb
erp_app-3.1.5 app/controllers/erp_app/desktop/user_management/role_management_controller.rb
erp_app-3.1.4 app/controllers/erp_app/desktop/user_management/role_management_controller.rb
erp_app-3.1.3 app/controllers/erp_app/desktop/user_management/role_management_controller.rb
erp_app-3.1.2 app/controllers/erp_app/desktop/user_management/role_management_controller.rb
erp_app-3.1.1 app/controllers/erp_app/desktop/user_management/role_management_controller.rb
erp_app-3.1.0 app/controllers/erp_app/desktop/user_management/role_management_controller.rb