Skip to content

Commit

Permalink
Remove cruft left over from the extraction of
Browse files Browse the repository at this point in the history
the gem from original application: CSS, JavaScript.

References #39

Convert to Rails 4 way of confirmation dialogs
on links.

Closes #44
  • Loading branch information
mgurley committed Sep 8, 2014
1 parent 58c68fb commit 0475e24
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 16 deletions.
11 changes: 8 additions & 3 deletions app/assets/javascripts/abstractor/abstractor.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,22 @@ Abstractor.AbstractionSuggestionUI = ->
return

Abstractor.AbstractionGroupUI = ->
$(document).on "ajax:success", ".abstractor_abstraction_group .delete_link", (e, data, status, xhr) ->
$(document).on "ajax:success", ".abstractor_abstraction_group .abstractor_group_delete_link", (e, data, status, xhr) ->
parent_div = $(this).closest(".abstractor_abstraction_group")
parent_div.html xhr.responseText
return

$(document).on "ajax:success", ".abstractor_subject_groups_container .add_link", (e, data, status, xhr) ->
$(document).on "ajax:success", ".abstractor_subject_groups_container .abstractor_group_add_link", (e, data, status, xhr) ->
parent_div = $(this).closest(".abstractor_subject_groups_container")
parent_div.find(".abstractor_subject_groups").append xhr.responseText
return

$(document).on "ajax:success", ".abstractor_abstraction_group .update_link", (e, data, status, xhr) ->
$(document).on "ajax:success", ".abstractor_abstraction_group .abstractor_group_not_applicable_all_link", (e, data, status, xhr) ->
parent_div = $(this).closest(".abstractor_abstraction_group")
parent_div.html xhr.responseText
return

$(document).on "ajax:success", ".abstractor_abstraction_group .abstractor_group_unknown_all_link", (e, data, status, xhr) ->
parent_div = $(this).closest(".abstractor_abstraction_group")
parent_div.html xhr.responseText
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
= render :partial => 'abstractor/abstractor_abstractions/fields', :locals => {:abstractor_abstraction => abstractor_abstraction}

