Class: ErpApp::Desktop::ConfigurationManagement::OptionsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- ApplicationController
- BaseController
- ErpApp::Desktop::ConfigurationManagement::OptionsController
- Defined in:
- app/controllers/erp_app/desktop/configuration_management/options_controller.rb
Instance Method Summary collapse
Instance Method Details
#create_or_update ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/erp_app/desktop/configuration_management/options_controller.rb', line 31 def create_or_update option = params[:model_id].blank? ? ConfigurationOption.new : ConfigurationOption.find(params[:model_id]) option.value = params[:value] option.internal_identifier = params[:internal_identifier] option.comment = params[:comment] option.description = params[:description] if option.save render :json => {:success => true} else render :json => {:success => false} end end |
#destroy ⇒ Object
44 45 46 47 48 49 50 |
# File 'app/controllers/erp_app/desktop/configuration_management/options_controller.rb', line 44 def destroy if ConfigurationOption.destroy(params[:id]) render :json => {:success => true} else render :json => {:success => false} end end |
#index ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/erp_app/desktop/configuration_management/options_controller.rb', line 6 def index = ConfigurationOption.arel_table arel_query = ConfigurationOption.where([:value].matches("%#{params[:query]}%") .or([:internal_identifier].matches("%#{params[:query]}%"))) .where([:user_defined].eq(false)) .limit(params[:limit]) .offset(params[:start]) = arel_query.all respond_to do |format| format.json { render :json => { :success => true, :total_count => .count, :options => .collect { |option| option.to_hash(:only => [:id, :description, :comment, :value, :internal_identifier]) }} } format.tree { render :json => .collect { |option| option.to_hash(:only => [:internal_identifier, :value, :comment, :description], :text => option.description, :model_id => option.id, :iconCls => 'icon-document', :leaf => true, :children => []) } } end end |