-
Notifications
You must be signed in to change notification settings - Fork 466
Contributor Roles and Type #11765
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
base: main
Are you sure you want to change the base?
Contributor Roles and Type #11765
Conversation
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.
Hi @jyhein,
Thanks a lot for the huge work!
I have not finished my review yet, but wanted to let you know about a few things I am wondering/thinking about:
I am wondering if we could have author object with the array of ContributorRole objects. Currently, it is not easy to understand where what is set or get, when, why...
I think it is then more similar to how else we have it in the code, and maybe also cleaner, easier to read and understand.
E.g. sometimes we set contributor roles with localized names, sometimes with all names... This should actually be handled (if localized or not) when we want to do something with author's contributor roles.
Also, it would be good to have add, edit, delete functions in contributorRole Repo, that would get an object.
I believe also in the ContributorRoleForm you could work with ContributorRole objects.
I believe it would be cleaner, easier to read it all...
What do you think?
Also, there are a few other comments...
And I will continue to review...
Could you maybe rebase and let me know, then I would also try to test it locally....
Thanks a lot!
|
||
$params = $this->convertStringsToSchema(PKPSchemaService::SCHEMA_AUTHOR, $illuminateRequest->input()); | ||
// Remove extra data that is irrelevant to the selected contributor type | ||
$this->removeIrrelevantContributorTypeData($params); |
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.
I am wondering if we should rather put this into the Repository validate() function...
Here and above...
Let me think... 🤔
classes/author/Author.php
Outdated
return match ($this->getData('contributorType')) { | ||
ContributorType::PERSON->getName() => parent::getFullName($preferred, $familyFirst, $preferredLocale), | ||
ContributorType::ORGANIZATION->getName() => $this->getLocalizedOrganizationName($preferredLocale), | ||
ContributorType::ANONYMOUS->getName() => __('submission.submit.contributorType.anonymous'), |
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.
Provide $preferredLocale as parameter for __():
__('submission.submit.contributorType.anonymous', locale: $preferredLocale)
or
__('submission.submit.contributorType.anonymous', [], $preferredLocale)
classes/author/Author.php
Outdated
/** | ||
* Get organization name. | ||
*/ | ||
public function getOrganizationName(string $locale): string|array|null |
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.
also null can be given, to get an array of all localized names, no? It also seems to be the default parameter, because above, in the function getFullNames() we call it without parameters.
classes/author/Author.php
Outdated
* | ||
* @return string | ||
*/ | ||
public function getLocalizedOrganizationName(string $preferredLocale = null) |
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.
to add return type like this:
public function getLocalizedOrganizationName(string $preferredLocale = null): string
?
classes/author/DAO.php
Outdated
} | ||
|
||
Repo::creditContributorRole()->addCreditRoles($author->getCreditRoles(), $newAuthorId); | ||
Repo::creditContributorRole()->addCreditRoles($author->getCreditRoles(false), $newAuthorId); |
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.
author->getCreditRoles() does not expect any parameter
schemas/author.json
Outdated
"readOnly": true, | ||
"items": { | ||
"type": "object", | ||
"multilingual": "true" |
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.
shell here also the properties be defined/listed?
}, | ||
"contributorRoles": { | ||
"type": "object", | ||
"description": "The names of this contributor's roles in the publication, such as 'Author' or 'Translator', and the translations", |
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.
Wouldn't it be better to have the array of objects here: That way we know also the role identifier and can match it when exporting?
|
||
// Get full details of the working publication and the current publication | ||
$mapper = Repo::publication()->getSchemaMap($submission, $contextUserGroups, $contextGenres); | ||
$mapper = Repo::publication()->getSchemaMap($submission, $contextGenres); |
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.
should then the arguments in the function getSchemaMap() in lib/pkp/classes/publication/Repository be changed as well?
classes/author/Author.php
Outdated
{ | ||
$this->setData('contributorRoles', !$contextId | ||
? $contributorRoles | ||
: Repo::contributorRole()->getByContextIdAndIdentifiers($contextId, $contributorRoles) |
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.
Somehow I think it would be cleaner to have array of objects/ContributorRoles in this author's property.
classes/author/Repository.php
Outdated
|
||
foreach ($authors as $author) { | ||
if (empty($author->getGivenName($newLocale))) { | ||
if (ContributorType::PERSON->getName() && empty($author->getGivenName($newLocale))) { |
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.
Shouldn't we check if author->getData('contributorType') == ContributorType::PERSON->getName() instead?
3d6c902
to
6e7408a
Compare
/** | ||
* Get form data | ||
*/ | ||
public function getContributorRoleFormData(Request $illuminateRequest): JsonResponse |
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.
I would suggest not making it form specific. Just expose it as any other data. I think its still valuable even if its not data from the database.
Endpoint could be contributorRoles/contributorRoleIdentifier
just with response
["EDITOR", "CHAIR"]
Tagging @ewhanson If he has some preference on this.
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.
Just to note that the identifiers are not all but what are currently not in use
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.
@jyhein Not sure if I understand. Can you elaborate more? Thanks.
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 identifiers are enum and some of them are saved to the db with translations. That function returns the identifiers that are not in the db for the form. Identifier per context is unique in db
Contributor Roles and Type
Add contributor Roles to Author
Add contributor Type to Author
Remove user group functions from Author
Remove translator from user groups
Add possibility to add more roles than author and translator
Selected contributor type changes what contributor form fields are required
More than one contributor role can be selected in the contributor form