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 - Step 1 New/Edit Study/Project Bug Fixes and Specs #233

Merged
merged 13 commits into from
Dec 15, 2015
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
//= require jquery
//= require jquery-ui
//= require jquery.qtip.min
//= require jquery.cookie
//= require jquery.form
//= require jquery_ujs
//= require jquery_nested_form
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/projects.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ $(document).ready ->
when "foundation", "investigator" then $('#project_indirect_cost_rate').val(I18n["indirect_cost_rates"]["foundation_and_investigator"])
when "federal" then $('#project_indirect_cost_rate').val(I18n["indirect_cost_rates"]["federal"])

#This is to disabled the submit after you click once, so you can't fire multiple posts at once.
#This is to disabled the submit after you click once, so you cant fire multiple posts at once.
$("form").submit ->
$('a.continue_button').unbind('click');
10 changes: 7 additions & 3 deletions app/assets/javascripts/shared.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,15 @@ $(document).ready ->
return false

$('.cancel_link').live 'click', ->
cur_step = $('#current_step').val()
$('.return-spinner').show()
cur_step = $.cookie('current_step')
date = new Date()
minutes = 30
date.setTime(date.getTime() + (minutes * 60 * 1000))
if cur_step == 'protocol'
$('#current_step').val('cancel_protocol')
$.cookie('current_step', 'cancel', {path: '/'})
else if cur_step == "user_details"
$('#current_step').val('go_back')
$.cookie('current_step', 'go_back', {path: '/'})

$('form').submit()

Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/studies.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ $(document).ready ->

FormFxManager.registerListeners($('.edit-project-view'), display_dependencies)

####### If send to epic is selected we need to do some crazy stuff, using FormFxManager for some of it but it couldn't handle the complexity, using a combination, see below ########
####### If send to epic is selected we need to do some crazy stuff, using FormFxManager for some of it but it couldnt handle the complexity, using a combination, see below ########

$('#study_selected_for_epic_true').click ->
$('.study_type').show()
Expand Down Expand Up @@ -158,7 +158,7 @@ $(document).ready ->
setupDatePicker('#iacuc_expiration_date', '#study_vertebrate_animals_info_attributes_iacuc_expiration_date')
$('#iacuc_expiration_date').attr("readOnly", true)

#This is to disabled the submit after you click once, so you can't fire multiple posts at once.
#This is to disabled the submit after you click once, so you cant fire multiple posts at once.
$("form").submit ->
unless $('#study_research_types_info_attributes_human_subjects').is(':checked')
$('#study_human_subjects_info_attributes_nct_number').val('')
Expand Down
40 changes: 33 additions & 7 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ ul {
list-style-position: inside;
}

.hidden {
display: none;
}

#sub_service_request_header {
float: right;
margin-top: 5px;
Expand Down Expand Up @@ -403,15 +407,14 @@ a.catalog-button,
color: #FFF;
height: 35px;
font-size: 13px;
margin-top: 63px;
border: none;
width: 150px;
}

.add-user{
padding-left: 395px;
padding-bottom: 55px;
margin-top: -157px;
margin-top: -60px;
text-align: center;
}

.blue-button a {
Expand Down Expand Up @@ -842,14 +845,32 @@ span#infotip img {
text-decoration: none;
font-size: 18px;
color: #fff;
line-height: 36px;
}

.continue div{
display: inline-block;
zoom: 1;
*display:inline;
height: 36px;
vertical-align: middle;
}

.continue div .continue-spinner {
padding-left: 0px !important;
padding-right: 5px !important;
padding-top: 2px !important;
padding-bottom: 2px !important;
}

.continue div .return-spinner {
padding-left: 5px !important;
padding-right: 0px !important;
padding-top: 2px !important;
padding-bottom: 2px !important;
}


.continue div.exit a{
margin: 0 0 0 60px;
}
Expand All @@ -860,7 +881,8 @@ span#infotip img {
vertical-align: bottom;
}

