Sha256: 5a0a765e1c7bb0f6cf495305f45b4e357acc7ac366ab3c44ed1f7cb9a7f28005

Contents?: true

Size: 1.92 KB

Versions: 15

Compression:

Stored size: 1.92 KB

Contents

module ErpApp
	module Desktop
		module UserManagement
			class ApplicationManagementController < ErpApp::Desktop::UserManagement::BaseController
			  
			  def available_applications
          user_id            = params[:user_id]
          app_container_type = params[:app_container_type]

          user = User.find(user_id)
          app_container = "::#{app_container_type}".constantize.find_by_user(user)
          applications  = "#{app_container_type}Application".constantize.all

          current_applications = app_container.applications
          applications.delete_if{|r| current_applications.collect(&:id).include?(r.id)}

          render :json => applications.map{|application| {:text => application.description, :app_id => application.id, :iconCls => application.icon, :leaf => true}}
			  end

			  def current_applications
          user_id            = params[:user_id]
          app_container_type = params[:app_container_type]

          user = User.find(user_id)
          app_container = "::#{app_container_type}".constantize.find_by_user(user)
          
          render :json => app_container.applications.map{|application| {:text => application.description, :app_id => application.id, :iconCls => application.icon, :leaf => true}}
			  end

			  def save_applications
          app_ids            = params[:app_ids]
          user_id            = params[:user_id]
          app_container_type = params[:app_container_type]

          user = User.find(user_id)
          app_container = "::#{app_container_type}".constantize.find_by_user(user)
          app_container.applications = []
          app_container.save

          app_ids.each do |app_id|
            app_container.applications << Application.find(app_id)
          end
          app_container.save
				
          render :json => {:success => true, :message => 'Application(s) Saved'}
			  end
			  
			end
		end
	end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
erp_app-3.0.16 app/controllers/erp_app/desktop/user_management/application_management_controller.rb
erp_app-3.0.15 app/controllers/erp_app/desktop/user_management/application_management_controller.rb
erp_app-3.0.14 app/controllers/erp_app/desktop/user_management/application_management_controller.rb
erp_app-3.0.13 app/controllers/erp_app/desktop/user_management/application_management_controller.rb
erp_app-3.0.12 app/controllers/erp_app/desktop/user_management/application_management_controller.rb
erp_app-3.0.10 app/controllers/erp_app/desktop/user_management/application_management_controller.rb
erp_app-3.0.9 app/controllers/erp_app/desktop/user_management/application_management_controller.rb
erp_app-3.0.8 app/controllers/erp_app/desktop/user_management/application_management_controller.rb
erp_app-3.0.7 app/controllers/erp_app/desktop/user_management/application_management_controller.rb
erp_app-3.0.6 app/controllers/erp_app/desktop/user_management/application_management_controller.rb
erp_app-3.0.5 app/controllers/erp_app/desktop/user_management/application_management_controller.rb
erp_app-3.0.4 app/controllers/erp_app/desktop/user_management/application_management_controller.rb
erp_app-3.0.3 app/controllers/erp_app/desktop/user_management/application_management_controller.rb
erp_app-3.0.2 app/controllers/erp_app/desktop/user_management/application_management_controller.rb
erp_app-3.0.1 app/controllers/erp_app/desktop/user_management/application_management_controller.rb