.abstractor_abstraction_actions
= link_to 'Not applicable group ', Abstractor::UserInterface.abstractor_relative_path(abstractor.abstractor_abstraction_group_path(abstractor_abstraction_group, abstractor_abstraction_value: 'not applicable')), :confirm => 'Are you sure?', :method => :put, :class => "icon_link update_link", :remote => true
= link_to 'Unknown group ', Abstractor::UserInterface.abstractor_relative_path(abstractor.abstractor_abstraction_group_path(abstractor_abstraction_group, abstractor_abstraction_value: 'unknown')), :confirm => 'Are you sure?', :method => :put, :class => "icon_link update_link", :remote => true
= link_to 'Not applicable group ', Abstractor::UserInterface.abstractor_relative_path(abstractor.abstractor_abstraction_group_path(abstractor_abstraction_group, abstractor_abstraction_value: 'not applicable')), data: { confirm: 'Are you sure?'} , method: :put, class: "abstractor_group_not_applicable_all_link", remote: true
= link_to 'Unknown group ', Abstractor::UserInterface.abstractor_relative_path(abstractor.abstractor_abstraction_group_path(abstractor_abstraction_group, abstractor_abstraction_value: 'unknown')), data: { confirm: 'Are you sure?'}, method: :put, class: 'abstractor_group_unknown_all_link', remote: true
- if abstractor_abstraction_group.removable?
= link_to 'Delete group', Abstractor::UserInterface.abstractor_relative_path(abstractor.abstractor_abstraction_group_path(abstractor_abstraction_group)), :confirm => 'Are you sure?', :method => :delete, :class => "icon_link delete_link", :remote => true
= link_to 'Delete group', Abstractor::UserInterface.abstractor_relative_path(abstractor.abstractor_abstraction_group_path(abstractor_abstraction_group)), data: { confirm: 'Are you sure?'}, method: :delete, class: "abstractor_group_delete_link", remote: true
%hr
7 changes: 3 additions & 4 deletions app/views/abstractor/abstractor_abstractions/_list.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
- namespace_type ||= @namespace_type
- namespace_id ||= @namespace_id
.abstractor_abstractions
= link_to 'Not applicable all', Abstractor::UserInterface.abstractor_relative_path(abstractor.update_all_abstractor_abstractions_path(about_type: about.class, about_id: about.id, abstractor_abstraction_value: 'not applicable')), confirm:'Are you sure?', method: :put, class: 'abstractor_not_applicable_all_link'
= link_to 'Unknown all', Abstractor::UserInterface.abstractor_relative_path(abstractor.update_all_abstractor_abstractions_path(about_type: about.class, about_id: about.id, abstractor_abstraction_value: 'unknown')), confirm: 'Are you sure?', method: :put, class: 'abstractor_unknown_all_link'
= link_to 'Not applicable all', Abstractor::UserInterface.abstractor_relative_path(abstractor.update_all_abstractor_abstractions_path(about_type: about.class, about_id: about.id, abstractor_abstraction_value: 'not applicable')), data: { confirm: 'Are you sure?'}, method: :put, class: 'abstractor_not_applicable_all_link'
= link_to 'Unknown all', Abstractor::UserInterface.abstractor_relative_path(abstractor.update_all_abstractor_abstractions_path(about_type: about.class, about_id: about.id, abstractor_abstraction_value: 'unknown')), data: { confirm: 'Are you sure?'}, method: :put, class: 'abstractor_unknown_all_link'
- abstractor_subject_groups = about.class.abstractor_subject_groups(namespace_type: namespace_type, namespace_id: namespace_id)
- abstractor_subject_groups.each do |abstractor_subject_group|
.abstractor_subject_groups_container
Expand All @@ -22,8 +22,7 @@
- abstractor_abstraction_groups = about.abstractor_abstraction_groups_by_namespace(namespace_type: namespace_type, namespace_id: namespace_id)
- abstractor_abstraction_groups.each_with_index do |abstractor_abstraction_group, index|
= render partial: 'abstractor/abstractor_abstraction_groups/form', locals: {abstractor_abstraction_group: abstractor_abstraction_group}
= link_to 'Add group', Abstractor::UserInterface.abstractor_relative_path(abstractor.abstractor_abstraction_groups_path(about_id: about.id, about_type: about.class.name, abstractor_subject_group_id: abstractor_subject_group.id)), method: :post, class: "icon_link add_link", remote: true

