Skip to content

Commit

Permalink
html success text
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanwoldatwork authored Apr 6, 2022
1 parent 713d8ed commit 3d6c253
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 26 deletions.
5 changes: 3 additions & 2 deletions app/channels/export_channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ def subscribed
stream_from "exports_channel_#{params[:uuid]}"
end

def unsubscribed; end
end
def unsubscribed
end
end
2 changes: 1 addition & 1 deletion app/views/admin/digital_products/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<p>
<strong>Organization:</strong>
<%= @digital_product.organization_id %>
<%= @digital_product.organization.name %>
</p>

<p>
Expand Down
38 changes: 20 additions & 18 deletions app/views/admin/questions/_success_text.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,25 @@
</span>
</div>
</div>
</div>
<% end %>

<script>
$(".success_text").on("blur", function(event) {
event.preventDefault();
$.ajax({
type: "PATCH",
url: $(this).attr("data_url") + "/update_success_text",
data: {
success_text: $(form_success_text).val(),
success_text_heading: $(form_success_text_heading).val()
}
}).done(function(data) {
$("#success_text_div").html(data);
$('.usa-hint.save-notice.survey-success-text').show();
$('.usa-hint.save-notice.survey-success-text').fadeOut(2000);
});
<script>
$(function() {
$(".success_text").on("blur", function(event) {
event.preventDefault();
$.ajax({
type: "PATCH",
url: "<%= update_success_text_admin_form_path(form) %>",
data: {
success_text: $(form_success_text).val(),
success_text_heading: $(form_success_text_heading).val()
}
}).done(function(data) {
$("#success_text_div").html(data);
$('.usa-hint.save-notice.survey-success-text').show();
$('.usa-hint.save-notice.survey-success-text').fadeOut(2000);
});
</script>
</div>
<% end %>
});
})
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<p>
</div>
</div>
<%= select_tag :service_manager_id, options_for_select(@service_provider_manager_options.map { |u| [u.email, u.id] }), { prompt: "Choose a Manager?", class: "usa-select add-service-manager" } %>
<%= select_tag :service_manager_id, options_for_select(@service_provider_manager_options.map { |u| [u.email, u.id] }), { prompt: "Choose a Manager", class: "usa-select add-service-manager" } %>
</div>

<script>
Expand Down
4 changes: 3 additions & 1 deletion app/views/admin/users/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@
Q<%= collection.quarter %>
FY<%= collection.year %>
&middot;
<%= link_to collection.name, admin_collection_path(collection) %><br>
<%= link_to collection.name, admin_collection_path(collection) %>
&middot;
<%= link_to collection.service_provider.name, admin_service_provider_path(service_provider) %>
</li>
<% end %>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/websites/_website_managers.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<p>
</div>
</div>
<%= select_tag :website_manager_id, options_for_select(@website_manager_options.map { |u| [u.email, u.id] }), prompt: "Choose a Manager?", class: "usa-select add-website-manager" %>
<%= select_tag :website_manager_id, options_for_select(@website_manager_options.map { |u| [u.email, u.id] }), prompt: "Choose a Manager", class: "usa-select add-website-manager" %>
<script>
$(".add-website-manager").change(function(e) {
event.preventDefault();
Expand Down
2 changes: 1 addition & 1 deletion app/views/components/forms/_flash.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<%= form.success_text_heading %>
</h3>
<p class="usa-alert__text">
<%= form.success_text %>
<%= sanitize(form.success_text) %>
</p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/components/widget/_fba.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ function FBAform(d, N) {
return "<%= escape_javascript(form.success_text_heading) %>";
},
successText: function() {
return "<%= escape_javascript(form.success_text) %>";
return "<%= escape_javascript(sanitize(form.success_text)) %>";
},
showFormSuccess: function(e)
{
Expand Down
20 changes: 20 additions & 0 deletions spec/features/touchpoints_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,26 @@
end
end
end

context "custom HTML success text" do
before do
form.update(success_text: "Much success. \n With a <a href='#'>Link</a>.")
form.reload
visit touchpoint_path(form)
expect(page.current_path).to eq("/touchpoints/#{form.short_uuid}/submit")
fill_in("answer_01", with: "User feedback")
click_button "Submit"
end

describe "display custom HTML success text" do
it "renders success flash message" do
expect(page).to have_text("Much success. With a Link.")
expect(page).to have_link("Link")
expect(page.current_path).to eq("/touchpoints/#{form.short_uuid}/submit") # stays on same page
end
end
end

end

describe "checkbox question" do
Expand Down

0 comments on commit 3d6c253

Please sign in to comment.