Sha256: 41d87930f4518933dc53e369c2c5ded8d7c9d42fb08af5a8950889a7ff0aec97

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

class ErpForms::ErpApp::Desktop::DynamicForms::ModelsController < ErpForms::ErpApp::Desktop::DynamicForms::BaseController
  
  # get dynamic form models
  # used in dynamic forms widget combo box
  def index
    models = []
    dynamic_form_models = DynamicFormModel.where("model_name != 'DynamicFormDocument'").order('model_name ASC')
    dynamic_form_models.each do |m|
      model_hash = {
        :id => m.id,
        :model_name => m.model_name,      
      }
      
      models << model_hash
    end
    
    render :json => models
  end

  # set default form for this model
  def set_default_form
    myDynamicObject = DynamicFormModel.get_constant(params[:model_name])    
    myDynamicObject.set_default(params[:id])
	
    render :json => {success => true}
  end

  # delete a dynamic form model
  def delete
    DynamicFormModel.destroy(params[:id])
	
    render :json => {:success => true}
  end
  
  # create a dynamic form model
  def create
    model_name = params[:model_name]
    DynamicFormModel.create({
      :model_name => model_name
    })
	
    render :json => {:success => true}
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
erp_forms-2.0.2 app/controllers/erp_forms/erp_app/desktop/dynamic_forms/models_controller.rb
erp_forms-2.0.1 app/controllers/erp_forms/erp_app/desktop/dynamic_forms/models_controller.rb