= link_to 'Add group', Abstractor::UserInterface.abstractor_relative_path(abstractor.abstractor_abstraction_groups_path(about_id: about.id, about_type: about.class.name, abstractor_subject_group_id: abstractor_subject_group.id)), data: { confirm: 'Are you sure?'}, method: :post, class: 'abstractor_group_add_link', remote: true
.clear
- ungrouped_subjects = about.class.abstractor_subjects(grouped: false, namespace_type: namespace_type, namespace_id: namespace_id)
- if ungrouped_subjects.any?
Expand Down
10 changes: 10 additions & 0 deletions features/encounter_notes/edit.feature
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,11 @@ Feature: Editing encounter note
And the "Needs review" radio button within ".has_karnofsky_performance_status_date" should be checked
And ".abstractor_abstraction_value" in the first ".has_karnofsky_performance_status" should contain text "[Not set]"
And ".abstractor_abstraction_value" in the first ".has_karnofsky_performance_status_date" should contain text "[Not set]"
When I do not confirm link "Not applicable all" in the first ".abstractor_abstractions"
Then the "Rejected" radio button within ".has_karnofsky_performance_status" should not be checked
And the "Rejected" radio button within ".has_karnofsky_performance_status_date" should not be checked
And ".abstractor_abstraction_value" in the first ".has_karnofsky_performance_status" should not contain text "not applicable"
And ".abstractor_abstraction_value" in the first ".has_karnofsky_performance_status_date" should not contain text "not applicable"
When I confirm link "Not applicable all" in the first ".abstractor_abstractions"
Then the "Rejected" radio button within ".has_karnofsky_performance_status" should be checked
And the "Rejected" radio button within ".has_karnofsky_performance_status_date" should be checked
Expand All @@ -443,6 +448,11 @@ Feature: Editing encounter note
And the "Needs review" radio button within ".has_karnofsky_performance_status_date" should be checked
And ".abstractor_abstraction_value" in the first ".has_karnofsky_performance_status" should contain text "[Not set]"
And ".abstractor_abstraction_value" in the first ".has_karnofsky_performance_status_date" should contain text "[Not set]"
When I do not confirm link "Unknown all" in the first ".abstractor_abstractions"
Then the "Accepted" radio button within ".has_karnofsky_performance_status" should not be checked
And the "Rejected" radio button within ".has_karnofsky_performance_status_date" should not be checked
And ".abstractor_abstraction_value" in the first ".has_karnofsky_performance_status" should not contain text "unknown"
And ".abstractor_abstraction_value" in the first ".has_karnofsky_performance_status_date" should not contain text "unknown"
When I confirm link "Unknown all" in the first ".abstractor_abstractions"
Then the "Accepted" radio button within ".has_karnofsky_performance_status" should be checked
And the "Rejected" radio button within ".has_karnofsky_performance_status_date" should be checked
Expand Down
30 changes: 25 additions & 5 deletions features/radiation_therapy_prescriptions/edit.feature
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ Feature: Editing radiation therapy prescription
When I go to the last radiation therapy prescription edit page
Then I should not see "Delete group"
And I should see "Add group"
When I follow "Add group"
When I do not confirm link "Add group"
Then I should not see "Delete group"
When I confirm link "Add group"
And I wait for the ajax request to finish
And I should see "Delete group"
And ".abstractor_abstraction_value" in the last ".abstractor_abstraction" should contain text "[Not set]"
Expand All @@ -43,8 +45,11 @@ Feature: Editing radiation therapy prescription
And I should see "Delete group"
And ".abstractor_abstraction_value" in the first ".abstractor_abstraction" should contain text "[Not set]"
And ".abstractor_abstraction_value" in the first ".abstractor_abstraction" should not contain selector ".edit_link"
When I do not confirm link "Delete group"
Then I should see 2 ".abstractor_abstraction_group" within ".abstractor_subject_groups"
When I confirm link "Delete group"
And I wait for the ajax request to finish
Then I should see 1 ".abstractor_abstraction_group" within ".abstractor_subject_groups"
Then I should see "Add group"
And ".abstractor_abstraction_value" in the first ".abstractor_abstraction" should contain text "[Not set]"
And I should not see an ".edit_link" element
Expand Down Expand Up @@ -86,11 +91,12 @@ Feature: Editing radiation therapy prescription
| Site |
| treat the temporal lobe |
When I go to the last radiation therapy prescription edit page
And I follow "Add group"
And I confirm link "Add group"
And I wait for the ajax request to finish
And ".abstractor_abstraction_actions" in the last ".abstractor_abstraction_group" should contain selector ".delete_link"
And ".abstractor_abstraction_actions" in the first ".abstractor_abstraction_group" should not contain selector ".delete_link"
And ".abstractor_abstraction_value" in the last ".abstractor_abstraction" should contain selector ".edit_link"
And ".abstractor_abstraction_actions" in the last ".abstractor_abstraction_group" should contain selector ".abstractor_group_delete_link"
And ".abstractor_abstraction_actions" in the first ".abstractor_abstraction_group" should not contain selector ".abstractor_group_delete_link"
And ".abstractor_abstraction_actions" in the last ".abstractor_abstraction_group" should contain selector ".abstractor_group_not_applicable_all_link"
And ".abstractor_abstraction_actions" in the last ".abstractor_abstraction_group" should contain selector ".abstractor_group_unknown_all_link"

