Skip to content

Commit

Permalink
aim logic
Browse files Browse the repository at this point in the history
  • Loading branch information
qinmingyuan committed Mar 6, 2024
1 parent b564a40 commit 05ddd44
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
19 changes: 18 additions & 1 deletion app/controllers/growth/admin/aim_codes_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
module Growth
class Admin::AimCodesController < Admin::BaseController

before_action :set_aim
before_action :set_new_aim_code, only: [:new, :create]
def index
@aim_codes = AimCode.default_where(default_params).page(params[:page])
end

private
def set_aim
@aim = Aim.find params[:aim_id]
end

def set_new_aim_code
@aim_code = @aim.aim_codes.build(aim_code_params)
end

def aim_code_params
params.fetch(:aim_code, {}).permit(
:controller_path,
:action_name
)
end

end
end
1 change: 0 additions & 1 deletion app/views/growth/admin/aim_codes/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
<%= f.text_field :controller_path %>
<%= f.text_field :action_name %>
<%= f.text_field :code %>
2 changes: 1 addition & 1 deletion app/views/growth/admin/aim_logs/_filter_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= form_with theme: 'search', model: AimLog.new do |f| %>
<%= form_with theme: 'search', model: Growth::AimLog.new do |f| %>
<div class="fields">
<%= f.text_field :entity_type %>
<%= f.text_field :entity_id %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/growth/admin/aims/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<%= f.text_field :unit %>
<%= f.number_field :rate %>
<%= f.number_field :reward_amount %>
<%= f.select :repeat_type, options_for_select(Aim.options_i18n(:repeat_type), @aim.repeat_type) %>
<%= 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| %>
<%= render partial: 'item_form', locals: { ef: ef } %>
<% end %>
8 changes: 5 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
namespace 'growth', defaults: { business: 'growth' } do
namespace :admin, defaults: { namespace: 'admin' } do
resources :aims do
get 'add_item/:item' => :add_item, on: :collection, as: :add_item
get 'remove_item/:item' => :remove_item, on: :collection, as: :remove_item
collection do
get 'add_item/:item' => :add_item
get 'remove_item/:item' => :remove_item
end
resources :aim_codes
resources :aim_users, shallow: true, only: [:index, :show, :destroy]
resources :aim_entities, shallow: true, only: [:index, :show, :destroy] do
resources :aim_logs, only: [:index, :destroy]
end
end
resources :aim_codes
resources :rewards, shallow: true do
resources :reward_incomes
end
Expand Down

0 comments on commit 05ddd44

Please sign in to comment.