From dfcfd4edfbb3ff1523942f06d828fe57c63d449b Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Fri, 24 Dec 2021 12:56:29 +0100 Subject: [PATCH 1/9] Fixed a typo --- .../cms/contenttypes/ui/ProfileSiteItemController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ccm-cms-profile/src/main/java/com/arsdigita/cms/contenttypes/ui/ProfileSiteItemController.java b/ccm-cms-profile/src/main/java/com/arsdigita/cms/contenttypes/ui/ProfileSiteItemController.java index 68594ef3a..6d4ed905e 100644 --- a/ccm-cms-profile/src/main/java/com/arsdigita/cms/contenttypes/ui/ProfileSiteItemController.java +++ b/ccm-cms-profile/src/main/java/com/arsdigita/cms/contenttypes/ui/ProfileSiteItemController.java @@ -90,7 +90,7 @@ class ProfileSiteItemController { ) ) ); - profileSiteItem.getPosition().addValue(locale, position); + profileSiteItem.getPosition().putValue(locale, position); } public void setInterests( @@ -108,7 +108,7 @@ class ProfileSiteItemController { ) ) ); - profileSiteItem.getInterests().addValue(locale, interests); + profileSiteItem.getInterests().putValue(locale, interests); } public void setMisc( @@ -124,7 +124,7 @@ class ProfileSiteItemController { ) ) ); - profileSiteItem.getMisc().addValue(locale, misc); + profileSiteItem.getMisc().putValue(locale, misc); } } -- 2.52.0 From b210d8fcdd201e4d001df0d0ff2c11938441b7b3 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Mon, 31 Jan 2022 20:26:22 +0100 Subject: [PATCH 2/9] First of authoring steps for Event. --- .../java/org/librecms/contenttypes/Event.java | 2 +- .../article/MvcArticleCreateStep.java | 4 +- .../event/EventMessageBundle.java | 41 ++ .../event/EventStepsConstants.java | 35 + .../event/MvcEventCreateStep.java | 285 +++++++++ .../event/MvcEventPropertiesStep.java | 605 ++++++++++++++++++ .../event/MvcEventPropertiesStepModel.java | 124 ++++ 7 files changed, 1092 insertions(+), 4 deletions(-) create mode 100644 ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/EventMessageBundle.java create mode 100644 ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/EventStepsConstants.java create mode 100644 ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventCreateStep.java create mode 100644 ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventPropertiesStep.java create mode 100644 ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventPropertiesStepModel.java diff --git a/ccm-cms/src/main/java/org/librecms/contenttypes/Event.java b/ccm-cms/src/main/java/org/librecms/contenttypes/Event.java index e46bbb35c..29cd4e43e 100644 --- a/ccm-cms/src/main/java/org/librecms/contenttypes/Event.java +++ b/ccm-cms/src/main/java/org/librecms/contenttypes/Event.java @@ -45,7 +45,7 @@ import org.librecms.contentsection.ContentItem; import javax.validation.constraints.NotNull; -import static org.librecms.CmsConstants.*; +import static org.librecms.CmsConstants.DB_SCHEMA; /** * @author Alexander Konermann diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/article/MvcArticleCreateStep.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/article/MvcArticleCreateStep.java index 5ea200093..7da8e5e72 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/article/MvcArticleCreateStep.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/article/MvcArticleCreateStep.java @@ -35,7 +35,6 @@ import javax.enterprise.context.RequestScoped; import javax.inject.Named; import javax.inject.Inject; -import javax.mvc.Models; import javax.transaction.Transactional; /** @@ -56,8 +55,7 @@ public class MvcArticleCreateStep private static final String FORM_PARAM_INITIAL_LOCALE = "locale"; - private static final String FORM_PARAM_SELECTED_WORKFLOW - = "workflow"; + private static final String FORM_PARAM_SELECTED_WORKFLOW = "workflow"; /** * Provides functions for working with content items. diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/EventMessageBundle.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/EventMessageBundle.java new file mode 100644 index 000000000..839206a43 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/EventMessageBundle.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2022 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.librecms.ui.contenttypes.event; + +import org.libreccm.ui.AbstractMessagesBean; +import org.librecms.contenttypes.Event; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Named; + +/** + * Message bundle for the authorings steps for editing an {@link Event}. + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("CmsEventMessageBundle") +public class EventMessageBundle extends AbstractMessagesBean { + + @Override + public String getMessageBundle() { + return EventStepsConstants.BUNDLE; + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/EventStepsConstants.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/EventStepsConstants.java new file mode 100644 index 000000000..b9e3d049f --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/EventStepsConstants.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2022 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.librecms.ui.contenttypes.event; + +/** + * Constants for the authoring steps for editing an {@link Event}. + * + * @author Jens Pelzetter + */ +public final class EventStepsConstants { + + private EventStepsConstants() { + // Nothing + } + + public static final String BUNDLE + = "org.librecms.ui.contenttypes.EventBundle"; + +} diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventCreateStep.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventCreateStep.java new file mode 100644 index 000000000..83a137b70 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventCreateStep.java @@ -0,0 +1,285 @@ +/* + * Copyright (C) 2022 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.librecms.ui.contenttypes.event; + +import org.libreccm.l10n.GlobalizationHelper; +import org.libreccm.security.AuthorizationRequired; +import org.libreccm.workflow.Workflow; +import org.librecms.contentsection.ContentItemManager; +import org.librecms.contentsection.ContentItemRepository; +import org.librecms.contenttypes.Event; +import org.librecms.ui.contentsections.documents.AbstractMvcDocumentCreateStep; + +import java.util.Locale; +import java.util.Map; +import java.util.Optional; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.inject.Named; +import javax.transaction.Transactional; + +/** + * Describes the create step for an {@link Event} + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("CmsEventCreateStep") +public class MvcEventCreateStep + extends AbstractMvcDocumentCreateStep { + + private static final String FORM_PARAM_NAME = "name"; + + private static final String FORM_PARAM_TITLE = "title"; + + private static final String FORM_PARAM_SUMMARY = "summary"; + + private static final String FORM_PARAM_INITIAL_LOCALE = "locale"; + + private static final String FORM_PARAM_SELECTED_WORKFLOW = "workflow"; + + /** + * Provides functions for working with content items. + */ + @Inject + private ContentItemManager itemManager; + + /** + * Used to save the event. + */ + @Inject + private ContentItemRepository itemRepo; + + /** + * Provides functions for working with {@link LocalizedString}s. + */ + @Inject + private GlobalizationHelper globalizationHelper; + + /** + * Name of the event. + */ + private String name; + + /** + * Title of the event. + */ + private String title; + + /** + * Summary of the event. + */ + private String summary; + + /** + * The initial locale of the event. + */ + private String initialLocale; + + /** + * The workflow to use for the new event. + */ + private String selectedWorkflow; + + @Override + public String getDocumentType() { + return Event.class.getName(); + } + + @Override + public String getDescription() { + return globalizationHelper + .getLocalizedTextsUtil(getBundle()) + .getText("createstep.description"); + } + + @Override + public String getBundle() { + return EventStepsConstants.BUNDLE; + } + + public String getName() { + return name; + } + + public String getTitle() { + return title; + } + + public String getSummary() { + return summary; + } + + public String getInitialLocale() { + return initialLocale; + } + + @Transactional(Transactional.TxType.REQUIRED) + public String getSelectedWorkflow() { + if (selectedWorkflow == null || selectedWorkflow.isEmpty()) { + return getContentSection() + .getContentTypes() + .stream() + .filter( + type -> type.getContentItemClass().equals( + Event.class.getName() + ) + ) + .findAny() + .map(type -> type.getDefaultWorkflow()) + .map( + workflow -> globalizationHelper.getValueFromLocalizedString( + workflow.getName() + ) + ) + .orElse(""); + } else { + return selectedWorkflow; + } + } + + @Override + public String showCreateStep() { + return "org/librecms/ui/contenttypes/event/create-event.xhtml"; + } + + @AuthorizationRequired + @Transactional(Transactional.TxType.REQUIRED) + @Override + public String createItem(final Map formParams) { + if (!formParams.containsKey(FORM_PARAM_NAME) + || formParams.get(FORM_PARAM_NAME) == null + || formParams.get(FORM_PARAM_NAME).length == 0) { + addMessage( + "danger", + globalizationHelper + .getLocalizedTextsUtil(getBundle()) + .getText("createstep.name.error.missing") + ); + return showCreateStep(); + } + + name = formParams.get(FORM_PARAM_NAME)[0]; + if (!name.matches("^([a-zA-Z0-9_-]*)$")) { + addMessage( + "danger", + globalizationHelper + .getLocalizedTextsUtil(getBundle()) + .getText("createstep.name.error.invalid") + ); + return showCreateStep(); + } + + if (!formParams.containsKey(FORM_PARAM_TITLE) + || formParams.get(FORM_PARAM_TITLE) == null + || formParams.get(FORM_PARAM_TITLE).length == 0) { + addMessage( + "danger", + globalizationHelper + .getLocalizedTextsUtil(getBundle()) + .getText("createstep.title.error.missing") + ); + return showCreateStep(); + } + title = formParams.get(FORM_PARAM_TITLE)[0]; + + if (!formParams.containsKey(FORM_PARAM_SUMMARY) + || formParams.get(FORM_PARAM_SUMMARY) == null + || formParams.get(FORM_PARAM_SUMMARY).length == 0) { + addMessage( + "danger", + globalizationHelper + .getLocalizedTextsUtil(getBundle()) + .getText("createstep.summary.error.missing") + ); + return showCreateStep(); + } + summary = formParams.get(FORM_PARAM_SUMMARY)[0]; + + if (!formParams.containsKey(FORM_PARAM_INITIAL_LOCALE) + || formParams.get(FORM_PARAM_INITIAL_LOCALE) == null + || formParams.get(FORM_PARAM_INITIAL_LOCALE).length == 0) { + addMessage( + "danger", + globalizationHelper.getLocalizedTextsUtil( + getBundle() + ).getText("createstep.initial_locale.error.missing") + ); + return showCreateStep(); + } + final Locale locale = new Locale( + formParams.get(FORM_PARAM_INITIAL_LOCALE)[0] + ); + + if (!formParams.containsKey(FORM_PARAM_SELECTED_WORKFLOW) + || formParams.get(FORM_PARAM_SELECTED_WORKFLOW) == null + || formParams.get(FORM_PARAM_SELECTED_WORKFLOW).length == 0) { + addMessage( + "danger", + globalizationHelper.getLocalizedTextsUtil( + getBundle() + ).getText("createstep.workflow.none_selected") + ); + return showCreateStep(); + } + selectedWorkflow = formParams.get(FORM_PARAM_SELECTED_WORKFLOW)[0]; + + final Optional workflowResult = getContentSection() + .getWorkflowTemplates() + .stream() + .filter(template -> template.getUuid().equals(selectedWorkflow)) + .findAny(); + + if (!workflowResult.isPresent()) { + addMessage( + "danger", + globalizationHelper.getLocalizedTextsUtil( + getBundle() + ).getText("createstep.workflow.error.not_available") + ); + return showCreateStep(); + } + + if (!getMessages().isEmpty()) { + return showCreateStep(); + } + + final Event event = itemManager.createContentItem( + name, + getContentSection(), + getFolder(), + workflowResult.get(), + Event.class, + locale + ); + + event.getTitle().putValue(locale, title); + event.getDescription().putValue(locale, summary); + itemRepo.save(event); + + return String.format( + "redirect:/%s/documents/%s/%s/@event-basicproperties", + getContentSectionLabel(), + getFolderPath(), + name + ); + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventPropertiesStep.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventPropertiesStep.java new file mode 100644 index 000000000..2cf4d5bc4 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventPropertiesStep.java @@ -0,0 +1,605 @@ +/* + * Copyright (C) 2022 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.librecms.ui.contenttypes.event; + +import org.libreccm.l10n.GlobalizationHelper; +import org.libreccm.security.AuthorizationRequired; +import org.librecms.contentsection.ContentItemManager; +import org.librecms.contentsection.ContentItemRepository; +import org.librecms.contentsection.FolderManager; +import org.librecms.contenttypes.Event; +import org.librecms.ui.contentsections.ContentSectionNotFoundException; +import org.librecms.ui.contentsections.ItemPermissionChecker; +import org.librecms.ui.contentsections.documents.AbstractMvcAuthoringStep; +import org.librecms.ui.contentsections.documents.DocumentNotFoundException; +import org.librecms.ui.contentsections.documents.DocumentUi; +import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef; +import org.librecms.ui.contentsections.documents.MvcAuthoringSteps; + +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.Locale; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.mvc.Controller; +import javax.mvc.Models; +import javax.transaction.Transactional; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.FormParam; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; + +/** + * Authoring step for editing the basic properties of an {@link Event}. + * + * @author Jens Pelzetter + */ +@RequestScoped +@Path(MvcAuthoringSteps.PATH_PREFIX + "event-basicproperties") +@Controller +@MvcAuthoringStepDef( + bundle = EventStepsConstants.BUNDLE, + descriptionKey = "authoringsteps.basicproperties.description", + labelKey = "authoringsteps.basicproperties.label", + supportedDocumentType = Event.class +) +public class MvcEventPropertiesStep extends AbstractMvcAuthoringStep { + + @Inject + private EventMessageBundle eventMessageBundle; + + /** + * Used for retrieving and saving the events. + */ + @Inject + private ContentItemRepository itemRepo; + + /** + * Provides functions for working with content items. + */ + @Inject + private ContentItemManager itemManager; + + @Inject + private DocumentUi documentUi; + + /** + * Provides functions for working with folders. + */ + @Inject + private FolderManager folderManager; + + /** + * Provides functions for working with {@link LocalizedString}s. + */ + @Inject + private GlobalizationHelper globalizationHelper; + + @Inject + private ItemPermissionChecker itemPermissionChecker; + + @Inject + private MvcEventPropertiesStepModel eventPropertiesStepModel; + + @Inject + private Models models; + + @Override + public Class getStepClass() { + return MvcEventPropertiesStep.class; + } + + @Override + @Transactional(Transactional.TxType.REQUIRED) + protected void init() throws ContentSectionNotFoundException, + DocumentNotFoundException { + super.init(); + + eventPropertiesStepModel.setName(getDocument().getDisplayName()); + + final Set titleLocales = getDocument() + .getTitle() + .getAvailableLocales(); + + eventPropertiesStepModel.setTitleValues( + getDocument() + .getTitle() + .getValues() + .entrySet() + .stream() + .collect( + Collectors.toMap( + entry -> entry.getKey().toString(), + entry -> entry.getValue() + ) + ) + ); + + eventPropertiesStepModel.setUnusedTitleLocales( + globalizationHelper + .getAvailableLocales() + .stream() + .filter(locale -> !titleLocales.contains(locale)) + .map(Locale::toString) + .collect(Collectors.toList()) + ); + + eventPropertiesStepModel.setDescriptionValues( + getDocument() + .getDescription() + .getValues() + .entrySet() + .stream() + .collect( + Collectors.toMap( + entry -> entry.getKey().toString(), + entry -> entry.getValue() + ) + ) + ); + + final Set descriptionLocales = getDocument() + .getDescription() + .getAvailableLocales(); + + eventPropertiesStepModel.setUnusedDescriptionLocales( + globalizationHelper + .getAvailableLocales() + .stream() + .filter(locale -> !descriptionLocales.contains(locale)) + .map(Locale::toString) + .collect(Collectors.toList()) + ); + + final Event event = (Event) getDocument(); + final DateTimeFormatter isoDateTimeFormatter + = DateTimeFormatter.ISO_DATE_TIME.withZone(ZoneId.systemDefault()); + + eventPropertiesStepModel.setStartDate( + Optional + .ofNullable(event.getStartDate()) + .map(startDate -> startDate.toInstant()) + .map(startDate -> isoDateTimeFormatter.format(startDate)) + .orElse("") + ); + + eventPropertiesStepModel.setEndDate( + Optional + .ofNullable(event.getEndDate()) + .map(endDate -> endDate.toInstant()) + .map(endDate -> isoDateTimeFormatter.format(endDate)) + .orElse("") + ); + + eventPropertiesStepModel.setMapLink(event.getMapLink()); + } + + @GET + @Path("/") + @AuthorizationRequired + @Transactional(Transactional.TxType.REQUIRED) + public String showStep( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDocument())) { + return "org/librecms/ui/contenttypes/event/event-basic-properties.xhtml"; + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDocument(), + eventMessageBundle.getMessage("event.edit.denied") + ); + } + } + + /** + * Updates the name of the current event. + * + * @param sectionIdentifier + * @param documentPath + * @param name + * + * @return A redirect to this authoring step. + */ + @POST + @Path("/name") + @AuthorizationRequired + @Transactional(Transactional.TxType.REQUIRED) + public String updateName( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @FormParam("name") @DefaultValue("") final String name + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDocument())) { + if (name.isEmpty() || name.matches("\\s*")) { + models.put("nameMissing", true); + + return showStep(sectionIdentifier, documentPath); + } + + getDocument().setDisplayName(name); + itemRepo.save(getDocument()); + + updateDocumentPath(); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDocument(), + getLabel() + ); + } + } + + @POST + @Path("/eventproperties") + @AuthorizationRequired + @Transactional(Transactional.TxType.REQUIRED) + public String updateEventProperties( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @FormParam("startDateTime") + final String startDateTime, + @FormParam("endDateTime") + final String endDateTime, + @FormParam("timeZone") + final String timeZone, + @FormParam("mapLink") + final String mapLink + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDocument())) { + final Event event = (Event) getDocument(); + final DateTimeFormatter isoDateTimeFormatter + = DateTimeFormatter.ISO_DATE_TIME + .withZone(ZoneId.of(timeZone)); + event.setStartDate( + Date.from( + ZonedDateTime.parse( + startDateTime, + isoDateTimeFormatter + ).toInstant() + ) + ); + + event.setEndDate( + Date.from( + ZonedDateTime.parse( + endDateTime, + isoDateTimeFormatter + ).toInstant() + ) + ); + event.setMapLink(mapLink); + + itemRepo.save(event); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDocument(), + getLabel() + ); + } + } + + /** + * Updates a localized title of the event. + * + * @param sectionIdentifier + * @param documentPath + * @param localeParam The locale to update. + * @param value The updated title value. + * + * @return A redirect to this authoring step. + */ + @POST + @Path("/title/@add") + @AuthorizationRequired + @Transactional(Transactional.TxType.REQUIRED) + public String addTitle( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @FormParam("locale") final String localeParam, + @FormParam("value") final String value + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDocument())) { + final Locale locale = new Locale(localeParam); + getDocument().getTitle().putValue(locale, value); + itemRepo.save(getDocument()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDocument(), + getLabel() + ); + } + } + + /** + * Updates a localized title of the event. + * + * @param sectionIdentifier + * @param documentPath + * @param localeParam The locale to update. + * @param value The updated title value. + * + * @return A redirect to this authoring step. + */ + @POST + @Path("/title/@edit/{locale}") + @AuthorizationRequired + @Transactional(Transactional.TxType.REQUIRED) + public String editTitle( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam, + @FormParam("value") final String value + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDocument())) { + final Locale locale = new Locale(localeParam); + getDocument().getTitle().putValue(locale, value); + itemRepo.save(getDocument()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDocument(), + getLabel() + ); + } + } + + /** + * Removes a localized title of the event. + * + * @param sectionIdentifier + * @param documentPath + * @param localeParam The locale to remove. + * + * @return A redirect to this authoring step. + */ + @POST + @Path("/title/@remove/{locale}") + @AuthorizationRequired + @Transactional(Transactional.TxType.REQUIRED) + public String removeTitle( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDocument())) { + final Locale locale = new Locale(localeParam); + getDocument().getTitle().removeValue(locale); + itemRepo.save(getDocument()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDocument(), + getLabel() + ); + } + } + + /** + * Adds a localized description to the event. + * + * @param sectionIdentifier + * @param documentPath + * @param localeParam The locale of the description. + * @param value The description value. + * + * @return A redirect to this authoring step. + */ + @POST + @Path("/description/@add") + @Transactional(Transactional.TxType.REQUIRED) + public String addDescription( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @FormParam("locale") final String localeParam, + @FormParam("value") final String value + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDocument())) { + final Locale locale = new Locale(localeParam); + getDocument().getDescription().putValue(locale, value); + itemRepo.save(getDocument()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDocument(), + getLabel() + ); + } + } + + /** + * Updates a localized description of the event. + * + * @param sectionIdentifier + * @param documentPath + * @param localeParam The locale to update. + * @param value The updated description value. + * + * @return A redirect to this authoring step. + */ + @POST + @Path("/description/@edit/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + public String editDescription( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam, + @FormParam("value") final String value + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDocument())) { + final Locale locale = new Locale(localeParam); + getDocument().getDescription().putValue(locale, value); + itemRepo.save(getDocument()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDocument(), + getLabel() + ); + } + } + + /** + * Removes a localized description of the event. + * + * @param sectionIdentifier + * @param documentPath + * @param localeParam The locale to remove. + * + * @return A redirect to this authoring step. + */ + @POST + @Path("/description/@remove/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + public String removeDescription( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDocument())) { + final Locale locale = new Locale(localeParam); + getDocument().getDescription().removeValue(locale); + itemRepo.save(getDocument()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDocument(), + getLabel() + ); + } + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventPropertiesStepModel.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventPropertiesStepModel.java new file mode 100644 index 000000000..d57a366bb --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventPropertiesStepModel.java @@ -0,0 +1,124 @@ +/* + * Copyright (C) 2022 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.librecms.ui.contenttypes.event; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("CmsEventPropertiesStep") +public class MvcEventPropertiesStepModel { + + private String name; + + private Map titleValues; + + private List unusedTitleLocales; + + private Map descriptionValues; + + private List unusedDescriptionLocales; + + private String startDate; + + private String endDate; + + private String mapLink; + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + public Map getTitleValues() { + return Collections.unmodifiableMap(titleValues); + } + + public void setTitleValues(final Map titleValues) { + this.titleValues = new HashMap<>(titleValues); + } + + public List getUnusedTitleLocales() { + return Collections.unmodifiableList(unusedTitleLocales); + } + + public void setUnusedTitleLocales(List unusedTitleLocales) { + this.unusedTitleLocales = new ArrayList<>(unusedTitleLocales); + } + + public Map getDescriptionValues() { + return Collections.unmodifiableMap(descriptionValues); + } + + public void setDescriptionValues( + final Map descriptionValues + ) { + this.descriptionValues = new HashMap<>(descriptionValues); + } + + public List getUnusedDescriptionLocales() { + return Collections.unmodifiableList(unusedDescriptionLocales); + } + + public void setUnusedDescriptionLocales( + final List unusedDescriptionLocales + ) { + this.unusedDescriptionLocales = new ArrayList<>( + unusedDescriptionLocales + ); + } + + public String getStartDate() { + return startDate; + } + + public void setStartDate(final String startDate) { + this.startDate = startDate; + } + + public String getEndDate() { + return endDate; + } + + public void setEndDate(final String endDate) { + this.endDate = endDate; + } + + public String getMapLink() { + return mapLink; + } + + public void setMapLink(final String mapLink) { + this.mapLink = mapLink; + } + +} -- 2.52.0 From c18336bc5eaa16c20a76320081e93a782382b8ed Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Wed, 2 Feb 2022 20:01:33 +0100 Subject: [PATCH 3/9] Java Part of authoring steps for Event --- .../documents/CmsEditorUtil.java | 52 ++ .../article/MvcArticleTextBodyStep.java | 38 +- .../article/MvcArticleTextBodyStepModel.java | 10 +- .../contenttypes/event/MvcEventInfoStep.java | 815 ++++++++++++++++++ .../event/MvcEventInfoStepEventDateModel.java | 92 ++ .../event/MvcEventInfoStepEventTypeModel.java | 90 ++ .../event/MvcEventInfoStepLocationModel.java | 90 ++ .../MvcEventInfoStepMainContributorModel.java | 92 ++ .../event/MvcEventInfoStepResources.java | 374 ++++++++ .../ui/contenttypes/EventBundle.properties | 13 + .../ui/contenttypes/EventBundle_de.properties | 13 + 11 files changed, 1649 insertions(+), 30 deletions(-) create mode 100644 ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CmsEditorUtil.java create mode 100644 ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStep.java create mode 100644 ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventDateModel.java create mode 100644 ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventTypeModel.java create mode 100644 ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepLocationModel.java create mode 100644 ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepMainContributorModel.java create mode 100644 ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepResources.java create mode 100644 ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle.properties create mode 100644 ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle_de.properties diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CmsEditorUtil.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CmsEditorUtil.java new file mode 100644 index 000000000..c4c40de99 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CmsEditorUtil.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2022 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.librecms.ui.contentsections.documents; + +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; + +import java.util.Locale; +import java.util.Map; +import java.util.StringTokenizer; + +/** + * + * @author Jens Pelzetter + */ +public final class CmsEditorUtil { + + private CmsEditorUtil() { + // Nothing + } + + public static CmsEditorLocaleVariantRow buildVariantRow( + final Map.Entry entry + ) { + final CmsEditorLocaleVariantRow variant + = new CmsEditorLocaleVariantRow(); + variant.setLocale(entry.getKey().toString()); + final Document document = Jsoup.parseBodyFragment(entry.getValue()); + variant.setWordCount( + new StringTokenizer(document.body().text()).countTokens() + ); + + return variant; + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/article/MvcArticleTextBodyStep.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/article/MvcArticleTextBodyStep.java index 80befc6a6..261c4db08 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/article/MvcArticleTextBodyStep.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/article/MvcArticleTextBodyStep.java @@ -29,6 +29,7 @@ import org.librecms.ui.contentsections.ItemPermissionChecker; import org.librecms.ui.contentsections.documents.AbstractMvcAuthoringStep; import org.librecms.ui.contentsections.documents.CmsEditorLocaleVariantRow; import org.librecms.ui.contentsections.ContentSectionNotFoundException; +import org.librecms.ui.contentsections.documents.CmsEditorUtil; import org.librecms.ui.contentsections.documents.DocumentNotFoundException; import org.librecms.ui.contentsections.documents.DocumentUi; @@ -144,6 +145,7 @@ public class MvcArticleTextBodyStep extends AbstractMvcAuthoringStep { * @param sectionIdentifier * @param documentPath * @param localeParam + * * @return The template for showing a preview of the text. */ @GET @@ -167,7 +169,7 @@ public class MvcArticleTextBodyStep extends AbstractMvcAuthoringStep { articleTextBodyStepModel.setSelectedLocale( new Locale(localeParam).toString() ); - + return "org/librecms/ui/contenttypes/article/article-text/view.xhtml"; } @@ -351,16 +353,16 @@ public class MvcArticleTextBodyStep extends AbstractMvcAuthoringStep { ); articleTextBodyStepModel.setTitleValues( getArticle() - .getTitle() - .getValues() - .entrySet() - .stream() - .collect( - Collectors.toMap( - entry -> entry.getKey().toString(), - Map.Entry::getValue + .getTitle() + .getValues() + .entrySet() + .stream() + .collect( + Collectors.toMap( + entry -> entry.getKey().toString(), + Map.Entry::getValue + ) ) - ) ); articleTextBodyStepModel.setTextValues( getArticle() @@ -382,7 +384,7 @@ public class MvcArticleTextBodyStep extends AbstractMvcAuthoringStep { .getValues() .entrySet() .stream() - .map(this::buildVariantRow) + .map(CmsEditorUtil::buildVariantRow) .collect(Collectors.toList()) ); @@ -404,18 +406,4 @@ public class MvcArticleTextBodyStep extends AbstractMvcAuthoringStep { return (Article) getDocument(); } - private CmsEditorLocaleVariantRow buildVariantRow( - final Map.Entry entry - ) { - final CmsEditorLocaleVariantRow variant - = new CmsEditorLocaleVariantRow(); - variant.setLocale(entry.getKey().toString()); - final Document document = Jsoup.parseBodyFragment(entry.getValue()); - variant.setWordCount( - new StringTokenizer(document.body().text()).countTokens() - ); - - return variant; - } - } diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/article/MvcArticleTextBodyStepModel.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/article/MvcArticleTextBodyStepModel.java index 02b163275..b3c2e3fcf 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/article/MvcArticleTextBodyStepModel.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/article/MvcArticleTextBodyStepModel.java @@ -38,9 +38,9 @@ import javax.inject.Named; public class MvcArticleTextBodyStepModel { private boolean canEdit; - + private Map titleValues; - + private Map textValues; private List variants; @@ -48,7 +48,7 @@ public class MvcArticleTextBodyStepModel { private List unusedLocales; private String selectedLocale; - + public Map getTitleValues() { return Collections.unmodifiableMap(titleValues); } @@ -60,7 +60,7 @@ public class MvcArticleTextBodyStepModel { public String getTitle() { return titleValues.get(selectedLocale); } - + /** * Get all localized values of the main text. * @@ -74,7 +74,7 @@ public class MvcArticleTextBodyStepModel { this.textValues = new HashMap<>(textValues); } - /** + /** * Gets the locales for which the main text has not been defined yet. * * @return The locales for which the main text has not been defined yet. diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStep.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStep.java new file mode 100644 index 000000000..c49c4a178 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStep.java @@ -0,0 +1,815 @@ +/* + * Copyright (C) 2022 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.librecms.ui.contenttypes.event; + +import org.libreccm.configuration.ConfigurationManager; +import org.libreccm.l10n.GlobalizationHelper; +import org.librecms.contentsection.ContentItemRepository; +import org.librecms.contenttypes.Event; +import org.librecms.ui.contentsections.ContentSectionNotFoundException; +import org.librecms.ui.contentsections.ItemPermissionChecker; +import org.librecms.ui.contentsections.documents.AbstractMvcAuthoringStep; +import org.librecms.ui.contentsections.documents.DocumentNotFoundException; +import org.librecms.ui.contentsections.documents.DocumentUi; +import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef; +import org.librecms.ui.contentsections.documents.MvcAuthoringSteps; + +import java.util.Locale; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.mvc.Controller; +import javax.transaction.Transactional; +import javax.ws.rs.FormParam; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; + +/** + * Authoring step for editing the localizable information of an event. + * + * @author Jens Pelzetter + */ +@RequestScoped +@Path(MvcAuthoringSteps.PATH_PREFIX + "event-info") +@Controller +@MvcAuthoringStepDef( + bundle = EventStepsConstants.BUNDLE, + descriptionKey = "authoringsteps.info.description", + labelKey = "authoringstep.info.label", + supportedDocumentType = Event.class +) +public class MvcEventInfoStep extends AbstractMvcAuthoringStep { + + @Inject + private EventMessageBundle eventMessageBundle; + + @Inject + private ConfigurationManager confManager; + + @Inject + private ContentItemRepository itemRepo; + + @Inject + private DocumentUi documentUi; + + @Inject + private GlobalizationHelper globalizationHelper; + + @Inject + private ItemPermissionChecker itemPermissionChecker; + + @Inject + private MvcEventInfoStepEventDateModel eventDateModel; + + @Inject + private MvcEventInfoStepLocationModel locationModel; + + @Inject + private MvcEventInfoStepMainContributorModel mainContributorModel; + + @Inject + private MvcEventInfoStepEventTypeModel eventTypeModel; + + @Override + public Class getStepClass() { + return MvcEventInfoStep.class; + } + + @GET + @Path("/") + @Transactional(Transactional.TxType.REQUIRED) + public String showStep( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getEvent())) { + return "org/librecms/ui/contenttypes/event/event-info/overview.xhtml"; + } else { + return documentUi.showAccessDenied( + getContentSection(), + getEvent(), + eventMessageBundle.getMessage("event.edit.denied") + ); + } + } + + // EventDate + @GET + @Path("/eventdate/view/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + public String viewEventDate( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + eventDateModel.setSelectedLocale(new Locale(localeParam).toString()); + + return "org/librecms/ui/contenttypes/event/eventdate/view.xhtml"; + } + + @POST + @Path("/eventdate/add") + @Transactional(Transactional.TxType.REQUIRED) + public String addEventDateValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @FormParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getEvent())) { + final String value; + if (getEvent().getEventDate().getAvailableLocales().isEmpty()) { + value = ""; + } else { + value = globalizationHelper.getValueFromLocalizedString( + getEvent().getText() + ); + } + final Locale locale = new Locale(localeParam); + getEvent().getEventDate().putValue(locale, value); + itemRepo.save(getEvent()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getEvent(), + getLabel() + ); + } + } + + @GET + @Path("/eventdate/edit/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + public String editEventDateValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getEvent())) { + eventDateModel.setSelectedLocale( + new Locale(localeParam).toString() + ); + + return "org/librecms/ui/contenttypes/event/eventdate/edit.xhtml"; + } else { + return documentUi.showAccessDenied( + getContentSection(), + getEvent(), + getLabel() + ); + } + } + + @POST + @Path("/eventdate/edit/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + public String editEventDateValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam, + @FormParam("value") final String value + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getEvent())) { + final Locale locale = new Locale(localeParam); + getEvent().getEventDate().putValue(locale, value); + itemRepo.save(getEvent()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getEvent(), + getLabel() + ); + } + } + + @POST + @Path("/eventdate/remove/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + public String removeEventDateValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getEvent())) { + final Locale locale = new Locale(localeParam); + getEvent().getText().removeValue(locale); + itemRepo.save(getEvent()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getEvent(), + getLabel() + ); + } + } + + // Location + @GET + @Path("/location/view/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + public String viewLocation( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + locationModel.setSelectedLocale(new Locale(localeParam).toString()); + + return "org/librecms/ui/contenttypes/event/location/view.xhtml"; + } + + @POST + @Path("/location/add") + @Transactional(Transactional.TxType.REQUIRED) + public String addLocationValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @FormParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getEvent())) { + final String value; + if (getEvent().getLocation().getAvailableLocales().isEmpty()) { + value = ""; + } else { + value = globalizationHelper.getValueFromLocalizedString( + getEvent().getLocation() + ); + } + final Locale locale = new Locale(localeParam); + getEvent().getLocation().putValue(locale, value); + itemRepo.save(getEvent()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getEvent(), + getLabel() + ); + } + } + + @GET + @Path("/location/edit/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + public String editLocationValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getEvent())) { + locationModel.setSelectedLocale(new Locale(localeParam).toString()); + + return "org/librecms/ui/contenttypes/event/location/edit.xhtml"; + } else { + return documentUi.showAccessDenied( + getContentSection(), + getEvent(), + getLabel() + ); + } + } + + @POST + @Path("/location/edit/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + public String editLocationValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam, + @FormParam("value") final String value + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getEvent())) { + final Locale locale = new Locale(localeParam); + getEvent().getLocation().putValue(locale, value); + itemRepo.save(getEvent()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getEvent(), + getLabel() + ); + } + } + + @POST + @Path("/location/remove/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + public String removeLocationValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getEvent())) { + final Locale locale = new Locale(localeParam); + getEvent().getLocation().removeValue(locale); + itemRepo.save(getEvent()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getEvent(), + getLabel() + ); + } + } + + // Main Contributor + @GET + @Path("/main-contributor/view/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + public String viewMainContributor( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + mainContributorModel.setSelectedLocale( + new Locale(localeParam).toString() + ); + + return "org/librecms/ui/contenttypes/event/main-contributor/view.xhtml"; + } + + @POST + @Path("/main-contributor/add") + @Transactional(Transactional.TxType.REQUIRED) + public String addMainContributorValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @FormParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getEvent())) { + final String value; + if (getEvent() + .getMainContributor() + .getAvailableLocales() + .isEmpty()) { + value = ""; + } else { + value = globalizationHelper.getValueFromLocalizedString( + getEvent().getMainContributor() + ); + } + final Locale locale = new Locale(localeParam); + getEvent().getText().putValue(locale, value); + itemRepo.save(getEvent()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getEvent(), + getLabel() + ); + } + } + + @GET + @Path("/main-contributor/edit/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + public String editMainContributorValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getEvent())) { + mainContributorModel.setSelectedLocale( + new Locale(localeParam).toString() + ); + + return "org/librecms/ui/contenttypes/event/main-contributor/edit.xhtml"; + } else { + return documentUi.showAccessDenied( + getContentSection(), + getEvent(), + getLabel() + ); + } + } + + @POST + @Path("/main-contributor/add") + @Transactional(Transactional.TxType.REQUIRED) + public String addMainContributorValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam, + @FormParam("value") final String value + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getEvent())) { + final Locale locale = new Locale(localeParam); + getEvent().getMainContributor().putValue(locale, value); + itemRepo.save(getEvent()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getEvent(), + getLabel() + ); + } + } + + @POST + @Path("/main-contributor/remove/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + public String removeMainContributorValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getEvent())) { + final Locale locale = new Locale(localeParam); + getEvent().getMainContributor().removeValue(locale); + itemRepo.save(getEvent()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getEvent(), + getLabel() + ); + } + } + + // Event Type + @GET + @Path("/eventtype/view/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + public String viewEventType( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + eventTypeModel.setSelectedLocale(new Locale(localeParam).toString()); + + return "org/librecms/ui/contenttypes/event/eventtype/view.xhtml"; + } + + @POST + @Path("/eventtype/add") + @Transactional(Transactional.TxType.REQUIRED) + public String addEventTypeValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @FormParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getEvent())) { + final String value; + if (getEvent().getEventType().getAvailableLocales().isEmpty()) { + value = ""; + } else { + value = globalizationHelper.getValueFromLocalizedString( + getEvent().getEventType() + ); + } + final Locale locale = new Locale(localeParam); + getEvent().getEventDate().putValue(locale, value); + itemRepo.save(getEvent()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getEvent(), + getLabel() + ); + } + } + + @GET + @Path("/eventdate/edit/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + public String editEventTypeValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getEvent())) { + eventTypeModel.setSelectedLocale(new Locale(localeParam).toString()); + + return "org/librecms/ui/contenttypes/event/eventtype/edit.xhtml"; + } else { + return documentUi.showAccessDenied( + getContentSection(), + getEvent(), + getLabel() + ); + } + } + + @POST + @Path("/eventdate/edit/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + public String editEventTypeValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam, + @FormParam("value") final String value + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getEvent())) { + final Locale locale = new Locale(localeParam); + getEvent().getEventType().putValue(locale, value); + itemRepo.save(getEvent()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getEvent(), + getLabel() + ); + } + } + + @POST + @Path("/eventdate/remove/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + public String removeEventTypeValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getEvent())) { + final Locale locale = new Locale(localeParam); + getEvent().getEventType().removeValue(locale); + itemRepo.save(getEvent()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getEvent(), + getLabel() + ); + } + } + + @Override + public void init() throws ContentSectionNotFoundException, + DocumentNotFoundException { + super.init(); + + if (itemPermissionChecker.canEditItem(getEvent())) { + eventDateModel.setCanEdit( + itemPermissionChecker.canEditItem(getEvent()) + ); + + locationModel.setCanEdit( + itemPermissionChecker.canEditItem(getEvent()) + ); + + mainContributorModel.setCanEdit( + itemPermissionChecker.canEditItem(getEvent()) + ); + + eventTypeModel.setCanEdit( + itemPermissionChecker.canEditItem(getEvent()) + ); + + // toDo + } + } + + private Event getEvent() { + return (Event) getDocument(); + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventDateModel.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventDateModel.java new file mode 100644 index 000000000..e539a3d02 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventDateModel.java @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2022 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.librecms.ui.contenttypes.event; + +import org.librecms.ui.contentsections.documents.CmsEditorLocaleVariantRow; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("CmsEventInfoStepEventDate") +class MvcEventInfoStepEventDateModel { + + private boolean canEdit; + + private Map eventDateValues; + + private List variants; + + private List unusedLocales; + + private String selectedLocale; + + public Map getEventDateValues() { + return Collections.unmodifiableMap(eventDateValues); + } + + protected void setEventDateValues( + final Map eventDateValues + ) { + this.eventDateValues = new HashMap<>(eventDateValues); + } + + public List getVariants() { + return Collections.unmodifiableList(variants); + } + + protected void setVariants(final List variants) { + this.variants = new ArrayList<>(variants); + } + + public List getUnusedLocales() { + return Collections.unmodifiableList(unusedLocales); + } + + protected void setUnusedLocales(final List unusedLocales) { + this.unusedLocales = new ArrayList<>(unusedLocales); + } + + public String getSelectedLocale() { + return selectedLocale; + } + + protected void setSelectedLocale(final String selectedLocale) { + this.selectedLocale = selectedLocale; + } + + public boolean getCanEdit() { + return canEdit; + } + + protected void setCanEdit(final boolean canEdit) { + this.canEdit = canEdit; + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventTypeModel.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventTypeModel.java new file mode 100644 index 000000000..7e1ad195c --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventTypeModel.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2022 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.librecms.ui.contenttypes.event; + +import org.librecms.ui.contentsections.documents.CmsEditorLocaleVariantRow; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("CmsEventInfoSstepEventType") +public class MvcEventInfoStepEventTypeModel { + + private boolean canEdit; + + private Map eventTypeValues; + + private List variants; + + private List unusedLocales; + + private String selectedLocale; + + public Map getEventTypeValues() { + return Collections.unmodifiableMap(eventTypeValues); + } + + protected void setEventTypeValues(final Map eventTypeValues) { + this.eventTypeValues = new HashMap<>(eventTypeValues); + } + + public List getVariants() { + return Collections.unmodifiableList(variants); + } + + protected void setVariants(final List variants) { + this.variants = new ArrayList<>(variants); + } + + public List getUnusedLocales() { + return Collections.unmodifiableList(unusedLocales); + } + + protected void setUnusedLocales(final List unusedLocales) { + this.unusedLocales = new ArrayList<>(unusedLocales); + } + + public String getSelectedLocale() { + return selectedLocale; + } + + protected void setSelectedLocale(final String selectedLocale) { + this.selectedLocale = selectedLocale; + } + + public boolean getCanEdit() { + return canEdit; + } + + protected void setCanEdit(final boolean canEdit) { + this.canEdit = canEdit; + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepLocationModel.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepLocationModel.java new file mode 100644 index 000000000..6d3e773ce --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepLocationModel.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2022 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.librecms.ui.contenttypes.event; + +import org.librecms.ui.contentsections.documents.CmsEditorLocaleVariantRow; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("CmsEventInfoStepLocation") +public class MvcEventInfoStepLocationModel { + + private boolean canEdit; + + private Map locationValues; + + private List variants; + + private List unusedLocales; + + private String selectedLocale; + + public Map getLocationValues() { + return Collections.unmodifiableMap(locationValues); + } + + protected void setLocationValues(final Map locationValues) { + this.locationValues = new HashMap<>(locationValues); + } + + public List getVariants() { + return Collections.unmodifiableList(variants); + } + + protected void setVariants(final List variants) { + this.variants = new ArrayList<>(variants); + } + + public List getUnusedLocales() { + return Collections.unmodifiableList(unusedLocales); + } + + protected void setUnusedLocales(final List unusedLocales) { + this.unusedLocales = new ArrayList<>(unusedLocales); + } + + public String getSelectedLocale() { + return selectedLocale; + } + + protected void setSelectedLocale(final String selectedLocale) { + this.selectedLocale = selectedLocale; + } + + public boolean getCanEdit() { + return canEdit; + } + + protected void setCanEdit(final boolean canEdit) { + this.canEdit = canEdit; + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepMainContributorModel.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepMainContributorModel.java new file mode 100644 index 000000000..3a8a53449 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepMainContributorModel.java @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2022 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.librecms.ui.contenttypes.event; + +import org.librecms.ui.contentsections.documents.CmsEditorLocaleVariantRow; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("CmsEventInfoStepMainContributor") +public class MvcEventInfoStepMainContributorModel { + + private boolean canEdit; + + private Map contributorValues; + + private List variants; + + private List unusedLocales; + + private String selectedLocale; + + public Map getContributorValues() { + return Collections.unmodifiableMap(contributorValues); + } + + protected void setContributorValues( + final Map contributorValues + ) { + this.contributorValues = new HashMap<>(contributorValues); + } + + public List getVariants() { + return Collections.unmodifiableList(variants); + } + + protected void setVariants(final List variants) { + this.variants = new ArrayList<>(variants); + } + + public List getUnusedLocales() { + return Collections.unmodifiableList(unusedLocales); + } + + protected void setUnusedLocales(final List unusedLocales) { + this.unusedLocales = new ArrayList<>(unusedLocales); + } + + public String getSelectedLocale() { + return selectedLocale; + } + + protected void setSelectedLocale(final String selectedLocale) { + this.selectedLocale = selectedLocale; + } + + public boolean getCanEdit() { + return canEdit; + } + + protected void setCanEdit(final boolean canEdit) { + this.canEdit = canEdit; + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepResources.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepResources.java new file mode 100644 index 000000000..d44766652 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepResources.java @@ -0,0 +1,374 @@ +/* + * Copyright (C) 2022 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.librecms.ui.contenttypes.event; + +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.librecms.contentsection.ContentItem; +import org.librecms.contentsection.ContentItemRepository; +import org.librecms.contentsection.ContentSection; +import org.librecms.contenttypes.Event; +import org.librecms.ui.contentsections.ContentSectionsUi; +import org.librecms.ui.contentsections.ItemPermissionChecker; +import org.librecms.ui.contentsections.documents.MvcAuthoringSteps; + +import java.util.Locale; +import java.util.StringTokenizer; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.transaction.Transactional; +import javax.ws.rs.ForbiddenException; +import javax.ws.rs.GET; +import javax.ws.rs.NotFoundException; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Path(MvcAuthoringSteps.PATH_PREFIX + "event-info-resources") +public class MvcEventInfoStepResources { + + @Inject + private ContentItemRepository itemRepo; + + @Inject + private ContentSectionsUi sectionsUi; + + @Inject + private ItemPermissionChecker itemPermissionChecker; + + // Event Date + @GET + @Path("/eventdate/wordcount/{locale}") + @Produces(MediaType.TEXT_HTML) + @Transactional(Transactional.TxType.REQUIRED) + public String getEventDateWordCount( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPathParam, + @PathParam("locale") final String localeParam + ) { + final ContentSection contentSection = sectionsUi + .findContentSection(sectionIdentifier) + .orElseThrow( + () -> new NotFoundException() + ); + + final ContentItem document = itemRepo + .findByPath(contentSection, documentPathParam) + .orElseThrow( + () -> new NotFoundException() + ); + + if (!(document instanceof Event)) { + throw new NotFoundException(); + } + + final Event event = (Event) document; + if (itemPermissionChecker.canEditItem(event)) { + final String text = event + .getEventDate() + .getValue(new Locale(localeParam)); + final Document jsoupDoc = Jsoup.parseBodyFragment(text); + final long result = new StringTokenizer( + jsoupDoc.body().text() + ).countTokens(); + return Long.toString(result); + } else { + throw new ForbiddenException(); + } + } + + @GET + @Path("/eventdate/{locale}") + @Produces(MediaType.TEXT_HTML) + @Transactional(Transactional.TxType.REQUIRED) + public String viewEventDateValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPathParam, + @PathParam("locale") final String localeParam + ) { + final ContentSection contentSection = sectionsUi + .findContentSection(sectionIdentifier) + .orElseThrow( + () -> new NotFoundException() + ); + + final ContentItem document = itemRepo + .findByPath(contentSection, documentPathParam) + .orElseThrow( + () -> new NotFoundException() + ); + + if (!(document instanceof Event)) { + throw new NotFoundException(); + } + + final Event event = (Event) document; + if (itemPermissionChecker.canEditItem(event)) { + return event.getEventDate().getValue(new Locale(localeParam)); + } else { + throw new ForbiddenException(); + } + } + + // Location + @GET + @Path("/eventdate/wordcount/{locale}") + @Produces(MediaType.TEXT_HTML) + @Transactional(Transactional.TxType.REQUIRED) + public String getLocationWordCount( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPathParam, + @PathParam("locale") final String localeParam + ) { + final ContentSection contentSection = sectionsUi + .findContentSection(sectionIdentifier) + .orElseThrow( + () -> new NotFoundException() + ); + + final ContentItem document = itemRepo + .findByPath(contentSection, documentPathParam) + .orElseThrow( + () -> new NotFoundException() + ); + + if (!(document instanceof Event)) { + throw new NotFoundException(); + } + + final Event event = (Event) document; + if (itemPermissionChecker.canEditItem(event)) { + final String text = event + .getLocation() + .getValue(new Locale(localeParam)); + final Document jsoupDoc = Jsoup.parseBodyFragment(text); + final long result = new StringTokenizer( + jsoupDoc.body().text() + ).countTokens(); + return Long.toString(result); + } else { + throw new ForbiddenException(); + } + } + + @GET + @Path("/eventdate/{locale}") + @Produces(MediaType.TEXT_HTML) + @Transactional(Transactional.TxType.REQUIRED) + public String viewLocationValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPathParam, + @PathParam("locale") final String localeParam + ) { + final ContentSection contentSection = sectionsUi + .findContentSection(sectionIdentifier) + .orElseThrow( + () -> new NotFoundException() + ); + + final ContentItem document = itemRepo + .findByPath(contentSection, documentPathParam) + .orElseThrow( + () -> new NotFoundException() + ); + + if (!(document instanceof Event)) { + throw new NotFoundException(); + } + + final Event event = (Event) document; + if (itemPermissionChecker.canEditItem(event)) { + return event.getLocation().getValue(new Locale(localeParam)); + } else { + throw new ForbiddenException(); + } + } + + // Main Contributor + @GET + @Path("/eventdate/wordcount/{locale}") + @Produces(MediaType.TEXT_HTML) + @Transactional(Transactional.TxType.REQUIRED) + public String getMainContributorWordCount( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPathParam, + @PathParam("locale") final String localeParam + ) { + final ContentSection contentSection = sectionsUi + .findContentSection(sectionIdentifier) + .orElseThrow( + () -> new NotFoundException() + ); + + final ContentItem document = itemRepo + .findByPath(contentSection, documentPathParam) + .orElseThrow( + () -> new NotFoundException() + ); + + if (!(document instanceof Event)) { + throw new NotFoundException(); + } + + final Event event = (Event) document; + if (itemPermissionChecker.canEditItem(event)) { + final String text = event + .getMainContributor() + .getValue(new Locale(localeParam)); + final Document jsoupDoc = Jsoup.parseBodyFragment(text); + final long result = new StringTokenizer( + jsoupDoc.body().text() + ).countTokens(); + return Long.toString(result); + } else { + throw new ForbiddenException(); + } + } + + @GET + @Path("/eventdate/{locale}") + @Produces(MediaType.TEXT_HTML) + @Transactional(Transactional.TxType.REQUIRED) + public String viewMainContributorValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPathParam, + @PathParam("locale") final String localeParam + ) { + final ContentSection contentSection = sectionsUi + .findContentSection(sectionIdentifier) + .orElseThrow( + () -> new NotFoundException() + ); + + final ContentItem document = itemRepo + .findByPath(contentSection, documentPathParam) + .orElseThrow( + () -> new NotFoundException() + ); + + if (!(document instanceof Event)) { + throw new NotFoundException(); + } + + final Event event = (Event) document; + if (itemPermissionChecker.canEditItem(event)) { + return event.getMainContributor().getValue(new Locale(localeParam)); + } else { + throw new ForbiddenException(); + } + } + + // Event Type + @GET + @Path("/eventdate/wordcount/{locale}") + @Produces(MediaType.TEXT_HTML) + @Transactional(Transactional.TxType.REQUIRED) + public String getEventTypeWordCount( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPathParam, + @PathParam("locale") final String localeParam + ) { + final ContentSection contentSection = sectionsUi + .findContentSection(sectionIdentifier) + .orElseThrow( + () -> new NotFoundException() + ); + + final ContentItem document = itemRepo + .findByPath(contentSection, documentPathParam) + .orElseThrow( + () -> new NotFoundException() + ); + + if (!(document instanceof Event)) { + throw new NotFoundException(); + } + + final Event event = (Event) document; + if (itemPermissionChecker.canEditItem(event)) { + final String text = event + .getEventType() + .getValue(new Locale(localeParam)); + final Document jsoupDoc = Jsoup.parseBodyFragment(text); + final long result = new StringTokenizer( + jsoupDoc.body().text() + ).countTokens(); + return Long.toString(result); + } else { + throw new ForbiddenException(); + } + } + + @GET + @Path("/eventdate/{locale}") + @Produces(MediaType.TEXT_HTML) + @Transactional(Transactional.TxType.REQUIRED) + public String viewEventTypeValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPathParam, + @PathParam("locale") final String localeParam + ) { + final ContentSection contentSection = sectionsUi + .findContentSection(sectionIdentifier) + .orElseThrow( + () -> new NotFoundException() + ); + + final ContentItem document = itemRepo + .findByPath(contentSection, documentPathParam) + .orElseThrow( + () -> new NotFoundException() + ); + + if (!(document instanceof Event)) { + throw new NotFoundException(); + } + + final Event event = (Event) document; + if (itemPermissionChecker.canEditItem(event)) { + return event.getEventType().getValue(new Locale(localeParam)); + } else { + throw new ForbiddenException(); + } + } + +} diff --git a/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle.properties b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle.properties new file mode 100644 index 000000000..55793bb94 --- /dev/null +++ b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle.properties @@ -0,0 +1,13 @@ + +authoringsteps.basicproperties.description=General properties of an event, for example the begin and end date. +authoringsteps.basicproperties.label=Basic Properties +authoringsteps.info.description=Extended information about the event, for example about the location. +authoringstep.info.label=Event Info +createstep.description=Creates a new event. +createstep.name.error.missing=The name of the event is missing. +createstep.name.error.invalid=The name of the event is not valid. The name can only contain the letters a to z and A to Z, numbers (0 to 9), the underscore ("_") and the dash ("-"). +createstep.title.error.missing=The title of the event is missing. +createstep.summary.error.missing=The summary of the event is missing. +createstep.initial_locale.error.missing=The initial locale of the event is missing. +createstep.workflow.none_selected=No workflow was selected. +createstep.workflow.error.not_available=The selected workflow is not available. diff --git a/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle_de.properties b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle_de.properties new file mode 100644 index 000000000..e402052d7 --- /dev/null +++ b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle_de.properties @@ -0,0 +1,13 @@ + +authoringsteps.basicproperties.description=Basiseigenschaften einer Veranstaltung, z.B. das Datum der Veranstaltung +authoringsteps.basicproperties.label=Basiseigenschaften +authoringsteps.info.description=Weitere Informationen \u00fcber die Veranstaltung, z.B. \u00fcber den Veranstaltungsort. +authoringstep.info.label=Informationen zur Veranstaltung +createstep.description=Legt eine neue Veranstaltung an. +createstep.name.error.missing=Der Name der Veranstaltung wurde nicht angegeben. +createstep.name.error.invalid=Der Name der Veranstaltung ist nicht valide. Der Name darf nur die Buchstaben a bis z und A bis Z, Ziffern (0 to 9), den Unterstrich ("_") und den Bindestrich ("-") enthalten. +createstep.title.error.missing=Der Titel der Veranstaltung wurde nicht angegeben. +createstep.summary.error.missing=Es wurde keine Zusammenfassung der Veranstaltung angegeben. +createstep.initial_locale.error.missing=Die initale Sprache f\u00fcr die Veranstaltung wurde nicht angegeben. +createstep.workflow.none_selected=Es wurde kein Arbeitsablauf ausgew\u00e4hlt. +createstep.workflow.error.not_available=Der ausgew\u00e4hlte Arbeitsablauf ist nicht verf\u00fcgbar. -- 2.52.0 From 88f7be396390afbb0b9f464b0a401ae967e1034f Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Thu, 3 Feb 2022 20:18:48 +0100 Subject: [PATCH 4/9] XHTML templates for the authoring steps of the event content type. --- .../contenttypes/event/MvcEventInfoStep.java | 4 +- .../event/MvcEventInfoStepEventTypeModel.java | 2 +- .../article-text/available-languages.xhtml | 2 +- .../ui/contenttypes/event/create-event.xhtml | 82 ++++++++++ .../event/event-basic-properties.xhtml | 152 ++++++++++++++++++ .../ui/contenttypes/event/event-info.xhtml | 85 ++++++++++ .../contenttypes/event/eventdate/edit.xhtml | 44 +++++ .../contenttypes/event/eventdate/view.xhtml | 39 +++++ .../contenttypes/event/eventtype/edit.xhtml | 45 ++++++ .../contenttypes/event/eventtype/view.xhtml | 40 +++++ .../ui/contenttypes/event/location/edit.xhtml | 45 ++++++ .../ui/contenttypes/event/location/view.xhtml | 41 +++++ .../event/main-contributor/edit.xhtml | 45 ++++++ .../event/main-contributor/view.xhtml | 42 +++++ .../ui/contenttypes/EventBundle.properties | 33 ++++ .../ui/contenttypes/EventBundle_de.properties | 33 ++++ 16 files changed, 730 insertions(+), 4 deletions(-) create mode 100644 ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/create-event.xhtml create mode 100644 ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/event-basic-properties.xhtml create mode 100644 ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/event-info.xhtml create mode 100644 ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/eventdate/edit.xhtml create mode 100644 ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/eventdate/view.xhtml create mode 100644 ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/eventtype/edit.xhtml create mode 100644 ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/eventtype/view.xhtml create mode 100644 ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/location/edit.xhtml create mode 100644 ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/location/view.xhtml create mode 100644 ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/main-contributor/edit.xhtml create mode 100644 ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/main-contributor/view.xhtml diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStep.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStep.java index c49c4a178..a3e7d069e 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStep.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStep.java @@ -48,7 +48,7 @@ import javax.ws.rs.PathParam; * @author Jens Pelzetter */ @RequestScoped -@Path(MvcAuthoringSteps.PATH_PREFIX + "event-info") +@Path(MvcAuthoringSteps.PATH_PREFIX + "@event-info") @Controller @MvcAuthoringStepDef( bundle = EventStepsConstants.BUNDLE, @@ -111,7 +111,7 @@ public class MvcEventInfoStep extends AbstractMvcAuthoringStep { } if (itemPermissionChecker.canEditItem(getEvent())) { - return "org/librecms/ui/contenttypes/event/event-info/overview.xhtml"; + return "org/librecms/ui/contenttypes/event/event-info.xhtml"; } else { return documentUi.showAccessDenied( getContentSection(), diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventTypeModel.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventTypeModel.java index 7e1ad195c..bd245f87c 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventTypeModel.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventTypeModel.java @@ -34,7 +34,7 @@ import javax.inject.Named; * @author Jens Pelzetter */ @RequestScoped -@Named("CmsEventInfoSstepEventType") +@Named("CmsEventInfoStepEventType") public class MvcEventInfoStepEventTypeModel { private boolean canEdit; diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/article/article-text/available-languages.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/article/article-text/available-languages.xhtml index 2b861b6c1..8e1c0b720 100644 --- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/article/article-text/available-languages.xhtml +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/article/article-text/available-languages.xhtml @@ -8,7 +8,7 @@ + value="/libreccm/@contentsections/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@article-text" />

#{CmsArticleMessageBundle['textstep.header']}

diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/create-event.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/create-event.xhtml new file mode 100644 index 000000000..fbd2c9d50 --- /dev/null +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/create-event.xhtml @@ -0,0 +1,82 @@ +]> + + + + +
+

${CmsEventMessageBundle["createform.title"]}

+ + + + + +
+ + + + + + + + + + + #{CmsEventMessageBundle['createform.cancel']} + + + + +
+
+ +
+ diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/event-basic-properties.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/event-basic-properties.xhtml new file mode 100644 index 000000000..ab114e305 --- /dev/null +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/event-basic-properties.xhtml @@ -0,0 +1,152 @@ +]> + + + + + + +

