From c0788db033f19c9067947f93b9a1e9370a56a3d8 Mon Sep 17 00:00:00 2001 From: Telgou <119911609+Telgou@users.noreply.github.com> Date: Mon, 16 Sep 2024 17:28:14 +0100 Subject: [PATCH] Improvment: UI review of the events details body - EXO-73527 (#688) - Conducted UI review for the agenda event details body - Better ICS file generation on the server side and eventtitle only as subject if creator or updater --- .../builder/AgendaTemplateBuilder.java | 11 ++++- .../agenda/util/NotificationUtils.java | 42 +++++++++++++++++-- .../org/exoplatform/agenda/util/Utils.java | 12 +++++- agenda-webapps/package-lock.json | 4 +- .../locale/portlet/Agenda_fr.properties | 6 +-- .../src/main/webapp/skin/less/agenda.less | 21 ++++++++-- .../event/view/AgendaEventAttendees.vue | 2 +- .../components/event/view/AgendaEventIcs.vue | 11 ++--- .../event/view/AgendaEventsDetailsBody.vue | 10 ++--- .../AgendaConnectorContemporaryEvents.vue | 6 +-- 10 files changed, 96 insertions(+), 29 deletions(-) diff --git a/agenda-services/src/main/java/org/exoplatform/agenda/notification/builder/AgendaTemplateBuilder.java b/agenda-services/src/main/java/org/exoplatform/agenda/notification/builder/AgendaTemplateBuilder.java index 35097190c..296270a3a 100644 --- a/agenda-services/src/main/java/org/exoplatform/agenda/notification/builder/AgendaTemplateBuilder.java +++ b/agenda-services/src/main/java/org/exoplatform/agenda/notification/builder/AgendaTemplateBuilder.java @@ -118,7 +118,16 @@ protected MessageInfo makeMessage(NotificationContext ctx) { templateProvider, notification, timeZone); - MessageInfo messageInfo = buildMessageSubjectAndBody(templateContext, notification, pushNotificationURL); + MessageInfo messageInfo = new MessageInfo(); + long creatorIdentityId = event.getCreatorId(); + long modifierIdentityId = event.getModifierId(); + if((StringUtils.equals(eventModificationType, AgendaEventModificationType.ADDED.name()) && identityId == creatorIdentityId) + || (StringUtils.equals(eventModificationType, AgendaEventModificationType.UPDATED.name()) && identityId == modifierIdentityId)){ + messageInfo.subject(notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_TITLE)); + messageInfo.body(TemplateUtils.processGroovy(templateContext)); + } else { + messageInfo = buildMessageSubjectAndBody(templateContext, notification, pushNotificationURL); + } addIcsFile(notification, messageInfo, timeZone); Throwable exception = templateContext.getException(); logException(notification, exception); diff --git a/agenda-services/src/main/java/org/exoplatform/agenda/util/NotificationUtils.java b/agenda-services/src/main/java/org/exoplatform/agenda/util/NotificationUtils.java index 668928c47..8f3056e7d 100644 --- a/agenda-services/src/main/java/org/exoplatform/agenda/util/NotificationUtils.java +++ b/agenda-services/src/main/java/org/exoplatform/agenda/util/NotificationUtils.java @@ -13,6 +13,7 @@ import net.fortuna.ical4j.data.CalendarOutputter; import net.fortuna.ical4j.model.DateTime; +import net.fortuna.ical4j.model.ParameterList; import net.fortuna.ical4j.model.component.VEvent; import net.fortuna.ical4j.model.parameter.Cn; import net.fortuna.ical4j.model.property.*; @@ -52,6 +53,7 @@ import org.exoplatform.webui.utils.TimeConvertUtils; import static org.exoplatform.agenda.util.Utils.getICalTimeZone; +import static org.exoplatform.agenda.util.Utils.getResourceBundleLabel; public class NotificationUtils { @@ -848,7 +850,7 @@ private static final String getEventNotificationCreatorOrModifierUserName(Identi .map(t -> t.substring(0, 1).toUpperCase() + t.substring(1)) .collect(Collectors.joining(" ")); if(Utils.isExternal(identity.getRemoteId())) { - fullName += " " + "(" + Utils.getResourceBundleLabel(new Locale(Utils.getUserLanguage(identity.getRemoteId())), "external.label.tag") + ")"; + fullName += " " + "(" + getResourceBundleLabel(new Locale(Utils.getUserLanguage(identity.getRemoteId())), "external.label.tag") + ")"; } return fullName; } @@ -898,12 +900,21 @@ public static String getWebConferenceLink(Event event) { } public static final void addIcsFile(NotificationInfo notification, MessageInfo messageInfo, ZoneId timeZone) { - Attachment attachment = new Attachment(); + IdentityManager identityManager = ExoContainerContext.getService(IdentityManager.class); + SpaceService spaceService = ExoContainerContext.getService(SpaceService.class); + String ownerId = notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_OWNER_ID); + Identity identity = identityManager.getIdentity(ownerId); + Space space = identity!=null ? spaceService.getSpaceByPrettyName(identity.getRemoteId()) : null; + String spaceName = space == null ? null : space.getDisplayName(); + String eventConference = notification.getValueOwnerParameter(TEMPLATE_VARIABLE_EVENT_CONFERENCE); + String eventCreator = notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_CREATOR); + Attachment attachment = new Attachment(); /* Generate unique identifier */ UidGenerator ug = new RandomUidGenerator(); Uid uid = ug.generateUid(); /* Create the event */ String eventSummary = notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_TITLE); + String eventDescription = notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_DESCRIPTION); String startDateRFC3339 = notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_START_DATE); String endDateRFC3339 = notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_END_DATE); ZonedDateTime startDate = ZonedDateTime.parse(startDateRFC3339).withZoneSameInstant(timeZone); @@ -919,8 +930,33 @@ public static final void addIcsFile(NotificationInfo notification, MessageInfo m calendar.getProperties().add(Version.VERSION_2_0); calendar.getProperties().add(CalScale.GREGORIAN); Organizer organizer = new Organizer(URI.create("noreply@noreply.com")); - organizer.getParameters().add(new Cn(notification.getValueOwnerParameter(STORED_PARAMETER_EVENT_CREATOR))); + organizer.getParameters().add(new Cn(eventCreator)); calendar.getProperties().add(organizer); + + Locale userLocale = Locale.of(Utils.getUserLanguage(notification.getTo())); + String plainTextContent = getResourceBundleLabel(userLocale, "agenda.invitationText") + " " + eventCreator + + " " + getResourceBundleLabel(userLocale, "agenda.inSpace") + " " + spaceName + ". \n" + + (eventConference != null ? getResourceBundleLabel(userLocale, "agenda.visioLink") + " " + eventConference : ""); + String htmlContent = "" + + getResourceBundleLabel(userLocale, "agenda.invitationText") + " " + " " + eventCreator + + " " + getResourceBundleLabel(userLocale, "agenda.inSpace") + " " + spaceName + ". " + + ( eventConference != null ? "
" + getResourceBundleLabel(userLocale, "agenda.visioLink") + " " + " " + + "" + + eventConference + "" :""); + if (eventDescription != null && !eventDescription.isEmpty()) { + plainTextContent = plainTextContent + "\n \n " + getResourceBundleLabel(userLocale, "agenda.eventDetail") + ": \n" + + eventDescription.replaceAll("]*>(.*?)", "$2 ($1)") + .replaceAll("]+(>|$)", "") + .replaceAll("\\n{2,}", "\n").trim(); + htmlContent = htmlContent + "

