Sha256: 8968d9a40b03e2bb1f4b5c2efb3fa430d4bf8c2983b272222637074cfa9b304c

Contents?: true

Size: 1.55 KB

Versions: 37

Compression:

Stored size: 1.55 KB

Contents

class Wco::OfficeActionTemplatesController < Wco::ApplicationController

  before_action :set_lists

  def edit
    @oat = OAT.find params[:id]
    @oat.ties.push Wco::OfficeActionTemplateTie.new
    authorize! :edit, @oat
  end

  def index
    authorize! :index, OAT
    @oats = OAT.all
    @new_oat = OAT.new
    @new_oat.ties.push Wco::OfficeActionTemplateTie.new
  end

  def new
    @oat = OAT.new
    @oat.ties.push Wco::OfficeActionTemplateTie.new
    authorize! :new, @oat
  end

  def show
    @oat = OAT.find params[:id]
    authorize! :show, @oat
  end

  def update
    params[:oat][:ties_attributes].permit!
    if params[:id]
      @oat = OAT.find params[:id]
    else
      @oat = OAT.new
    end
    authorize! :upsert, @oat

    if params[:oat][:ties_attributes]
      params[:oat][:ties_attributes].each do |k, v|
        if !v[:next_office_action_template_id].present?
          params[:oat][:ties_attributes].delete( k )
        end
        if v[:to_delete] == "1"
          OATT.find( v[:id] ).delete
          params[:oat][:ties_attributes].delete( k )
        end
      end
    end

    if @oat.update params[:oat].permit!
      flash_notice @oat
    else
      flash_alert @oat
    end
    redirect_to action: :index
  end

  ##
  ## private
  ##
  private

  def set_lists
    @from_types_list = [ nil, 'Wco::Gallery', 'Wco::Tag' ]
    @from_type = params[:from_type]
    @from_ids_list = []
    if @from_type.present?
      @from_ids_list = @from_type.constantize.list
    end
    @publishers_list = Wco::Publisher.list

    @oats_list = OAT.list
  end


end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
wco_models-3.1.0.122 app/controllers/wco/office_action_templates_controller.rb
wco_models-3.1.0.121 app/controllers/wco/office_action_templates_controller.rb
wco_models-3.1.0.120 app/controllers/wco/office_action_templates_controller.rb
wco_models-3.1.0.119 app/controllers/wco/office_action_templates_controller.rb
wco_models-3.1.0.118 app/controllers/wco/office_action_templates_controller.rb
wco_models-3.1.0.117 app/controllers/wco/office_action_templates_controller.rb
wco_models-3.1.0.116 app/controllers/wco/office_action_templates_controller.rb
wco_models-3.1.0.115 app/controllers/wco/office_action_templates_controller.rb
wco_models-3.1.0.114 app/controllers/wco/office_action_templates_controller.rb
wco_models-3.1.0.113 app/controllers/wco/office_action_templates_controller.rb
wco_models-3.1.0.112 app/controllers/wco/office_action_templates_controller.rb
wco_models-3.1.0.111 app/controllers/wco/office_action_templates_controller.rb
wco_models-3.1.0.110 app/controllers/wco/office_action_templates_controller.rb
wco_models-3.1.0.109 app/controllers/wco/office_action_templates_controller.rb
wco_models-3.1.0.108 app/controllers/wco/office_action_templates_controller.rb
wco_models-3.1.0.107 app/controllers/wco/office_action_templates_controller.rb
wco_models-3.1.0.106 app/controllers/wco/office_action_templates_controller.rb
wco_models-3.1.0.105 app/controllers/wco/office_action_templates_controller.rb
wco_models-3.1.0.104 app/controllers/wco/office_action_templates_controller.rb
wco_models-3.1.0.103 app/controllers/wco/office_action_templates_controller.rb