#{CmsEventMessageBundle.getMessage('basicproperties.header', [CmsEventPropertiesStep.name])}

+ +

#{CmsEventPropertiesStep.getMessage('basicproperties.name.header')}

+
+
#{CmsEventPropertiesStep.name}
+ + + +
+ + + + + + + + + +
+ +
+ + + diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/event-info.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/event-info.xhtml new file mode 100644 index 000000000..570b85f84 --- /dev/null +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/event-info.xhtml @@ -0,0 +1,85 @@ +]> + + + + + + +

#{CmsEventMessageBundle['eventinfo_step.header']}

+ + + + + + + + + +
+ + + + + +
+ + diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/eventdate/edit.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/eventdate/edit.xhtml new file mode 100644 index 000000000..733d0ca9d --- /dev/null +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/eventdate/edit.xhtml @@ -0,0 +1,44 @@ +]> + + + + +
+ + + #{CmsEventMessageBundle['eventinfo_step.back']} + + +

#{CmsEventMessageBundle.getMessage('eventinfo_step.eventdate.header.edit',[CmsSelectedDocumentModel.itemName, CmsEventInfoStepEventDate.selectedLocale])}

+
+ + + + + + + + + +
+ +
+ + diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/eventdate/view.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/eventdate/view.xhtml new file mode 100644 index 000000000..ddb0356eb --- /dev/null +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/eventdate/view.xhtml @@ -0,0 +1,39 @@ +]> + + + + +
+ + + #{CmsEventMessageBundle['eventinfo_step.back']} + + +

