Add checkbox to mark task as finished in personal timesheets popup
FEA: ItEr77S12AdaptPlanningAccordingTimesheets
This commit is contained in:
parent
5a3d07e226
commit
2b07654d61
9 changed files with 115 additions and 28 deletions
|
|
@ -69,7 +69,7 @@ public interface IWorkReportLineDAO extends
|
|||
Pair<Date, Date> findMinAndMaxDatesByOrderElement(
|
||||
OrderElement orderElement);
|
||||
|
||||
List<WorkReportLine> findByOrderElementNotInWorkReportAnotherTransaction(
|
||||
List<WorkReportLine> findFinishedByOrderElementNotInWorkReportAnotherTransaction(
|
||||
OrderElement orderElement, WorkReport workReport);
|
||||
|
||||
Boolean isFinished(OrderElement orderElement);
|
||||
|
|
|
|||
|
|
@ -171,13 +171,13 @@ public class WorkReportLineDAO extends IntegrationEntityDAO<WorkReportLine>
|
|||
|
||||
@Override
|
||||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW)
|
||||
public List<WorkReportLine> findByOrderElementNotInWorkReportAnotherTransaction(
|
||||
public List<WorkReportLine> findFinishedByOrderElementNotInWorkReportAnotherTransaction(
|
||||
OrderElement orderElement, WorkReport workReport) {
|
||||
return findByOrderElementNotInWorkReport(orderElement, workReport);
|
||||
return findFinishedByOrderElementNotInWorkReport(orderElement, workReport);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<WorkReportLine> findByOrderElementNotInWorkReport(
|
||||
private List<WorkReportLine> findFinishedByOrderElementNotInWorkReport(
|
||||
OrderElement orderElement, WorkReport workReport) {
|
||||
Criteria criteria = getSession().createCriteria(WorkReportLine.class);
|
||||
|
||||
|
|
@ -185,6 +185,7 @@ public class WorkReportLineDAO extends IntegrationEntityDAO<WorkReportLine>
|
|||
if (!workReport.isNewObject()) {
|
||||
criteria.add(Restrictions.ne("workReport", workReport));
|
||||
}
|
||||
criteria.add(Restrictions.eq("finished", true));
|
||||
|
||||
return (List<WorkReportLine>) criteria.list();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -555,4 +555,14 @@ public class WorkReport extends IntegrationEntity implements
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean isFinished(OrderElement orderElement) {
|
||||
for (WorkReportLine line : workReportLines) {
|
||||
if (line.isFinished()
|
||||
&& Util.equals(line.getOrderElement(), orderElement)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -571,15 +571,9 @@ public class WorkReportLine extends IntegrationEntity implements Comparable,
|
|||
}
|
||||
|
||||
List<WorkReportLine> lines = Registry.getWorkReportLineDAO()
|
||||
.findByOrderElementNotInWorkReportAnotherTransaction(
|
||||
.findFinishedByOrderElementNotInWorkReportAnotherTransaction(
|
||||
orderElement, workReport);
|
||||
for (WorkReportLine line : lines) {
|
||||
if (line.isFinished()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return lines.isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import org.libreplan.business.resources.entities.Resource;
|
|||
import org.libreplan.business.resources.entities.Worker;
|
||||
import org.libreplan.business.workingday.EffortDuration;
|
||||
import org.libreplan.business.workreports.entities.WorkReport;
|
||||
import org.libreplan.business.workreports.entities.WorkReportLine;
|
||||
|
||||
/**
|
||||
* Interface for creation/edition of a personal timesheet model
|
||||
|
|
@ -227,4 +228,26 @@ public interface IPersonalTimesheetModel {
|
|||
*/
|
||||
LocalDate getNext();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> (or <code>false</code>) if the specified
|
||||
* <code>orderElement</code> is marked as finished (or not) in the current
|
||||
* personal timesheet for the specified <code>date</code>.
|
||||
*/
|
||||
Boolean isFinished(OrderElement orderElement, LocalDate date);
|
||||
|
||||
/**
|
||||
* Mark the specified <code>orderElement</code> as finished in the current
|
||||
* personal timesheet for the specified <code>date</code>.<br />
|
||||
*
|
||||
* Marks the current personal timesheet as modified.
|
||||
*/
|
||||
void setFinished(OrderElement orderElement, LocalDate textboxDate,
|
||||
Boolean finished);
|
||||
|
||||
/**
|
||||
* Checks if the specified <code>orderElement</code> is marked or not as
|
||||
* finished in any {@link WorkReportLine}.
|
||||
*/
|
||||
Boolean isFinished(OrderElement orderElement);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ import org.zkoss.zk.ui.util.Clients;
|
|||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
import org.zkoss.zul.Button;
|
||||
import org.zkoss.zul.Cell;
|
||||
import org.zkoss.zul.Checkbox;
|
||||
import org.zkoss.zul.Column;
|
||||
import org.zkoss.zul.Columns;
|
||||
import org.zkoss.zul.Frozen;
|
||||
|
|
@ -124,6 +125,8 @@ public class PersonalTimesheetController extends GenericForwardComposer
|
|||
|
||||
private Div personalTimesheetPopupEffort;
|
||||
|
||||
private Div personalTimesheetPopupFinished;
|
||||
|
||||
@Resource
|
||||
private IPersonalTimesheetController personalTimesheetController;
|
||||
|
||||
|
|
@ -289,6 +292,29 @@ public class PersonalTimesheetController extends GenericForwardComposer
|
|||
}
|
||||
});
|
||||
personalTimesheetPopupEffort.appendChild(effortTextbox);
|
||||
|
||||
personalTimesheetPopupFinished.getChildren().clear();
|
||||
Checkbox finishedCheckbox = Util.bind(new Checkbox(),
|
||||
new Util.Getter<Boolean>() {
|
||||
@Override
|
||||
public Boolean get() {
|
||||
return personalTimesheetModel.isFinished(
|
||||
orderElement, textboxDate);
|
||||
}
|
||||
}, new Util.Setter<Boolean>() {
|
||||
@Override
|
||||
public void set(Boolean value) {
|
||||
personalTimesheetModel.setFinished(orderElement,
|
||||
textboxDate, value);
|
||||
markAsModified(textbox);
|
||||
}
|
||||
});
|
||||
if (!finishedCheckbox.isChecked()) {
|
||||
finishedCheckbox.setDisabled(personalTimesheetModel
|
||||
.isFinished(orderElement));
|
||||
}
|
||||
personalTimesheetPopupFinished.appendChild(finishedCheckbox);
|
||||
|
||||
return effortTextbox;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -396,14 +396,21 @@ public class PersonalTimesheetModel implements IPersonalTimesheetModel {
|
|||
@Transactional(readOnly = true)
|
||||
public void setEffortDuration(OrderElement orderElement, LocalDate date,
|
||||
EffortDuration effortDuration) {
|
||||
WorkReportLine workReportLine = getOrCreateWorkReportLine(orderElement,
|
||||
date);
|
||||
workReportLine.setEffort(effortDuration);
|
||||
modified = true;
|
||||
markAsModified(orderElement, date);
|
||||
}
|
||||
|
||||
private WorkReportLine getOrCreateWorkReportLine(OrderElement orderElement,
|
||||
LocalDate date) {
|
||||
WorkReportLine workReportLine = getWorkReportLine(orderElement, date);
|
||||
if (workReportLine == null) {
|
||||
workReportLine = createWorkReportLine(orderElement, date);
|
||||
workReport.addWorkReportLine(workReportLine);
|
||||
}
|
||||
workReportLine.setEffort(effortDuration);
|
||||
modified = true;
|
||||
markAsModified(orderElement, date);
|
||||
return workReportLine;
|
||||
}
|
||||
|
||||
private void markAsModified(OrderElement orderElement, LocalDate date) {
|
||||
|
|
@ -619,4 +626,35 @@ public class PersonalTimesheetModel implements IPersonalTimesheetModel {
|
|||
return periodicity.next(date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isFinished(OrderElement orderElement, LocalDate date) {
|
||||
WorkReportLine workReportLine = getWorkReportLine(orderElement, date);
|
||||
if (workReportLine == null) {
|
||||
return false;
|
||||
}
|
||||
return workReportLine.isFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFinished(OrderElement orderElement, LocalDate date,
|
||||
Boolean finished) {
|
||||
WorkReportLine workReportLine = getOrCreateWorkReportLine(orderElement,
|
||||
date);
|
||||
workReportLine.setFinished(finished);
|
||||
modified = true;
|
||||
markAsModified(orderElement, date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isFinished(OrderElement orderElement) {
|
||||
if (workReport.isFinished(orderElement)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
List<WorkReportLine> lines = workReportLineDAO
|
||||
.findFinishedByOrderElementNotInWorkReportAnotherTransaction(
|
||||
orderElement, workReport);
|
||||
return !lines.isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ import java.util.Set;
|
|||
import org.apache.commons.lang.Validate;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.libreplan.business.common.IntegrationEntity;
|
||||
import org.libreplan.business.common.Util;
|
||||
import org.libreplan.business.common.daos.IConfigurationDAO;
|
||||
import org.libreplan.business.common.entities.EntityNameEnum;
|
||||
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
|
||||
|
|
@ -661,22 +660,14 @@ public class WorkReportModel extends IntegrationEntityModel implements
|
|||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public boolean isFinished(OrderElement orderElement) {
|
||||
for (WorkReportLine line : workReport.getWorkReportLines()) {
|
||||
if (line.isFinished()
|
||||
&& Util.equals(line.getOrderElement(), orderElement)) {
|
||||
return true;
|
||||
}
|
||||
if (workReport.isFinished(orderElement)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
List<WorkReportLine> lines = workReportLineDAO
|
||||
.findByOrderElementNotInWorkReportAnotherTransaction(
|
||||
.findFinishedByOrderElementNotInWorkReportAnotherTransaction(
|
||||
orderElement, workReport);
|
||||
for (WorkReportLine line : lines) {
|
||||
if (line.isFinished()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return !lines.isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,6 +158,10 @@
|
|||
<label value="${i18n:_('Effort')}" />
|
||||
<div id="personalTimesheetPopupEffort" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Finished')}" />
|
||||
<div id="personalTimesheetPopupFinished" />
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
<button onClick="controller.closePersonalTimesheetPopup();"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue