Skip to content

Commit

Permalink
Merge pull request #268 from sparc-request/jl-conditionally-show-requ…
Browse files Browse the repository at this point in the history
…est-dialog

Only showing new request popup for new requests.
  • Loading branch information
jleonardw9 committed Jan 27, 2016
2 parents 1949e60 + 75349a4 commit 0f3cc15
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion app/assets/javascripts/cart.js.coffee.erb
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ $(document).ready ->
$(document).on('click', '.add_service' , ->
sr_id = $(this).attr('sr_id')
id = $(this).attr('id')
from_portal = $(this).attr('from_portal')
first_service = $(this).attr('first_service')
li_count = $('#line_item_count').val()

if first_service == 'true' && li_count == '0'
if (from_portal != 'true') && (first_service == 'true') && (li_count == '0')
options = {
resizable: false,
height: 220,
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,13 @@ def initialize_service_request
use_existing_service_request
validate_existing_service_request
elsif params[:from_portal]
session[:from_portal] = params[:from_portal]
create_or_use_request_from_portal(params)
else
# If the cookie is nil (as with visiting the main catalog for
# the first time), then create a new service request.
create_new_service_request
session.delete(:from_portal)
end
elsif params[:controller] == 'devise/sessions'
if session[:service_request_id]
Expand Down
1 change: 1 addition & 0 deletions app/controllers/catalogs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class CatalogsController < ApplicationController
def update_description
@organization = Organization.find params[:id]
@service_request = ServiceRequest.find session[:service_request_id]
@from_portal = session[:from_portal]
end

end
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,10 @@ def ssr_primary_contacts organization
sps.map{|x| x.is_primary_contact? ? x.identity.display_name : nil}.compact.join("<br />")
end

def display_service_in_catalog service, service_request
def display_service_in_catalog service, service_request, from_portal
has_current_pricing_map = service.current_pricing_map rescue false # work around for current_pricing_map method raising false
if (service.is_available? or service.is_available.nil?) and has_current_pricing_map
render :partial => 'service', :locals => {:service => service, :service_request => service_request}
render :partial => 'service', :locals => {:service => service, :service_request => service_request, :from_portal => from_portal}
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/views/catalogs/_description.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
- unless organization.services.empty?
.program-services
- organization.services.order('`order`, `name`').each do |service|
= display_service_in_catalog service, service_request
= display_service_in_catalog(service, service_request, from_portal)
%br
- unless organization.cores.empty?
.core-accordion
Expand All @@ -37,7 +37,7 @@
= link_to core.name, "#"
.core_view
- core.services.order('`order`, `name`').each do |service|
= display_service_in_catalog service, service_request
= display_service_in_catalog(service, service_request, from_portal)

- else
.panel.panel-default
Expand Down
2 changes: 1 addition & 1 deletion app/views/catalogs/_service.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
.service-view
%span.title
%span.name= link_to service.display_service_name, 'javascript:void(0);'
%button.add_service.btn.btn-success{id: "service-#{service.id}", sr_id: "#{service_request.id}", first_service: "#{first_service?(service_request)}"} Add
%button.add_service.btn.btn-success{id: "service-#{service.id}", sr_id: "#{service_request.id}", first_service: "#{first_service?(service_request)}", from_portal: "#{from_portal}"} Add
.clear
%span.service-description.description{style: 'display:none'}= raw service.description

Expand Down
2 changes: 1 addition & 1 deletion app/views/catalogs/update_description.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# 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.

$('#welcome_message').html("<%= escape_javascript render :partial => 'catalogs/description', :locals => {:organization => @organization, :service_request => @service_request} %>")
$('#welcome_message').html("<%= escape_javascript render :partial => 'catalogs/description', :locals => {:organization => @organization, :service_request => @service_request, :from_portal => @from_portal} %>")
$('.core-accordion').accordion({
heightStyle: 'content'
collapsible: true
Expand Down
2 changes: 1 addition & 1 deletion app/views/service_requests/_catalog.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/[if lte IE 8]
%img(src="/assets/search_bar.png"){:class => 'test_search'}
= render :partial => 'catalogs/service_search'
#welcome_message= render :partial => 'catalogs/description', :locals => {:organization => @organization, :service_request => @service_request}
#welcome_message= render :partial => 'catalogs/description', :locals => {:organization => @organization, :service_request => @service_request, :from_portal => @from_portal}
#calendar-blog
= render :partial => 'catalogs/news_and_events'

Expand Down

0 comments on commit 0f3cc15

Please sign in to comment.