From a20517fe8bd50d50f58989b89d6608da9dea4322 Mon Sep 17 00:00:00 2001 From: tomas-muller Date: Sat, 18 Apr 2015 16:08:43 +0200 Subject: [PATCH] Events: Time Grid (course title) - added ability to display course title in the header of an event in the time grid - this only happens when the application property unitime.events.grid_display_title is set to true (defaults to false, current behaviour) - only applies to class events (course related events and examination events can relate to multiple courses and can have multiple titles with ambiguous choice which one to display) - when multiple course title exists, only the first one is displayed (e.g., in the case of a cross-list, it should be the title of the controlling course) - format: course title (instruction section) - example: Fundamentals of Biology II (Laboratory 12038-042) Events: ICS Export (course title) - when the grid display title is enabled (see above), course title is used as event name (summary field) Events: ICS Export (instructors) - added ability to include instructor names in the description of an event - this only happens when the application property unitime.events.ics_instructors_in_description is set to true (defaults to false, current behaviour) --- .../defaults/ApplicationProperty.java | 10 +++++ .../events/EventPropertiesBackend.java | 2 + .../events/EventsExportEventsToICal.java | 18 ++++++++- .../client/events/EventResourceTimetable.java | 4 +- .../client/events/EventRoomAvailability.java | 8 ++-- .../timetable/gwt/client/events/TimeGrid.java | 39 +++++++++++++++---- .../timetable/gwt/resources/GwtMessages.java | 3 ++ .../timetable/gwt/shared/EventInterface.java | 4 ++ WebContent/help/Release-Notes.xml | 20 ++++++++++ 9 files changed, 93 insertions(+), 15 deletions(-) diff --git a/JavaSource/org/unitime/timetable/defaults/ApplicationProperty.java b/JavaSource/org/unitime/timetable/defaults/ApplicationProperty.java index 80fdbdea3c..e30affbe5e 100644 --- a/JavaSource/org/unitime/timetable/defaults/ApplicationProperty.java +++ b/JavaSource/org/unitime/timetable/defaults/ApplicationProperty.java @@ -1090,6 +1090,16 @@ public enum ApplicationProperty { @DefaultValue("true") @Description("Room Timetable: allow to see all the rooms (when set to false)") EventRoomTimetableAllRooms("unitime.event_timetable.event_rooms_only"), + + @Type(Boolean.class) + @DefaultValue("false") + @Description("Event Time Grid: display event title instead of event name in the header") + EventGridDisplayTitle("unitime.events.grid_display_title"), + + @Type(Boolean.class) + @DefaultValue("false") + @Description("Event ICS Calendar: include instructor names in the event description") + EventCalendarDisplayInstructorsInDescription("unitime.events.ics_instructors_in_description"), @Type(Class.class) @Implements(Email.class) diff --git a/JavaSource/org/unitime/timetable/events/EventPropertiesBackend.java b/JavaSource/org/unitime/timetable/events/EventPropertiesBackend.java index 1cc4e1ae0e..99145412c3 100644 --- a/JavaSource/org/unitime/timetable/events/EventPropertiesBackend.java +++ b/JavaSource/org/unitime/timetable/events/EventPropertiesBackend.java @@ -104,6 +104,8 @@ public EventPropertiesRpcResponse execute(EventPropertiesRpcRequest request, Eve if (tooEarly > 0) response.setTooEarlySlot(tooEarly); + response.setGridDisplayTitle(ApplicationProperty.EventGridDisplayTitle.isTrue()); + return response; } diff --git a/JavaSource/org/unitime/timetable/export/events/EventsExportEventsToICal.java b/JavaSource/org/unitime/timetable/export/events/EventsExportEventsToICal.java index d86a51862a..9ae0c0be8f 100644 --- a/JavaSource/org/unitime/timetable/export/events/EventsExportEventsToICal.java +++ b/JavaSource/org/unitime/timetable/export/events/EventsExportEventsToICal.java @@ -30,6 +30,7 @@ import org.joda.time.DateTime; import org.joda.time.DateTimeConstants; import org.springframework.stereotype.Service; +import org.unitime.timetable.defaults.ApplicationProperty; import org.unitime.timetable.export.ExportHelper; import org.unitime.timetable.gwt.client.events.EventComparator.EventMeetingSortBy; import org.unitime.timetable.gwt.shared.EventInterface; @@ -216,8 +217,21 @@ public boolean print(ICalendar ical, EventInterface event, Status status) throws for (VEvent vevent: events) { vevent.setSequence(event.getSequence()); vevent.setUid(event.getId().toString()); - vevent.setSummary(event.getName()); - vevent.setDescription(event.getInstruction() != null ? event.getInstruction() : event.getType().getName(CONSTANTS)); + String name = event.getName(); + String description = (event.hasInstruction() ? event.getInstruction() : event.getType().getName(CONSTANTS)); + if (event.hasCourseTitles() && event.getType() == EventType.Class && ApplicationProperty.EventGridDisplayTitle.isTrue()) { + name = event.getCourseTitles().get(0); + if (event.hasInstruction() && event.hasExternalIds()) + description = event.getInstruction() + " " + event.getExternalIds().get(0); + else if (event.hasInstruction() && event.hasSectionNumber()) + description = event.getInstruction() + " " + event.getSectionNumber(); + } + if (event.hasInstructors() && ApplicationProperty.EventCalendarDisplayInstructorsInDescription.isTrue()) { + for (ContactInterface instructor: event.getInstructors()) + description += "\n" + instructor.getName(MESSAGES); + } + vevent.setSummary(name); + vevent.setDescription(description); if (event.hasTimeStamp()) { DateTimeStamp ts = new DateTimeStamp(event.getTimeStamp()); diff --git a/JavaSource/org/unitime/timetable/gwt/client/events/EventResourceTimetable.java b/JavaSource/org/unitime/timetable/gwt/client/events/EventResourceTimetable.java index 19712b8839..75ecb442b4 100644 --- a/JavaSource/org/unitime/timetable/gwt/client/events/EventResourceTimetable.java +++ b/JavaSource/org/unitime/timetable/gwt/client/events/EventResourceTimetable.java @@ -562,7 +562,7 @@ public void onClick(ClickEvent clickEvent) { if (firstHour <= 7 && firstHour > 0 && ((firstSlot % 12) <= 6)) firstHour--; HashMap colors = new HashMap(); - final TimeGrid tg = new TimeGrid(colors, days, (int)(1000 / nrDays), 55, true, false, (firstHour < 7 ? firstHour : 7), (lastHour > 18 ? lastHour : 18)); + final TimeGrid tg = new TimeGrid(colors, days, (int)(1000 / nrDays), 55, true, false, (firstHour < 7 ? firstHour : 7), (lastHour > 18 ? lastHour : 18), EventResourceTimetable.this); tg.setResourceType(getResourceType()); tg.setSelectedWeeks(iWeekPanel.getSelected()); tg.setRoomResources(iRoomPanel.getSelected()); @@ -1002,7 +1002,7 @@ private void tabOrDataChanged(boolean keepSelection) { if (keepSelection) selections = iTimeGrid.getSelections(); iTimeGrid.destroy(); } - iTimeGrid = new TimeGrid(colors, days, (int)(0.9 * ToolBox.getClientWidth() / nrDays), false, false, (firstHour < 7 ? firstHour : 7), (lastHour > 18 ? lastHour : 18)); + iTimeGrid = new TimeGrid(colors, days, (int)(0.9 * ToolBox.getClientWidth() / nrDays), false, false, (firstHour < 7 ? firstHour : 7), (lastHour > 18 ? lastHour : 18), this); iTimeGrid.addMeetingClickHandler(iMeetingClickHandler); iTimeGrid.clear(); diff --git a/JavaSource/org/unitime/timetable/gwt/client/events/EventRoomAvailability.java b/JavaSource/org/unitime/timetable/gwt/client/events/EventRoomAvailability.java index aa225261fe..bd687a1c35 100644 --- a/JavaSource/org/unitime/timetable/gwt/client/events/EventRoomAvailability.java +++ b/JavaSource/org/unitime/timetable/gwt/client/events/EventRoomAvailability.java @@ -244,7 +244,7 @@ public void onClick(ClickEvent clickEvent) { endHour = Math.min(24, (17 + iSelectedTimes.getEnd()) / 12); } - final TimeGrid grid = new TimeGrid(colors, days, (int)(1000 / days.length), 55, true, false, startHour, endHour); + final TimeGrid grid = new TimeGrid(colors, days, (int)(1000 / days.length), 55, true, false, startHour, endHour, EventRoomAvailability.this); grid.setResourceType(ResourceType.ROOM); grid.setSelectedWeeks(weeks); List rooms = new ArrayList(iSelectedRooms); @@ -304,7 +304,7 @@ public void onClick(ClickEvent clickEvent) { endHour = Math.min(24, (17 + iSelectedTimes.getEnd()) / 12); } - final TimeGrid grid = new TimeGrid(colors, days, (int)(1000 / days.length), 55, true, false, startHour, endHour); + final TimeGrid grid = new TimeGrid(colors, days, (int)(1000 / days.length), 55, true, false, startHour, endHour, EventRoomAvailability.this); grid.setResourceType(ResourceType.ROOM); grid.setSelectedWeeks(weeks); List rooms = new ArrayList(); rooms.add(room); @@ -936,7 +936,7 @@ private void populate(List result, Integer sortBy) { endHour = Math.min(24, (17 + iSelectedTimes.getEnd()) / 12); } - TimeGrid grid = new TimeGrid(colors, days, (int)(0.9 * ToolBox.getClientWidth() / days.length), false, false, startHour, endHour); + TimeGrid grid = new TimeGrid(colors, days, (int)(0.9 * ToolBox.getClientWidth() / days.length), false, false, startHour, endHour, this); grid.setResourceType(ResourceType.ROOM); grid.setSelectedWeeks(weeks); List rooms = new ArrayList(iSelectedRooms); @@ -1008,7 +1008,7 @@ private void populate(List result, Integer sortBy) { endHour = Math.min(24, (17 + iSelectedTimes.getEnd()) / 12); } - TimeGrid grid = new TimeGrid(colors, days, (int)(0.9 * ToolBox.getClientWidth() / days.length), false, false, startHour, endHour); + TimeGrid grid = new TimeGrid(colors, days, (int)(0.9 * ToolBox.getClientWidth() / days.length), false, false, startHour, endHour, this); grid.setResourceType(ResourceType.ROOM); grid.setSelectedWeeks(weeks); List rooms = new ArrayList(); rooms.add(room); diff --git a/JavaSource/org/unitime/timetable/gwt/client/events/TimeGrid.java b/JavaSource/org/unitime/timetable/gwt/client/events/TimeGrid.java index 18a774c6e2..366f8ed2ff 100644 --- a/JavaSource/org/unitime/timetable/gwt/client/events/TimeGrid.java +++ b/JavaSource/org/unitime/timetable/gwt/client/events/TimeGrid.java @@ -29,6 +29,7 @@ import org.unitime.timetable.gwt.client.GwtHint; import org.unitime.timetable.gwt.client.ToolBox; +import org.unitime.timetable.gwt.client.events.EventAdd.EventPropertiesProvider; import org.unitime.timetable.gwt.client.rooms.RoomHint; import org.unitime.timetable.gwt.client.widgets.P; import org.unitime.timetable.gwt.client.widgets.SimpleForm; @@ -113,6 +114,7 @@ public class TimeGrid extends Composite { private List iRoomResources = null; private List iSelectedWeeks = null; + private EventPropertiesProvider iPropertiesProvider = null; private List iHandlerRegistrations = new ArrayList(); @@ -124,17 +126,18 @@ public static enum Mode { private Mode iMode = Mode.FILLSPACE; - public TimeGrid() { - this(new HashMap(), new int[] {0, 1, 2, 3, 4}, (int) (0.9 * ToolBox.getClientWidth() / 5), false, false, 0, 24); + public TimeGrid(EventPropertiesProvider properties) { + this(new HashMap(), new int[] {0, 1, 2, 3, 4}, (int) (0.9 * ToolBox.getClientWidth() / 5), false, false, 0, 24, properties); } - public TimeGrid(HashMap colors, int[] days, int cellWidth, boolean print, boolean scroll, int start, int end) { - this(colors, days, cellWidth, 60, print, scroll, start, end); + public TimeGrid(HashMap colors, int[] days, int cellWidth, boolean print, boolean scroll, int start, int end, EventPropertiesProvider properties) { + this(colors, days, cellWidth, 60, print, scroll, start, end, properties); } private List

iDayLabels = new ArrayList

(); - public TimeGrid(HashMap colors, int[] days, int cellWidth, int cellHeight, boolean print, boolean scroll, int start, int end) { + public TimeGrid(HashMap colors, int[] days, int cellWidth, int cellHeight, boolean print, boolean scroll, int start, int end, EventPropertiesProvider properties) { + iPropertiesProvider = properties; iColors = colors; iDays = days; iCellWidth = cellWidth; @@ -284,7 +287,7 @@ public TimeGrid getPrintWidget() { int firstHour = firstSlot / 12; if (firstHour <= 7 && firstHour > 0 && ((firstSlot % 12) <= 6)) firstHour--; int lastHour = (11 + lastSlot()) / 12; - TimeGrid tg = new TimeGrid(iColors, iDays, (int) (1000 / iDays.length), true, false, (firstHour < 7 ? firstHour : 7), (lastHour > 18 ? lastHour : 18)); + TimeGrid tg = new TimeGrid(iColors, iDays, (int) (1000 / iDays.length), true, false, (firstHour < 7 ? firstHour : 7), (lastHour > 18 ? lastHour : 18), iPropertiesProvider); tg.setSelectedWeeks(getSelectedWeeks()); tg.setRoomResources(getRoomResources()); tg.setResourceType(getResourceType()); @@ -728,12 +731,34 @@ public int compare(MeetingInterface m1, MeetingInterface m2) { if (event.hasSponsor()) notes.add(event.getSponsor().getName()); + String eventName = event.getName(); + if (iPropertiesProvider.getProperties() != null && iPropertiesProvider.getProperties().isGridDisplayTitle() && event.hasCourseTitles() && event.getType() == EventType.Class) { + eventName = event.getCourseTitles().get(0); + if (event.hasInstruction()) { + if (event.hasExternalIds()) { + eventName += " (" + event.getInstruction() + " " + event.getExternalIds().get(0) + ")"; + } else if (event.hasSectionNumber()) + eventName += " (" + event.getInstruction() + " " + event.getSectionNumber() + ")"; + else + eventName += " (" + event.getInstruction() + ")"; + } else if (event.getType() != EventType.Unavailabile) { + eventName += " (" + CONSTANTS.eventTypeShort()[event.getType().ordinal()] + ")"; + } + } else { + if (event.hasInstruction()) + eventName += " (" + event.getInstruction() + ")"; + else if (event.getType() != EventType.Unavailabile) + eventName += " (" + CONSTANTS.eventTypeShort()[event.getType().ordinal()] + ")"; + } + if (!meeting.isApproved()) + eventName = MESSAGES.gridEventHeaderNotApproved(eventName); + Meeting m = addMeeting( event, meeting, meeting.getGridIndex(), meeting.getStartSlot(), meeting.getEndSlot() - meeting.getStartSlot(), meeting.getStartOffset(), meeting.getEndOffset(), - (meeting.isApproved() ? "" : "") + event.getName() + (event.getType() == EventType.Unavailabile ? "" : " (" + (event.hasInstruction() ? event.getInstruction() : event.getType()) + ")" + (meeting.isApproved() ? "" : " -- not approved")), + eventName, notes, color, weekIndex(meeting), !isVerticalSplitByWeek() && iMode == Mode.OVERLAP ? rooms.size() : days.size(), done, dateString, roomString); if (m != null) done.add(m); } diff --git a/JavaSource/org/unitime/timetable/gwt/resources/GwtMessages.java b/JavaSource/org/unitime/timetable/gwt/resources/GwtMessages.java index f93dbeddf9..e023bb69c0 100644 --- a/JavaSource/org/unitime/timetable/gwt/resources/GwtMessages.java +++ b/JavaSource/org/unitime/timetable/gwt/resources/GwtMessages.java @@ -3109,4 +3109,7 @@ public interface GwtMessages extends Messages { @DefaultMessage("Or you can download an iCalendar file by clicking the {0} button below. While it is often easier to import an iCalendar file, such a calendar will not get updated automatically.") String exportICalendarDownload(String button); + + @DefaultMessage("{0} -- not approved") + String gridEventHeaderNotApproved(String header); } \ No newline at end of file diff --git a/JavaSource/org/unitime/timetable/gwt/shared/EventInterface.java b/JavaSource/org/unitime/timetable/gwt/shared/EventInterface.java index efe5862e89..1b560b6c29 100644 --- a/JavaSource/org/unitime/timetable/gwt/shared/EventInterface.java +++ b/JavaSource/org/unitime/timetable/gwt/shared/EventInterface.java @@ -1751,6 +1751,7 @@ public static class EventPropertiesRpcResponse implements GwtRpcResponse { private Map iFilterDefaults = null; private Integer iTooEarlySlot = null; private boolean iCanEditAcademicTitle = false; + private boolean iGridDisplayTitle = false; public EventPropertiesRpcResponse() {} @@ -1821,6 +1822,9 @@ public String getFilterDefault(String name) { public boolean isCanEditAcademicTitle() { return iCanEditAcademicTitle; } public void setCanEditAcademicTitle(boolean canEditAcademicTitle) { iCanEditAcademicTitle = canEditAcademicTitle; } + + public boolean isGridDisplayTitle() { return iGridDisplayTitle; } + public void setGridDisplayTitle(boolean gridDisplayTitle) { iGridDisplayTitle = gridDisplayTitle; } } public static class EventDetailRpcRequest extends EventRpcRequest { diff --git a/WebContent/help/Release-Notes.xml b/WebContent/help/Release-Notes.xml index 3c469bef02..6dc0f651cb 100644 --- a/WebContent/help/Release-Notes.xml +++ b/WebContent/help/Release-Notes.xml @@ -139,6 +139,26 @@ + + Events: Course Title + + Time Grid: Added ability to display course title in the header of an event in the time grid. + This only happens when the application property unitime.events.grid_display_title is set to true (defaults to false, current behaviour). + Only applies to class events (course related events and examination events can relate to multiple courses and can have multiple titles with ambiguous choice which one to display). + When multiple course title exists, only the first one is displayed (e.g., in the case of a cross-list, it should be the title of the controlling course). + Format: course title (instruction section) + Example: Fundamentals of Biology II (Laboratory 12038-042) + + + + Events: ICS Export + + When the grid display title is enabled (see above), course title is used as event name (summary field). + Added ability to include instructor names in the description of an event. + Tis only happens when the application property unitime.events.ics_instructors_in_description is set to true (defaults to false, current behaviour). + + + CPSolver updated to version 1.3.52 (was 1.3.47)