#{CmsEventMessageBundle.getMessage('eventinfo_step.eventdate.header.view',[CmsSelectedDocumentModel.itemName, CmsEventInfoStepEventDate.selectedLocale])}

+
+ + + + +
+ +
+ +
+ +
+ + diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/eventtype/edit.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/eventtype/edit.xhtml new file mode 100644 index 000000000..38b266043 --- /dev/null +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/eventtype/edit.xhtml @@ -0,0 +1,45 @@ +]> + + + + +
+ + + #{CmsEventMessageBundle['eventinfo_step.back']} + + +

#{CmsEventMessageBundle.getMessage('eventinfo_step.eventtype.header.edit',[CmsSelectedDocumentModel.itemName, CmsEventInfoStepEventType.selectedLocale])}

+
+ + + + + + + + + +
+ +
+ + + diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/eventtype/view.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/eventtype/view.xhtml new file mode 100644 index 000000000..93e1e6d24 --- /dev/null +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/eventtype/view.xhtml @@ -0,0 +1,40 @@ +]> + + + + +
+ + + #{CmsEventMessageBundle['eventinfo_step.back']} + + +

#{CmsEventMessageBundle.getMessage('eventinfo_step.eventtype.header.view',[CmsSelectedDocumentModel.itemName, CmsEventInfoStepEventType.selectedLocale])}

