Sha256: 85e1266a8b506b837d5b334f75f8db3a5d537223668b090dbe9d6bd1b7a126b3

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

class PageModuleCollectionsModulesController < ApplicationController
  respond_to :html, :js
  
  before_filter :authenticate_user!
  
  def create
    @page_module_collection = PageModuleCollection.find(params[:page_module_collection_module][:collection_id])
    
    if params[:page_module_collection_module][:module_id].to_i == 0
      @template_namespace = 'page_modules'
      @template = 'new'
      @page_module = PageModule.new(params[:page_module])
      @page_module.collection_id = @page_module_collection.id
      @target_needs_modal_layout = false
      @target = '.modal-content'
      
      render_or_redirect_by_request_type
    else
      @page_module = PageModule.find params[:page_module_collection_module][:module_id]
      @page_module_collection.modules << @page_module
      page_module_collection_module = PageModuleCollectionModule.where(collection_id: @page_module_collection.id).order('position DESC').first
      @collection_module_id = page_module_collection_module.id
      @position = page_module_collection_module.position
      @template_format = 'js'
    end
  end
  
  def destroy
    @page_module_collection_module = PageModuleCollectionModule.find(params[:id]).destroy
    
    if @page_module_collection_module.persisted?
      flash[:alert] = I18n.t('general.form.destroy_failed')
    else
      flash[:notice] = I18n.t('general.form.destroyed')
    end
    
    redirect_to page_module_collection_path(@page_module_collection_module.collection) unless request.xhr?
  end
  
  def resource
    @page_module || @page_module_collection_module
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
home_page-0.0.6 app/controllers/page_module_collections_modules_controller.rb