Skip to content

Commit

Permalink
Merge pull request #1048 from sparc-request/jm-edit-visit-position-bug
Browse files Browse the repository at this point in the history
JM - (SPARCDashboard) Edit Visit Position Bug [#149936624] https://ww…
  • Loading branch information
Stuart-Johnson committed Aug 4, 2017
2 parents e317688 + 2b347a5 commit 5fbf220
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/controllers/dashboard/visit_groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ def update_params
:day,
:window_before,
:window_after)
temp[:position] = temp[:position].to_i - 1

if @visit_group.position < temp[:position].to_i
temp[:position] = temp[:position].to_i - 1
end

temp
end

Expand Down
8 changes: 7 additions & 1 deletion app/controllers/service_calendars_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,13 @@ def move_visit_position

@visit_group = VisitGroup.find(params[:visit_group].to_i)

@visit_group.insert_at( params[:position].to_i - 1 )
new_position = params[:position].to_i

if @visit_group.position < new_position
@visit_group.insert_at( new_position - 1 )
else
@visit_group.insert_at( new_position )
end

@pages = {}
@service_request.arms.each do |arm|
Expand Down

0 comments on commit 5fbf220

Please sign in to comment.