Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sj jw fulfillment calendar confirmation #94

Merged
merged 2 commits into from
Oct 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
72 changes: 37 additions & 35 deletions app/assets/javascripts/study_schedule.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -97,42 +97,44 @@ $ ->
url: "/line_items/#{line_item_id}/edit"

$(document).on 'click', '.check_row', ->
check = $(this).attr('check')
line_item_id = $(this).data('line_item_id')
data =
'line_item_id': line_item_id,
'check': check
$.ajax
type: 'PUT'
url: '/study_schedule/check_row'
data: data
success: =>
# Check off visits
# Update text fields
identifier = ".visits_for_line_item_#{line_item_id}"
if check == 'true'
check_row_column($(this), identifier, 'glyphicon-ok', 'glyphicon-remove', 'false', I18n["visit"]["uncheck_row"], true, 1, 0)
else
check_row_column($(this), identifier, 'glyphicon-remove', 'glyphicon-ok', 'true', I18n["visit"]["check_row"], false, 0, 0)
if confirm("This will reset custom values for this row, do you wish to continue?")
check = $(this).attr('check')
line_item_id = $(this).data('line_item_id')
data =
'line_item_id': line_item_id,
'check': check
$.ajax
type: 'PUT'
url: '/study_schedule/check_row'
data: data
success: =>
# Check off visits
# Update text fields
identifier = ".visits_for_line_item_#{line_item_id}"
if check == 'true'
check_row_column($(this), identifier, 'glyphicon-ok', 'glyphicon-remove', 'false', I18n["visit"]["uncheck_row"], true, 1, 0)
else
check_row_column($(this), identifier, 'glyphicon-remove', 'glyphicon-ok', 'true', I18n["visit"]["check_row"], false, 0, 0)

$(document).on 'click', '.check_column', ->
check = $(this).attr('check')
visit_group_id = $(this).attr('visit_group_id')
data =
'visit_group_id': visit_group_id,
'check': check
$.ajax
type: 'PUT'
url: '/study_schedule/check_column'
data: data
success: =>
# Check off visits
# Update text fields
identifier = ".visit_for_visit_group_#{visit_group_id}"
if check == 'true'
check_row_column($(this), identifier, 'glyphicon-ok', 'glyphicon-remove', 'false', I18n["visit"]["uncheck_column"], true, 1, 0)
else
check_row_column($(this), identifier, 'glyphicon-remove', 'glyphicon-ok', 'true', I18n["visit"]["check_column"], false, 0, 0)
if confirm("This will reset custom values for this column, do you wish to continue?")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this confirmation box occur if they currently have no boxes checked in the column?

check = $(this).attr('check')
visit_group_id = $(this).attr('visit_group_id')
data =
'visit_group_id': visit_group_id,
'check': check
$.ajax
type: 'PUT'
url: '/study_schedule/check_column'
data: data
success: =>
# Check off visits
# Update text fields
identifier = ".visit_for_visit_group_#{visit_group_id}"
if check == 'true'
check_row_column($(this), identifier, 'glyphicon-ok', 'glyphicon-remove', 'false', I18n["visit"]["uncheck_column"], true, 1, 0)
else
check_row_column($(this), identifier, 'glyphicon-remove', 'glyphicon-ok', 'true', I18n["visit"]["check_column"], false, 0, 0)

check_row_column = (obj, identifier, remove_class, add_class, attr_check, attr_title, prop_check, research_val, insurance_val) ->
obj.removeClass(remove_class).addClass(add_class)
Expand All @@ -143,4 +145,4 @@ $ ->
$("#{identifier} input[type=checkbox]").prop('checked', prop_check)
$("#{identifier} input[type=text].research").val(research_val)
$("#{identifier} input[type=text].insurance").val(insurance_val)

12 changes: 9 additions & 3 deletions spec/features/study_schedule/study_schedule_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def when_i_click_the_next_page_button
end

def when_i_click_the_previous_page_button
@page = find("#arrow-left-#{@arm.id}")[:page].to_i + 1
@page = find("#arrow-left-#{@arm.id}")[:page].to_i + 1
find("#arrow-left-#{@arm.id}").click()
wait_for_ajax
end
Expand All @@ -254,7 +254,10 @@ def when_i_select_a_visit_group_from_the_dropdown
end

def when_i_click_a_check_all_row_box
find("#line_item_#{@line_item.id} .check_row").click()
@alert = accept_confirm(with: "This will reset custom values for this row, do you wish to continue?") do
find("#line_item_#{@line_item.id} .check_row").click()
end
expect(@alert).to eq("This will reset custom values for this row, do you wish to continue?")
wait_for_ajax
end

Expand All @@ -264,7 +267,10 @@ def when_i_click_an_uncheck_all_row_box
end

def when_i_click_a_check_all_column_box
first(".check_column").click()
@alert = accept_confirm(with: "This will reset custom values for this column, do you wish to continue?") do
first(".check_column").click()
end
expect(@alert).to eq("This will reset custom values for this column, do you wish to continue?")
wait_for_ajax
end

Expand Down