-
Notifications
You must be signed in to change notification settings - Fork 20
Author improvements #1245
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
Open
fbacall
wants to merge
57
commits into
master
Choose a base branch
from
author-improvements
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Author improvements #1245
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
8d5710c
Add Author model and migration for authors has_many relationship
Copilot b399963
Update serializers, views, bioschemas and ingestors for new Author model
Copilot 2f8ce09
Fix tests to work with new Author model
Copilot ea5876a
Refactor Author to generic Person model with polymorphic PersonLink
Copilot d360ced
Add custom authors= setter for legacy API backwards compatibility
Copilot fbd140c
Add HasPeople concern, apply to contributors like authors
Copilot 508211d
Add full_name column, rename first_name/last_name to given_name/famil…
Copilot 4009375
Add legacy first_name/last_name to permitted params for API backwards…
Copilot d209e06
Add optional belongs_to :profile on Person, auto-link by ORCID on save
Copilot 507208e
Schema
fbacall 6d79f96
Fix missing `end`
fbacall 97f8bcd
DRY up some ORCID handling code
fbacall 5d8acf6
Revert CSV ingestor changes and fix test
fbacall 0921ece
Revert material API change
fbacall ba745c9
Fix bad ORCIDs in tests
fbacall d3c818d
Remove the indirection - resources manage their own `Person` objects*
fbacall d840bac
Fix broken person form (it still looks bad though)
fbacall b8f36f8
Restore contributors and authors to materials serializer
fbacall 8003356
Test fix
fbacall c28bada
Just use `full_name` for people
fbacall 8d1af15
Migration to convert people to new table
fbacall 2afa622
Improve person form
fbacall f8cb2f6
Test fix
fbacall 7435f71
Tidying people form code. Use partial. Refactor JS. Tidying. I18n.
fbacall 46f756e
Richer display of people that have ORCID/profile links
fbacall 60870c4
Only auto-link people to profiles with authenticated ORCIDs
fbacall f133be7
Remove link to profile if no longer a profile matching the person ORCID
fbacall 7aad8e1
Async job that links `people` to `profiles` when ORCID is authenticat…
fbacall d4e6747
Autocomplete (name + orcid) in person form
fbacall 8ac96bb
Test fix
fbacall 16718fd
Fix XSS
fbacall ada5b5a
Migrate Workflow and LearningPath authors/contributors
fbacall def105b
Deprecate old authors/contributors DB fields
fbacall 22cf330
Prevent needless destruction/creation of `Person` records
fbacall 5ceedaf
Fix assignment of `Person` objects to association
fbacall bfb09bf
Rename `Person#full_name` -> just `name`
fbacall fc3acf1
Test author params allows string/structured forms
fbacall 7837e82
Bump RDF extractor lib to parse structured people objects
fbacall 165c28a
Fix string authors no longer working
fbacall 43a99bf
Use both `@id` and `identifier` to serialize person's ORCID in Biosch…
fbacall 6ca7e25
Revert API change
fbacall 9dcb919
Test fix
fbacall 0b7606e
Fix missing associated resources when previewing scraped resources. F…
fbacall cdc4d39
Merge branch 'master' into author-improvements
fbacall beda636
Remove generic `people` association and just use role-specific ones
fbacall 873da43
Address Copilot review
fbacall b099ad2
Fix down migrations
fbacall b65e7ed
Add space between name and ORCID
fbacall 6decfa1
Merge branch 'author-improvements' of github.com:ElixirTeSS/TeSS into…
fbacall c2e8085
Remove test for redundant method
fbacall 6f6fbb6
Fix param conversion issue
fbacall 35e95d6
Validate orcid in `has_orcid`
fbacall d71f98f
Remove leftover `accepts_nested_attributes_for` stuff. Ensure all aut…
fbacall 55e59f9
Index people on name to speed up autocomplete
fbacall 9b3ae7c
Ensure ORCIDs in test code are valid
fbacall 5788cef
Test fix
fbacall 81240a8
Merge branch 'master' into author-improvements
fbacall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| const People = { | ||
| add: function (template, list) { | ||
| let newForm = template.clone().html(); | ||
| // Ensure the index of the new form is 1 greater than the current highest index, to prevent collisions | ||
| let index = 0; | ||
| $('.person-form', list).each(function () { | ||
| var newIndex = parseInt($(this).data('index')); | ||
| if (newIndex > index) { | ||
| index = newIndex; | ||
| } | ||
| }); | ||
|
|
||
| // Replace the placeholder index with the actual index | ||
| newForm = $(newForm.replace(/replace-me/g, index + 1)); | ||
| newForm.appendTo(list); | ||
| const nameInput = newForm.find('.person-name'); | ||
| const orcidInput = newForm.find('.person-orcid'); | ||
| const opts = { | ||
| orientation: 'top', | ||
| triggerSelectOnValidInput: false, | ||
| onSelect: function (suggestion) { | ||
| orcidInput.val(suggestion.data.orcid); | ||
| }, | ||
| transformResult: function(response) { | ||
| return { | ||
| suggestions: $.map(response.suggestions, function(item) { | ||
| item.data.hint = item.data.orcid; | ||
| return item; | ||
| }) | ||
| }; | ||
| }, | ||
| formatResult: Autocompleters.formatResultWithHint | ||
| } | ||
|
|
||
| opts.serviceUrl = list.parents('[data-role="people-form"]').data('autocompleteUrl'); | ||
| opts.dataType = 'json'; | ||
| opts.deferRequestBy = 100; | ||
|
|
||
| nameInput.autocomplete(opts); | ||
|
|
||
| return newForm; | ||
| }, | ||
|
|
||
| delete: function () { | ||
| $(this).parents('.person-form').fadeOut('fast', function() { | ||
| $(this).remove(); | ||
| }); | ||
| }, | ||
|
|
||
| init: function () { | ||
| $('[data-role="people-form"]').each(function () { | ||
| const form = $(this); | ||
| const template = form.find('[data-role="people-form-template"]'); | ||
| const list = form.find('[data-role="people-form-list"]'); | ||
|
|
||
| form.find('[data-role="people-form-add"]').click(function (e) { | ||
| e.preventDefault(); | ||
| const nextItem = People.add(template, list); | ||
| nextItem.find('input.form-control:first').focus(); | ||
| }); | ||
|
|
||
| // Add new person if enter is pressed on final person, otherwise focus the next person in the list. | ||
| $(form).on('keyup', 'input', function (e) { | ||
| if (e.which === 13) { | ||
| e.preventDefault(); | ||
| let nextItem = $(e.target).parents('.person-form').next('.person-form'); | ||
| if (!nextItem.length) { | ||
| nextItem = People.add(template, list); | ||
| } | ||
| nextItem.find('input.form-control:first').focus(); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| $('.delete-person-btn input.destroy-attribute').change(People.delete); | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
display_peoplehelper iterates over each person and callsperson.profile, but thehas_person_roleassociation doesn't eager-load profiles. This causes N+1 database queries when a resource has multiple authors or contributors. Thehas_person_rolemacro should addincludes: :profileto the association scope, or thedisplay_peoplehelper should receive a collection that is already preloaded with profiles.