diff --git a/app/controllers/growth/admin/aims_controller.rb b/app/controllers/growth/admin/aims_controller.rb index 44214f3..132e7e6 100644 --- a/app/controllers/growth/admin/aims_controller.rb +++ b/app/controllers/growth/admin/aims_controller.rb @@ -1,45 +1,31 @@ module Growth class Admin::AimsController < Admin::BaseController - before_action :set_aim, only: [:show, :edit, :update, :destroy] + before_action :set_aim, only: [:show, :edit, :update, :destroy, :actions] + before_action :set_new_aim, only: [:new, :create] def index @aims = Aim.includes(:aim_codes).order(id: :desc).page(params[:page]) end def new - @aim = Aim.new @aim.aim_codes.build end - def create - @aim = Aim.new(aim_params) - - if @aim.save - redirect_to admin_aims_url, notice: 'Aim was successfully created.' - else - render :new - end - end - def edit if @aim.aim_codes.count == 0 @aim.aim_codes.build end end - def add_item - @aim = Aim.new - @aim.aim_codes.build - end - - def remove_item - end - private def set_aim @aim = Aim.find(params[:id]) end + def set_new_aim + @aim = Aim.new(aim_params) + end + def aim_params params.fetch(:aim, {}).permit( :name, diff --git a/app/views/growth/admin/aims/_form.html.erb b/app/views/growth/admin/aims/_form.html.erb index 5a456e5..db94bfe 100644 --- a/app/views/growth/admin/aims/_form.html.erb +++ b/app/views/growth/admin/aims/_form.html.erb @@ -5,6 +5,6 @@ <%= f.number_field :rate %> <%= f.number_field :reward_amount %> <%= f.select :repeat_type, options_for_select(Growth::Aim.options_i18n(:repeat_type), @aim.repeat_type) %> -<%= f.fields :aim_codes, on: { wrap_all: false, label: false, placeholder: true }, css: { wrap_input: 'two wide field' } do |ef| %> +<%= f.fields :aim_codes, wrap: { input: 'field is-narrow' }, all: { normal: nil }, label: nil, placeholder: true do |ef| %> <%= render partial: 'item_form', locals: { ef: ef } %> <% end %> diff --git a/app/views/growth/admin/aims/_item_form.html.erb b/app/views/growth/admin/aims/_item_form.html.erb index b1b6d79..422b068 100644 --- a/app/views/growth/admin/aims/_item_form.html.erb +++ b/app/views/growth/admin/aims/_item_form.html.erb @@ -1,24 +1,15 @@ -