Skip to content

Commit

Permalink
Reservations Table
Browse files Browse the repository at this point in the history
- limit the number of restrictions and owners to 5 lines
  - but only when showing as tooltip in the dashboard
- show all restrictions/owners on the Reservations page and on the Instructional Offering Detail page
  - this fixes a problem introduced in commit 1c58aab (limiting the number of owners everywhere)
  • Loading branch information
tomas-muller committed Jul 17, 2024
1 parent b7b0126 commit 956d38d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,13 @@ private void clear(boolean loading) {
else
iHeader.clearMessage();
}

public void populate(List<ReservationInterface> reservations) {
populate(reservations, -1);
}


public void populate(List<ReservationInterface> reservations) {
public void populate(List<ReservationInterface> reservations, int owLimit) {
List<UniTimeTableHeader> header = new ArrayList<UniTimeTableHeader>();

for (final ReservationColumn column: ReservationColumn.values()) {
Expand Down Expand Up @@ -297,10 +301,10 @@ public String getName() {
for (IdName student: ((IndividualReservation) reservation).getStudents()) {
students.add(new Label(student.getName(), false));
}
if (students.getWidgetCount() > 6) {
int more = students.getWidgetCount();
while (students.getWidgetCount() > 5)
students.remove(5);
if (owLimit > 0 && students.getWidgetCount() > owLimit + 1) {
int more = students.getWidgetCount() - owLimit;
while (students.getWidgetCount() > owLimit)
students.remove(owLimit);
Label l = new Label(MESSAGES.moreItems(more), false); l.getElement().getStyle().setMarginLeft(10, Unit.PX);
students.add(l);
}
Expand Down Expand Up @@ -387,10 +391,10 @@ else if (firstClasf) {
l.getElement().getStyle().setMarginLeft(10, Unit.PX);
owner.add(l);
}
if (owner.getWidgetCount() > 6) {
int more = owner.getWidgetCount() - 5;
while (owner.getWidgetCount() > 5)
owner.remove(5);
if (owLimit > 0 && owner.getWidgetCount() > owLimit + 1) {
int more = owner.getWidgetCount() - owLimit;
while (owner.getWidgetCount() > owLimit)
owner.remove(owLimit);
Label l = new Label(MESSAGES.moreItems(more), false); l.getElement().getStyle().setMarginLeft(10, Unit.PX);
owner.add(l);
}
Expand All @@ -412,6 +416,13 @@ else if (firstClasf) {
for (Clazz clazz: reservation.getClasses()) {
restrictions.add(new Label(clazz.getName() + (clazz.getLimit() == null ? "" : " (" + clazz.getLimit() + ")"), false));
}
if (owLimit > 0 && restrictions.getWidgetCount() > owLimit + 1) {
int more = restrictions.getWidgetCount() - owLimit;
while (restrictions.getWidgetCount() > owLimit)
restrictions.remove(owLimit);
Label l = new Label(MESSAGES.moreItems(more), false); l.getElement().getStyle().setMarginLeft(10, Unit.PX);
restrictions.add(l);
}
line.add(restrictions);
if (reservation.hasInclusive() && reservation.isInclusive()) {
restrictions.addStyleName("unitime-ReservationInclusive");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3154,7 +3154,7 @@ public void onSuccess(List<ReservationInterface> result) {
}
if (result != null && !result.isEmpty() && iMouseOver) {
ReservationTable rt = new ReservationTable(false, false);
rt.populate(result);
rt.populate(result, 5);
rt.getTable().setColumnVisible(ReservationColumn.LAST_LIKE.ordinal(), false);
rt.getTable().setColumnVisible(ReservationColumn.PROJECTED_BY_RULE.ordinal(), false);
rt.getTable().setColumnVisible(ReservationColumn.EXPIRATION_DATE.ordinal(), iOnline);
Expand Down

0 comments on commit 956d38d

Please sign in to comment.