Skip to content

Commit 56a6f79

Browse files
authored
Merge pull request #1245 from ElixirTeSS/author-improvements
Author improvements
2 parents f12e30a + 81240a8 commit 56a6f79

63 files changed

Lines changed: 1362 additions & 220 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Gemfile.lock

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
GIT
22
remote: https://github.com/ElixirTeSS/TeSS_RDF_Extractors
3-
revision: f9eee4621738c8fcaa9e0729e76a307fcd55650f
3+
revision: 135ce24ef909bf5f7c6e14ccb1e404b51478ab07
44
branch: master
55
specs:
6-
tess_rdf_extractors (1.1.0)
6+
tess_rdf_extractors (1.2.0)
77
linkeddata (~> 3.2.0)
88

99
GEM
@@ -97,8 +97,8 @@ GEM
9797
minitest (>= 5.1)
9898
securerandom (>= 0.3)
9999
tzinfo (~> 2.0, >= 2.0.5)
100-
addressable (2.8.7)
101-
public_suffix (>= 2.0.2, < 7.0)
100+
addressable (2.8.9)
101+
public_suffix (>= 2.0.2, < 8.0)
102102
aes_key_wrap (1.1.0)
103103
ahoy_matey (4.2.1)
104104
activesupport (>= 5.2)
@@ -119,7 +119,7 @@ GEM
119119
erubi (>= 1.0.0)
120120
rack (>= 0.9.0)
121121
rouge (>= 1.0.0)
122-
bigdecimal (3.2.3)
122+
bigdecimal (3.3.1)
123123
bindata (2.5.0)
124124
bindex (0.8.1)
125125
binding_of_caller (1.0.0)
@@ -147,8 +147,8 @@ GEM
147147
json_schema (~> 0.14, >= 0.14.3)
148148
openapi_parser (~> 1.0)
149149
rack (>= 1.5)
150-
concurrent-ruby (1.3.5)
151-
connection_pool (2.5.4)
150+
concurrent-ruby (1.3.6)
151+
connection_pool (3.0.2)
152152
countries (5.6.0)
153153
unaccent (~> 0.3)
154154
country_select (8.0.2)
@@ -157,7 +157,7 @@ GEM
157157
rexml
158158
crass (1.0.6)
159159
csv (3.3.2)
160-
date (3.4.1)
160+
date (3.5.1)
161161
debug_inspector (1.1.0)
162162
device_detector (1.1.1)
163163
devise (4.9.4)
@@ -206,7 +206,7 @@ GEM
206206
globalid (1.2.1)
207207
activesupport (>= 6.1)
208208
gravtastic (3.2.6)
209-
haml (6.3.0)
209+
haml (6.4.0)
210210
temple (>= 0.8.2)
211211
thor
212212
tilt
@@ -218,7 +218,7 @@ GEM
218218
tilt (>= 1.2)
219219
hashdiff (1.0.1)
220220
hashie (5.0.0)
221-
htmlentities (4.3.4)
221+
htmlentities (4.4.2)
222222
http-accept (1.7.0)
223223
http-cookie (1.0.5)
224224
domain_name (~> 0.5)
@@ -233,7 +233,7 @@ GEM
233233
icalendar (2.9.0)
234234
ice_cube (~> 0.16)
235235
ice_cube (0.16.4)
236-
io-console (0.8.1)
236+
io-console (0.8.2)
237237
irb (1.15.2)
238238
pp (>= 0.6.0)
239239
rdoc (>= 4.0.0)
@@ -365,15 +365,15 @@ GEM
365365
money (~> 6.13)
366366
railties (>= 3.0)
367367
msgpack (1.7.2)
368-
multi_json (1.17.0)
368+
multi_json (1.19.1)
369369
multi_xml (0.8.0)
370370
bigdecimal (>= 3.1, < 5)
371371
multipart-post (2.4.1)
372372
nested_form (0.3.2)
373373
net-http (0.9.1)
374374
uri (>= 0.11.1)
375-
net-http-persistent (4.0.6)
376-
connection_pool (~> 2.2, >= 2.2.4)
375+
net-http-persistent (4.0.8)
376+
connection_pool (>= 2.2.4, < 4)
377377
net-imap (0.5.8)
378378
date
379379
net-protocol
@@ -436,15 +436,15 @@ GEM
436436
pry-byebug (3.10.1)
437437
byebug (~> 11.0)
438438
pry (>= 0.13, < 0.15)
439-
psych (5.2.6)
439+
psych (5.3.1)
440440
date
441441
stringio
442442
public_activity (3.0.1)
443443
actionpack (>= 6.1.0)
444444
activerecord (>= 6.1)
445445
i18n (>= 0.5.0)
446446
railties (>= 6.1.0)
447-
public_suffix (6.0.2)
447+
public_suffix (7.0.5)
448448
puma (6.5.0)
449449
nio4r (~> 2.0)
450450
pundit (2.3.1)
@@ -599,7 +599,7 @@ GEM
599599
redis-client (0.16.0)
600600
connection_pool
601601
regexp_parser (2.8.1)
602-
reline (0.6.2)
602+
reline (0.6.3)
603603
io-console (~> 0.5)
604604
responders (3.1.1)
605605
actionpack (>= 5.2)
@@ -611,7 +611,7 @@ GEM
611611
netrc (~> 0.8)
612612
reverse_markdown (2.1.1)
613613
nokogiri
614-
rexml (3.4.2)
614+
rexml (3.4.4)
615615
rouge (4.1.3)
616616
rsolr (2.6.0)
617617
builder (>= 2.1.2)
@@ -729,7 +729,7 @@ GEM
729729
actionpack (>= 5.2)
730730
activesupport (>= 5.2)
731731
sprockets (>= 3.0.0)
732-
stringio (3.1.7)
732+
stringio (3.2.0)
733733
sunspot (2.7.1)
734734
bigdecimal
735735
pr_geohash (~> 1.0)
@@ -750,8 +750,8 @@ GEM
750750
climate_control (>= 0.0.3, < 1.0)
751751
terser (1.1.17)
752752
execjs (>= 0.3.0, < 3)
753-
thor (1.4.0)
754-
tilt (2.6.1)
753+
thor (1.5.0)
754+
tilt (2.7.0)
755755
timeout (0.4.3)
756756
tsort (0.2.0)
757757
turbo-rails (2.0.11)
@@ -771,7 +771,7 @@ GEM
771771
unf_ext
772772
unf_ext (0.0.8.2)
773773
unicode-display_width (2.4.2)
774-
unicode-types (1.10.0)
774+
unicode-types (1.11.0)
775775
uri (1.1.1)
776776
useragent (0.16.11)
777777
validate_email (0.1.6)