+
+ + + + +
+ +
+ +
+ +
+ + + diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/location/edit.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/location/edit.xhtml new file mode 100644 index 000000000..36ef8b2a2 --- /dev/null +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/location/edit.xhtml @@ -0,0 +1,45 @@ +]> + + + + +
+ + + #{CmsEventMessageBundle['eventinfo_step.back']} + + +

#{CmsEventMessageBundle.getMessage('eventinfo_step.location.header.edit',[CmsSelectedDocumentModel.itemName, CmsEventInfoStepLocation.selectedLocale])}

+
+ + + + + + + + + +
+ +
+ + + diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/location/view.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/location/view.xhtml new file mode 100644 index 000000000..fe832f60b --- /dev/null +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/location/view.xhtml @@ -0,0 +1,41 @@ +]> + + + + +
+ + + #{CmsEventMessageBundle['eventinfo_step.back']} + + +

#{CmsEventMessageBundle.getMessage('eventinfo_step.location.header.view',[CmsSelectedDocumentModel.itemName, CmsEventInfoStepLocation.selectedLocale])}

+
+ + + + +
+ +
+ +
+ +
+ + + + diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/main-contributor/edit.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/main-contributor/edit.xhtml new file mode 100644 index 000000000..6387b8079 --- /dev/null +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/main-contributor/edit.xhtml @@ -0,0 +1,45 @@ +]> + + + + +
+ + + #{CmsEventMessageBundle['eventinfo_step.back']} + + +

