Skip to content

Commit 13fad47

Browse files
committed
Merge branch 'development' of https://github.com/DMPRoadmap/roadmap into development
2 parents a1a22f0 + 9b08312 commit 13fad47

File tree

13 files changed

+90
-79
lines changed

13 files changed

+90
-79
lines changed

app/controllers/concerns/paginable.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,12 @@ def refine_query(scope)
126126
scope = scope.search(@args[:search]) if @args[:search].present?
127127
# Can raise NoMethodError if the scope does not define a search method
128128
if @args[:sort_field].present?
129-
unless @args[:sort_field][SORT_COLUMN_FORMAT]
130-
raise ArgumentError, "sort_field param looks unsafe"
131-
end
129+
frmt = @args[:sort_field][SORT_COLUMN_FORMAT]
130+
raise ArgumentError, "sort_field param looks unsafe" unless frmt
132131

133132
# Can raise ActiveRecord::StatementInvalid (e.g. column does not
134133
# exist, ambiguity on column, etc)
135-
scope = scope.order(@args[:sort_field].to_sym => sort_direction)
134+
scope = scope.order(@args[:sort_field].to_sym => sort_direction.to_s)
136135
end
137136
if @args[:page] != "ALL"
138137
# Can raise error if page is not a number
@@ -142,7 +141,6 @@ def refine_query(scope)
142141
end
143142

144143
def sort_direction
145-
@args = @args.with_indifferent_access
146144
@sort_direction ||= SortDirection.new(@args[:sort_direction])
147145
end
148146

app/helpers/identifier_helper.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
module IdentifierHelper
4+
5+
def id_for_display(id:, with_scheme_name: true)
6+
return _("None defined") if id.new_record? || id.value.blank?
7+
8+
without = id.value_without_scheme_prefix
9+
prefix = with_scheme_name ? id.identifier_scheme.description + ": " : ""
10+
return prefix + id.value unless without != id.value && !without.starts_with?("http")
11+
12+
link_to "#{prefix} #{without}", id.value, class: "has-new-window-popup-info"
13+
end
14+
15+
end

app/models/concerns/date_rangeable.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ def date_range?(term:)
1616
def by_date_range(field, term)
1717
date = Date.parse(term) if term[0..1].match(/[0-9]{2}/).present?
1818
date = Date.parse("1st #{term}") unless date.present?
19-
where("#{table_name}.#{field} BETWEEN ? AND ?", date, date.end_of_month)
19+
query = "%{table}.%{field} BETWEEN ? AND ?" % { table: table_name, field: field }
20+
where(query, date, date.end_of_month)
2021
end
2122

2223
end

app/presenters/identifier_presenter.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,6 @@ def scheme_by_name(name:)
2323
schemes.select { |scheme| scheme.name.downcase == name.downcase }
2424
end
2525

26-
def id_for_display(id:, with_scheme_name: true)
27-
return _("None defined") if id.new_record? || id.value.blank?
28-
29-
without = id.value_without_scheme_prefix
30-
prefix = with_scheme_name ? id.identifier_scheme.description + ": " : ""
31-
return prefix + id.value unless without != id.value && !without.starts_with?("http")
32-
33-
"<a href=\"#{id.value}\" class=\"has-new-window-popup-info\"> " \
34-
"#{prefix} #{without}</a>"
35-
end
36-
3726
private
3827

3928
def load_schemes

app/views/org_admin/users/edit.html.erb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@
5858

5959
<% if @user.identifiers.present? %>
6060
<h2>Identifiers</h2>
61-
<% presenter = IdentifierPresenter.new(identifiable: @user) %>
6261
<% presenter.identifiers.each do |identifier| %>
63-
<p><%= presenter.id_for_display(id: identifier, with_scheme_name: true).html_safe %></p>
62+
<p><%= id_for_display(id: identifier, with_scheme_name: true) %></p>
6463
<% end %>
6564
<% end %>
6665

app/views/orgs/_external_identifiers.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<div class="form-group col-xs-10">
1818
<% id = presenter.id_for_scheme(scheme: scheme) %>
1919
<span class="bold"><%= scheme.description %>:</span>
20-
<%= presenter.id_for_display(id: id).html_safe %>
20+
<%= id_for_display(id: id) %>
2121
</div>
2222
</div>
2323
<% end %>
@@ -62,7 +62,7 @@
6262
<div class="form-group col-xs-10">
6363
<% id = presenter.id_for_scheme(scheme: scheme) %>
6464
<span class="bold"><%= scheme.description %>:</span>
65-
<%= presenter.id_for_display(id: id).html_safe %>
65+
<%= id_for_display(id: id) %>
6666
</div>
6767
</div>
6868
<% end %>

app/views/paginable/contributors/_index.html.erb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@
3838
<%= contributor.org&.name %>
3939
<% ror = contributor.org.identifier_for_scheme(scheme: ror_scheme) %>
4040
<% if ror.present? %>
41-
<% id_presenter = IdentifierPresenter.new(identifiable: contributor.org) %>
4241
<br/>
43-
<%= id_presenter.id_for_display(id: ror).html_safe %>
42+
<%= id_for_display(id: ror) %>
4443
<% end %>
4544
<% end %>
4645
</td>

app/views/plans/_project_details.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
identifier = id_presenter.id_for_scheme(scheme: scheme)
101101
%>
102102
<div class="col-md-8">
103-
<li><%= id_presenter.id_for_display(id: identifier).html_safe %></li>
103+
<li><%= id_for_display(id: identifier) %></li>
104104
</div>
105105
<% end %>
106106
</ul>

app/views/super_admin/users/edit.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<h2>Identifiers</h2>
7171
<% presenter = IdentifierPresenter.new(identifiable: @user) %>
7272
<% presenter.identifiers.each do |identifier| %>
73-
<p><%= presenter.id_for_display(id: identifier, with_scheme_name: true).html_safe %></p>
73+
<p><%= id_for_display(id: identifier, with_scheme_name: true) %></p>
7474
<% end %>
7575
<% end %>
7676

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
"bootstrap-select": "^1.13.18",
3434
"chart.js": "^2.9.3",
3535
"core-js": "^3.6.5",
36+
"eslint": "^7.1.0",
37+
"eslint-config-airbnb-base": "^14.1.0",
38+
"eslint-loader": "^4.0.2",
39+
"eslint-plugin-import": "^2.21.1",
3640
"jquery": "^3.5.1",
3741
"jquery-ui": "^1.12.1",
3842
"jquery-ui-sass": "^0.0.1",
@@ -42,12 +46,8 @@
4246
"rails-erb-loader": "^5.5.2",
4347
"regenerator-runtime": "^0.13.5",
4448
"timeago.js": "^4.0.2",
45-
"tinymce": "^4.9.10",
46-
"turbolinks": "^5.2.0",
47-
"eslint": "^7.1.0",
48-
"eslint-config-airbnb-base": "^14.1.0",
49-
"eslint-loader": "^4.0.2",
50-
"eslint-plugin-import": "^2.21.1"
49+
"tinymce": "4.9.10",
50+
"turbolinks": "^5.2.0"
5151
},
5252
"devDependencies": {
5353
"eslint": "^7.1.0",

0 commit comments

Comments
 (0)