Class: ErpApp::Shared::ConfigurationController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ErpApp::Shared::ConfigurationController
- Defined in:
- app/controllers/erp_app/shared/configuration_controller.rb
Instance Method Summary collapse
Instance Method Details
#load ⇒ Object
24 25 26 27 28 29 |
# File 'app/controllers/erp_app/shared/configuration_controller.rb', line 24 def load category_id = params[:category_id] configuration = ::Configuration.find(params[:id]) render :json => {:success => true, :configurationItems => configuration.items.by_category(Category.find(category_id)).collect(&:to_js_hash)} end |
#setup ⇒ Object
17 18 19 20 21 22 |
# File 'app/controllers/erp_app/shared/configuration_controller.rb', line 17 def setup category_id = params[:category_id] configuration = ::Configuration.find(params[:id]) render :json => {:success => true, :configurationItemTypes => configuration.item_types.by_category(Category.find(category_id)).order('precedence').order('internal_identifier').collect(&:to_js_hash)} end |
#setup_categories ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'app/controllers/erp_app/shared/configuration_controller.rb', line 6 def setup_categories configuration = ::Configuration.find(params[:id]) tree_array = [].tap do |array| configuration.item_types.collect{|item| item.category_classification.category}.uniq.each do |category| array << category.to_tree_hash(:only => [{:id => :categoryId}], :iconCls => 'icon-index') end end tree_array.sort_by!{|hash| [hash[:text]]} render :json => tree_array end |
#update ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/erp_app/shared/configuration_controller.rb', line 31 def update configuration = ::Configuration.find(params[:id]) begin params.each do |k,v| #options can come is a comma delimited strings and may need to be broken apart = [].tap do || v.split(',').each do |option| << option end end configuration.update_configuration_item(ConfigurationItemType.find_by_internal_identifier(k), ) unless (k.to_s == 'action' or k.to_s == 'controller' or k.to_s == 'id' or k.to_s == 'authenticity_token' or k.to_s == 'client_utc_offset') end render :json => {:success => true, :configurationItems => configuration.items.collect(&:to_js_hash)} rescue => ex logger.error(ex.) logger.error(ex.backtrace) render :json => {:success => false, :message => ex.} end end |