app/assets/javascripts/application.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ document.addEventListener("turbolinks:load", function(e) {
276276

277277
LearningPaths.init();
278278

279+
People.init();
280+
279281
$('.tess-expandable').each(function () {
280282
if (this.dataset.origHeight) {
281283
return;

app/assets/javascripts/people.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
const People = {
2+
add: function (template, list) {
3+
let newForm = template.clone().html();
4+
// Ensure the index of the new form is 1 greater than the current highest index, to prevent collisions
5+
let index = 0;
6+
$('.person-form', list).each(function () {
7+
var newIndex = parseInt($(this).data('index'));
8+
if (newIndex > index) {
9+
index = newIndex;
10+
}
11+
});
12+
13+
// Replace the placeholder index with the actual index
14+
newForm = $(newForm.replace(/replace-me/g, index + 1));
15+
newForm.appendTo(list);
16+
const nameInput = newForm.find('.person-name');
17+
const orcidInput = newForm.find('.person-orcid');
18+
const opts = {
19+
orientation: 'top',
20+
triggerSelectOnValidInput: false,
21+
onSelect: function (suggestion) {
22+
orcidInput.val(suggestion.data.orcid);
23+
},
24+
transformResult: function(response) {
25+
return {
26+
suggestions: $.map(response.suggestions, function(item) {
27+
item.data.hint = item.data.orcid;
28+
return item;
29+
})
30+
};
31+
},
32+
formatResult: Autocompleters.formatResultWithHint
33+
}
34+
35+
opts.serviceUrl = list.parents('[data-role="people-form"]').data('autocompleteUrl');
36+
opts.dataType = 'json';
37+
opts.deferRequestBy = 100;
38+
39+
nameInput.autocomplete(opts);
40+
41+
return newForm;
42+
},
43+
44+
delete: function () {
45+
$(this).parents('.person-form').fadeOut('fast', function() {
46+
$(this).remove();
47+
});
48+
},
49+
50+
init: function () {
51+
$('[data-role="people-form"]').each(function () {
52+
const form = $(this);
53+
const template = form.find('[data-role="people-form-template"]');
54+
const list = form.find('[data-role="people-form-list"]');
55+
56+
form.find('[data-role="people-form-add"]').click(function (e) {
57+
e.preventDefault();
58+
const nextItem = People.add(template, list);
59+
nextItem.find('input.form-control:first').focus();
60+
});
61+
62+
// Add new person if enter is pressed on final person, otherwise focus the next person in the list.
63+
$(form).on('keyup', 'input', function (e) {
64+
if (e.which === 13) {
65+
e.preventDefault();
66+
let nextItem = $(e.target).parents('.person-form').next('.person-form');
67+
if (!nextItem.length) {
68+
nextItem = People.add(template, list);
69+
}
70+
nextItem.find('input.form-control:first').focus();
71+
}
72+
});
73+
});
74+
75+
$('.delete-person-btn input.destroy-attribute').change(People.delete);
76+
}
77+
};

app/assets/stylesheets/external-resources.scss

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
.external-resource-form {
2-
padding-bottom: 10px;
3-
margin-bottom: 10px;
4-
5-
&.deleted {
6-
color: $brand-danger;
7-
text-decoration: line-through;
8-
}
9-
}
10-
111
.associate-resource {
122
cursor: pointer;
133
}

app/assets/stylesheets/forms.scss

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,17 @@ label.required abbr {
3636
margin-top: 0;
3737
}
3838

39-
.delete-external-resource-btn {
39+
.nested-resource-form {
40+
padding-bottom: 10px;
41+
margin-bottom: 10px;
42+
43+
&.deleted {
44+
color: $brand-danger;
45+
text-decoration: line-through;
46+
}
47+
}
48+
49+
.delete-nested-resource-btn {
4050
@include delete-cross;
4151

4252
cursor: pointer;

app/controllers/autocomplete_controller.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ def suggestions
77
end
88

99
def people_suggestions
10-
suggestions = AutocompleteSuggestion.people.query(params[:query])
10+
people = Person.query(params[:query])
11+
suggestions = people.map do |p|
12+
{ value: p.name,
13+
data: {
14+
orcid: p.orcid,
15+
profile_id: p.profile_id
16+
}
17+
}
18+
end
1119
respond_with({ suggestions: suggestions })
1220
end
1321
end

app/controllers/learning_paths_controller.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,14 @@ def learning_path_params
103103
params.require(:learning_path).permit(:id, :title, :description, :licence, :doi,
104104
:content_provider_id, :difficulty_level, :status,
105105
:prerequisites, :syllabus, :learning_objectives,
106-
{ contributors: [] }, { authors: [] }, { target_audience: [] },
106+
{ target_audience: [] },
107107
{ keywords: [] },
108108
{ scientific_topic_names: [] }, { scientific_topic_uris: [] },
109109
{ node_ids: [] }, { node_names: [] },
110-
{ topic_links_attributes: [:id, :topic_id, :order, :_destroy] }, :public)
110+
{ topic_links_attributes: [:id, :topic_id, :order, :_destroy] }, :public,
111+
{ authors: [:name, :orcid] }, { contributors: [:name, :orcid] }, # Structured
112+
{ authors: [] }, { contributors: [] } # as strings
113+
)
111114
end
112115

113116
end

app/controllers/materials_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,13 @@ def material_params
171171
:content_provider_id, :difficulty_level, :version, :status,
172172
:date_created, :date_modified, :date_published, :other_types,
173173
:prerequisites, :syllabus, :visible, :learning_objectives, { subsets: [] },
174-
{ contributors: [] }, { authors: [] }, { target_audience: [] },
174+
{ target_audience: [] },
175175
{ collection_ids: [] }, { keywords: [] }, { resource_type: [] },
176176
{ scientific_topic_names: [] }, { scientific_topic_uris: [] },
177177
{ operation_names: [] }, { operation_uris: [] },
178178
{ node_ids: [] }, { node_names: [] }, { fields: [] },
179+
{ authors: [:name, :orcid] }, { contributors: [:name, :orcid] }, # Structured
180+
{ authors: [] }, { contributors: [] }, # as strings
179181
external_resources_attributes: %i[id url title _destroy],
180182
external_resources: %i[url title],
181183
event_ids: [], locked_fields: [])

app/controllers/workflows_controller.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,11 @@ def workflow_params
117117
params.require(:workflow).permit(:title, :description, :user_id, :workflow_content, :doi,
118118
:remote_created_date, :remote_updated_date, { keywords: [] },
119119
{ scientific_topic_names: [] }, { scientific_topic_uris: [] }, :licence,
120-
:difficulty_level, { contributors: [] }, { authors: [] }, { target_audience: [] },
121-
:hide_child_nodes, :public)
120+
:difficulty_level, { target_audience: [] },
121+
:hide_child_nodes, :public,
122+
{ authors: [:name, :orcid] }, { contributors: [:name, :orcid] }, # Structured
123+
{ authors: [] }, { contributors: [] } # as strings
124+
)
122125
end
123126

124127
end

app/helpers/application_helper.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,4 +714,27 @@ def per_page_options_for_select
714714
options_for_select(SearchableIndex::PER_PAGE_OPTIONS.map { |k| [k, k] },
715715
params[:per_page].presence || SearchableIndex::DEFAULT_PAGE_SIZE)
716716
end
717+
718+
def attributes_to_hidden_fields(param_key, attrs)
719+
flatten_params(param_key, attrs).map do |name, value|
720+
hidden_field_tag(name, value)
721+
end.join.html_safe
722+
end
723+
724+
private
725+
726+
def flatten_params(prefix, value)
727+
case value
728+
when Hash
729+
value.flat_map do |k, v|
730+
flatten_params("#{prefix}[#{k}]", v)
731+
end
732+
when Array
733+
value.flat_map do |v|
734+
flatten_params("#{prefix}[]", v)
735+
end
736+
else
737+
[[prefix, value]]
738+
end
739+
end
717740
end

0 commit comments

Comments
 (0)