" + getResourceBundleLabel(userLocale, "agenda.eventDetail") + "
" + eventDescription; + } + vEvent.getProperties().add(new Description(plainTextContent)); + htmlContent = htmlContent + ""; + ParameterList parameters = new ParameterList(); + parameters.add(new net.fortuna.ical4j.model.parameter.XParameter("FMTTYPE", "text/html")); + XProperty xProperty = new XProperty("X-ALT-DESC", parameters, htmlContent); + vEvent.getProperties().add(xProperty); + /* Add event to calendar */ calendar.getComponents().add(vEvent); CalendarOutputter outputter = new CalendarOutputter(); diff --git a/agenda-services/src/main/java/org/exoplatform/agenda/util/Utils.java b/agenda-services/src/main/java/org/exoplatform/agenda/util/Utils.java index 61138395f..768e629c7 100644 --- a/agenda-services/src/main/java/org/exoplatform/agenda/util/Utils.java +++ b/agenda-services/src/main/java/org/exoplatform/agenda/util/Utils.java @@ -22,6 +22,7 @@ import java.util.stream.Collectors; import net.fortuna.ical4j.model.Month; +import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -611,8 +612,15 @@ public static void detectEventModifiedFields(Event newEvent, Event oldEvent, Age } public static String getResourceBundleLabel(Locale locale, String label) { - ResourceBundleService resourceBundleService = ExoContainerContext.getService(ResourceBundleService.class); - return resourceBundleService.getResourceBundle(resourceBundleService.getSharedResourceBundleNames(), locale).getString(label); + ResourceBundleService resourceBundleService = ExoContainerContext.getService(ResourceBundleService.class); + try { + return resourceBundleService.getResourceBundle(ArrayUtils.addAll(resourceBundleService.getSharedResourceBundleNames(), + "locale.portlet.Agenda"), + locale) + .getString(label); + } catch (MissingResourceException mre) { + return label; + } } /** diff --git a/agenda-webapps/package-lock.json b/agenda-webapps/package-lock.json index 52fbef754..af4fb3dc4 100644 --- a/agenda-webapps/package-lock.json +++ b/agenda-webapps/package-lock.json @@ -5815,9 +5815,7 @@ "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.1.tgz", "integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==", "dev": true, - "requires": { - "ajv": "^8.0.0" - } + "requires": {} }, "ajv-keywords": { "version": "5.1.0", diff --git a/agenda-webapps/src/main/resources/locale/portlet/Agenda_fr.properties b/agenda-webapps/src/main/resources/locale/portlet/Agenda_fr.properties index e4b55ba63..0addbb941 100644 --- a/agenda-webapps/src/main/resources/locale/portlet/Agenda_fr.properties +++ b/agenda-webapps/src/main/resources/locale/portlet/Agenda_fr.properties @@ -147,11 +147,11 @@ agenda.doYouParticipate=Participer ? agenda.repitition=R\u00e9p\u00e9tition agenda.connect=Connecter agenda.disconnect=D\u00e9connecter -agenda.icsbutton=Ajouter à mon Agenda -agenda.invitationText=Invitation issue +agenda.icsbutton=Ajouter \u00e0 mon Agenda +agenda.invitationText=Invitation issue par agenda.inSpace=dans l'espace agenda.visioLink=Lien de visio : -agenda.eventDetail=Détail de l'évènement : +agenda.eventDetail=D\u00e9tail de l'\u00e9v\u00e9nement : agenda.connectYourPersonalAgenda=Connectez votre calendrier personnel agenda.synchronizeEventsWithPersonalCalendarSubTitle=Synchronisez vos \u00e9v\u00e9nements avec votre calendrier personnel agenda.connectYourPersonalAgendaSubTitle=Cliquez ici pour connecter votre calendrier personnel diff --git a/agenda-webapps/src/main/webapp/skin/less/agenda.less b/agenda-webapps/src/main/webapp/skin/less/agenda.less index c22cd594b..9963e5f29 100644 --- a/agenda-webapps/src/main/webapp/skin/less/agenda.less +++ b/agenda-webapps/src/main/webapp/skin/less/agenda.less @@ -452,8 +452,11 @@ } .event-details-body { - .event-details-body-right, .event-details-body-left { - max-width: ~"calc(50% - 21px)"; + .event-details-body-left { + max-width: ~"calc(100% - 463px)"; + } + .event-details-body-right{ + max-width: 420px !important; } .event-time { .uiIconClock.uiIcon32x32:before { @@ -506,7 +509,7 @@ } .remote-events-details { - max-width: 250px; + max-width: 100%; min-width: 250px; } @@ -827,6 +830,18 @@ max-height: 82px !important; } +@media (min-width: @maxMobileWidth) { + .VuetifyApp { + .event-details { + .event-details-body { + .event-details-body-right { + min-width: 420px !important; + } + } + } + } +} + @media (max-width: @maxMobileWidth) { .VuetifyApp { .event-details { diff --git a/agenda-webapps/src/main/webapp/vue-app/agenda-common/components/event/view/AgendaEventAttendees.vue b/agenda-webapps/src/main/webapp/vue-app/agenda-common/components/event/view/AgendaEventAttendees.vue index e5f427f73..8721a7bf2 100644 --- a/agenda-webapps/src/main/webapp/vue-app/agenda-common/components/event/view/AgendaEventAttendees.vue +++ b/agenda-webapps/src/main/webapp/vue-app/agenda-common/components/event/view/AgendaEventAttendees.vue @@ -4,7 +4,7 @@ {{ attendeesResponsesTitle }} -
+
- - + + fa-calendar-plus {{ $t('agenda.icsbutton') }}
-
+
fa-calendar-plus @@ -130,4 +131,4 @@ export default { }, } }; - \ No newline at end of file + diff --git a/agenda-webapps/src/main/webapp/vue-app/agenda-common/components/event/view/AgendaEventsDetailsBody.vue b/agenda-webapps/src/main/webapp/vue-app/agenda-common/components/event/view/AgendaEventsDetailsBody.vue index 63336c6e6..8c4fc1b99 100644 --- a/agenda-webapps/src/main/webapp/vue-app/agenda-common/components/event/view/AgendaEventsDetailsBody.vue +++ b/agenda-webapps/src/main/webapp/vue-app/agenda-common/components/event/view/AgendaEventsDetailsBody.vue @@ -1,7 +1,7 @@