Skip to content

Commit

Permalink
Events: Time Grid (course title)
Browse files Browse the repository at this point in the history
- 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)
  • Loading branch information
tomas-muller committed Apr 18, 2015
1 parent b275d8b commit a20517f
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 15 deletions.
10 changes: 10 additions & 0 deletions JavaSource/org/unitime/timetable/defaults/ApplicationProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public EventPropertiesRpcResponse execute(EventPropertiesRpcRequest request, Eve
if (tooEarly > 0)
response.setTooEarlySlot(tooEarly);

response.setGridDisplayTitle(ApplicationProperty.EventGridDisplayTitle.isTrue());

return response;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ public void onClick(ClickEvent clickEvent) {
if (firstHour <= 7 && firstHour > 0 && ((firstSlot % 12) <= 6)) firstHour--;
HashMap<Long, String> colors = new HashMap<Long, String>();

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());
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ResourceInterface> rooms = new ArrayList<EventInterface.ResourceInterface>(iSelectedRooms);
Expand Down Expand Up @@ -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<ResourceInterface> rooms = new ArrayList<EventInterface.ResourceInterface>(); rooms.add(room);
Expand Down Expand Up @@ -936,7 +936,7 @@ private void populate(List<EventInterface> 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<ResourceInterface> rooms = new ArrayList<EventInterface.ResourceInterface>(iSelectedRooms);
Expand Down Expand Up @@ -1008,7 +1008,7 @@ private void populate(List<EventInterface> 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<ResourceInterface> rooms = new ArrayList<EventInterface.ResourceInterface>(); rooms.add(room);
Expand Down
39 changes: 32 additions & 7 deletions JavaSource/org/unitime/timetable/gwt/client/events/TimeGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -113,6 +114,7 @@ public class TimeGrid extends Composite {

private List<ResourceInterface> iRoomResources = null;
private List<WeekInterface> iSelectedWeeks = null;
private EventPropertiesProvider iPropertiesProvider = null;

private List<HandlerRegistration> iHandlerRegistrations = new ArrayList<HandlerRegistration>();

Expand All @@ -124,17 +126,18 @@ public static enum Mode {

private Mode iMode = Mode.FILLSPACE;

public TimeGrid() {
this(new HashMap<Long, String>(), new int[] {0, 1, 2, 3, 4}, (int) (0.9 * ToolBox.getClientWidth() / 5), false, false, 0, 24);
public TimeGrid(EventPropertiesProvider properties) {
this(new HashMap<Long, String>(), new int[] {0, 1, 2, 3, 4}, (int) (0.9 * ToolBox.getClientWidth() / 5), false, false, 0, 24, properties);
}

public TimeGrid(HashMap<Long, String> 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<Long, String> 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<P> iDayLabels = new ArrayList<P>();

public TimeGrid(HashMap<Long, String> colors, int[] days, int cellWidth, int cellHeight, boolean print, boolean scroll, int start, int end) {
public TimeGrid(HashMap<Long, String> 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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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() ? "" : "<i>") + event.getName() + (event.getType() == EventType.Unavailabile ? "" : " (" + (event.hasInstruction() ? event.getInstruction() : event.getType()) + ")" + (meeting.isApproved() ? "" : " -- not approved</i>")),
eventName,
notes, color, weekIndex(meeting), !isVerticalSplitByWeek() && iMode == Mode.OVERLAP ? rooms.size() : days.size(), done, dateString, roomString);
if (m != null) done.add(m);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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&nbsp;calendar will not get updated automatically.")
String exportICalendarDownload(String button);

@DefaultMessage("<i>{0} -- not approved</i>")
String gridEventHeaderNotApproved(String header);
}
Original file line number Diff line number Diff line change
Expand Up @@ -1751,6 +1751,7 @@ public static class EventPropertiesRpcResponse implements GwtRpcResponse {
private Map<String, String> iFilterDefaults = null;
private Integer iTooEarlySlot = null;
private boolean iCanEditAcademicTitle = false;
private boolean iGridDisplayTitle = false;

public EventPropertiesRpcResponse() {}

Expand Down Expand Up @@ -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<EventInterface> {
Expand Down
20 changes: 20 additions & 0 deletions WebContent/help/Release-Notes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,26 @@
</line>
</description>
</item>
<item>
<name>Events: Course Title</name>
<description>
<line>Time Grid: Added ability to display course title in the header of an event in the time grid.</line>
<line>This only happens when the application property unitime.events.grid_display_title is set to true (defaults to false, current behaviour).</line>
<line>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).</line>
<line>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).</line>
<line>Format: course title (instruction section)</line>
<line>Example: Fundamentals of Biology II (Laboratory 12038-042)</line>
</description>
</item>
<item>
<name>Events: ICS Export</name>
<description>
<line>When the grid display title is enabled (see above), course title is used as event name (summary field).</line>
<line>Added ability to include instructor names in the description of an event.
<line>Tis only happens when the application property unitime.events.ics_instructors_in_description is set to true (defaults to false, current behaviour).</line>
</line>
</description>
</item>
</category>
<category>
<title>CPSolver updated to version 1.3.52 (was 1.3.47)</title>
Expand Down

0 comments on commit a20517f

Please sign in to comment.