Set a pink background for days with zero capacity in the monthly timesheet
FEA: ItEr76S28UserDashboard
This commit is contained in:
parent
f1be35c432
commit
d960bb47cb
2 changed files with 48 additions and 8 deletions
|
|
@ -149,7 +149,11 @@ public class MonthlyTimesheetController extends GenericForwardComposer
|
|||
|
||||
});
|
||||
|
||||
row.appendChild(textbox);
|
||||
if (monthlyTimesheetModel.getResourceCapacity(day).isZero()) {
|
||||
row.appendChild(getNonCapacityCell(textbox));
|
||||
} else {
|
||||
row.appendChild(textbox);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -185,7 +189,13 @@ public class MonthlyTimesheetController extends GenericForwardComposer
|
|||
private void appendTotalForDays(Row row) {
|
||||
for (LocalDate day = start; day.compareTo(end) <= 0; day = day
|
||||
.plusDays(1)) {
|
||||
row.appendChild(getCenteredCell(getDisabledTextbox(getTotalRowTextboxId(day))));
|
||||
Textbox textbox = getDisabledTextbox(getTotalRowTextboxId(day));
|
||||
if (monthlyTimesheetModel.getResourceCapacity(day).isZero()) {
|
||||
row.appendChild(getNonCapacityCell(textbox));
|
||||
} else {
|
||||
row.appendChild(textbox);
|
||||
}
|
||||
|
||||
updateTotalRow(day);
|
||||
}
|
||||
}
|
||||
|
|
@ -237,8 +247,12 @@ public class MonthlyTimesheetController extends GenericForwardComposer
|
|||
.plusDays(1)) {
|
||||
EffortDuration capacity = monthlyTimesheetModel
|
||||
.getResourceCapacity(day);
|
||||
row.appendChild(getCenteredCell(new Label(capacity
|
||||
.toFormattedString())));
|
||||
Label label = new Label(capacity.toFormattedString());
|
||||
if (monthlyTimesheetModel.getResourceCapacity(day).isZero()) {
|
||||
row.appendChild(getNonCapacityCell(label));
|
||||
} else {
|
||||
row.appendChild(label);
|
||||
}
|
||||
|
||||
totalCapacity = totalCapacity.plus(capacity);
|
||||
}
|
||||
|
|
@ -261,6 +275,12 @@ public class MonthlyTimesheetController extends GenericForwardComposer
|
|||
return cell;
|
||||
}
|
||||
|
||||
private Cell getNonCapacityCell(Component component) {
|
||||
Cell cell = getCenteredCell(component);
|
||||
cell.setStyle("background-color: #FFEEEE");
|
||||
return cell;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -20,7 +20,9 @@
|
|||
package org.libreplan.web.users.dashboard;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.NonUniqueResultException;
|
||||
import org.joda.time.LocalDate;
|
||||
|
|
@ -70,6 +72,8 @@ public class MonthlyTimesheetModel implements IMonthlyTimesheetModel {
|
|||
|
||||
private WorkReport workReport;
|
||||
|
||||
private Map<LocalDate, EffortDuration> capacityMap;
|
||||
|
||||
@Autowired
|
||||
private IResourceAllocationDAO resourceAllocationDAO;
|
||||
|
||||
|
|
@ -96,14 +100,31 @@ public class MonthlyTimesheetModel implements IMonthlyTimesheetModel {
|
|||
throw new RuntimeException(
|
||||
"This page only can be used by users bound to a resource");
|
||||
}
|
||||
forceLoad(getWorker().getCalendar());
|
||||
|
||||
this.date = date;
|
||||
|
||||
initCapacityMap();
|
||||
|
||||
initOrderElements();
|
||||
initWorkReport();
|
||||
}
|
||||
|
||||
private void initCapacityMap() {
|
||||
forceLoad(getWorker().getCalendar());
|
||||
|
||||
LocalDate date = getDate();
|
||||
LocalDate start = date.dayOfMonth().withMinimumValue();
|
||||
LocalDate end = date.dayOfMonth().withMaximumValue();
|
||||
|
||||
capacityMap = new HashMap<LocalDate, EffortDuration>();
|
||||
for (LocalDate day = start; day.compareTo(end) <= 0; day = day
|
||||
.plusDays(1)) {
|
||||
capacityMap.put(
|
||||
day,
|
||||
getWorker().getCalendar().getCapacityOn(
|
||||
PartialDay.wholeDay(day)));
|
||||
}
|
||||
}
|
||||
|
||||
private void forceLoad(ResourceCalendar calendar) {
|
||||
BaseCalendarModel.forceLoadBaseCalendar(calendar);
|
||||
}
|
||||
|
|
@ -270,8 +291,7 @@ public class MonthlyTimesheetModel implements IMonthlyTimesheetModel {
|
|||
|
||||
@Override
|
||||
public EffortDuration getResourceCapacity(LocalDate date) {
|
||||
return getWorker().getCalendar().getCapacityOn(
|
||||
PartialDay.wholeDay(date));
|
||||
return capacityMap.get(date);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue