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

user details authorized user bug and other cleanup #389

Merged
merged 2 commits into from
May 20, 2016
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
3 changes: 3 additions & 0 deletions app/controllers/identities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def add_to_protocol
@protocol_type = session[:protocol_type]

identity = Identity.find params[:identity][:id]
params[:identity].delete(:id) # we can't mass assign ID
identity.update_attributes params[:identity]

# {"identity_id"=>"11968", "first_name"=>"Colin", "last_name"=>"Alstad", "email"=>"alstad@musc.edu", "phone"=>"843-792-5378", "role"=>"pi", "role_other"=>"",
Expand All @@ -66,11 +67,13 @@ def add_to_protocol

# should check if this is an existing project role
if params[:project_role][:id].blank?
params[:project_role].delete(:id) # we can't mass assign ID
@project_role = ProjectRole.new params[:project_role]
@project_role.set_default_rights
@project_role.identity = identity
else
@project_role = ProjectRole.find params[:project_role][:id]
params[:project_role].delete(:id) # we can't mass assign ID
@project_role.update_attributes params[:project_role]
@project_role.set_default_rights
end
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/protocols_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def update

if @current_step == 'cancel'
@current_step = 'return_to_service_request'
elsif @current_step == 'go_back'
elsif @current_step == 'go_back' and @protocol.valid?
@current_step = 'protocol'
@protocol.populate_for_edit
elsif @current_step == 'protocol' and @protocol.group_valid? :protocol
Expand All @@ -125,6 +125,9 @@ def update
if @service_request.status == "first_draft"
@service_request.update_attributes(status: "draft")
end
elsif @current_step == 'go_back' and !@protocol.valid?
@current_step = 'user_details'
@protocol.populate_for_edit
else
@protocol.populate_for_edit
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/identities/add_to_protocol.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ else if $(".project_role_<%= @project_role.identity.id %>").length > 0 and "<%=
$('.add-user-details').hide()
else
$('#user_detail_errors').hide()
$('.user-details-left').hide()
$('.user-details-right').hide()
$('.authorized-users tbody').append("<%= escape_javascript(render :partial => 'shared/user_proxy_right', :locals => {:project_role => @project_role, :protocol_use_epic => @protocol_use_epic}) %>")
$('.user_added_message p').html("<%= escape_javascript(t("protocol_shared.add_user")) %>")
$('.user_added_message').show().fadeOut(2500, 'linear')
Expand Down
2 changes: 1 addition & 1 deletion app/views/studies/_fields.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@
#user_detail_errors.errorExplanation{:style => 'display:none'}
.info
= render :partial => 'shared/user_search', :locals => {:protocol => study}
- hide_user_details = (study.new_record? and study.project_roles.empty?) ? '' : 'display:none;'
- hide_user_details = study.project_roles.any? && study.project_roles.first.identity_id.blank? ? '' : 'display:none;'
.user_added_message{:style => 'display:none;'}
%p
- t(:protocol_shared)[:add_user]
Expand Down