Sha256: 2579545b60d892debc8de4f869cc3c9cde12567754286eeaf9cd383baf70de00

Contents?: true

Size: 1.02 KB

Versions: 14

Compression:

Stored size: 1.02 KB

Contents

module Admin
  class CustomFieldsController < BaseController

    layout false

    before_filter :set_parent_and_fields

    def edit
      @field = @fields.find(params[:id])
      render :action => "edit_#{@field.kind.downcase}"
    end

    def update
      @field = @fields.find(params[:id])
      @field.updated_at = Time.now # forces mongoid to save the object

      params[:custom_field][:category_items_attributes].delete('-1')

      if @field.update_attributes(params[:custom_field])
        render :json => @field.attributes
      else
        render :json => { :error => t('flash.admin.custom_fields.update.alert') }
      end
    end

    protected

    def set_parent_and_fields
      if params[:parent] == 'asset_collection'
        @parent = current_site.asset_collections.where(:slug => params[:slug]).first
        @fields = @parent.asset_custom_fields
      else
        @parent = current_site.content_types.where(:slug => params[:slug]).first
        @fields = @parent.content_custom_fields
      end
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
locomotive_cms-1.0.0.beta.2 app/controllers/admin/custom_fields_controller.rb
locomotive_cms-1.0.0.beta app/controllers/admin/custom_fields_controller.rb
locomotive_cms-0.0.4.beta12 app/controllers/admin/custom_fields_controller.rb
locomotive_cms-0.0.4.beta11 app/controllers/admin/custom_fields_controller.rb
locomotive_cms-0.0.4.beta10 app/controllers/admin/custom_fields_controller.rb
locomotive_cms-0.0.4.beta9 app/controllers/admin/custom_fields_controller.rb
locomotive_cms-0.0.4.beta8 app/controllers/admin/custom_fields_controller.rb
locomotive_cms-0.0.4.beta7 app/controllers/admin/custom_fields_controller.rb
locomotive_cms-0.0.4.beta5 app/controllers/admin/custom_fields_controller.rb
locomotive_cms-0.0.4.beta4 app/controllers/admin/custom_fields_controller.rb
locomotive_cms-0.0.4.beta3 app/controllers/admin/custom_fields_controller.rb
locomotive_cms-0.0.4.beta2 app/controllers/admin/custom_fields_controller.rb
locomotive_cms-0.0.4.beta1 app/controllers/admin/custom_fields_controller.rb
locomotive_cms-0.0.4 app/controllers/admin/custom_fields_controller.rb