Skip to content

Commit

Permalink
Merge pull request #1794 from datadryad/pub-history
Browse files Browse the repository at this point in the history
Highlight journal and manuscript changes for curators on the review page
  • Loading branch information
ahamelers authored Jul 31, 2024
2 parents 55e3b35 + af2d311 commit 56cb6cb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/stash_engine/user_admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def setup_tenants
end

def add_filters
@users = @users.joins(:roles).where(roles: { role: params[:role] }) if params[:role].present?
@users = @users.joins(:roles).where(roles: { role: params[:role] }).distinct if params[:role].present?
@users = @users.where(tenant_id: params[:tenant_id]) if params[:tenant_id].present?
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/stash_engine/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -857,8 +857,8 @@ def changed_fields(other_resource)

changed = []

changed << 'journal' if journal != other_resource.journal
changed << 'manuscript' if manuscript != other_resource.manuscript
changed << 'journal' if resource_publication&.publication_name != other_resource&.resource_publication&.publication_name
changed << 'manuscript' if resource_publication&.manuscript_number != other_resource&.resource_publication&.manuscript_number
changed << 'title' if title != other_resource.title

changed.concat(changed_authors(other_resource.authors))
Expand Down
7 changes: 7 additions & 0 deletions app/views/stash_datacite/resources/_review.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
<%= link_to "Edit Description",
stash_url_helpers.metadata_entry_pages_find_or_create_path(resource_id: @resource.id),
class: 't-review__edit-button-top o-button__icon-left', role: 'button' %>
<% if highlight_fields.intersect?(['journal', 'manuscript'])%>
<% prev = @resource.previous_curated_resource&.resource_publication %>
<% curr = @resource&.resource_publication %>
<p><b>Journal:</b> <%if prev&.publication_name != curr&.publication_name %><del><%= prev&.publication_name %></del> <%end%><span<%if prev&.publication_name != curr&.publication_name %> class="highlight"<%end%>><%= curr&.publication_name %></span>
<b style="margin-left: 2ch">Manuscript:</b> <%if prev&.manuscript_number != curr&.manuscript_number %><del><%= prev&.manuscript_number %></del> <%end%><span<%if prev&.manuscript_number != curr&.manuscript_number %> class="highlight"<%end%>><%= curr&.manuscript_number %></span>
</p>
<% end %>
<%= render partial: "stash_datacite/titles/show", locals: { title: @review.title_str, highlight: highlight_fields.include?('title') } %>
<div class="t-landing__metadata o-metadata">
<% author_highlight = highlight_fields[highlight_fields.find_index('authors') + 1] if highlight_fields.include?('authors') %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/stash_engine/resources/prepare_readme.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
fileList: @resource.data_files.map do |f|
h = { name: f.upload_file_name }
if f.upload_file_name.end_with?('.csv', '.tsv', '.xlsx', '.xls', '.rdata', '.rda', '.mat', '.txt')
h[:variables] = f.upload_file_name.end_with?('.csv', '.tsv') ? f.preview_file.lines.first.chomp.delete_prefix('"').delete_suffix('"').split(Regexp.union([/"?,"?/, /"?\t"?/])) : []
h[:variables] = f.upload_file_name.end_with?('.csv', '.tsv') && f.preview_file.present? ? f.preview_file.lines.first.chomp.delete_prefix('"').delete_suffix('"').split(Regexp.union([/"?,"?/, /"?\t"?/])) : []
end
h
end,
Expand Down

0 comments on commit 56cb6cb

Please sign in to comment.