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 - Historical protocol merges #2205

Merged
merged 4 commits into from
Feb 5, 2020
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
23 changes: 23 additions & 0 deletions app/controllers/dashboard/protocols_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ def index

@default_filter_params = { show_archived: 0 }

# if we are performing a search, check if user is looking for an old protocol
# that has been merged and return the most current master protocol
if params.has_key?(:filterrific) && params[:filterrific].has_key?(:search_query)
search_term = params[:filterrific][:search_query][:search_text].to_i
merge = search_protocol_merges(search_term)
if merge
params[:filterrific][:search_query][:search_text] = merge.master_protocol_id.to_s
end
end

# if we are an admin we want to default to admin organizations
if @admin
@organizations = Dashboard::IdentityOrganizations.new(current_user.id).admin_organizations_with_protocols
Expand Down Expand Up @@ -218,4 +228,17 @@ def filterrific_params
with_status: [],
with_owner: [])
end

def search_protocol_merges(protocol_id)
jleonardw9 marked this conversation as resolved.
Show resolved Hide resolved
merge = ProtocolMerge.where(merged_protocol_id: protocol_id).first

while merge do
check_merge = ProtocolMerge.where(merged_protocol_id: merge.master_protocol_id).first
if check_merge
merge = check_merge
else
return merge
end
end
end
end
10 changes: 10 additions & 0 deletions app/helpers/dashboard/protocols_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,14 @@ def display_requests_button(protocol, access)
end
end
end

def display_merges(protocol)
jleonardw9 marked this conversation as resolved.
Show resolved Hide resolved
merges = ProtocolMerge.where(master_protocol_id: protocol.id)
protocol_ids = []
merges.each do |merge|
protocol_ids << merge.merged_protocol_id
end

protocol_ids
end
end
2 changes: 2 additions & 0 deletions app/views/dashboard/protocols/_table.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
%tr
%th.w-10{ data: { field: 'id', align: 'center', sortable: 'true' } }
= Protocol.human_attribute_name(:id)
%th.w-10{ data: { field: 'protocol_merges', align: 'center', sortable: 'true', visible: 'false' } }
jleonardw9 marked this conversation as resolved.
Show resolved Hide resolved
= t(:activerecord)[:attributes][:protocol][:protocol_merge]
%th.w-40{ data: { field: 'short_title', sortable: 'true' } }
= Protocol.human_attribute_name(:short_title)
%th.w-40{ data: { field: 'pis', sortable: 'true' } }
Expand Down
9 changes: 5 additions & 4 deletions app/views/dashboard/protocols/index.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ json.total @protocol_count
json.rows (@protocols) do |protocol|
access = authorized_user_protocols.include?(protocol.id) || admin_protocols.include?(protocol.id)

json.id protocol_id_link(protocol)
json.short_title protocol_short_title_link(protocol)
json.pis pis_display(protocol)
json.requests display_requests_button(protocol, access)
json.id protocol_id_link(protocol)
json.protocol_merges display_merges(protocol)
json.short_title protocol_short_title_link(protocol)
json.pis pis_display(protocol)
json.requests display_requests_button(protocol, access)
end
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,10 @@ en:
study_phase_ids: "Study Phase(s)"
study_type_questions: "Study Type Questions"
udak_project_number: "Financial Account (UDAK #)"
protocol_merge: "Historical Protocol Merges"
protocol_filter:
search_name: "Name"

question:
content: "Question"
question_response:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
protocol_archived = create(:study_without_validations, primary_pi: jug2, archived: true, short_title: 'ArchivedProtocol')
protocol_unarchived = create(:study_without_validations, primary_pi: jug2, archived: false, short_title: 'UnarchivedProtocol')

filter = create(:protocol_filter, identity: jug2, show_archived: true)
filter = create(:protocol_filter, identity: jug2, show_archived: true, search_query: {"search_drop"=>"", "search_text"=>""})

visit dashboard_protocols_path
wait_for_javascript_to_finish
Expand Down