#{CmsEventMessageBundle.getMessage('eventinfo_step.main_contributor.header.edit',[CmsSelectedDocumentModel.itemName, CmsEventInfoStepMainContributor.selectedLocale])}

+
+ + + + + + + + + +
+ +
+ + + diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/main-contributor/view.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/main-contributor/view.xhtml new file mode 100644 index 000000000..d07e9e009 --- /dev/null +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/main-contributor/view.xhtml @@ -0,0 +1,42 @@ +]> + + + + +
+ + + #{CmsEventMessageBundle['eventinfo_step.back']} + + +

#{CmsEventMessageBundle.getMessage('eventinfo_step.main_contributor.header.view',[CmsSelectedDocumentModel.itemName, CmsEventInfoStepMainContributor.selectedLocale])}

+
+ + + + +
+ +
+ +
+ +
+ + + + + diff --git a/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle.properties b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle.properties index 55793bb94..c78a0d443 100644 --- a/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle.properties +++ b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle.properties @@ -11,3 +11,36 @@ createstep.summary.error.missing=The summary of the event is missing. createstep.initial_locale.error.missing=The initial locale of the event is missing. createstep.workflow.none_selected=No workflow was selected. createstep.workflow.error.not_available=The selected workflow is not available. +createform.title=Create a new event +createform.name.help=The name of the new event. Can only contain the letters a to z and A to Z, numbers, the underscore ("_") and the dash ("-"). +createform.name.label=Name +createform.initial_locale.help=The initial locale of the new event. All localizable provided using this form is created for the selected language. +createform.title.help=The title of the new event. +createform.title.label=Title +createform.summary.help=A short summary of the new event. +createform.workflow.label=Summary +createform.cancel=Cancel +createform.submit=Create new event +eventinfo_step.header=Event Information +eventdate.editor.header=Additonal information about the date of the event +eventdate.editor.add_variant=Add language +location.editor.add_variant=Add language +location.editor.header=Information about the location of the event +main_contributor.editor.add_variant=Add language +main_contributor.editor.header=Information about the organizer of the event +eventtype.editor.add_variant=Add language +eventtype.editor.header=Information about the type of the event +eventinfo_step.back=Back +eventinfo_step.eventdate.header.view=Viewing information about event date of event {0} for language {1} +eventinfo_step.edit=Edit +eventinfo_step.eventtype.header.view=Showing information about event type of event {0} for language {1} +eventinfo_step.location.header.view=Showing information about location of event {0} for language {1} +eventinfo_step.main_contributor.header.view=Showing information about organizer of event {0} for language {1} +eventinfo_step.eventdate.header.edit=Edit information about event date of event {0} for language {1} +eventinfo_step.eventdate.editor.header=Information about the date of the event +eventinfo_step.eventtype.header.edit=Edit information about the type of event {0} for language {1} +eventinfo_step.eventtype.editor.header=Information about the type of event +eventinfo_step.main_contributor.header.edit=Edit information about the organizer of event {0} for language {1} +eventinfo_step.location.editor.header=Informatio about the location of the event +eventinfo_step.location.header.edit=Edit information about the location of event {0} for language {1} +eventinfo_step.main_contributor.editor.header=Information about the organizier of the event diff --git a/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle_de.properties b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle_de.properties index e402052d7..657713b94 100644 --- a/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle_de.properties +++ b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle_de.properties @@ -11,3 +11,36 @@ createstep.summary.error.missing=Es wurde keine Zusammenfassung der Veranstaltun createstep.initial_locale.error.missing=Die initale Sprache f\u00fcr die Veranstaltung wurde nicht angegeben. createstep.workflow.none_selected=Es wurde kein Arbeitsablauf ausgew\u00e4hlt. createstep.workflow.error.not_available=Der ausgew\u00e4hlte Arbeitsablauf ist nicht verf\u00fcgbar. +createform.title=Eine neue Veranstaltung anlegen +createform.name.help=Der Name der neuen Veranstaltung. Darf nur die Buchstaben a bis z, A bis Z, Ziffern, den Bindestrich ("-") und den Unterstrich ("_") enthalten. +createform.name.label=Name +createform.initial_locale.help=Die initiale Sprache der neuen Veranstaltung. Alle lokalisierbaren Angaben in diesem Formular werden f\u00fcr diese Sprache angelegt. +createform.title.help=Der Titel der neuen Veranstaltung. +createform.title.label=Titel +createform.summary.help=Eine kurze Zusammenfassung der neuen Veranstaltung. +createform.workflow.label=Zusammenfassung +createform.cancel=Abbrechen +createform.submit=Neue Veranstaltung anlegen +eventinfo_step.header=Informationen \u00fcber die Veranstaltung +eventdate.editor.header=Zus\u00e4tzliche Informationen \u00fcber den Zeitpunkt der Veranstaltung +eventdate.editor.add_variant=Sprache hinzuf\u00fcgen +location.editor.add_variant=Sprache hinzuf\u00fcgen +location.editor.header=Informationen \u00fcber den Veranstaltungsort +main_contributor.editor.add_variant=Sprache hinzuf\u00fcgen +main_contributor.editor.header=Informationen \u00fcber den Veranstalter +eventtype.editor.add_variant=Sprache hinzuf\u00fcgen +eventtype.editor.header=Informationen \u00fcber die Art der Veranstaltung +eventinfo_step.back=Zur\u00fcck +eventinfo_step.eventdate.header.view=Zeige Informationen \u00fcber Veranstaltungsdatum in Sprache {1} f\u00fcr Veranstaltung {0} +eventinfo_step.edit=Bearbeiten +eventinfo_step.eventtype.header.view=Zeige Informationen \u00fcber den Typ der Veranstaltung {0} in Sprache {1} +eventinfo_step.location.header.view=Zeige Informationen \u00fcber Veranstaltungsort f\u00fcr Veranstaltung {0} in Sprache {1} +eventinfo_step.main_contributor.header.view=Zeige Informationen \u00fcber Veranstalter der Veranstaltung {0} f\u00fcr Sprache {1} +eventinfo_step.eventdate.header.edit=Informationen \u00fcber den Zeitpunkt der Veranstaltung {0} f\u00fcr Sprache {1} bearbeiten +eventinfo_step.eventdate.editor.header=Informationen \u00fcber den Zeitpunkt der Veranstaltung +eventinfo_step.eventtype.header.edit=Informationen \u00fcber die Art der Veranstaltung {0} f\u00fcr Sprache {1} bearbeiten +eventinfo_step.eventtype.editor.header=Informationen \u00fcber die Art der Veranstaltung +eventinfo_step.main_contributor.header.edit=Informationen \u00fcber den Veranstalter der Veranstaltung {0} f\u00fcr Sprache {1} bearbeiten +eventinfo_step.location.editor.header=Informationen \u00fcber den Ort der Veranstaltung +eventinfo_step.location.header.edit=Informationen \u00fcber den Ort der Veranstaltung {0} f\u00fcr Sprache {1} bearbeiten +eventinfo_step.main_contributor.editor.header=Informationen \u00fcber den Veranstalter -- 2.52.0 From 257c71e185075f0fdf2775b50fa37a0627e3f1fc Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Sat, 5 Feb 2022 19:52:24 +0100 Subject: [PATCH 5/9] Component for a Bootstrap Form Group component with a datetime-local input field --- .../bootstrap/formGroupDateTime.xhtml | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 ccm-core/src/main/resources/META-INF/resources/components/bootstrap/formGroupDateTime.xhtml diff --git a/ccm-core/src/main/resources/META-INF/resources/components/bootstrap/formGroupDateTime.xhtml b/ccm-core/src/main/resources/META-INF/resources/components/bootstrap/formGroupDateTime.xhtml new file mode 100644 index 000000000..5e35f1c4e --- /dev/null +++ b/ccm-core/src/main/resources/META-INF/resources/components/bootstrap/formGroupDateTime.xhtml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + +
+ + + + #{cc.attrs.help} + +
+
+ + -- 2.52.0 From 53956098fbfe83b5d1100ed7f9a5b4d3f957dd01 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Sat, 5 Feb 2022 19:52:57 +0100 Subject: [PATCH 6/9] Bugfixes for the authoring of event --- .../java/org/librecms/contenttypes/Event.java | 16 +++- .../documents/CmsMvcAuthoringSteps.java | 6 ++ .../event/MvcEventCreateStep.java | 61 ++++++++++++- .../event/MvcEventInfoStepEventDateModel.java | 58 +++++++++---- .../event/MvcEventInfoStepEventTypeModel.java | 44 +++++++--- .../event/MvcEventInfoStepLocationModel.java | 36 ++++++-- .../MvcEventInfoStepMainContributorModel.java | 40 +++++++-- .../event/MvcEventPropertiesStep.java | 85 +++++++++++++++--- .../event/MvcEventPropertiesStepModel.java | 52 ++++++++--- .../ui/contenttypes/event/create-event.xhtml | 8 ++ .../event/event-basic-properties.xhtml | 84 +++++++++++++++++- .../contenttypes/event/event-info-tmp.xhtml | 86 +++++++++++++++++++ .../ui/contenttypes/event/event-info.xhtml | 30 +++---- ..._0_0_28__make_event_startdate_nullable.sql | 1 + ..._0_0_28__make_event_startdate_nullable.sql | 1 + .../ui/contenttypes/EventBundle.properties | 72 +++++++++++++++- .../ui/contenttypes/EventBundle_de.properties | 72 +++++++++++++++- 17 files changed, 661 insertions(+), 91 deletions(-) create mode 100644 ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/event-info-tmp.xhtml create mode 100644 ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_28__make_event_startdate_nullable.sql create mode 100644 ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/pgsql/V7_0_0_28__make_event_startdate_nullable.sql diff --git a/ccm-cms/src/main/java/org/librecms/contenttypes/Event.java b/ccm-cms/src/main/java/org/librecms/contenttypes/Event.java index 29cd4e43e..36c4479af 100644 --- a/ccm-cms/src/main/java/org/librecms/contenttypes/Event.java +++ b/ccm-cms/src/main/java/org/librecms/contenttypes/Event.java @@ -42,8 +42,10 @@ import org.libreccm.l10n.LocalizedString; import org.librecms.CmsConstants; import org.librecms.contentsection.ContentItem; - -import javax.validation.constraints.NotNull; +import org.librecms.ui.contentsections.documents.MvcAuthoringKit; +import org.librecms.ui.contenttypes.event.MvcEventCreateStep; +import org.librecms.ui.contenttypes.event.MvcEventInfoStep; +import org.librecms.ui.contenttypes.event.MvcEventPropertiesStep; import static org.librecms.CmsConstants.DB_SCHEMA; @@ -77,6 +79,13 @@ import static org.librecms.CmsConstants.DB_SCHEMA; order = 2 ) }) +@MvcAuthoringKit( + createStep = MvcEventCreateStep.class, + authoringSteps = { + MvcEventPropertiesStep.class, + MvcEventInfoStep.class + } +) public class Event extends ContentItem implements Serializable { private static final long serialVersionUID = -9104886733503414635L; @@ -94,9 +103,8 @@ public class Event extends ContentItem implements Serializable { )) private LocalizedString text; - @Column(name = "START_DATE", nullable = false) + @Column(name = "START_DATE") @Temporal(TemporalType.TIMESTAMP) - @NotNull private Date startDate; @Column(name = "END_DATE") diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CmsMvcAuthoringSteps.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CmsMvcAuthoringSteps.java index 4c54011e3..fcd8672a4 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CmsMvcAuthoringSteps.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CmsMvcAuthoringSteps.java @@ -25,6 +25,9 @@ import org.librecms.ui.contentsections.documents.relatedinfo.RelatedInfoStepServ import org.librecms.ui.contenttypes.article.MvcArticlePropertiesStep; import org.librecms.ui.contenttypes.article.MvcArticleTextBodyStep; import org.librecms.ui.contenttypes.article.MvcArticleTextBodyStepResources; +import org.librecms.ui.contenttypes.event.MvcEventInfoStep; +import org.librecms.ui.contenttypes.event.MvcEventInfoStepResources; +import org.librecms.ui.contenttypes.event.MvcEventPropertiesStep; import org.librecms.ui.contenttypes.mpa.MpaSectionsResources; import org.librecms.ui.contenttypes.mpa.MvcMpaPropertiesStep; import org.librecms.ui.contenttypes.mpa.MvcMpaSectionsStep; @@ -51,6 +54,8 @@ public class CmsMvcAuthoringSteps implements MvcAuthoringSteps { RelatedInfoStep.class, MvcArticlePropertiesStep.class, MvcArticleTextBodyStep.class, + MvcEventPropertiesStep.class, + MvcEventInfoStep.class, MvcMpaPropertiesStep.class, MvcMpaSectionsStep.class ); @@ -61,6 +66,7 @@ public class CmsMvcAuthoringSteps implements MvcAuthoringSteps { return Set.of( MediaStepService.class, MvcArticleTextBodyStepResources.class, + MvcEventInfoStepResources.class, MpaSectionsResources.class, RelatedInfoStepService.class ); diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventCreateStep.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventCreateStep.java index 83a137b70..298f4e985 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventCreateStep.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventCreateStep.java @@ -19,6 +19,7 @@ package org.librecms.ui.contenttypes.event; import org.libreccm.l10n.GlobalizationHelper; +import org.libreccm.l10n.LocalizedString; import org.libreccm.security.AuthorizationRequired; import org.libreccm.workflow.Workflow; import org.librecms.contentsection.ContentItemManager; @@ -26,6 +27,13 @@ import org.librecms.contentsection.ContentItemRepository; import org.librecms.contenttypes.Event; import org.librecms.ui.contentsections.documents.AbstractMvcDocumentCreateStep; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; +import java.util.Date; import java.util.Locale; import java.util.Map; import java.util.Optional; @@ -49,6 +57,8 @@ public class MvcEventCreateStep private static final String FORM_PARAM_TITLE = "title"; + private static final String FORM_PARAM_STARTDATE = "startDate"; + private static final String FORM_PARAM_SUMMARY = "summary"; private static final String FORM_PARAM_INITIAL_LOCALE = "locale"; @@ -83,6 +93,11 @@ public class MvcEventCreateStep */ private String title; + /** + * The start date of the event (ISO 8601 string) + */ + private String startDate; + /** * Summary of the event. */ @@ -123,6 +138,10 @@ public class MvcEventCreateStep return title; } + public String getStartDate() { + return startDate; + } + public String getSummary() { return summary; } @@ -200,6 +219,37 @@ public class MvcEventCreateStep } title = formParams.get(FORM_PARAM_TITLE)[0]; + if (!formParams.containsKey(FORM_PARAM_STARTDATE) + || formParams.get(FORM_PARAM_STARTDATE) == null + || formParams.get(FORM_PARAM_STARTDATE).length == 0) { + addMessage( + "danger", + globalizationHelper + .getLocalizedTextsUtil(getBundle()) + .getText("createstep.startdate.error.missing") + ); + return showCreateStep(); + } + startDate = formParams.get(FORM_PARAM_STARTDATE)[0]; + final DateTimeFormatter isoDateTimeFormatter + = DateTimeFormatter.ISO_DATE_TIME.withZone(ZoneId.systemDefault()); + + final LocalDateTime startDateTime; + try { + startDateTime = LocalDateTime.parse( + startDate, + isoDateTimeFormatter + ); + } catch (DateTimeParseException ex) { + addMessage( + "danger", + globalizationHelper + .getLocalizedTextsUtil(getBundle()) + .getText("createstep.startdate.error.malformed") + ); + return showCreateStep(); + } + if (!formParams.containsKey(FORM_PARAM_SUMMARY) || formParams.get(FORM_PARAM_SUMMARY) == null || formParams.get(FORM_PARAM_SUMMARY).length == 0) { @@ -269,11 +319,18 @@ public class MvcEventCreateStep Event.class, locale ); - + event.getTitle().putValue(locale, title); + event.setStartDate( + Date.from( + startDateTime.toInstant( + ZoneId.systemDefault().getRules().getOffset(startDateTime) + ) + ) + ); event.getDescription().putValue(locale, summary); itemRepo.save(event); - + return String.format( "redirect:/%s/documents/%s/%s/@event-basicproperties", getContentSectionLabel(), diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventDateModel.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventDateModel.java index e539a3d02..58890e4ca 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventDateModel.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventDateModel.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import javax.enterprise.context.RequestScoped; import javax.inject.Named; @@ -36,41 +37,62 @@ import javax.inject.Named; @RequestScoped @Named("CmsEventInfoStepEventDate") class MvcEventInfoStepEventDateModel { - + private boolean canEdit; - + private Map eventDateValues; - + private List variants; - + private List unusedLocales; - + private String selectedLocale; - + public Map getEventDateValues() { - return Collections.unmodifiableMap(eventDateValues); + return Optional + .ofNullable(eventDateValues) + .map(Collections::unmodifiableMap) + .orElse(Collections.emptyMap()); } - + protected void setEventDateValues( final Map eventDateValues ) { - this.eventDateValues = new HashMap<>(eventDateValues); + this.eventDateValues = Optional + .ofNullable(eventDateValues) + .map(values -> new HashMap<>(values)) + .map(values -> (Map) values) + .orElse(Collections.emptyMap()); } - + public List getVariants() { - return Collections.unmodifiableList(variants); + return Optional + .ofNullable(variants) + .map(Collections::unmodifiableList) + .orElse(Collections.emptyList()); } - + protected void setVariants(final List variants) { - this.variants = new ArrayList<>(variants); + this.variants = Optional + .ofNullable(variants) + .map(list -> new ArrayList<>(list)) + .map(list -> (List) list) + .orElse(Collections.emptyList()); } - + public List getUnusedLocales() { - return Collections.unmodifiableList(unusedLocales); + return Optional + .ofNullable(unusedLocales) + .map(Collections::unmodifiableList) + .orElse(Collections.emptyList()); } - protected void setUnusedLocales(final List unusedLocales) { - this.unusedLocales = new ArrayList<>(unusedLocales); + protected void setUnusedLocales(final List unusedLocales) { + this.unusedLocales = Optional + .ofNullable(unusedLocales) + .map(list -> new ArrayList<>(list)) + .map(list -> (List) list) + .orElse(Collections.emptyList()); } public String getSelectedLocale() { @@ -88,5 +110,5 @@ class MvcEventInfoStepEventDateModel { protected void setCanEdit(final boolean canEdit) { this.canEdit = canEdit; } - + } diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventTypeModel.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventTypeModel.java index bd245f87c..1e9552ed9 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventTypeModel.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventTypeModel.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import javax.enterprise.context.RequestScoped; import javax.inject.Named; @@ -36,8 +37,8 @@ import javax.inject.Named; @RequestScoped @Named("CmsEventInfoStepEventType") public class MvcEventInfoStepEventTypeModel { - - private boolean canEdit; + + private boolean canEdit; private Map eventTypeValues; @@ -48,27 +49,50 @@ public class MvcEventInfoStepEventTypeModel { private String selectedLocale; public Map getEventTypeValues() { - return Collections.unmodifiableMap(eventTypeValues); + return Optional + .ofNullable(eventTypeValues) + .map(Collections::unmodifiableMap) + .orElse(Collections.emptyMap()); } - protected void setEventTypeValues(final Map eventTypeValues) { - this.eventTypeValues = new HashMap<>(eventTypeValues); + protected void setEventTypeValues( + final Map eventTypeValues + ) { + this.eventTypeValues = Optional + .ofNullable(eventTypeValues) + .map(values -> new HashMap<>(values)) + .map(values -> (Map) values) + .orElse(Collections.emptyMap()); } public List getVariants() { - return Collections.unmodifiableList(variants); + return Optional + .ofNullable(variants) + .map(Collections::unmodifiableList) + .orElse(Collections.emptyList()); } protected void setVariants(final List variants) { - this.variants = new ArrayList<>(variants); + this.variants = Optional + .ofNullable(variants) + .map(list -> new ArrayList<>(list)) + .map(list -> (List) list) + .orElse(Collections.emptyList()); } public List getUnusedLocales() { - return Collections.unmodifiableList(unusedLocales); + return Optional + .ofNullable(unusedLocales) + .map(Collections::unmodifiableList) + .orElse(Collections.emptyList()); } protected void setUnusedLocales(final List unusedLocales) { - this.unusedLocales = new ArrayList<>(unusedLocales); + this.unusedLocales = Optional + .ofNullable(unusedLocales) + .map(list -> new ArrayList<>(list)) + .map(list -> (List) list) + .orElse(Collections.emptyList()); } public String getSelectedLocale() { @@ -86,5 +110,5 @@ public class MvcEventInfoStepEventTypeModel { protected void setCanEdit(final boolean canEdit) { this.canEdit = canEdit; } - + } diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepLocationModel.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepLocationModel.java index 6d3e773ce..cdbe7abc6 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepLocationModel.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepLocationModel.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import javax.enterprise.context.RequestScoped; import javax.inject.Named; @@ -48,27 +49,48 @@ public class MvcEventInfoStepLocationModel { private String selectedLocale; public Map getLocationValues() { - return Collections.unmodifiableMap(locationValues); + return Optional + .ofNullable(locationValues) + .map(Collections::unmodifiableMap) + .orElse(Collections.emptyMap()); } protected void setLocationValues(final Map locationValues) { - this.locationValues = new HashMap<>(locationValues); + this.locationValues = Optional + .ofNullable(locationValues) + .map(values -> new HashMap<>(values)) + .map(values -> (Map) values) + .orElse(Collections.emptyMap()); } - public List getVariants() { - return Collections.unmodifiableList(variants); + public List getVariants() { + return Optional + .ofNullable(variants) + .map(Collections::unmodifiableList) + .orElse(Collections.emptyList()); } protected void setVariants(final List variants) { - this.variants = new ArrayList<>(variants); + this.variants = Optional + .ofNullable(variants) + .map(list -> new ArrayList<>(list)) + .map(list -> (List) list) + .orElse(Collections.emptyList()); } public List getUnusedLocales() { - return Collections.unmodifiableList(unusedLocales); + return Optional + .ofNullable(unusedLocales) + .map(Collections::unmodifiableList) + .orElse(Collections.emptyList()); } protected void setUnusedLocales(final List unusedLocales) { - this.unusedLocales = new ArrayList<>(unusedLocales); + this.unusedLocales = Optional + .ofNullable(unusedLocales) + .map(list -> new ArrayList<>(list)) + .map(list -> (List) list) + .orElse(Collections.emptyList()); } public String getSelectedLocale() { diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepMainContributorModel.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepMainContributorModel.java index 3a8a53449..faab96494 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepMainContributorModel.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepMainContributorModel.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import javax.enterprise.context.RequestScoped; import javax.inject.Named; @@ -36,8 +37,8 @@ import javax.inject.Named; @RequestScoped @Named("CmsEventInfoStepMainContributor") public class MvcEventInfoStepMainContributorModel { - - private boolean canEdit; + + private boolean canEdit; private Map contributorValues; @@ -48,29 +49,50 @@ public class MvcEventInfoStepMainContributorModel { private String selectedLocale; public Map getContributorValues() { - return Collections.unmodifiableMap(contributorValues); + return Optional + .ofNullable(contributorValues) + .map(Collections::unmodifiableMap) + .orElse(Collections.emptyMap()); } protected void setContributorValues( final Map contributorValues ) { - this.contributorValues = new HashMap<>(contributorValues); + this.contributorValues = Optional + .ofNullable(contributorValues) + .map(values -> new HashMap<>(values)) + .map(values -> (Map) values) + .orElse(Collections.emptyMap()); } public List getVariants() { - return Collections.unmodifiableList(variants); + return Optional + .ofNullable(variants) + .map(Collections::unmodifiableList) + .orElse(Collections.emptyList()); } protected void setVariants(final List variants) { - this.variants = new ArrayList<>(variants); + this.variants = Optional + .ofNullable(variants) + .map(list -> new ArrayList<>(list)) + .map(list -> (List) list) + .orElse(Collections.emptyList()); } public List getUnusedLocales() { - return Collections.unmodifiableList(unusedLocales); + return Optional + .ofNullable(unusedLocales) + .map(Collections::unmodifiableList) + .orElse(Collections.emptyList()); } protected void setUnusedLocales(final List unusedLocales) { - this.unusedLocales = new ArrayList<>(unusedLocales); + this.unusedLocales = Optional + .ofNullable(unusedLocales) + .map(list -> new ArrayList<>(list)) + .map(list -> (List) list) + .orElse(Collections.emptyList()); } public String getSelectedLocale() { @@ -88,5 +110,5 @@ public class MvcEventInfoStepMainContributorModel { protected void setCanEdit(final boolean canEdit) { this.canEdit = canEdit; } - + } diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventPropertiesStep.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventPropertiesStep.java index 2cf4d5bc4..bf73f831e 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventPropertiesStep.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventPropertiesStep.java @@ -176,24 +176,55 @@ public class MvcEventPropertiesStep extends AbstractMvcAuthoringStep { ); final Event event = (Event) getDocument(); + final DateTimeFormatter isoDateFormatter + = DateTimeFormatter.ISO_LOCAL_DATE.withZone(ZoneId.systemDefault()); + final DateTimeFormatter isoTimeFormatter + = DateTimeFormatter.ISO_TIME.withZone(ZoneId.systemDefault()); final DateTimeFormatter isoDateTimeFormatter - = DateTimeFormatter.ISO_DATE_TIME.withZone(ZoneId.systemDefault()); + = DateTimeFormatter.ISO_LOCAL_DATE_TIME + .withZone(ZoneId.systemDefault()); - eventPropertiesStepModel.setStartDate( + eventPropertiesStepModel.setStartDateTime( Optional .ofNullable(event.getStartDate()) .map(startDate -> startDate.toInstant()) .map(startDate -> isoDateTimeFormatter.format(startDate)) .orElse("") ); + eventPropertiesStepModel.setFormattedStartDateTime( + Optional + .ofNullable(event.getStartDate()) + .map(startDate -> startDate.toInstant()) + .map( + startDate -> String.format( + "%s %s", + isoDateFormatter.format(startDate), + isoTimeFormatter.format(startDate) + ) + ) + .orElse("") + ); - eventPropertiesStepModel.setEndDate( + eventPropertiesStepModel.setEndDateTime( Optional .ofNullable(event.getEndDate()) .map(endDate -> endDate.toInstant()) .map(endDate -> isoDateTimeFormatter.format(endDate)) .orElse("") ); + eventPropertiesStepModel.setFormattedEndDateTime( + Optional + .ofNullable(event.getEndDate()) + .map(endDate -> endDate.toInstant()) + .map( + endDate -> String.format( + "%s %s", + isoDateFormatter.format(endDate), + isoTimeFormatter.format(endDate) + ) + ) + .orElse("") + ); eventPropertiesStepModel.setMapLink(event.getMapLink()); } @@ -278,10 +309,10 @@ public class MvcEventPropertiesStep extends AbstractMvcAuthoringStep { } @POST - @Path("/eventproperties") + @Path("/eventdatetime") @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) - public String updateEventProperties( + public String updateEventDateTime( @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) final String sectionIdentifier, @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) @@ -289,11 +320,7 @@ public class MvcEventPropertiesStep extends AbstractMvcAuthoringStep { @FormParam("startDateTime") final String startDateTime, @FormParam("endDateTime") - final String endDateTime, - @FormParam("timeZone") - final String timeZone, - @FormParam("mapLink") - final String mapLink + final String endDateTime ) { try { init(); @@ -307,7 +334,7 @@ public class MvcEventPropertiesStep extends AbstractMvcAuthoringStep { final Event event = (Event) getDocument(); final DateTimeFormatter isoDateTimeFormatter = DateTimeFormatter.ISO_DATE_TIME - .withZone(ZoneId.of(timeZone)); + .withZone(ZoneId.systemDefault()); event.setStartDate( Date.from( ZonedDateTime.parse( @@ -325,6 +352,42 @@ public class MvcEventPropertiesStep extends AbstractMvcAuthoringStep { ).toInstant() ) ); + + itemRepo.save(event); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDocument(), + getLabel() + ); + } + } + + @POST + @Path("/maplink") + @AuthorizationRequired + @Transactional(Transactional.TxType.REQUIRED) + public String updateMapLink( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @FormParam("mapLink") + final String mapLink + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDocument())) { + final Event event = (Event) getDocument(); + event.setMapLink(mapLink); itemRepo.save(event); diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventPropertiesStepModel.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventPropertiesStepModel.java index d57a366bb..ce022210e 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventPropertiesStepModel.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventPropertiesStepModel.java @@ -45,9 +45,13 @@ public class MvcEventPropertiesStepModel { private List unusedDescriptionLocales; - private String startDate; + private String startDateTime; - private String endDate; + private String formattedStartDateTime; + + private String endDateTime; + + private String formattedEndDateTime; private String mapLink; @@ -97,20 +101,44 @@ public class MvcEventPropertiesStepModel { ); } - public String getStartDate() { - return startDate; + public String getStartDateTime() { + return startDateTime; } - public void setStartDate(final String startDate) { - this.startDate = startDate; + public void setStartDateTime(final String startDateTime) { + this.startDateTime = startDateTime; } - public String getEndDate() { - return endDate; + public String getFormattedStartDateTime() { + return formattedStartDateTime; } - public void setEndDate(final String endDate) { - this.endDate = endDate; + public void setFormattedStartDateTime(final String formattedStartDateTime) { + this.formattedStartDateTime = formattedStartDateTime; + } + + public boolean getHasStartDate() { + return !startDateTime.isBlank(); + } + + public String getEndDateTime() { + return endDateTime; + } + + public void setEndDateTime(final String endDateTime) { + this.endDateTime = endDateTime; + } + + public String getFormattedEndDateTime() { + return formattedEndDateTime; + } + + public void setFormattedEndDateTime(final String formattedEndDateTime) { + this.formattedEndDateTime = formattedEndDateTime; + } + + public boolean getHasEndDate() { + return !endDateTime.isBlank(); } public String getMapLink() { @@ -121,4 +149,8 @@ public class MvcEventPropertiesStepModel { this.mapLink = mapLink; } + public boolean getHasMapLink() { + return !mapLink.isBlank(); + } + } diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/create-event.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/create-event.xhtml index fbd2c9d50..19c7721d6 100644 --- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/create-event.xhtml +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/create-event.xhtml @@ -47,6 +47,14 @@ required="true" /> + +

#{CmsEventMessageBundle.getMessage('basicproperties.header', [CmsEventPropertiesStep.name])}

-

#{CmsEventPropertiesStep.getMessage('basicproperties.name.header')}

+

#{CmsEventMessageBundle['basicproperties.name.header']}

#{CmsEventPropertiesStep.name}
@@ -41,7 +41,7 @@ +
+
#{CmsEventMessageBundle['basicproperties.startdate']}
+
+ #{CmsEventPropertiesStep.hasStartDate ? CmsEventPropertiesStep.formattedStartDateTime : CmsEventMessageBundle['basicproperties.startdate.none']} +
+
#{CmsEventMessageBundle['basicproperties.enddate']}
+
+ #{CmsEventPropertiesStep.hasEndDate ? CmsEventPropertiesStep.formattedEndDateTime : CmsEventMessageBundle['basicproperties.enddate.none']} +
+
+ + - + diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/event-info-tmp.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/event-info-tmp.xhtml new file mode 100644 index 000000000..23f57d074 --- /dev/null +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/event-info-tmp.xhtml @@ -0,0 +1,86 @@ +]> + + + + + + +

#{CmsEventMessageBundle['eventinfo_step.header']}

+ + + + + + + + + +
+ + + + + +
+ + + diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/event-info.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/event-info.xhtml index 570b85f84..3e467df17 100644 --- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/event-info.xhtml +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/event-info.xhtml @@ -12,7 +12,7 @@

#{CmsEventMessageBundle['eventinfo_step.header']}

- + - + - + - + - +
- + diff --git a/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_28__make_event_startdate_nullable.sql b/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_28__make_event_startdate_nullable.sql new file mode 100644 index 000000000..2c666b3ff --- /dev/null +++ b/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_28__make_event_startdate_nullable.sql @@ -0,0 +1 @@ +alter table ccm_cms.events alter COLUMN start_date drop not null; \ No newline at end of file diff --git a/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/pgsql/V7_0_0_28__make_event_startdate_nullable.sql b/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/pgsql/V7_0_0_28__make_event_startdate_nullable.sql new file mode 100644 index 000000000..2c666b3ff --- /dev/null +++ b/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/pgsql/V7_0_0_28__make_event_startdate_nullable.sql @@ -0,0 +1 @@ +alter table ccm_cms.events alter COLUMN start_date drop not null; \ No newline at end of file diff --git a/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle.properties b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle.properties index c78a0d443..691fb695c 100644 --- a/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle.properties +++ b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle.properties @@ -1,5 +1,5 @@ -authoringsteps.basicproperties.description=General properties of an event, for example the begin and end date. +authoringsteps.basicproperties.description=General properties of an event, for example the start and end of the event. authoringsteps.basicproperties.label=Basic Properties authoringsteps.info.description=Extended information about the event, for example about the location. authoringstep.info.label=Event Info @@ -44,3 +44,73 @@ eventinfo_step.main_contributor.header.edit=Edit information about the organizer eventinfo_step.location.editor.header=Informatio about the location of the event eventinfo_step.location.header.edit=Edit information about the location of event {0} for language {1} eventinfo_step.main_contributor.editor.header=Information about the organizier of the event +createform.initial_locale.label=Initial Locale +createform.summary.label=Summary +createform.workflow.help=The workflow to use for the new event. +basicproperties.eventdatetime.header=Start and End of the Event +basicproperties.startdate=Start of the event +basicproperties.enddate=End of the event +createform.startdate.help=Date and time of the start of the event. +createform.startdate.label=Start of the event +createstep.startdate.error.missing=The start of event set. +basicproperties.startdate.edit=Edit start of event +basicproperties.enddate.edit=Edit end of event +basicproperties.eventdatetime.edit=Edit +createstep.startdate.error.malformed=The date/time for the start of the event is malformed. +basicproperties.header=Edit basic properties of event {0} +basicproperties.name.header=Name +basicproperties.name.edit=Edit name +basicproperties.description.header=Description +basicproperties.name.edit.close=Cancel +basicproperties.name.edit.title=Edit name of event +basicproperties.name.help=The name of the event. Can only contain the letters a to z and A to Z, numbers, the underscore ("_") and the dash ("-"). +basicproperties.name.label=Name +basicproperties.name.edit.submit=Update name of event +basicproperties.title.add=Add locale +basicproperties.title.add.cancel=Cancel +basicproperties.title.add.locale.help=The language to add. +basicproperties.title.add.locale.label=Locale +basicproperties.title.add.submit=Add locale +basicproperties.title.add.header=Add title locale +basicproperties.title.add.value.help=The localized title of the event. +basicproperties.title.add.value.label=Title +basicproperties.title.edit=Edit +basicproperties.title.edit.cancel=Cancel +basicproperties.title.edit.submit=Save +basicproperties.title.edit.header=Edit title +basicproperties.title.edit.value.help=The localized title of the event. +basicproperties.title.edit.value.label=Title +basicproperties.title.remove=Remove +basicproperties.title.remove.cancel=Cancel +basicproperties.title.remove.submit=Remove +basicproperties.title.remove.text=Are you sure to remove the localized title for the folloing locale? +basicproperties.title.remove.header=Remove localized title +basicproperties.title.header=Title +basicproperties.description.add=Add localized description +basicproperties.description.add.cancel=Cancel +basicproperties.description.add.locale.help=The locale of the localized description. +basicproperties.description.add.locale.label=Locale +basicproperties.description.add.submit=Add localized description +basicproperties.description.add.header=Add localized description +basicproperties.description.add.value.help=The localized description. +basicproperties.description.add.value.label=Description +basicproperties.description.edit=Edit +basicproperties.description.edit.cancel=Cancel +basicproperties.description.edit.submit=Submit +basicproperties.description.edit.header=Edit localized description +basicproperties.description.edit.value.help=The localized description. +basicproperties.description.edit.value.label=Description +basicproperties.description.remove=Remove +basicproperties.description.remove.cancel=Cancel +basicproperties.description.remove.submit=Remove localized description +basicproperties.description.remove.text=Are you sure to remove the localized description for this locale? +basicproperties.description.remove.header=Remove localized description +basicproperties.startdate.none=Start of event is missing. +basicproperties.enddate.none=End of event is missing +basicproperties.eventdatetime.edit.dialog.title=Edit start and end of the event +basicproperties.eventdatetime.edit.dialog.close=Cancel +basicproperties.eventdatetime.edit.dialog.startdate.help=Start of the event (date and time). +basicproperties.eventdatetime.edit.dialog.startdate.label=Start +basicproperties.eventdatetime.edit.dialog.enddate.help=The end of the event (date and time) +basicproperties.eventdatetime.edit.dialog.enddate.label=End +basicproperties.eventdatetime.edit.dialog.submit=Submit diff --git a/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle_de.properties b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle_de.properties index 657713b94..43402db17 100644 --- a/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle_de.properties +++ b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle_de.properties @@ -14,7 +14,7 @@ createstep.workflow.error.not_available=Der ausgew\u00e4hlte Arbeitsablauf ist n createform.title=Eine neue Veranstaltung anlegen createform.name.help=Der Name der neuen Veranstaltung. Darf nur die Buchstaben a bis z, A bis Z, Ziffern, den Bindestrich ("-") und den Unterstrich ("_") enthalten. createform.name.label=Name -createform.initial_locale.help=Die initiale Sprache der neuen Veranstaltung. Alle lokalisierbaren Angaben in diesem Formular werden f\u00fcr diese Sprache angelegt. +createform.initial_locale.help=Initiale Sprache createform.title.help=Der Titel der neuen Veranstaltung. createform.title.label=Titel createform.summary.help=Eine kurze Zusammenfassung der neuen Veranstaltung. @@ -44,3 +44,73 @@ eventinfo_step.main_contributor.header.edit=Informationen \u00fcber den Veransta eventinfo_step.location.editor.header=Informationen \u00fcber den Ort der Veranstaltung eventinfo_step.location.header.edit=Informationen \u00fcber den Ort der Veranstaltung {0} f\u00fcr Sprache {1} bearbeiten eventinfo_step.main_contributor.editor.header=Informationen \u00fcber den Veranstalter +createform.initial_locale.label=Initial Locale +createform.summary.label=Zusammenfassung +createform.workflow.help=Der Arbeitsablauf, der f\u00fcr die neue Veranstaltung verwendet wird. +basicproperties.eventdatetime.header=Beginn und Ende der Veranstaltung +basicproperties.startdate=Beginn der Veranstaltung +basicproperties.enddate=Ende der Veranstaltung +createform.startdate.help=Datum und Uhrzeit des Beginns der Veranstaltung. +createform.startdate.label=Beginn der Veranstaltung +createstep.startdate.error.missing=Der Beginn der Veranstaltugn wurde nicht angegeben. +basicproperties.startdate.edit=Beginn der Veranstaltung bearbeiten +basicproperties.enddate.edit=Ende der Veranstaltung bearbeiten +basicproperties.eventdatetime.edit=Bearbeiten +createstep.startdate.error.malformed=Der Zeitpunkt f\u00fcr den Beginn der Veranstaltung ist keine valide Datums-/Zeitangabe. +basicproperties.header=Basiseigenschaften der Veranstaltung {0} bearbeiten +basicproperties.name.header=Name +basicproperties.name.edit=Name bearbeiten +basicproperties.description.header=Beschreibung +basicproperties.name.edit.close=Abbrechen +basicproperties.name.edit.title=Name der Veranstaltung bearbeiten +basicproperties.name.help=Der Name der Veranstaltung. Darf nur die Buchstaben a bis z, A bis Z, Ziffern, den Bindestrich ("-") und den Unterstrich ("_") enthalten. +basicproperties.name.label=Name +basicproperties.name.edit.submit=Name der Veranstaltung aktualisieren +basicproperties.title.add=Sprache hinzuf\u00fcgen +basicproperties.title.add.cancel=Abbrechen +basicproperties.title.add.locale.help=Die Sprache, die hinzugef\u00fcgt wird. +basicproperties.title.add.locale.label=Sprache +basicproperties.title.add.submit=Sprache hinzuf\u00fcgen +basicproperties.title.add.header=Titel f\u00fcr Sprache hinzuf\u00fcgen +basicproperties.title.add.value.help=Der lokalisierte Titel der Veranstaltung. +basicproperties.title.add.value.label=Titel +basicproperties.title.edit=Bearbeiten +basicproperties.title.edit.cancel=Abbrechen +basicproperties.title.edit.submit=Speichern +basicproperties.title.edit.header=Titel bearbeiten +basicproperties.title.edit.value.help=Der lokalisierte Titel der Veranstaltung. +basicproperties.title.edit.value.label=Titel +basicproperties.title.remove=Entfernen +basicproperties.title.remove.cancel=Abbrechen +basicproperties.title.remove.submit=Entfernen +basicproperties.title.remove.text=Sind Sie sicher, dass den lokalisierten Titel f\u00fcr diese Sprache entfernen wollen? +basicproperties.title.remove.header=Lokalisierten Titel entfernen +basicproperties.title.header=Titel +basicproperties.description.add=Lokalisierte Beschreibung hinzuf\u00fcgen +basicproperties.description.add.cancel=Abbrechen +basicproperties.description.add.locale.help=Die Sprache der lokalisierten Beschreibung. +basicproperties.description.add.locale.label=Sprache +basicproperties.description.add.submit=Lokalisierte Beschreibung hinzuf\u00fcgen +basicproperties.description.add.header=Lokalisierte Beschreibung hinzuf\u00fcgen +basicproperties.description.add.value.help=Die lokalisierte Beschreibung. +basicproperties.description.add.value.label=Beschreibung +basicproperties.description.edit=Bearbeiten +basicproperties.description.edit.cancel=Abbrechen +basicproperties.description.edit.submit=Speichern +basicproperties.description.edit.header=Lokalisierte Beschreibung bearbeiten +basicproperties.description.edit.value.help=Die lokalisierte Beschreibung. +basicproperties.description.edit.value.label=Beschreibung +basicproperties.description.remove=Entfernen +basicproperties.description.remove.cancel=Abbrechen +basicproperties.description.remove.submit=Lokalisierte Beschreibung entfernen +basicproperties.description.remove.text=Sind Sie sicher, dass Sie die lokalisierte Beschreibung f\u00fcr diese Sprache entfernen wollen? +basicproperties.description.remove.header=Lokalisierte Beschreibung entfernen +basicproperties.startdate.none=Es wurde keine Begin angegeben. +basicproperties.enddate.none=Es wurde keine Ende der Veranstaltung angegeben. +basicproperties.eventdatetime.edit.dialog.title=Beginn und Ende der Veranstaltung bearbeiten +basicproperties.eventdatetime.edit.dialog.close=Abbrechen +basicproperties.eventdatetime.edit.dialog.startdate.help=Beginn und Ende der Veranstaltung (Datum und Uhrzeit) +basicproperties.eventdatetime.edit.dialog.startdate.label=Beginn +basicproperties.eventdatetime.edit.dialog.enddate.help=Ende der Veranstaltung (Datum und Uhrzeit) +basicproperties.eventdatetime.edit.dialog.enddate.label=Ende +basicproperties.eventdatetime.edit.dialog.submit=Speichern -- 2.52.0 From 84c2f9a858654ab75b691e5e36ee48a014446a21 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Sun, 6 Feb 2022 09:48:29 +0100 Subject: [PATCH 7/9] Some more bugfixes for the authoring steps of the event content type. --- .../contenttypes/event/MvcEventInfoStep.java | 152 ++++++++++++++++-- .../event/MvcEventInfoStepEventDateModel.java | 6 +- .../contenttypes/event/event-info-tmp.xhtml | 6 +- 3 files changed, 146 insertions(+), 18 deletions(-) diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStep.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStep.java index a3e7d069e..c7a7c9120 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStep.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStep.java @@ -25,12 +25,16 @@ import org.librecms.contenttypes.Event; import org.librecms.ui.contentsections.ContentSectionNotFoundException; import org.librecms.ui.contentsections.ItemPermissionChecker; import org.librecms.ui.contentsections.documents.AbstractMvcAuthoringStep; +import org.librecms.ui.contentsections.documents.CmsEditorUtil; import org.librecms.ui.contentsections.documents.DocumentNotFoundException; import org.librecms.ui.contentsections.documents.DocumentUi; import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef; import org.librecms.ui.contentsections.documents.MvcAuthoringSteps; import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; @@ -771,7 +775,7 @@ public class MvcEventInfoStep extends AbstractMvcAuthoringStep { final Locale locale = new Locale(localeParam); getEvent().getEventType().removeValue(locale); itemRepo.save(getEvent()); - + return buildRedirectPathForStep(); } else { return documentUi.showAccessDenied( @@ -787,24 +791,148 @@ public class MvcEventInfoStep extends AbstractMvcAuthoringStep { DocumentNotFoundException { super.init(); - if (itemPermissionChecker.canEditItem(getEvent())) { - eventDateModel.setCanEdit( - itemPermissionChecker.canEditItem(getEvent()) + final boolean canEdit = itemPermissionChecker.canEditItem(getEvent()); + if (canEdit) { + + eventDateModel.setCanEdit(canEdit); + eventDateModel.setEventDateValues( + getEvent() + .getEventDate() + .getValues() + .entrySet() + .stream() + .collect( + Collectors.toMap( + entry -> entry.getKey().toString(), + Map.Entry::getValue + ) + ) + ); + eventDateModel.setVariants( + getEvent() + .getEventDate() + .getValues() + .entrySet() + .stream() + .map(CmsEditorUtil::buildVariantRow) + .collect(Collectors.toList()) + ); + final Set eventDateLocales = getEvent() + .getEventDate() + .getAvailableLocales(); + eventDateModel.setUnusedLocales( + globalizationHelper + .getAvailableLocales() + .stream() + .filter(locale -> !eventDateLocales.contains(locale)) + .map(Locale::toString) + .collect(Collectors.toList()) ); - locationModel.setCanEdit( - itemPermissionChecker.canEditItem(getEvent()) + locationModel.setCanEdit(canEdit); + locationModel.setLocationValues( + getEvent() + .getLocation() + .getValues() + .entrySet() + .stream() + .collect( + Collectors.toMap( + entry -> entry.getKey().toString(), + Map.Entry::getValue + ) + ) + ); + locationModel.setVariants( + getEvent() + .getEventDate() + .getValues() + .entrySet() + .stream() + .map(CmsEditorUtil::buildVariantRow) + .collect(Collectors.toList()) + ); + final Set locationLocales = getEvent() + .getLocation() + .getAvailableLocales(); + locationModel.setUnusedLocales( + globalizationHelper + .getAvailableLocales() + .stream() + .filter(locale -> !locationLocales.contains(locale)) + .map(Locale::toString) + .collect(Collectors.toList()) ); - mainContributorModel.setCanEdit( - itemPermissionChecker.canEditItem(getEvent()) + mainContributorModel.setCanEdit(canEdit); + mainContributorModel.setContributorValues( + getEvent() + .getMainContributor() + .getValues() + .entrySet() + .stream() + .collect( + Collectors.toMap( + entry -> entry.getKey().toString(), + Map.Entry::getValue + ) + ) + ); + mainContributorModel.setVariants( + getEvent() + .getMainContributor() + .getValues() + .entrySet() + .stream() + .map(CmsEditorUtil::buildVariantRow) + .collect(Collectors.toList()) + ); + final Set contributorLocales = getEvent() + .getMainContributor() + .getAvailableLocales(); + mainContributorModel.setUnusedLocales( + globalizationHelper + .getAvailableLocales() + .stream() + .filter(locale -> !contributorLocales.contains(locale)) + .map(Locale::toString) + .collect(Collectors.toList()) ); - eventTypeModel.setCanEdit( - itemPermissionChecker.canEditItem(getEvent()) + eventTypeModel.setCanEdit(canEdit); + eventTypeModel.setEventTypeValues( + getEvent() + .getEventType() + .getValues() + .entrySet() + .stream() + .collect( + Collectors.toMap( + entry -> entry.getKey().toString(), + Map.Entry::getValue + ) + ) + ); + eventTypeModel.setVariants( + getEvent() + .getEventType() + .getValues() + .entrySet() + .stream() + .map(CmsEditorUtil::buildVariantRow) + .collect(Collectors.toList()) + ); + final Set eventTypeLocales = getEvent() + .getEventType() + .getAvailableLocales(); + eventTypeModel.setUnusedLocales( + globalizationHelper + .getAvailableLocales() + .stream() + .filter(locale -> !eventTypeLocales.contains(locale)) + .map(Locale::toString) + .collect(Collectors.toList()) ); - - // toDo } } diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventDateModel.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventDateModel.java index 58890e4ca..8ca9fc415 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventDateModel.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventDateModel.java @@ -36,7 +36,7 @@ import javax.inject.Named; */ @RequestScoped @Named("CmsEventInfoStepEventDate") -class MvcEventInfoStepEventDateModel { +public class MvcEventInfoStepEventDateModel { private boolean canEdit; @@ -81,12 +81,12 @@ class MvcEventInfoStepEventDateModel { } public List getUnusedLocales() { - return Optional + return Optional .ofNullable(unusedLocales) .map(Collections::unmodifiableList) .orElse(Collections.emptyList()); } - + protected void setUnusedLocales(final List unusedLocales) { this.unusedLocales = Optional .ofNullable(unusedLocales) diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/event-info-tmp.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/event-info-tmp.xhtml index 23f57d074..ca46823f2 100644 --- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/event-info-tmp.xhtml +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/event/event-info-tmp.xhtml @@ -28,7 +28,7 @@ variants="#{CmsEventInfoStepEventDate.variants}" viewPageUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@event-info/view" /> - + - + - + Date: Mon, 7 Feb 2022 21:08:09 +0100 Subject: [PATCH 8/9] Some more bugfixes for event. --- .../contenttypes/event/MvcEventInfoStep.java | 60 +++++++++---------- .../event/MvcEventInfoStepResources.java | 12 ++-- .../librecms/cmsEditorVariants.xhtml | 37 +++++++----- .../ui/contenttypes/event/event-info.xhtml | 20 ++++--- .../contenttypes/event/eventdate/edit.xhtml | 24 ++++---- .../contenttypes/event/eventdate/view.xhtml | 2 +- .../contenttypes/event/eventtype/edit.xhtml | 24 ++++---- .../contenttypes/event/eventtype/view.xhtml | 2 +- .../ui/contenttypes/event/location/edit.xhtml | 24 ++++---- .../ui/contenttypes/event/location/view.xhtml | 2 +- .../event/main-contributor/edit.xhtml | 24 ++++---- .../event/main-contributor/view.xhtml | 2 +- .../ui/contenttypes/EventBundle.properties | 1 + .../ui/contenttypes/EventBundle_de.properties | 1 + .../event-info-step-eventdate.ts | 52 ++++++++++++++++ .../event-info-step-eventtype.ts | 52 ++++++++++++++++ .../event-info-step-location.ts | 52 ++++++++++++++++ .../event-info-step-maincontributor.ts | 52 ++++++++++++++++ ccm-cms/webpack.config.js | 4 ++ 19 files changed, 336 insertions(+), 111 deletions(-) create mode 100644 ccm-cms/src/main/typescript/content-sections/event-info-step-eventdate.ts create mode 100644 ccm-cms/src/main/typescript/content-sections/event-info-step-eventtype.ts create mode 100644 ccm-cms/src/main/typescript/content-sections/event-info-step-location.ts create mode 100644 ccm-cms/src/main/typescript/content-sections/event-info-step-maincontributor.ts diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStep.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStep.java index c7a7c9120..286b6f57d 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStep.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStep.java @@ -52,7 +52,7 @@ import javax.ws.rs.PathParam; * @author Jens Pelzetter */ @RequestScoped -@Path(MvcAuthoringSteps.PATH_PREFIX + "@event-info") +@Path(MvcAuthoringSteps.PATH_PREFIX + "event-info") @Controller @MvcAuthoringStepDef( bundle = EventStepsConstants.BUNDLE, @@ -277,7 +277,7 @@ public class MvcEventInfoStep extends AbstractMvcAuthoringStep { if (itemPermissionChecker.canEditItem(getEvent())) { final Locale locale = new Locale(localeParam); - getEvent().getText().removeValue(locale); + getEvent().getEventDate().removeValue(locale); itemRepo.save(getEvent()); return buildRedirectPathForStep(); @@ -510,7 +510,7 @@ public class MvcEventInfoStep extends AbstractMvcAuthoringStep { ); } final Locale locale = new Locale(localeParam); - getEvent().getText().putValue(locale, value); + getEvent().getMainContributor().putValue(locale, value); itemRepo.save(getEvent()); return buildRedirectPathForStep(); @@ -557,9 +557,9 @@ public class MvcEventInfoStep extends AbstractMvcAuthoringStep { } @POST - @Path("/main-contributor/add") + @Path("/main-contributor/edit/{locale}") @Transactional(Transactional.TxType.REQUIRED) - public String addMainContributorValue( + public String editMainContributorValue( @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) final String sectionIdentifier, @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) @@ -675,7 +675,7 @@ public class MvcEventInfoStep extends AbstractMvcAuthoringStep { ); } final Locale locale = new Locale(localeParam); - getEvent().getEventDate().putValue(locale, value); + getEvent().getEventType().putValue(locale, value); itemRepo.save(getEvent()); return buildRedirectPathForStep(); @@ -689,7 +689,7 @@ public class MvcEventInfoStep extends AbstractMvcAuthoringStep { } @GET - @Path("/eventdate/edit/{locale}") + @Path("/eventtype/edit/{locale}") @Transactional(Transactional.TxType.REQUIRED) public String editEventTypeValue( @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @@ -720,7 +720,7 @@ public class MvcEventInfoStep extends AbstractMvcAuthoringStep { } @POST - @Path("/eventdate/edit/{locale}") + @Path("/eventtype/edit/{locale}") @Transactional(Transactional.TxType.REQUIRED) public String editEventTypeValue( @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @@ -754,7 +754,7 @@ public class MvcEventInfoStep extends AbstractMvcAuthoringStep { } @POST - @Path("/eventdate/remove/{locale}") + @Path("/eventtype/remove/{locale}") @Transactional(Transactional.TxType.REQUIRED) public String removeEventTypeValue( @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @@ -845,7 +845,7 @@ public class MvcEventInfoStep extends AbstractMvcAuthoringStep { ); locationModel.setVariants( getEvent() - .getEventDate() + .getLocation() .getValues() .entrySet() .stream() @@ -902,36 +902,36 @@ public class MvcEventInfoStep extends AbstractMvcAuthoringStep { eventTypeModel.setCanEdit(canEdit); eventTypeModel.setEventTypeValues( getEvent() - .getEventType() - .getValues() - .entrySet() - .stream() - .collect( - Collectors.toMap( - entry -> entry.getKey().toString(), - Map.Entry::getValue + .getEventType() + .getValues() + .entrySet() + .stream() + .collect( + Collectors.toMap( + entry -> entry.getKey().toString(), + Map.Entry::getValue + ) ) - ) ); eventTypeModel.setVariants( getEvent() - .getEventType() - .getValues() - .entrySet() - .stream() - .map(CmsEditorUtil::buildVariantRow) - .collect(Collectors.toList()) + .getEventType() + .getValues() + .entrySet() + .stream() + .map(CmsEditorUtil::buildVariantRow) + .collect(Collectors.toList()) ); final Set eventTypeLocales = getEvent() .getEventType() .getAvailableLocales(); eventTypeModel.setUnusedLocales( globalizationHelper - .getAvailableLocales() - .stream() - .filter(locale -> !eventTypeLocales.contains(locale)) - .map(Locale::toString) - .collect(Collectors.toList()) + .getAvailableLocales() + .stream() + .filter(locale -> !eventTypeLocales.contains(locale)) + .map(Locale::toString) + .collect(Collectors.toList()) ); } } diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepResources.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepResources.java index d44766652..210f1fa9d 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepResources.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepResources.java @@ -139,7 +139,7 @@ public class MvcEventInfoStepResources { // Location @GET - @Path("/eventdate/wordcount/{locale}") + @Path("/location/wordcount/{locale}") @Produces(MediaType.TEXT_HTML) @Transactional(Transactional.TxType.REQUIRED) public String getLocationWordCount( @@ -181,7 +181,7 @@ public class MvcEventInfoStepResources { } @GET - @Path("/eventdate/{locale}") + @Path("/location/{locale}") @Produces(MediaType.TEXT_HTML) @Transactional(Transactional.TxType.REQUIRED) public String viewLocationValue( @@ -217,7 +217,7 @@ public class MvcEventInfoStepResources { // Main Contributor @GET - @Path("/eventdate/wordcount/{locale}") + @Path("/main-contributor/wordcount/{locale}") @Produces(MediaType.TEXT_HTML) @Transactional(Transactional.TxType.REQUIRED) public String getMainContributorWordCount( @@ -259,7 +259,7 @@ public class MvcEventInfoStepResources { } @GET - @Path("/eventdate/{locale}") + @Path("/main-contributor/{locale}") @Produces(MediaType.TEXT_HTML) @Transactional(Transactional.TxType.REQUIRED) public String viewMainContributorValue( @@ -295,7 +295,7 @@ public class MvcEventInfoStepResources { // Event Type @GET - @Path("/eventdate/wordcount/{locale}") + @Path("/eventtype/wordcount/{locale}") @Produces(MediaType.TEXT_HTML) @Transactional(Transactional.TxType.REQUIRED) public String getEventTypeWordCount( @@ -337,7 +337,7 @@ public class MvcEventInfoStepResources { } @GET - @Path("/eventdate/{locale}") + @Path("/eventtype/{locale}") @Produces(MediaType.TEXT_HTML) @Transactional(Transactional.TxType.REQUIRED) public String viewEventTypeValue( diff --git a/ccm-cms/src/main/resources/META-INF/resources/components/librecms/cmsEditorVariants.xhtml b/ccm-cms/src/main/resources/META-INF/resources/components/librecms/cmsEditorVariants.xhtml index 6318a72a7..d084b0477 100644 --- a/ccm-cms/src/main/resources/META-INF/resources/components/librecms/cmsEditorVariants.xhtml +++ b/ccm-cms/src/main/resources/META-INF/resources/components/librecms/cmsEditorVariants.xhtml @@ -189,6 +189,13 @@ shortDescription="Info about the available variants. Must be a List of CmsEditorLocaleVariantRow objects." type="java.util.List" /> +