XHTML templates for some authoring steps of SciProject

pull/1/head
Jens Pelzetter 2022-04-16 17:41:17 +02:00
parent e93fcbe7a1
commit 2ba30e3e15
9 changed files with 557 additions and 14 deletions

View File

@ -2,6 +2,7 @@ package org.scientificcms.contenttypes.sciproject.ui;
import org.librecms.assets.ContactableEntity; import org.librecms.assets.ContactableEntity;
import org.scientificcms.contenttypes.sciproject.Contact; import org.scientificcms.contenttypes.sciproject.Contact;
import org.scientificcms.contenttypes.sciproject.SciProject;
/** /**
* DTO providing the information about a {@link Contact} of a {@link SciProject} * DTO providing the information about a {@link Contact} of a {@link SciProject}

View File

@ -1,5 +1,7 @@
package org.scientificcms.contenttypes.sciproject.ui; package org.scientificcms.contenttypes.sciproject.ui;
import org.librecms.assets.ContactableEntity;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -35,4 +37,7 @@ public class SciProjectDescriptionContactsModel {
this.contacts = new ArrayList<>(contacts); this.contacts = new ArrayList<>(contacts);
} }
public String getContactableType() {
return ContactableEntity.class.getName();
}
} }

View File

@ -4,9 +4,13 @@
*/ */
package org.scientificcms.contenttypes.sciproject.ui; package org.scientificcms.contenttypes.sciproject.ui;
import org.librecms.assets.Person;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
import javax.inject.Named; import javax.inject.Named;
@ -23,6 +27,8 @@ public class SciProjectDescriptionMembersModel {
private List<SciProjectMembershipModel> members; private List<SciProjectMembershipModel> members;
private Map<String, String> statusValues;
public boolean getCanEdit() { public boolean getCanEdit() {
return canEdit; return canEdit;
} }
@ -39,4 +45,15 @@ public class SciProjectDescriptionMembersModel {
this.canEdit = canEdit; this.canEdit = canEdit;
} }
public String getMemberType() {
return Person.class.getName();
}
public Map<String, String> getStatusValues() {
return Collections.unmodifiableMap(statusValues);
}
protected void setStatusValues(final Map<String, String> statusValues) {
this.statusValues = new LinkedHashMap<>(statusValues);
}
} }

View File

