Skip to content

Commit

Permalink
wth - organization lock warning message
Browse files Browse the repository at this point in the history
I updated the locked organization warning message to be more helpful to
the user. I added a new controller action that requests the necessary
data and moved some pieces around that I feel reflects a more MVC
approach. [#134877103]
  • Loading branch information
William Holt committed Nov 30, 2016
1 parent 946eaea commit 361e005
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 7 deletions.
9 changes: 6 additions & 3 deletions app/assets/javascripts/catalog.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ $(document).ready ->
else if $(this).hasClass('program-link')
$('.program-link').removeClass('clicked')
$(this).addClass('clicked')

id = $(this).data('id')
data = process_ssr_found : $(this).data('process-ssr-found')
$.ajax
Expand All @@ -42,8 +41,12 @@ $(document).ready ->
url: "/catalogs/#{id}/update_description"

$(document).on 'click', '.program-link.locked-program', ->
$('#modal_place').html($('#locked-organization-modal').html())
$('#modal_place').modal('show')
organizationId = $(this).data('id')
protocolId = $('.protocol-id').val()
serviceRequestId = $('.service-request-id').val()
$.ajax
type: 'GET'
url: "/locked_organizations?org_id=#{organizationId}&protocol_id=#{protocolId}&service_request_id=#{serviceRequestId}"

$(document).on 'click', '.core-header', ->
$('.service-description').addClass('hidden')
Expand Down
10 changes: 10 additions & 0 deletions app/controllers/locked_organizations_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class LockedOrganizationsController < ApplicationController

def show
@organization = Organization.find(params[:org_id])
@service_provider = @organization.service_providers.where(is_primary_contact: true).first
@identity = Identity.find(@service_provider.identity_id)
@protocol = Protocol.find(params[:protocol_id])
@ssr = SubServiceRequest.where(service_request_id: params[:service_request_id], organization_id: @organization.id).first
end
end
2 changes: 2 additions & 0 deletions app/views/locked_organizations/show.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$('#modal_place').html("<%= j render 'service_requests/modals/locked_organization_modal', organization: @organization, identity: @identity, protocol: @protocol, ssr: @ssr %>")
$('#modal_place').modal('show')
3 changes: 2 additions & 1 deletion app/views/service_requests/catalog.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

= hidden_field_tag :signed_in, identity_signed_in? ? 1 : 0
= hidden_field_tag :has_protocol, @service_request.protocol ? 1 : 0
= hidden_field_tag :service_request_id, @service_request.id, class: 'service-request-id'
= hidden_field_tag :protocol_id, @service_request.protocol.id, class: 'protocol-id'

= render 'catalogs/about_section'
= render 'catalogs/service_accordion', institutions: @institutions, ssr_org: @sub_service_request.try(:organization), locked_org_ids: @locked_org_ids
Expand All @@ -32,4 +34,3 @@
= render 'service_requests/modals/new_request_modal'
= render 'service_requests/modals/request_submitted_modal', service_request: @service_request
= render 'service_requests/modals/login_required_modal'
= render 'service_requests/modals/locked_organization_modal'
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
-# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#locked-organization-modal.hidden
#locked-organization-modal
.modal-dialog
.modal-content
.modal-header
Expand All @@ -28,7 +28,7 @@
.modal-body
#modal_errors
.form-group.text-center
= raw(t(:proper)[:catalog][:locked_organization][:warning])
= raw(t('proper.catalog.locked_organization.warning', organization: organization.name, request: "#{protocol.id}-#{ssr.ssr_id}", title: "#{protocol.short_title}", contact_name: "#{identity.first_name} #{identity.last_name}", contact_info: identity.phone.blank? ? identity.email : identity.phone))
.modal-footer
.center-block
%button.btn.btn-default{ type: 'button', data: { dismiss: 'modal' } }
Expand Down
2 changes: 1 addition & 1 deletion config/locales/proper.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ en:
warning: "Deleting this service from the service cart will be irreversible and will cause it to be deleted from the associated protocol (%{protocol_id}). Are you sure you want to proceed?"
locked_organization:
header: "Locked Organization"
warning: "This Organization has locked your request, pending approval.<br>Please wait for the Organization to finish processing your request.<br><br>If this is incorrect, please contact them directly."
warning: "%{organization} services are already present on request %{request} pertaining to this Study/Project, %{title}.<br>Please contact %{contact_name} at %{contact_info} to edit existing request."

############
# PROTOCOL #
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@

resources :contact_forms, only: [:new, :create]

resource :locked_organizations, only: [:show]

resources :subsidies, only: [:new, :create, :edit, :update, :destroy]

resources :service_requests, only: [:show] do
Expand Down

0 comments on commit 361e005

Please sign in to comment.