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

Jl - associated user bug refactor #315

Merged
merged 2 commits into from
Jun 8, 2017
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
1 change: 0 additions & 1 deletion app/controllers/associated_users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class AssociatedUsersController < ApplicationController

before_action :initialize_service_request
before_action :authorize_identity
skip_before_action :authorize_identity, only: [:update, :create]
before_action :find_protocol_role, only: [:edit, :destroy]
before_action :find_protocol, only: [:index, :new, :edit, :destroy]

Expand Down
4 changes: 3 additions & 1 deletion app/views/associated_users/_user_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
= identity.display_name
%a.btn.btn-xs.btn-danger.glyphicon.glyphicon-remove#new-associated-user-button{ href: "javascript:void(0);", data: { protocol_id: protocol.id, permission: 'true', toggle: "tooltip", animation: 'false', placement: 'right' }, title: "Remove" }
%div#protocol_role_data{ data: { pr_id: identity.id, pr_name: identity.full_name, pi_id: current_pi.id, pi_name: current_pi.full_name }}
= form_for determine_entity(dashboard, project_role), url: determine_url(dashboard, project_role), remote: true, html: { class: "protocol_role_form" } do |form|
= form_for determine_entity(dashboard, project_role), url: determine_url(dashboard, project_role), remote: true, html: { class: "protocol_role_form" } do |form|
- unless dashboard
= hidden_field_tag :service_request_id, service_request.id
= form.hidden_field :identity_id
= form.hidden_field :protocol_id
.row
Expand Down
2 changes: 1 addition & 1 deletion app/views/associated_users/edit.js.coffee
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.
$("#modal_place").html("<%= escape_javascript(render( 'associated_users/user_form', protocol: @protocol, project_role: @protocol_role, identity: @identity, current_pi: @current_pi, header_text: @header_text, dashboard: @dashboard )) %>")
$("#modal_place").html("<%= escape_javascript(render( 'associated_users/user_form', protocol: @protocol, project_role: @protocol_role, identity: @identity, current_pi: @current_pi, header_text: @header_text, dashboard: @dashboard, service_request: @service_request )) %>")
$("#modal_place").modal 'show'
$(".selectpicker").selectpicker()
window.update_disabled_hidden_form_items()
2 changes: 1 addition & 1 deletion app/views/associated_users/new.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ getSRId = () ->
$("#modal_place #modal_errors").html("<%= escape_javascript(render( 'shared/modal_errors', errors: @errors )) %>")
$('#authorized_user_search').val('')
<% elsif @identity.present? %># User selected, go to 'User Form'
$("#modal_place").html("<%= escape_javascript(render( 'associated_users/user_form', protocol: @protocol, project_role: @project_role, identity: @identity, current_pi: @current_pi, header_text: @header_text, dashboard: @dashboard )) %>")
$("#modal_place").html("<%= escape_javascript(render( 'associated_users/user_form', protocol: @protocol, project_role: @project_role, identity: @identity, current_pi: @current_pi, header_text: @header_text, dashboard: @dashboard, service_request: @service_request )) %>")
<% else %># User not selected, go to 'Select User Form'
$("#modal_place").html("<%= escape_javascript(render( 'associated_users/select_user_form', protocol: @protocol, header_text: @header_text )) %>")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
def render_user_form(epic = false)
protocol = build(:unarchived_study_without_validations, id: 1, primary_pi: jug2, selected_for_epic: epic)
project_role = build(:project_role, id: 1, protocol_id: protocol.id, identity_id: jug2.id, role: 'consultant', epic_access: 0)
service_request = build(:service_request_without_validations)
dashboard = false
stub_const("USE_EPIC", epic)
render "/associated_users/user_form", header_text: "Edit Authorized User",
identity: jug2,
protocol: protocol,
current_pi: jug2,
project_role: project_role,
dashboard: dashboard
dashboard: dashboard,
service_request: service_request
end

context 'When the user views the associated users form' do
Expand Down