@ -19,8 +19,8 @@
package org.scientificcms.contenttypes.sciproject.ui; package org.scientificcms.contenttypes.sciproject.ui;
import org.libreccm.l10n.GlobalizationHelper; import org.libreccm.l10n.GlobalizationHelper;
import org.libreccm.security.AuthorizationRequired;
import org.librecms.assets.ContactableEntity; import org.librecms.assets.ContactableEntity;
import org.librecms.assets.ContactableEntityRepository;
import org.librecms.assets.Person; import org.librecms.assets.Person;
import org.librecms.contentsection.AssetRepository; import org.librecms.contentsection.AssetRepository;
import org.librecms.contentsection.ContentItemRepository; import org.librecms.contentsection.ContentItemRepository;
@ -33,11 +33,15 @@ import org.librecms.ui.contentsections.documents.DocumentUi;
import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef; import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef;
import org.librecms.ui.contentsections.documents.MvcAuthoringSteps; import org.librecms.ui.contentsections.documents.MvcAuthoringSteps;
import org.scientificcms.contenttypes.sciproject.Contact; import org.scientificcms.contenttypes.sciproject.Contact;
import org.scientificcms.contenttypes.sciproject.ContactRepository;
import org.scientificcms.contenttypes.sciproject.Membership; import org.scientificcms.contenttypes.sciproject.Membership;
import org.scientificcms.contenttypes.sciproject.MembershipRepository;
import org.scientificcms.contenttypes.sciproject.MembershipStatus; import org.scientificcms.contenttypes.sciproject.MembershipStatus;
import org.scientificcms.contenttypes.sciproject.SciProject; import org.scientificcms.contenttypes.sciproject.SciProject;
import org.scientificcms.contenttypes.sciproject.SciProjectMananger; import org.scientificcms.contenttypes.sciproject.SciProjectMananger;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@ -80,6 +84,9 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
@Inject @Inject
private ContentItemRepository itemRepo; private ContentItemRepository itemRepo;
@Inject
private ContactRepository contactRepo;
@Inject @Inject
private DocumentUi documentUi; private DocumentUi documentUi;
@ -89,6 +96,9 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
@Inject @Inject
private ItemPermissionChecker itemPermissionChecker; private ItemPermissionChecker itemPermissionChecker;
@Inject
private MembershipRepository membershipRepo;
@Inject @Inject
private Models models; private Models models;
@ -104,6 +114,9 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
@Inject @Inject
private SciProjectDescriptionMembersModel membersModel; private SciProjectDescriptionMembersModel membersModel;
@Inject
private SciProjectMessageBundle messageBundle;
@Override @Override
public Class<SciProjectDescriptionStep> getStepClass() { public Class<SciProjectDescriptionStep> getStepClass() {
return SciProjectDescriptionStep.class; return SciProjectDescriptionStep.class;
@ -112,6 +125,7 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
@GET @GET
@Path("/") @Path("/")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String showStep( public String showStep(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@ -140,6 +154,7 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
@GET @GET
@Path("/description/view/{locale}") @Path("/description/view/{locale}")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String viewDescription( public String viewDescription(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@ -172,6 +187,7 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
@POST @POST
@Path("/description/add") @Path("/description/add")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String addDescriptionValue( public String addDescriptionValue(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@ -214,6 +230,7 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
@GET @GET
@Path("/description/edit/{locale}") @Path("/description/edit/{locale}")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String editDescriptionValue( public String editDescriptionValue(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@ -247,6 +264,7 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
@POST @POST
@Path("/description/edit/{locale}") @Path("/description/edit/{locale}")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String editDescriptionValue( public String editDescriptionValue(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@ -281,6 +299,7 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
@POST @POST
@Path("/description/remove/{locale}") @Path("/description/remove/{locale}")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String removeDescriptionValue( public String removeDescriptionValue(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@ -314,6 +333,7 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
@POST @POST
@Path("/contacts/add") @Path("/contacts/add")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String addContact( public String addContact(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@ -354,9 +374,62 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
} }
} }
@POST
@Path("/contacts/edit/{contactId}")
@Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String editContact(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
final String documentPath,
@PathParam("contactId")
final String contactId,
@FormParam("type")
final String type
) {
try {
init();
} catch (ContentSectionNotFoundException ex) {
return ex.showErrorMessage();
} catch (DocumentNotFoundException ex) {
return ex.showErrorMessage();
}
if (itemPermissionChecker.canEditItem(getProject())) {
final Optional<Contact> result = getProject()
.getContacts()
.stream()
.filter(
contact -> Long
.toString(contact.getContactId())
.equals(contactId)
)
.findFirst();
if (!result.isPresent()) {
models.put("contactNotFound", contactId);
return showStep(sectionIdentifier, documentPath);
}
final Contact contact = result.get();
contact.setContactType(type);
contactRepo.save(contact);
return buildRedirectPathForStep();
} else {
return documentUi.showAccessDenied(
getContentSection(),
getProject(),
sciProjectMessageBundle.getMessage("event.edit.denied")
);
}
}
@POST @POST
@Path("/contacts/remove") @Path("/contacts/remove")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String removeContact( public String removeContact(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@ -404,7 +477,8 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
@POST @POST
@Path("/members/add") @Path("/members/add")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
public String addMember( @AuthorizationRequired
public String addMembership(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
@ -456,10 +530,66 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
} }
} }
@POST
@Path("/members/edit/{membershipId")
@Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String editMembership(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
final String documentPath,
@PathParam("membershipId")
final String membershipId,
@FormParam("role")
final String role,
@FormParam("status")
final String statusParam
) {
try {
init();
} catch (ContentSectionNotFoundException ex) {
return ex.showErrorMessage();
} catch (DocumentNotFoundException ex) {
return ex.showErrorMessage();
}
if (itemPermissionChecker.canEditItem(getProject())) {
final Optional<Membership> result = getProject()
.getMembers()
.stream()
.filter(
member -> Long
.toString(member.getMembershipId())
.equals(membershipId)
)
.findFirst();
if (!result.isPresent()) {
models.put("membershipNotFound", membershipId);
return showStep(sectionIdentifier, documentPath);
}
final Membership membership = result.get();
membership.setRole(role);
membership.setStatus(MembershipStatus.valueOf(statusParam));
membershipRepo.save(membership);
return buildRedirectPathForStep();
} else {
return documentUi.showAccessDenied(
getContentSection(),
getProject(),
sciProjectMessageBundle.getMessage("event.edit.denied")
);
}
}
@POST @POST
@Path("/members/remove") @Path("/members/remove")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
public String removeMember( @AuthorizationRequired
public String removeMembership(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
@ -562,6 +692,23 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
.map(this::buildMembershipModel) .map(this::buildMembershipModel)
.collect(Collectors.toList()) .collect(Collectors.toList())
); );
membersModel.setStatusValues(
Arrays
.stream(MembershipStatus.values())
.collect(
Collectors.toMap(
status -> status.toString(),
status -> messageBundle.getMessage(
String.format(
"members.status.%s",
status.toString().toLowerCase()
)
),
(value1, value2) -> value1,
LinkedHashMap::new
)
)
);
} }
} }

View File

@ -1,6 +1,7 @@
package org.scientificcms.contenttypes.sciproject.ui; package org.scientificcms.contenttypes.sciproject.ui;
import org.libreccm.l10n.GlobalizationHelper; import org.libreccm.l10n.GlobalizationHelper;
import org.libreccm.security.AuthorizationRequired;
import org.librecms.assets.Organization; import org.librecms.assets.Organization;
import org.librecms.contentsection.AssetRepository; import org.librecms.contentsection.AssetRepository;
import org.librecms.contentsection.ContentItemRepository; import org.librecms.contentsection.ContentItemRepository;
@ -15,6 +16,7 @@ import org.librecms.ui.contentsections.documents.MvcAuthoringSteps;
import org.scientificcms.contenttypes.sciproject.SciProject; import org.scientificcms.contenttypes.sciproject.SciProject;
import org.scientificcms.contenttypes.sciproject.SciProjectMananger; import org.scientificcms.contenttypes.sciproject.SciProjectMananger;
import org.scientificcms.contenttypes.sciproject.Sponsoring; import org.scientificcms.contenttypes.sciproject.Sponsoring;
import org.scientificcms.contenttypes.sciproject.SponsoringRepository;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
@ -81,6 +83,9 @@ public class SciProjectFundingStep extends AbstractMvcAuthoringStep {
@Inject @Inject
private SciProjectFundingSponsoringModel sponsoringModel; private SciProjectFundingSponsoringModel sponsoringModel;
@Inject
private SponsoringRepository sponsoringRepo;
@Override @Override
public Class<SciProjectFundingStep> getStepClass() { public Class<SciProjectFundingStep> getStepClass() {
return SciProjectFundingStep.class; return SciProjectFundingStep.class;
@ -89,6 +94,7 @@ public class SciProjectFundingStep extends AbstractMvcAuthoringStep {
@GET @GET
@Path("/") @Path("/")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String showStep( public String showStep(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@ -117,6 +123,7 @@ public class SciProjectFundingStep extends AbstractMvcAuthoringStep {
@GET @GET
@Path("/funding-text/view/{locale}") @Path("/funding-text/view/{locale}")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String viewFundingText( public String viewFundingText(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@ -150,6 +157,7 @@ public class SciProjectFundingStep extends AbstractMvcAuthoringStep {
@POST @POST
@Path("/funding-text/add") @Path("/funding-text/add")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String addFundingTextValue( public String addFundingTextValue(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@ -191,6 +199,7 @@ public class SciProjectFundingStep extends AbstractMvcAuthoringStep {
@GET @GET
@Path("/funding-text/edit") @Path("/funding-text/edit")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String editFundingTextValue( public String editFundingTextValue(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@ -224,6 +233,7 @@ public class SciProjectFundingStep extends AbstractMvcAuthoringStep {
@POST @POST
@Path("/funding-text/edit/{locale}") @Path("/funding-text/edit/{locale}")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String editFundingTextValue( public String editFundingTextValue(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@ -258,6 +268,7 @@ public class SciProjectFundingStep extends AbstractMvcAuthoringStep {
@POST @POST
@Path("/funding-text/remove/{locale}") @Path("/funding-text/remove/{locale}")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String removeFundingTextValue( public String removeFundingTextValue(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@ -291,6 +302,7 @@ public class SciProjectFundingStep extends AbstractMvcAuthoringStep {
@GET @GET
@Path("/funding-volume/view/{locale}") @Path("/funding-volume/view/{locale}")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String viewFundingVolume( public String viewFundingVolume(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@ -324,6 +336,7 @@ public class SciProjectFundingStep extends AbstractMvcAuthoringStep {
@POST @POST
@Path("/funding-volume/add") @Path("/funding-volume/add")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String addFundingVolumeValue( public String addFundingVolumeValue(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@ -365,6 +378,7 @@ public class SciProjectFundingStep extends AbstractMvcAuthoringStep {
@GET @GET
@Path("/funding-volume/edit") @Path("/funding-volume/edit")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String editFundingVolumeValue( public String editFundingVolumeValue(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@ -398,6 +412,7 @@ public class SciProjectFundingStep extends AbstractMvcAuthoringStep {
@POST @POST
@Path("/funding-volume/edit/{locale}") @Path("/funding-volume/edit/{locale}")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String editFundingVolumeValue( public String editFundingVolumeValue(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@ -432,6 +447,7 @@ public class SciProjectFundingStep extends AbstractMvcAuthoringStep {
@POST @POST
@Path("/funding-volume/remove/{locale}") @Path("/funding-volume/remove/{locale}")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String removeFundingVolumeValue( public String removeFundingVolumeValue(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@ -465,7 +481,7 @@ public class SciProjectFundingStep extends AbstractMvcAuthoringStep {
@POST @POST
@Path("/sponsoring/add") @Path("/sponsoring/add")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
public String addSponsoring( public String addSponsoringing(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
@ -505,10 +521,62 @@ public class SciProjectFundingStep extends AbstractMvcAuthoringStep {
} }
} }
@POST
@Path("/sponsoring/edit/{sponsoringId}")
@Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String editSponsoring(
final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
final String documentPath,
@PathParam("sponsoringId")
final String sponsoringId,
@FormParam("fundingCode")
final String fundingCode
) {
try {
init();
} catch (ContentSectionNotFoundException ex) {
return ex.showErrorMessage();
} catch (DocumentNotFoundException ex) {
return ex.showErrorMessage();
}
if (itemPermissionChecker.canEditItem(getProject())) {
final Optional<Sponsoring> result = getProject()
.getSponsoring()
.stream()
.filter(
sponsoring -> Long
.toString(sponsoring.getSponsoringId())
.equals(sponsoringId)
)
.findFirst();
if (!result.isPresent()) {
models.put("sponsoringNotFound", sponsoringId);
return showStep(sectionIdentifier, documentPath);
}
final Sponsoring sponsoring = result.get();
sponsoring.setFundingCode(fundingCode);
sponsoringRepo.save(sponsoring);
return buildRedirectPathForStep();
} else {
return documentUi.showAccessDenied(
getContentSection(),
getProject(),
sciProjectMessageBundle.getMessage("event.edit.denied")
);
}
}
@POST @POST
@Path("/sponsoring/remove") @Path("/sponsoring/remove")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
public String removeSponsor( @AuthorizationRequired
public String removeSponsoring(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)

View File

@ -26,7 +26,7 @@ public class SciProjectMembershipModel {
private String role; private String role;
/** /**
* The status of teh membership. * The status of the membership.
* *
* @see Membership#status * @see Membership#status
*/ */
@ -84,6 +84,30 @@ public class SciProjectMembershipModel {
this.status = status; this.status = status;
} }
public String getName() {
final StringBuilder builder = new StringBuilder();
if (prefix != null && !prefix.isBlank()) {
builder.append(prefix);
builder.append(" ");
}
if (surname != null && !surname.isBlank()) {
builder.append(surname);
}
if (surname != null
&& !surname.isBlank()
&& givenName != null
&& !givenName.isBlank()) {
builder.append(", ");
}
if (givenName != null && !givenName.isBlank()) {
builder.append(givenName);
}
if (suffix != null && !suffix.isBlank()) {
builder.append(" ");
builder.append(suffix);
}
}
public String getGivenName() { public String getGivenName() {
return givenName; return givenName;
} }

View File

@ -461,6 +461,7 @@ public class SciProjectPropertiesStep extends AbstractMvcAuthoringStep {
@POST @POST
@Path("/short-description/@add") @Path("/short-description/@add")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String addShortDescription( public String addShortDescription(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@ -507,6 +508,7 @@ public class SciProjectPropertiesStep extends AbstractMvcAuthoringStep {
@POST @POST
@Path("/short-description/{locale}") @Path("/short-description/{locale}")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String editShortDescription( public String editShortDescription(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@ -549,6 +551,10 @@ public class SciProjectPropertiesStep extends AbstractMvcAuthoringStep {
* *
* @return A redirect to this authoring step. * @return A redirect to this authoring step.
*/ */
@POST
@Path("/short-description/remove/{locale}")
@Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public String removeShortDescription( public String removeShortDescription(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,

View File

@ -0,0 +1,280 @@
<!DOCTYPE html [<!ENTITY times '&#215;'>]>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:bootstrap="http://xmlns.jcp.org/jsf/composite/components/bootstrap"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:librecms="http://xmlns.jcp.org/jsf/composite/components/librecms"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition template="/WEB-INF/views/org/librecms/ui/contentsection/documents/authoringstep.xhtml">
<ui:param name="authoringStep"
value="/libreccm/@contentsections/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/sciproject-description" />
<ui:define name="authoringStep">
<h2>#{SciProjectMessageBundle['description_step.header']}</h2>
<librecms:cmsEditorVariants
addButtonLabel="#{SciProjectMessageBundle['description.editor.add_variant']}"
addDialogLocaleSelectHelp="#{SciProjectMessageBundle['description.editor.add.locale.help']}"
addMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@sciproject-description/description/add"
canEdit="#{SciProjectDescriptionModel.canEdit}"
editorPageUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@sciproject-description/description/edit"
hasUnusedLocales="#{!SciProjectDescriptionModel.unusedLocales.isEmpty()}"
headingLevel="3"
removeMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@sciproject-description/description/remove"
sourceEditorPageUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/docuements/#{CmsSelectedDocumentModel.itemPath}/@sciproject-description/description/edit-source"
title="#{SciProjectMessageBundle['description.editor.header']}"
unusedLocales="#{SciProjectDescriptionModel.unusedLocales}"
variants="#{SciProjectDescriptionModel.variants}"
variantsId="description"
viewPageUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@sciproject-description/description/view"
/>
<h3>#{SciProjectMessageBundle['contacts.header']}</h3>
<div class="mb-2">
<div class="text-right">
<librecms:assetPickerButton
assetPickerId="contacts-picker"
buttonIcon="plus-circle"
buttonText="#{SciProjectMessageBundle['contacts.add_button.label']}"
/>
</div>
</div>
<librecms:assetPicker
actionUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@sciproject-description/contacts/add"
assetType="#{SciProjectDescriptionContacts.contactableType}"
assetPickerId="contacts-picker"
baseUrl="#{SciProjectDescriptionContacts.baseUrl}"
contentSection="#{ContentSectionModel.sectionName}"
formParamName="contactableUuid">
<bootstrap:formGroupText
help="#{SciProjectMessageBundle['contacts.type.help']}"
inputId="type"
label="#{SciProjectMessageBundle['contacts.type.label']}"
name="type"
/>
</librecms:assetPicker>
<table>
<thead>
<tr>
<th scope="col">#{SciProjectMessageBundle['contacts.cols.contactable']}</th>
<th scope="col">#{SciProjectMessageBundle['contacts.cols.type']}</th>
<th colspan="2"
scope="col"
>#{SciProjectMessageBundle['contacts.cols.actions']}</th>
</tr>
</thead>
<c:forEach items="#{SciProjectDescriptionContacts.contacts}"
var="contact">
<tr id="#{contact.contactId}">
<td>#{contact.contactable}</td>
<td>#{contact.contactType}</td>
<td>
<button class="btn btn-secondary"
data-toggle="modal"
data-target="#contact-edit-dialog"
type="button">
<bootstrap:svgIcon icon="pen" />
<span>#{SciProjectMessageBundle['contacts.edit.label']}</span>
</button>
<div aria-hidden="true"
aria-labelledby="contact-edit-dialog-title"
class="modal fade"
id="contact-edit-dialog"
tabindex="-1">
<div class="modal-dialog">
<form class="modal-content">
<div class="modal-header">
<h4 class="modal-title"
id="contact-edit-dialog-title">
#{SciProjectMessageBundle['contacts.edit.title']}
</h4>
<button
aria-label="#{SciProjectMessageBundle['contacts.edit.cancel']}"
class="close"
data-dismiss="modal"
type="button">
<bootstrap:svgIcon icon="x"/>
</button>
</div>
<div class="modal-body">
<bootstrap:formGroupText
help="#{SciProjectMessageBundle['contacts.edit.type.help']}"
inputId="type-edit"
label="#{SciProjectMessageBundle['contacts.edit.type.label']}"
name="type"
/>
</div>
<div class="modal-footer">
<button class="btn btn-warning"
data-dismiss="modal"
type="button">
#{SciProjectMessageBundle['contacts.edit.cancel']}
</button>
<button class="btn btn-success"
type="submit">
#{SciProjectMessageBundle['contacts.edit.submit']}
</button>
</div>
</form>
</div>
</div>
</td>
<td>
<libreccm:deleteDialog
actionTarget="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@sciproject-description/contacts/remove/#{contact.contactId}"
buttonText="#{SciProjectMessageBundle['contacts.delete.label']}"
cancelLabel="#{SciProjectMessageBundle['contacts.delete.cancel']}"
confirmLabel="#{SciProjectMessageBundle['contacts.delete.confirm']}"
dialogId="contact-delete-dialog"
dialogTitle="#{SciProjectMessageBundle['contacts.delete.title']}"
message="#{SciProjectMessageBundle['contacts.delete.message']}"
/>
</td>
</tr>
</c:forEach>
</table>
<h3>#{SciProjectMessageBundle['memberships.header']}</h3>
<div class="mb-2">
<div class="text-right">
<librecms:assetPickerButton
assetPickerId="contacts-picker"
buttonIcon="plus-circle"
buttonText="#{SciProjectMessageBundle['memberships.add_button.label']}"
/>
</div>
</div>
<librecms:assetPicker
actionUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@sciproject-description/description/members/add"
assetPickerId="members-picker"
assetType="#{SciProjectDescriptionMembers.memberType}"
baseUrl="#{SciProjectDescriptionContacts.baseUrl}"
contentSection="#{ContentSectionModel.sectionName}"
formParamName="memberUuid">
<bootstrap:formGroupText
help="#{SciProjectMessageBundle['memberships.role.help']}"
inputId="type"
label="#{SciProjectMessageBundle['contacts.role.label']}"
name="type"
/>
<bootstrap:formGroupSelect
help="#{SciProjectMessageBundle['memberships.status.help']}"
inputId="status"
label="#{SciProjectMessageBundle['memberships.status.label']}"
name="status"
options="#{SciProjectDescriptionMembers.statusValues}"
/>
</librecms:assetPicker>
<table>
<thead>
<tr>
<th scope="col">#{SciProjectMessageBundle['memberships.cols.name']}</th>
<th scope="col">#{SciProjectMessageBundle['memberships.cols.role']}</th>
<th scope="col">#{SciProjectMessageBundle['memberships.cols.status']}</th>
<th colspan="2"
scope="col">#{SciProjectMessageBundle['memberships.cols.actions']}</th>
</tr>
</thead>
<tbody>
<c:forEach items="#{SciProjectDescriptionMembers.members}"
var="member">
<tr>
<td>
#{member.name}
</td>
<td>
#{member.role}
</td>
<td>
#{member.status}
</td>
<td>
<button class="btn btn-secondary"
data-toggle="modal"
data-target="#membership-edit-dialog"
type="button">
<bootstrap:svgIcon icon="pen"/>
<span class="sr-only">#{SciProjectMessageBundle['memberships.edit.label']}</span>
</button>
<div aria-hidden="true"
aria-labelledby="membership-edit-dialog-title"
class="modal fade"
id="membership-edit-dialog"
tabindex="-1">
<div class="modal-dialog">
<form class="modal-content">
<div class="modal-header">
<h4 class="modal-title"
id="membership-edit-dialog-title">
</h4>
<button
aria-label="#{SciProjectMessageBundle['memberships.edit.cancel']}"
class="close"
data-dismiss="modal"
type="button">
<bootstrap:svgIcon icon="x"/>
</button>
</div>
<div class="modal-body">
<bootstrap:formGroupText
help="#{SciProjectMessageBundle['memberships.edit.role.help']}"
inputId="type"
label="#{SciProjectMessageBundle['contacts.edit.role.label']}"
name="type-edit"
/>
<bootstrap:formGroupSelect
help="#{SciProjectMessageBundle['memberships.edit.status.help']}"
inputId="status"
label="#{SciProjectMessageBundle['memberships.edit.status.label']}"
name="status-edit"
options="#{SciProjectDescriptionMembers.statusValues}"
/>
</div>
<div class="modal-footer">
<button class="btn btn-warning"
data-dismiss="modal"
type="button">
#{SciProjectMessageBundle['contacts.edit.cancel']}
</button>
<button class="btn btn-success"
type="submit">
#{SciProjectMessageBundle['contacts.edit.submit']}
</button>
</div>
</form>
</div>
</div>
</td>
<td>
<libreccm:deleteDialog
actionTarget="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@sciproject-description/members/remove/#{member.membershipId}"
buttonText="#{SciProjectMessageBundle['memberships.delete.label']}"
cancelLabel="#{SciProjectMessageBundle['memberships.delete.cancel']}"
confirmLabel="#{SciProjectMessageBundle['memberships.delete.confirm']}"
dialogId="membership-delete-dialog"
dialogTitle="#{SciProjectMessageBundle['memberships.delete.title']}"
message="#{SciProjectMessageBundle['memberships.delete.message']}"
/>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</ui:define>
</ui:composition>
</html>

View File

@ -39,11 +39,6 @@
<version>${project.parent.version}</version> <version>${project.parent.version}</version>
</dependency> </dependency>
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId>
</dependency>
<!-- CCM modules --> <!-- CCM modules -->
<dependency> <dependency>
<groupId>org.libreccm</groupId> <groupId>org.libreccm</groupId>