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

As a user who is viewing a Protocol, I should see a link to the corre… #92

Merged
merged 2 commits into from
Oct 21, 2015
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
6 changes: 6 additions & 0 deletions app/helpers/protocol_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
module ProtocolHelper

def admin_portal_link(protocol)
content_tag(:a, href: protocol.sparc_uri, target: :blank, class: 'btn btn-default btn-xs admin_portal_link', title: 'Admin Portal link', aria: { expanded: 'false' }) do
content_tag(:span, '', class: 'glyphicon glyphicon-link')
end
end

def formatted_status protocol
if protocol.status.present?
t(:sub_service_request)[:statuses][protocol.status.to_sym]
Expand Down
14 changes: 12 additions & 2 deletions app/models/protocol.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Protocol < ActiveRecord::Base

attr_accessor :document_counter_updated
attr_accessor :document_counter_updated

has_paper_trail
acts_as_paranoid
Expand Down Expand Up @@ -41,11 +41,21 @@ class Protocol < ActiveRecord::Base
:title,
:funding_source,
to: :sparc_protocol

def self.title id
["Protocol", Protocol.find(id).srid].join(' ')
end

def sparc_uri
[
ENV.fetch('GLOBAL_SCHEME'),
'://',
ENV.fetch('SPARC_API_HOST'),
'/portal/admin/sub_service_requests/',
sparc_id
].join
end

def srid # this is a combination of sparc_id and sub_service_request.ssr_id
"#{sparc_id} - #{sub_service_request.ssr_id}"
end
Expand Down
18 changes: 10 additions & 8 deletions app/views/protocols/_protocol.html.haml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
.fixed-table-container.bootstrap-table-dropdown-overflow
%table.protocol.details.custom_striped{id: dom_id(protocol), "data-toggle" => 'table', "data-url" => protocol_path(protocol, format: :json)}
%table.protocol.details.custom_striped{ id: dom_id(protocol), data: { toggle: 'table', url: protocol_path(protocol, format: :json) } }
%thead
%tr
%th{data: {class: "srid", align: "left", field: "srid"}}
%th{ data: { class: 'srid', align: 'left', field: 'srid' } }
= t(:protocol)[:srid]
%th{data: {class: "pi", align: "left", field: "pi"}}
%th{ data: { class: 'pi', align: 'left', field: 'pi' } }
= t(:protocol)[:principal_investigator]
%th{data: {class: "coordinators", align: "center", field: "coordinators"}}
%th{ data: { class: 'coordinators', align: 'center', field: 'coordinators' } }
= t(:protocol)[:coordinators]
%th{data: {class: "short_title", align: "left", field: "short_title"}}
%th{ data: { class: 'short_title', align: 'left', field: 'short_title' } }
= t(:protocol)[:short_title]
%th{data: {class: "irb_number", align: "left", field: "irb_number"}}
%th{ data: { class: 'irb_number', align: 'left', field: 'irb_number' } }
= t(:protocol)[:irb_number]
%th{data: {class: "irb_expiration_date", align: "center", field: "irb_expiration_date"}}
%th{ data: { class: 'irb_expiration_date', align: 'center', field: 'irb_expiration_date' } }
= t(:protocol)[:irb_expiration_date]
%th{data: {class: "study_schedule_report", align: "center", field: "study_schedule_report"}}
%th{ data: { class: 'study_schedule_report', align: 'center', field: 'study_schedule_report' } }
= t(:protocol)[:study_schedule_report]
%th{ data: { class: 'admin_portal_link', align: 'center', field: 'admin_portal_link' } }
= t(:protocol)[:admin_portal_link]
3 changes: 2 additions & 1 deletion app/views/protocols/_protocol.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ json.coordinators formatted_coordinators(protocol.coordinators.map(&:full_name))
json.study_schedule_report formatted_study_schedule_report(protocol)
json.owner formatted_owner(protocol)
json.requester formatted_requester(protocol)
json.organizations protocol.sub_service_request.org_tree_display
json.organizations protocol.sub_service_request.org_tree_display
json.admin_portal_link admin_portal_link(protocol)
3 changes: 2 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ en:
principal_investigator: "Principal Investigator"
coordinators: "Coordinators"
irb_approval_date: "IRB Approval Date"
irb_expiration_date: "Current IRB Expiration Date"
irb_expiration_date: "IRB Expiration"
irb_number: "IRB #"
udak_project_number: "UDAK Project #"
start_date: "Study Start Date"
Expand All @@ -251,6 +251,7 @@ en:
subsidy_committed: "Subsidy Amount"
subsidy_expended: "Subsidy Expended"
study_schedule_report: "Export"
admin_portal_link: "Admin Portal"
owner: "Owner"
requester: "Service Requester"
organizations: "Provider/Program/Core"
Expand Down
13 changes: 13 additions & 0 deletions spec/models/protocol/sparc_uri_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'rails_helper'

RSpec.describe Protocol, type: :model do

describe '.sparc_uri' do

let(:protocol) { create(:protocol) }

it 'should return a valid URI' do
expect(protocol.sparc_uri).to eq('http://localhost:5000/portal/admin/sub_service_requests/1')
end
end
end