1
0

Preliminary Target :edit support

This commit is contained in:
cryptogopher 2020-08-25 02:55:21 +02:00
parent 8d4e5215b3
commit 6ba8ad5376
4 changed files with 11 additions and 5 deletions

View File

@ -5,7 +5,7 @@ class TargetsController < ApplicationController
include Concerns::Finders
before_action :find_goal_by_project_id, only: [:index, :new]
before_action :find_goal_by_project_id, only: [:index, :new, :edit]
#, if: ->{ params[:project_id].present? }
#before_action :find_goal, only: [:index, :new],
# unless: -> { @goal }
@ -51,6 +51,7 @@ class TargetsController < ApplicationController
end
def edit
@targets = @goal.targets.where(effective_from: params[:effective_from])
end
def update
@ -108,6 +109,6 @@ class TargetsController < ApplicationController
else
{view: :by_scope, scope: :all}
end
@view_params[:goal_id] = @goal.id if @goal
#@view_params[:goal_id] = @goal.id if @goal
end
end

View File

@ -6,7 +6,7 @@ module TargetsHelper
def action_links(d)
link_to(l(:button_reapply), reapply_project_targets_path(@project, d, @view_params),
{remote: true, class: "icon icon-reload"}) +
link_to(l(:button_edit), edit_target_path(@project, d, @view_params),
link_to(l(:button_edit), edit_project_targets_path(@project, d, @view_params),
{remote: true, class: "icon icon-edit"}) +
delete_link(target_path(d), {remote: true, data: {}})
end

View File

@ -12,8 +12,9 @@ resources :projects, shallow: true do
post 'toggle_exposure', to: 'goals#toggle_exposure'
end
end
resources :targets, except: [:show] do
resources :targets, except: [:show, :edit] do
collection do
get 'edit/:date', to: 'targets#edit', as: :edit
post 'reapply/:date', to: 'targets#reapply', as: :reapply
end
end

View File

@ -75,6 +75,10 @@ class TargetsTest < BodyTrackingSystemTestCase
assert_equal @project1.goals.binding, Target.last.goal
end
def test_edit
# TODO: test_create_failure(s)
# * restoring user input
# * removing empty targets
def test_update
end
end