.continue div.nav-backward img {
.continue div.nav-backward img,
.review-bottom-navigation div.return-to-step-3 img {
vertical-align: middle;
padding-right: 5px;
padding-bottom: 2px;
Expand All @@ -884,7 +906,8 @@ span#infotip img {

}

.continue div.nav-forward img {
.continue div.nav-forward img,
.review-bottom-navigation div.submit-request img {
vertical-align: middle;
padding-right: 5px;
padding-bottom: 2px;
Expand Down Expand Up @@ -942,9 +965,14 @@ span#infotip img {
background-color: #ccc;
}

.review-bottom-navigation div {
height: 36px;
vertical-align: middle;
}
.review-bottom-navigation a {
color: #fff;
font-size: 18px;
line-height: 36px;
}

.return-to-step-3, .save-as-draft, .obtain-research-pricing, .submit-request {
Expand All @@ -959,8 +987,6 @@ span#infotip img {
}

.save-as-draft, .obtain-research-pricing {
padding-top: 4px;
height: 28px;
width: 205px;
}

Expand Down
39 changes: 29 additions & 10 deletions app/controllers/protocols_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,23 @@ def new
@protocol = self.model_class.new
@protocol.requester_id = current_user.id
@protocol.populate_for_edit
@current_step = 'protocol'
current_step_cookie = cookies['current_step']
if current_step_cookie.nil? || (current_step_cookie != "protocol")
cookies['current_step'] = 'protocol'
end
@portal = false
end

def create
@service_request = ServiceRequest.find session[:service_request_id]
@current_step = params[:current_step]
@current_step = cookies['current_step']
@protocol = self.model_class.new(params[:study] || params[:project])
@protocol.validate_nct = true
@portal = params[:portal]

if @current_step == 'go_back'
if @current_step == 'cancel'
@current_step = 'return_to_service_request'
elsif @current_step == 'go_back'
@current_step = 'protocol'
@protocol.populate_for_edit
elsif @current_step == 'protocol' and @protocol.group_valid? :protocol
Expand All @@ -52,11 +57,15 @@ def create
@current_step = 'return_to_service_request'
session[:saved_protocol_id] = @protocol.id
flash[:notice] = "New #{@protocol.type.downcase} created"
elsif @current_step == 'cancel_protocol'
@current_step = 'return_to_service_request'

if @service_request.status == "first_draft"
@service_request.update_attributes(status: "draft")
end
else
@protocol.populate_for_edit
end

cookies['current_step'] = @current_step
end

def edit
Expand All @@ -65,19 +74,24 @@ def edit
@protocol = current_user.protocols.find params[:id]
@protocol.populate_for_edit
@protocol.valid?
@current_step = 'protocol'
current_step_cookie = cookies['current_step']
if current_step_cookie.nil? || (current_step_cookie != "protocol")
cookies['current_step'] = 'protocol'
end
@portal = false
end

def update
@service_request = ServiceRequest.find session[:service_request_id]
@current_step = params[:current_step]
@current_step = cookies['current_step']
@protocol = current_user.protocols.find params[:id]
@protocol.validate_nct = true
@portal = params[:portal]
@protocol.assign_attributes(params[:study] || params[:project])

if @current_step == 'go_back'
if @current_step == 'cancel'
@current_step = 'return_to_service_request'
elsif @current_step == 'go_back'
@current_step = 'protocol'
@protocol.populate_for_edit
elsif @current_step == 'protocol' and @protocol.group_valid? :protocol
Expand All @@ -88,11 +102,16 @@ def update
@current_step = 'return_to_service_request'
session[:saved_protocol_id] = @protocol.id
flash[:notice] = "#{@protocol.type.humanize} updated"
elsif @current_step == 'cancel_protocol'
@current_step = 'return_to_service_request'

#Added as a safety net for older SRs
if @service_request.status == "first_draft"
@service_request.update_attributes(status: "draft")
end
else
@protocol.populate_for_edit
end

cookies['current_step'] = @current_step
end

def set_protocol_type
Expand Down
1 change: 1 addition & 0 deletions app/controllers/service_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def catalog
end

def protocol
cookies.delete :current_step
@service_request.update_attribute(:service_requester_id, current_user.id) if @service_request.service_requester_id.nil?
if @sub_service_request.nil?
studies = current_user.project_roles.map{|pr| pr.protocol unless ['view','none'].include?(pr.project_rights) || pr.protocol.type.eql?("Project")}.compact
Expand Down
16 changes: 11 additions & 5 deletions app/views/projects/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
:javascript
$(document).ready( function() {
$('a.continue_button').click(function() {
$('.continue-spinner').show();
$('form').submit();
});
})
Expand All @@ -33,7 +34,8 @@

= form_for project, :remote => true do |f|
.grid_12
%h3.blue-provider.step-header.ui-corner-all= current_step == 'protocol' ? t(:protocol_shared)[:step_text] : t(:protocol_shared)[:step_text_2]
%h3.blue-provider.step-header.ui-corner-all
= current_step == 'protocol' ? t(:protocol_shared)[:step_text] : t(:protocol_shared)[:step_text_2]
= f.hidden_field :requester_id
= hidden_field_tag :current_step, current_step
.clear
Expand All @@ -45,12 +47,16 @@
%div{:class => 'blue-provider'}
.nav-backward
.return-to-previous
%a.cancel_link{:href => "javascript:void(0)"}
%a.cancel_link{:class => cookies['current_step'] == 'protocol' ? 'cancel' : 'go-back', :href => "javascript:void(0)"}
= image_tag('left_arrow.png', :alt => "Cancel")
%span.btn.btn-success.btn-lg= t(:bottom_navigation)[:cancel]
%span.btn.btn-success.btn-lg
= current_step == 'protocol' ? t(:bottom_navigation)[:cancel] : t(:bottom_navigation)[:go_back]
= image_tag 'spinner.gif', :class => 'return-spinner hidden'
.exit= image_tag('Filler.png')
.nav-forward
= image_tag 'spinner.gif', :class => 'continue-spinner hidden'
.save-and-continue
%a{:href => "javascript:void(0)", :class => 'continue_button'}
%span.btn.btn-success.btn-lg= t(:bottom_navigation)[:continue]
%a.continue_button{:class => cookies['current_step'] == 'protocol' ? 'continue' : 'save', :href => "javascript:void(0)"}
%span.btn.btn-success.btn-lg
= current_step == 'protocol' ? t(:bottom_navigation)[:continue] : t(:bottom_navigation)[:save_and_continue]
= image_tag('right_arrow.png', :alt => "SaveAndContinue")
5 changes: 1 addition & 4 deletions app/views/projects/create.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@
if <%= @current_step == 'return_to_service_request' %>
window.location.href = "<%= protocol_service_request_path @service_request %>"
else
#This is to re-enable the submit, it is disabled to prevent multiple posts, if you click rapidly.
$('a.continue_button').click ->
$('form').submit()

$('#current_step').val("<%= @current_step %>")
$('.new_project').html("<%= escape_javascript(render :partial => 'projects/form', :locals => {:project => @protocol, :service_request => @service_request, :current_step => @current_step}) %>")

if <%= @current_step == "user_details" %>
$('.return-to-previous a span').text("Go Back")
2 changes: 1 addition & 1 deletion app/views/projects/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@

= render :partial => 'service_requests/steps'
.clear
.edit_project= render :partial => 'projects/form', :locals => {:project => @protocol, :service_request => @service_request, :current_step => @current_step}
.edit_project= render :partial => 'projects/form', :locals => {:project => @protocol, :service_request => @service_request, :current_step => cookies['current_step']}
2 changes: 1 addition & 1 deletion app/views/projects/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@

= render :partial => 'service_requests/steps'
.clear
.new_project= render :partial => 'projects/form', :locals => {:project => @protocol, :service_request => @service_request, :current_step => @current_step}
.new_project= render :partial => 'projects/form', :locals => {:project => @protocol, :service_request => @service_request, :current_step => cookies['current_step']}
7 changes: 1 addition & 6 deletions app/views/projects/update.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

# /////////////////////////////////////////////
# //
# // Project - Edit.js for Editing Projects
# // Project - Update.js for Editing Projects
# //
# /////////////////////////////////////////////

Expand All @@ -31,9 +31,4 @@ else
$('a.continue_button').click ->
$('form').submit()

$('#current_step').val("<%= @current_step %>")
$('.edit_project').html("<%= escape_javascript(render :partial => 'projects/form', :locals => {:project => @protocol, :service_request => @service_request, :current_step => @current_step}) %>")

if <%= @current_step == "user_details" %>
$('.return-to-previous a span').text("Go Back")

2 changes: 2 additions & 0 deletions app/views/shared/_user_search.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
.search.form-group
= text_field_tag 'user_search_term', nil, :placeholder => t(:user_search)[:search_placeholder], :class => "search-identities form-control", :'data-protocol_use_epic' => protocol.selected_for_epic
- if USE_LDAP
%br
%br
%span.help-block
= t(:user_search)[:help_block]
%a{href: admin_identities_path(), target: "_blank", title: t(:user_search)[:advanced_user_search_title]}= t(:user_search)[:help_block_link_text]
16 changes: 11 additions & 5 deletions app/views/studies/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
:javascript
$(document).ready( function(e) {
$('a.continue_button').click(function() {
$('.continue-spinner').show();
if ($('#study_selected_for_epic_true').is(':checked')) {
$('form').submit();
}
Expand All @@ -37,6 +38,7 @@
:javascript
$(document).ready( function() {
$('a.continue_button').click(function() {
$('.continue-spinner').show();
$('form').submit();
});
})
Expand All @@ -63,18 +65,22 @@
.clear
= f.error_messages

.edit-project-view.portal_container= render :partial => 'studies/fields', :locals => {:study => study, :f => f, :portal => portal, :current_step => @current_step}
.edit-project-view.portal_container= render :partial => 'studies/fields', :locals => {:study => study, :f => f, :portal => portal, :current_step => current_step}
.continue.portal_container
.grid_12
%div{:class => 'blue-provider'}
.nav-backward
.return-to-previous
%a.cancel_link{:href => "javascript:void(0)"}
%a.cancel_link{:class => cookies['current_step'] == 'protocol' ? 'cancel' : 'go-back', :href => "javascript:void(0)"}
= image_tag('left_arrow.png', :alt => "Cancel")
%span.btn.btn-success.btn-lg= t(:bottom_navigation)[:cancel]
%span.btn.btn-success.btn-lg
= current_step == 'protocol' ? t(:bottom_navigation)[:cancel] : t(:bottom_navigation)[:go_back]
= image_tag 'spinner.gif', :class => 'return-spinner hidden'
.exit= image_tag('Filler.png')
.nav-forward
= image_tag 'spinner.gif', :class => 'continue-spinner hidden'
.save-and-continue
%a{:href => "javascript:void(0)", :class => 'continue_button'}
%span.btn.btn-success.btn-lg= t(:bottom_navigation)[:continue]
%a.continue_button{:class => cookies['current_step'] == 'protocol' ? 'continue' : 'save',:href => "javascript:void(0)"}
%span.btn.btn-success.btn-lg
= current_step == 'protocol' ? t(:bottom_navigation)[:continue] : t(:bottom_navigation)[:save_and_continue]
= image_tag('right_arrow.png', :alt => "SaveAndContinue")