Managing members of a SciProject.

pull/1/head
Jens Pelzetter 2022-05-12 20:52:55 +02:00
parent 06d7839b70
commit aaaa9d8277
5 changed files with 64 additions and 17 deletions

View File

@ -130,9 +130,13 @@ public class SciProjectMananger implements Serializable {
final Optional<Membership> result = fromProject
.getMembers()
.stream()
.filter(membership -> filterMembership(membership,
person,
fromProject))
.filter(
membership -> filterMembership(
membership,
person,
fromProject
)
)
.findFirst();
if (result.isPresent()) {

View File

@ -533,8 +533,28 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
}
if (itemPermissionChecker.canEditItem(getProject())) {
final Optional<Person> result = assetRepo
.findByUuidAndType(personUuid, Person.class);
final Optional<Person> result;
final Identifier personIdentifier = identifierParser
.parseIdentifier(personUuid);
switch (personIdentifier.getType()) {
case ID:
result = assetRepo.findById(
Long.parseLong(personIdentifier.getIdentifier()),
Person.class
);
break;
case UUID:
result = assetRepo
.findByUuidAndType(
personIdentifier.getIdentifier(),
Person.class
);
break;
default:
models.put("personNotFound", personUuid);
return showStep(sectionIdentifier, documentPath);
}
if (!result.isPresent()) {
models.put("personNotFound", personUuid);
@ -565,7 +585,7 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
}
@POST
@Path("/members/edit/{membershipId")
@Path("/members/edit/{membershipId}")
@Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String editMembership(
@ -620,7 +640,7 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
}
@POST
@Path("/members/remove")
@Path("/members/remove/{membershipId}")
@Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String removeMembership(
@ -628,7 +648,7 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
final String documentPath,
@FormParam("membershipId")
@PathParam("membershipId")
final String membershipId
) {
try {
@ -778,6 +798,7 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
model.setPrefix(
membership.getMember().getPersonName().getPrefix()
);
model.setRole(membership.getRole());
model.setStatus(Objects.toString(membership.getStatus()));
model.setSuffix(
membership.getMember().getPersonName().getSuffix()

View File

@ -19,6 +19,18 @@
</div>
</c:if>
<c:if test="#{personNotFound != null}">
<div class="alert alert-warning">
#{SciProjectMessageBundle.getMessage('description_step.errors.person_not_found', [personNotFound])}
</div>
</c:if>
<c:if test="#{illegalStatusValue != null}">
<div class="alert alert-warning">
#{SciProjectMessageBundle.getMessage('description_step.errors.illegal_member_status_value', [illegalStatusValue])}
</div>
</c:if>
<template id="sciproject-contacts-sort-error-general">
<div class="alert alert-danger mt-3" role="alert">
#{SciProjectMessageBundle['contacts.sort.errors.general']}
@ -206,18 +218,19 @@
</div>
</div>
<librecms:assetPicker
actionUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@sciproject-description/description/members/add"
actionUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@sciproject-description/members/add"
assetPickerId="members-picker"
assetType="#{SciProjectDescriptionMembers.memberType}"
baseUrl="#{SciProjectDescriptionContacts.baseUrl}"
contentSection="#{ContentSectionModel.sectionName}"
formParamName="memberUuid">
dialogTitle="#{SciProjectMessageBundle['memberships.add.title']}"
formParamName="personUuid">
<bootstrap:formGroupText
help="#{SciProjectMessageBundle['memberships.role.help']}"
inputId="type"
label="#{SciProjectMessageBundle['contacts.role.label']}"
name="type"
label="#{SciProjectMessageBundle['memberships.role.label']}"
name="role"
/>
<bootstrap:formGroupSelect
@ -271,7 +284,9 @@
id="membership-edit-dialog"
tabindex="-1">
<div class="modal-dialog">
<form class="modal-content">
<form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@sciproject-description/members/edit/#{member.membershipId}"
class="modal-content"
method="post">
<div class="modal-header">
<h4 class="modal-title"
id="membership-edit-dialog-title">
@ -287,17 +302,19 @@
<div class="modal-body">
<bootstrap:formGroupText
help="#{SciProjectMessageBundle['memberships.edit.role.help']}"
inputId="type"
inputId="role"
label="#{SciProjectMessageBundle['memberships.edit.role.label']}"
name="type-edit"
name="role"
value="#{member.role}"
/>
<bootstrap:formGroupSelect
help="#{SciProjectMessageBundle['memberships.edit.status.help']}"
inputId="status"
label="#{SciProjectMessageBundle['memberships.edit.status.label']}"
name="status-edit"
name="status"
options="#{SciProjectDescriptionMembers.statusValues}"
selectedOptions="#{[member.status]}"
/>
</div>
<div class="modal-footer">
@ -337,7 +354,6 @@
<ui:define name="scripts">
<script src="#{request.contextPath}/assets/@sciproject/sciproject-contacts.js" />
<!--<script src="#{request.contextPath}/assets/@content-sections/sciproject-members.js" />-->
</ui:define>
</ui:composition>

View File

@ -178,3 +178,6 @@ contacts.order.save=Save order
contacts.sort.errors.general=Error sorting contacts.
contacts.sort.errors.save=Failed to save contacts order.
contact.add.title=Add contact
memberships.add.title=Add member
description_step.errors.person_not_found=Selected person {0} not found.
description_step.errors.illegal_member_status_value=The status value {0} is not valid.

View File

@ -178,3 +178,6 @@ contacts.order.save=Sortierung speichern
contacts.sort.errors.general=Fehler f\u00fcr Sortierung der Kontakte.
contacts.sort.errors.save=Fehler beim Speichern der Sortierung der Kontakte.
contact.add.title=Kontakt hinzuf\u00fcgen
memberships.add.title=Mitglied hinzuf\u00fcgen
description_step.errors.person_not_found=Die ausgew\u00e4hlte Person {0} wurde nicht gefunden.
description_step.errors.illegal_member_status_value=Der Status {0} wird nicht unterst\u00fctzt.