Skip to content

Conversation

jyhein
Copy link
Contributor

@jyhein jyhein commented Sep 1, 2025

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

Copy link
Contributor

@bozana bozana left a 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);
Copy link
Contributor

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... 🤔

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'),
Copy link
Contributor

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)

/**
* Get organization name.
*/
public function getOrganizationName(string $locale): string|array|null
Copy link
Contributor

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.

*
* @return string
*/
public function getLocalizedOrganizationName(string $preferredLocale = null)
Copy link
Contributor

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
?

}

Repo::creditContributorRole()->addCreditRoles($author->getCreditRoles(), $newAuthorId);
Repo::creditContributorRole()->addCreditRoles($author->getCreditRoles(false), $newAuthorId);
Copy link
Contributor

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

"readOnly": true,
"items": {
"type": "object",
"multilingual": "true"
Copy link
Contributor

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",
Copy link
Contributor

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);
Copy link
Contributor

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?

{
$this->setData('contributorRoles', !$contextId
? $contributorRoles
: Repo::contributorRole()->getByContextIdAndIdentifiers($contextId, $contributorRoles)
Copy link
Contributor

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.


foreach ($authors as $author) {
if (empty($author->getGivenName($newLocale))) {
if (ContributorType::PERSON->getName() && empty($author->getGivenName($newLocale))) {
Copy link
Contributor

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?

/**
* Get form data
*/
public function getContributorRoleFormData(Request $illuminateRequest): JsonResponse
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants