Skip to content

Commit

Permalink
Merge pull request #1096 from uclibs/982/orcid-form-field
Browse files Browse the repository at this point in the history
Restore ORCID attribute on hyrax user object
  • Loading branch information
Janell-Huyck committed Nov 13, 2023
2 parents 536e441 + c644570 commit f2a6fb6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 25 deletions.
25 changes: 10 additions & 15 deletions app/views/hyrax/dashboard/profiles/_edit_primary.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@
</div>
</div>

<div class="form-group">
<%= f.label :orcid, 'Orcid'.html_safe, class: 'col-xs-4 control-label' %>
<div class="col-xs-8">
<%= f.text_field :orcid, class: "form-control" %>
</div>
</div>

<div class="form-group">
<%= f.label :website, class: 'col-xs-4 control-label' do %>
<%= t('hyrax.user_profile.website') %>
Expand Down Expand Up @@ -143,28 +150,16 @@
</div>
</div><!-- .form-group -->

<div class="form-group">

<div class="form-group">
<%= f.label :googleplus_handle, '<i class="fa fa-google-plus"></i> Google+ Handle'.html_safe, class: 'col-xs-4 control-label' %>
<div class="col-xs-8">
<%= f.text_field :googleplus_handle, class: "form-control" %>
</div>
</div><!-- .form-group -->


<%= render 'trophy_edit', trophies: @trophies %>
<%= f.button '<i class="glyphicon glyphicon-save"></i> Save Profile'.html_safe, type: 'submit', class: "btn btn-primary" %>
<% end %>

<div class="orcid-section">
<div class="well">
<% defined?(status_processor) || status_processor = Orcid::ProfileStatus.method(:for) %>
<% status_processor.call(current_user) do |on| %>
<% on.authenticated_connection do |profile| %>
<% end %>
<% end %>
<%= render partial: 'orcid/profile_connections/orcid_connector', locals: {default_search_text: current_user.name } %>
<p>
<%= link_to 'What is ORCID?', main_app.orcid_about_path %>
</p>
</div>
</div>
9 changes: 3 additions & 6 deletions app/views/hyrax/users/_user_info.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<dl id="user_info">

<% defined?(status_processor) || status_processor = Orcid::ProfileStatus.method(:for)
status_processor.call(current_user) do |on|
on.authenticated_connection do |profile| %>
<dt><%= orcid_label('profile') %></dt>
<dd><%= link_to profile.orcid_profile_id, Orcid.url_for_orcid_id(profile.orcid_profile_id), { target: '_blank' } %></dd>
<% end %>
<% if user.orcid.present? %>
<dt><%= orcid_label('profile') %></dt>
<dd><%= link_to user.orcid, user.orcid, { target: '_blank' } %></dd>
<% end %>
<% if Hyrax.config.arkivo_api? && user.zotero_userid.present? %>
Expand Down
1 change: 1 addition & 0 deletions spec/factories/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
website { 'Personal webpage' }
rd_page { 'https://researchdirectory.uc.edu/p/user' }
blog { 'Blog' }
orcid { '0000-0000-0000-0000' }

transient do
# Allow for custom groups when a user is instantiated.
Expand Down
13 changes: 11 additions & 2 deletions spec/features/hyrax/users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
it 'renders identity and contact fields' do
visit profile_path
click_link('Edit Profile', match: :first)

expect(page).to have_field('First Name', with: user.first_name)
expect(page).to have_field('Last Name', with: user.last_name)
expect(page).to have_field('Job title', with: user.title)
Expand All @@ -51,8 +52,16 @@
expect(page).to have_field('Research Directory webpage', with: user.rd_page)
expect(page).to have_field('Personal webpage', with: user.website)
expect(page).to have_field('Blog', with: user.blog)
expect(page).to have_content('Create or Connect your ORCID iD')
expect(page).to have_link('What is ORCID?')
expect(page).to have_field('Orcid', with: user.orcid)
end

it 'persists orcid id after editing' do
visit profile_path
click_link('Edit Profile', match: :first)
expect(page).to have_field('Orcid', with: user.orcid)
fill_in('Orcid', with: '1234-1234-1234-1234')
click_on('Save Profile')
expect(page).to have_content('https://orcid.org/1234-1234-1234-1234')
end

it 'shows permalinks after editing' do
Expand Down
4 changes: 2 additions & 2 deletions spec/views/hyrax/dashboard/profiles/edit.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
expect(rendered).to match(/Blog/)
end

it "does not show hyrax orcid field" do
it "shows hyrax orcid field" do
render
expect(rendered).not_to match(/ORCID Profile/)
expect(rendered).to match(/Orcid/)
end
end

0 comments on commit f2a6fb6

Please sign in to comment.