From 53956098fbfe83b5d1100ed7f9a5b4d3f957dd01 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Sat, 5 Feb 2022 19:52:57 +0100 Subject: [PATCH] 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