Add number of tasks column in monthly timesheets area

FEA: ItEr76S28UserDashboard
This commit is contained in:
Manuel Rego Casasnovas 2012-05-30 16:18:48 +02:00
parent 991599fc80
commit 05ba8527b6
6 changed files with 52 additions and 6 deletions

View file

@ -32,6 +32,7 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.libreplan.business.common.BaseEntity;
import org.libreplan.business.common.Configuration;
import org.libreplan.business.common.IOnTransaction;
import org.libreplan.business.common.Registry;
@ -725,4 +726,19 @@ public class Util {
row.addEventListener(Events.ON_CLICK, editButtonListener);
}
/**
* Checks if the <code>entity</code> is contained in the provided
* <code>list</code>.
*/
public static boolean contains(List<? extends BaseEntity> list,
BaseEntity entity) {
for (BaseEntity each : list) {
if (each.getId() != null && entity.getId() != null
&& each.getId().equals(entity.getId())) {
return true;
}
}
return false;
}
}

View file

@ -22,6 +22,7 @@ package org.libreplan.web.users.dashboard;
import java.util.List;
import org.libreplan.business.calendars.entities.CalendarAvailability;
import org.libreplan.business.orders.entities.OrderElement;
import org.libreplan.business.users.entities.User;
import org.libreplan.business.workreports.entities.WorkReport;
@ -46,4 +47,10 @@ public interface IMonthlyTimesheetsAreaModel {
*/
List<MonthlyTimesheet> getMonthlyTimesheets();
/**
* Returns the number of different {@link OrderElement OrderElements} with
* tracked time in the specified <code>workReport</code>.
*/
int getNumberOfOrderElementsWithTrackedTime(WorkReport workReport);
}

View file

@ -55,6 +55,7 @@ import org.libreplan.business.workreports.entities.WorkReportLine;
import org.libreplan.business.workreports.entities.WorkReportType;
import org.libreplan.web.UserUtil;
import org.libreplan.web.calendars.BaseCalendarModel;
import org.libreplan.web.common.Util;
import org.libreplan.web.common.concurrentdetection.OnConcurrentModification;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
@ -216,12 +217,7 @@ public class MonthlyTimesheetModel implements IMonthlyTimesheetModel {
}
private boolean isNotInOrderElements(OrderElement orderElement) {
for (OrderElement each : orderElements) {
if (each.getId().equals(orderElement.getId())) {
return false;
}
}
return true;
return !Util.contains(orderElements, orderElement);
}
private void forceLoad(OrderElement orderElement) {

View file

@ -59,6 +59,11 @@ public class MonthlyTimesheetsAreaController extends GenericForwardComposer {
Util.appendLabel(row, workReport.getTotalEffortDuration()
.toFormattedString());
Util.appendLabel(
row,
monthlyTimesheetsAreaModel
.getNumberOfOrderElementsWithTrackedTime(workReport) + "");
Util.appendOperationsAndOnClickEvent(row, new EventListener() {
@Override

View file

@ -25,13 +25,16 @@ import java.util.List;
import org.joda.time.LocalDate;
import org.joda.time.Months;
import org.libreplan.business.orders.entities.OrderElement;
import org.libreplan.business.resources.entities.Resource;
import org.libreplan.business.resources.entities.Worker;
import org.libreplan.business.users.entities.User;
import org.libreplan.business.workreports.daos.IWorkReportDAO;
import org.libreplan.business.workreports.entities.WorkReport;
import org.libreplan.business.workreports.entities.WorkReportLine;
import org.libreplan.business.workreports.entities.WorkReportType;
import org.libreplan.web.UserUtil;
import org.libreplan.web.common.Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
@ -97,4 +100,22 @@ public class MonthlyTimesheetsAreaModel implements IMonthlyTimesheetsAreaModel {
.getStartDate();
}
@Override
public int getNumberOfOrderElementsWithTrackedTime(WorkReport workReport) {
if (workReport == null) {
return 0;
}
List<OrderElement> orderElements = new ArrayList<OrderElement>();
for (WorkReportLine line : workReport.getWorkReportLines()) {
if (!line.getEffort().isZero()) {
OrderElement orderElement = line.getOrderElement();
if (!Util.contains(orderElements, orderElement)) {
orderElements.add(orderElement);
}
}
}
return orderElements.size();
}
}

View file

@ -26,6 +26,7 @@
<columns sizable="true">
<column label="${i18n:_('Date')}" />
<column label="${i18n:_('Total work')}" />
<column label="${i18n:_('Number of tasks')}" />
<column label="${i18n:_('Operations')}" />
</columns>
</grid>