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

KG - Fix SSR Resubmission Issues #2341

Merged
merged 2 commits into from
May 15, 2020
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
2 changes: 1 addition & 1 deletion app/assets/javascripts/review.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

$ ->
if $('#use_system_satisfaction').val() == 'true'
$(document).one 'click ajax:beforeSend', '#getCostEstimate, #submitRequest', (event) ->
$(document).one 'click ajax:beforeSend', '#submitRequest', (event) ->
event.preventDefault()
$this = $(this)
$this.addClass('disabled')
Expand Down
3 changes: 2 additions & 1 deletion app/lib/notifier_logic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def self.confirmation_logic(service_request, current_user, ssrids)
def initialize(service_request, current_user, ssrids=[])
@service_request = service_request
@current_user = current_user
@ssrids = ssrids
@destroyed_ssrs_needing_notification = destroyed_ssr_that_needs_a_request_amendment_email
@created_ssrs_needing_notification = @service_request.created_ssrs_since_previous_submission(ssrids)
@ssrs_updated_from_un_updatable_status = ssrs_that_have_been_updated_from_a_un_updatable_status(ssrids)
Expand All @@ -46,7 +47,7 @@ def update_ssrs_and_send_emails
# @to_notify holds the SSRs that require an "initial submission" email
@send_request_amendment_and_not_initial = @ssrs_updated_from_un_updatable_status.present? || @destroyed_ssrs_needing_notification.present? || @created_ssrs_needing_notification.present?
@service_request.previous_submitted_at = @service_request.submitted_at
@to_notify = @service_request.update_status('submitted', @current_user)
@to_notify = @service_request.update_status('submitted', @current_user, @ssrids)
@service_request.update_arm_minimum_counts
send_request_amendment_email_evaluation
send_initial_submission_email
Expand Down
8 changes: 6 additions & 2 deletions app/models/service_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ def service_list(is_one_time_fee=nil, service_provider=nil, admin_ssr=nil)
groupings
end

def has_ssrs_for_resubmission?
self.previously_submitted? && self.sub_service_requests.any?{ |ssr| ['draft', 'awaiting_pi_approval'].include?(ssr.status) }
end

def deleted_ssrs_since_previous_submission(start_time_at_previous_sub_time=false)
### start_time varies depending on if the submitted_at has been updated or not
if start_time_at_previous_sub_time
Expand Down Expand Up @@ -362,12 +366,12 @@ def relevant_service_providers_and_super_users

# Returns the SSR ids that need an initial submission email, updates the SR status,
# and updates the SSR status to new status if appropriate
def update_status(new_status, current_user)
def update_status(new_status, current_user, ssrids=nil)
# Do not change the Service Request if it has been submitted
update_attribute(:status, new_status) unless self.previously_submitted?
update_attribute(:submitted_at, Time.now) if new_status == 'submitted'

self.sub_service_requests.map do |ssr|
self.sub_service_requests.select{ |ssr| ssrids.blank? || ssrids.include?(ssr.id.to_s) }.map do |ssr|
ssr.update_status_and_notify(new_status, current_user)
end.compact
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/service_requests/navigation/_footer.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
.col.text-right
- if action_name == 'review'
-# If the request has SSRs to be resubmitted, send a remote request to prompt the SSR Resubmission Modal, else submit the request
= link_to confirmation_service_request_path(srid: @service_request.id), remote: @service_request.previously_submitted? && @service_request.sub_service_requests.any?{ |ssr| ['draft', 'awaiting_pi_approval'].include?(ssr.status) }, class: 'btn btn-lg btn-outline-success', id: 'submitRequest' do
= link_to confirmation_service_request_path(srid: @service_request.id), class: 'btn btn-lg btn-outline-success', id: 'submitRequest' do
- succeed icon('fas', 'arrow-right ml-2') do
= t('proper.navigation.bottom.submit')
- else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ConfirmSwal.fire(
confirmButtonText: I18n.t('constants.yes_select')
cancelButtonText: I18n.t('constants.no_select')
).then (result) ->
$('#getCostEstimate, #submitRequest').removeClass('disabled')
$('#submitRequest').removeClass('disabled')
if result.value
$.ajax
method: 'get'
Expand All @@ -39,7 +39,7 @@ ConfirmSwal.fire(
success: ->
$(document).one 'hidden.bs.modal', ->
# When previously subbmited show the SSRs resubmission modal
<% if @service_request.previously_submitted? && @forward.include?('confirmation') %>
<% if @service_request.has_ssrs_for_resubmission? && @forward.include?('confirmation') %>
$.ajax
method: 'get'
dataType: 'script'
Expand All @@ -48,8 +48,8 @@ ConfirmSwal.fire(
window.location = "<%= @forward %>"
<% end %>
else
# When previously subbmited show the SSRs resubmission modal
<% if @service_request.previously_submitted? && @forward.include?('confirmation') %>
# When previously submited show the SSRs resubmission modal
<% if @service_request.has_ssrs_for_resubmission? && @forward.include?('confirmation') %>
$.ajax
method: 'get'
dataType: 'script'
Expand Down
2 changes: 1 addition & 1 deletion app/views/surveyor/responses/create.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if window.location.pathname.startsWith('/dashboard')
$(document).trigger('ajax:complete') # rails-ujs element replacement bug fix

<% elsif @response.survey.is_a?(SystemSurvey) && @response.survey.system_satisfaction? %>
<% if @response.respondable.previously_submitted? %>
<% if @response.respondable.has_ssrs_for_resubmission? %>
$.ajax
method: 'GET'
dataType: 'script'
Expand Down
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
config.cache_classes = false

# Do not eager load code on boot.
config.eager_load = true
config.eager_load = false

# Show full error reports and disable caching
config.consider_all_requests_local = true
Expand Down