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(
|
Pair<Date, Date> findMinAndMaxDatesByOrderElement(
|
||||||
OrderElement orderElement);
|
OrderElement orderElement);
|
||||||
|
|
||||||
List<WorkReportLine> findByOrderElementNotInWorkReportAnotherTransaction(
|
List<WorkReportLine> findFinishedByOrderElementNotInWorkReportAnotherTransaction(
|
||||||
OrderElement orderElement, WorkReport workReport);
|
OrderElement orderElement, WorkReport workReport);
|
||||||
|
|
||||||
Boolean isFinished(OrderElement orderElement);
|
Boolean isFinished(OrderElement orderElement);
|
||||||
|
|
|
||||||
|
|
@ -171,13 +171,13 @@ public class WorkReportLineDAO extends IntegrationEntityDAO<WorkReportLine>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW)
|
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW)
|
||||||
public List<WorkReportLine> findByOrderElementNotInWorkReportAnotherTransaction(
|
public List<WorkReportLine> findFinishedByOrderElementNotInWorkReportAnotherTransaction(
|
||||||
OrderElement orderElement, WorkReport workReport) {
|
OrderElement orderElement, WorkReport workReport) {
|
||||||
return findByOrderElementNotInWorkReport(orderElement, workReport);
|
return findFinishedByOrderElementNotInWorkReport(orderElement, workReport);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private List<WorkReportLine> findByOrderElementNotInWorkReport(
|
private List<WorkReportLine> findFinishedByOrderElementNotInWorkReport(
|
||||||
OrderElement orderElement, WorkReport workReport) {
|
OrderElement orderElement, WorkReport workReport) {
|
||||||
Criteria criteria = getSession().createCriteria(WorkReportLine.class);
|
Criteria criteria = getSession().createCriteria(WorkReportLine.class);
|
||||||
|
|
||||||
|
|
@ -185,6 +185,7 @@ public class WorkReportLineDAO extends IntegrationEntityDAO<WorkReportLine>
|
||||||
if (!workReport.isNewObject()) {
|
if (!workReport.isNewObject()) {
|
||||||
criteria.add(Restrictions.ne("workReport", workReport));
|
criteria.add(Restrictions.ne("workReport", workReport));
|
||||||
}
|
}
|
||||||
|
criteria.add(Restrictions.eq("finished", true));
|
||||||
|
|
||||||
return (List<WorkReportLine>) criteria.list();
|
return (List<WorkReportLine>) criteria.list();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -555,4 +555,14 @@ public class WorkReport extends IntegrationEntity implements
|
||||||
return true;
|
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()
|
List<WorkReportLine> lines = Registry.getWorkReportLineDAO()
|
||||||
.findByOrderElementNotInWorkReportAnotherTransaction(
|
.findFinishedByOrderElementNotInWorkReportAnotherTransaction(
|
||||||
orderElement, workReport);
|
orderElement, workReport);
|
||||||
for (WorkReportLine line : lines) {
|
return lines.isEmpty();
|
||||||
if (line.isFinished()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import org.libreplan.business.resources.entities.Resource;
|
||||||
import org.libreplan.business.resources.entities.Worker;
|
import org.libreplan.business.resources.entities.Worker;
|
||||||
import org.libreplan.business.workingday.EffortDuration;
|
import org.libreplan.business.workingday.EffortDuration;
|
||||||
import org.libreplan.business.workreports.entities.WorkReport;
|
import org.libreplan.business.workreports.entities.WorkReport;
|
||||||
|
import org.libreplan.business.workreports.entities.WorkReportLine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for creation/edition of a personal timesheet model
|
* Interface for creation/edition of a personal timesheet model
|
||||||
|
|
@ -227,4 +228,26 @@ public interface IPersonalTimesheetModel {
|
||||||
*/
|
*/
|
||||||
LocalDate getNext();
|
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.zk.ui.util.GenericForwardComposer;
|
||||||
import org.zkoss.zul.Button;
|
import org.zkoss.zul.Button;
|
||||||
import org.zkoss.zul.Cell;
|
import org.zkoss.zul.Cell;
|
||||||
|
import org.zkoss.zul.Checkbox;
|
||||||
import org.zkoss.zul.Column;
|
import org.zkoss.zul.Column;
|
||||||
import org.zkoss.zul.Columns;
|
import org.zkoss.zul.Columns;
|
||||||
import org.zkoss.zul.Frozen;
|
import org.zkoss.zul.Frozen;
|
||||||
|
|
@ -124,6 +125,8 @@ public class PersonalTimesheetController extends GenericForwardComposer
|
||||||
|
|
||||||
private Div personalTimesheetPopupEffort;
|
private Div personalTimesheetPopupEffort;
|
||||||
|
|
||||||
|
private Div personalTimesheetPopupFinished;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private IPersonalTimesheetController personalTimesheetController;
|
private IPersonalTimesheetController personalTimesheetController;
|
||||||
|
|
||||||
|
|
@ -289,6 +292,29 @@ public class PersonalTimesheetController extends GenericForwardComposer
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
personalTimesheetPopupEffort.appendChild(effortTextbox);
|
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;
|
return effortTextbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -396,14 +396,21 @@ public class PersonalTimesheetModel implements IPersonalTimesheetModel {
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public void setEffortDuration(OrderElement orderElement, LocalDate date,
|
public void setEffortDuration(OrderElement orderElement, LocalDate date,
|
||||||
EffortDuration effortDuration) {
|
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);
|
WorkReportLine workReportLine = getWorkReportLine(orderElement, date);
|
||||||
if (workReportLine == null) {
|
if (workReportLine == null) {
|
||||||
workReportLine = createWorkReportLine(orderElement, date);
|
workReportLine = createWorkReportLine(orderElement, date);
|
||||||
workReport.addWorkReportLine(workReportLine);
|
workReport.addWorkReportLine(workReportLine);
|
||||||
}
|
}
|
||||||
workReportLine.setEffort(effortDuration);
|
return workReportLine;
|
||||||
modified = true;
|
|
||||||
markAsModified(orderElement, date);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void markAsModified(OrderElement orderElement, LocalDate date) {
|
private void markAsModified(OrderElement orderElement, LocalDate date) {
|
||||||
|
|
@ -619,4 +626,35 @@ public class PersonalTimesheetModel implements IPersonalTimesheetModel {
|
||||||
return periodicity.next(date);
|
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.apache.commons.lang.Validate;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.libreplan.business.common.IntegrationEntity;
|
import org.libreplan.business.common.IntegrationEntity;
|
||||||
import org.libreplan.business.common.Util;
|
|
||||||
import org.libreplan.business.common.daos.IConfigurationDAO;
|
import org.libreplan.business.common.daos.IConfigurationDAO;
|
||||||
import org.libreplan.business.common.entities.EntityNameEnum;
|
import org.libreplan.business.common.entities.EntityNameEnum;
|
||||||
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
|
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
|
||||||
|
|
@ -661,22 +660,14 @@ public class WorkReportModel extends IntegrationEntityModel implements
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public boolean isFinished(OrderElement orderElement) {
|
public boolean isFinished(OrderElement orderElement) {
|
||||||
for (WorkReportLine line : workReport.getWorkReportLines()) {
|
if (workReport.isFinished(orderElement)) {
|
||||||
if (line.isFinished()
|
|
||||||
&& Util.equals(line.getOrderElement(), orderElement)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
List<WorkReportLine> lines = workReportLineDAO
|
List<WorkReportLine> lines = workReportLineDAO
|
||||||
.findByOrderElementNotInWorkReportAnotherTransaction(
|
.findFinishedByOrderElementNotInWorkReportAnotherTransaction(
|
||||||
orderElement, workReport);
|
orderElement, workReport);
|
||||||
for (WorkReportLine line : lines) {
|
return !lines.isEmpty();
|
||||||
if (line.isFinished()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,10 @@
|
||||||
<label value="${i18n:_('Effort')}" />
|
<label value="${i18n:_('Effort')}" />
|
||||||
<div id="personalTimesheetPopupEffort" />
|
<div id="personalTimesheetPopupEffort" />
|
||||||
</row>
|
</row>
|
||||||
|
<row>
|
||||||
|
<label value="${i18n:_('Finished')}" />
|
||||||
|
<div id="personalTimesheetPopupFinished" />
|
||||||
|
</row>
|
||||||
</rows>
|
</rows>
|
||||||
</grid>
|
</grid>
|
||||||
<button onClick="controller.closePersonalTimesheetPopup();"
|
<button onClick="controller.closePersonalTimesheetPopup();"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue