Sha256: 841763a9ee1a41973b3572a3ffbc1f52056d149239ab86a50cb924bc7ee6379f

Contents?: true

Size: 1.37 KB

Versions: 9

Compression:

Stored size: 1.37 KB

Contents

module Caboose
  class PageBlockFieldValuesController < ApplicationController
    
    # PUT /admin/page-block-field-values/:id
    def admin_update
      return unless user_is_allowed('pages', 'edit')
      
      resp = StdClass.new({'attributes' => {}})
      fv = PageBlockFieldValue.find(params[:id])
                  
      save = true
      user = logged_in_user      
      
      params.each do |k,v|
        case k
          when 'value'
            fv.value = v        
        end
      end      
               
      resp.success = save && fv.save
      render :json => resp
    end
    
    # POST /admin/page-block-field-values/:id/image
    def admin_update_image
      return unless user_is_allowed('pages', 'edit')
      
      resp = StdClass.new({'attributes' => {}})
      fv = PageBlockFieldValue.find(params[:id])
      fv.image = params[:value]
      fv.save
      resp.success = true 
      resp.attributes = { 'value' => { 'value' => fv.image.url(:tiny) }}
      
      render :json => resp
    end
    
    # POST /admin/page-block-field-values/:id/image
    def admin_update_file
      return unless user_is_allowed('pages', 'edit')
      
      resp = StdClass.new({'attributes' => {}})
      fv = PageBlockFieldValue.find(params[:id])
      fv.file = params[:value]               
      resp.success = fv.save      
      
      render :json => resp
    end
		
  end  
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
caboose-cms-0.3.51 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.50 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.49 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.48 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.47 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.46 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.45 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.44 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.43 app/controllers/caboose/page_block_field_values_controller.rb