Class: ErpApp::Desktop::Scaffold::BaseController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- ApplicationController
- BaseController
- ErpApp::Desktop::Scaffold::BaseController
- Defined in:
- app/controllers/erp_app/desktop/scaffold/base_controller.rb
Instance Method Summary collapse
Methods inherited from BaseController
Instance Method Details
#data ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/erp_app/desktop/scaffold/base_controller.rb', line 53 def data active_ext_core = setup_active_ext_core json_text = nil if request.get? json_text = ActiveExt::ExtHelpers::DataHelper.build_json_data(active_ext_core, :limit => params[:limit], :offset => params[:start]) elsif request.post? json_text = ActiveExt::ExtHelpers::DataHelper.create_record(active_ext_core, :data => params[:data]) elsif request.put? json_text = ActiveExt::ExtHelpers::DataHelper.update_record(active_ext_core, :data => params[:data], :id => params[:data][:id]) elsif request.delete? json_text = ActiveExt::ExtHelpers::DataHelper.delete_record(active_ext_core, :data => params[:data], :id => params[:data][:id]) end render :inline => json_text end |
#get_columns ⇒ Object
30 31 32 33 34 35 36 |
# File 'app/controllers/erp_app/desktop/scaffold/base_controller.rb', line 30 def get_columns active_ext_core = ActiveExt::Core.new(params[:model], :ignore_associations => true, :include_timestamps => false) non_excluded_columns = active_ext_core.non_excluded_columns.collect{|column| {:name => column.name}} render :json => {:success => true, :columns => non_excluded_columns.sort{|a,b| a[:name] <=> b[:name]}} end |
#get_models ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/erp_app/desktop/scaffold/base_controller.rb', line 9 def get_models names = ActiveRecord::Base.all_subclasses.collect{|klass| klass.name}.delete_if{|item| item =~ /::/}.uniq.sort{|a,b| a <=> b} names = names.select { |name| name =~ Regexp.new("^#{params[:name]}.", Regexp::IGNORECASE)} respond_to do |format| format.json do render :json => {:success => true, :names => names.collect{|name| {:name => name}}} end format.tree do if params[:node].blank? || params[:node] == "root" render :json => {:success => true, :names => names.collect{|model| {:text => model, :id => model.underscore, :model => model, :iconCls => 'icon-grid', :leaf => false}}} else active_ext_core = ActiveExt::Core.new(params[:node].classify, :ignore_associations => true, :include_timestamps => false) non_excluded_columns = active_ext_core.non_excluded_columns.collect{|column| column.name} render :json => {:success => true, :names => non_excluded_columns.collect{|column| {:text => column, :iconCls => 'icon-gear', :leaf => true}}} end end end end |
#setup ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/erp_app/desktop/scaffold/base_controller.rb', line 38 def setup active_ext_core = setup_active_ext_core columns, fields, validations = ActiveExt::ExtHelpers::TableBuilder.generate_columns_and_fields(active_ext_core) result = { :success => true, :use_ext_forms => active_ext_core.[:use_ext_forms].nil? ? false : active_ext_core.[:use_ext_forms], :inline_edit => active_ext_core.[:inline_edit].nil? ? false : active_ext_core.[:inline_edit], :columns => columns, :fields => fields, :validations => validations } render :inline => result.to_json end |