@javascript
Scenario: User setting the value of an abstraction schema with a date object type in a group
Expand Down Expand Up @@ -120,6 +126,13 @@ Feature: Editing radiation therapy prescription
And ".abstractor_abstraction_value" in the first ".has_anatomical_location" should contain text "[Not set]"
And ".abstractor_abstraction_value" in the first ".has_laterality" should contain text "[Not set]"
And ".abstractor_abstraction_value" in the first ".has_radiation_therapy_prescription_date" should contain text "[Not set]"
When I do not confirm link "Not applicable group" in the first ".abstractor_abstraction_group"
Then the "Rejected" radio button within ".has_anatomical_location" should not be checked
And the "Rejected" radio button within ".has_laterality" should not be checked
And the "Rejected" radio button within ".has_radiation_therapy_prescription_date" should not be checked
And ".abstractor_abstraction_value" in the first ".has_anatomical_location" should not contain text "not applicable"
And ".abstractor_abstraction_value" in the first ".has_laterality" should not contain text "not applicable"
And ".abstractor_abstraction_value" in the first ".has_radiation_therapy_prescription_date" should not contain text "not applicable"
When I confirm link "Not applicable group" in the first ".abstractor_abstraction_group"
And I wait for the ajax request to finish
Then the "Rejected" radio button within the first ".has_anatomical_location" should be checked
Expand All @@ -142,6 +155,13 @@ Feature: Editing radiation therapy prescription
And ".abstractor_abstraction_value" in the first ".has_anatomical_location" should contain text "[Not set]"
And ".abstractor_abstraction_value" in the first ".has_laterality" should contain text "[Not set]"
And ".abstractor_abstraction_value" in the first ".has_radiation_therapy_prescription_date" should contain text "[Not set]"
When I do not confirm link "Unknown group" in the first ".abstractor_abstraction_group"
Then the "Accepted" radio button within ".has_anatomical_location" should not be checked
And the "Accepted" radio button within ".has_laterality" should not be checked
And the "Accepted" radio button within ".has_radiation_therapy_prescription_date" should not be checked
And ".abstractor_abstraction_value" in the first ".has_anatomical_location" should not contain text "unknown"
And ".abstractor_abstraction_value" in the first ".has_laterality" should not contain text "unknown"
And ".abstractor_abstraction_value" in the first ".has_radiation_therapy_prescription_date" should not contain text "unknown"
When I confirm link "Unknown group" in the first ".abstractor_abstraction_group"
And I wait for the ajax request to finish
Then the "Accepted" radio button within the first ".has_anatomical_location" should be checked
Expand Down
9 changes: 9 additions & 0 deletions features/step_definitions/common_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@
}
end

When /^I do not confirm link "([^"]*)"(?: in the(?: (first|last)?) "([^\"]*)")?$/ do |selector, position, scope_selector|
within_scope(get_scope(position, scope_selector)) {
page.evaluate_script('window.confirm = function() { return false; }')
steps %Q{
When I follow "#{selector}"
}
}
end

When /^I confirm "([^"]*)"$/ do |selector|
page.evaluate_script('window.confirm = function() { return true; }')
steps %Q{
Expand Down
2 changes: 1 addition & 1 deletion features/surgeries/edit.feature
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Feature: Editing surgery
And I click on ".edit_link" within the last ".abstractor_abstraction"
Then ".indirect_source_list" in the first ".indirect_source" should have "123 (2014-01-01)" selected
When I go to the last surgery edit page
And I follow "Add group"
When I confirm link "Add group"
And I wait for the ajax request to finish
And I click on ".edit_link" within the last ".abstractor_abstraction"
And I select "456 (2014-01-02)" from ".indirect_source_list" in the first ".indirect_source"
Expand Down

0 comments on commit 0475e24

Please sign in to comment.