Show marks from timesheet dates in tasks when showing reported hours bar

FEA: ItEr77S12AdaptPlanningAccordingTimesheets
This commit is contained in:
Manuel Rego Casasnovas 2012-11-13 18:33:35 +01:00
parent c9a638e4f3
commit 9e4cbd2484
10 changed files with 120 additions and 4 deletions

View file

@ -24,11 +24,14 @@ package org.zkoss.ganttz;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.IOException;
import java.util.Date;
import java.util.Map;
import java.util.UUID;
import org.apache.commons.lang.Validate;
import org.joda.time.DateTime;
import org.joda.time.Days;
import org.joda.time.Duration;
import org.joda.time.LocalDate;
import org.zkoss.ganttz.adapters.IDisabilityConfiguration;
import org.zkoss.ganttz.data.GanttDate;
@ -517,8 +520,34 @@ public class TaskComponent extends Div implements AfterCompose {
this.task.getHoursAdvanceEndDate()) + "px";
response(null, new AuInvoke(this, "resizeCompletionAdvance",
widthHoursAdvancePercentage));
Date firstTimesheetDate = task.getFirstTimesheetDate();
Date lastTimesheetDate = task.getLastTimesheetDate();
if (firstTimesheetDate != null && lastTimesheetDate != null) {
Duration firstDuration = Days.daysBetween(
task.getBeginDateAsLocalDate(),
LocalDate.fromDateFields(firstTimesheetDate))
.toStandardDuration();
int pixelsFirst = getMapper().toPixels(firstDuration);
String positionFirst = pixelsFirst + "px";
Duration lastDuration = Days
.daysBetween(
task.getBeginDateAsLocalDate(),
LocalDate.fromDateFields(lastTimesheetDate)
.plusDays(1)).toStandardDuration();
int pixelsLast = getMapper().toPixels(lastDuration);
String positionLast = pixelsLast + "px";
response(null, new AuInvoke(this, "showTimsheetDateMarks",
positionFirst, positionLast));
} else {
response(null, new AuInvoke(this, "hideTimsheetDateMarks"));
}
} else {
response(null, new AuInvoke(this, "resizeCompletionAdvance", "0px"));
response(null, new AuInvoke(this, "hideTimsheetDateMarks"));
}
}

View file

@ -313,4 +313,14 @@ public class DefaultFundamentalProperties implements ITaskFundamentalProperties
return false;
}
@Override
public Date getFirstTimesheetDate() {
return null;
}
@Override
public Date getLastTimesheetDate() {
return null;
}
}

View file

@ -127,4 +127,8 @@ public interface ITaskFundamentalProperties {
boolean isUpdatedFromTimesheets();
Date getFirstTimesheetDate();
Date getLastTimesheetDate();
}

View file

@ -553,4 +553,14 @@ public abstract class Task implements ITaskFundamentalProperties {
return fundamentalProperties.isUpdatedFromTimesheets();
}
@Override
public Date getFirstTimesheetDate() {
return fundamentalProperties.getFirstTimesheetDate();
}
@Override
public Date getLastTimesheetDate() {
return fundamentalProperties.getLastTimesheetDate();
}
}

View file

@ -221,6 +221,18 @@ ganttz.TaskComponent = zk.$extends(zul.Widget, {
resizeCompletionAdvance : function(width){
jq('#' + this.uuid + ' .completion:first').css('width', width);
},
showTimsheetDateMarks : function(positionFirst, postionLast) {
var firstTimesheetDateMark = jq('#' + this.uuid + ' .first-timesheet-date');
var lastTimesheetDateMark = jq('#' + this.uuid + ' .last-timesheet-date');
firstTimesheetDateMark.css('left', positionFirst);
lastTimesheetDateMark.css('left', postionLast);
firstTimesheetDateMark.show();
lastTimesheetDateMark.show();
},
hideTimsheetDateMarks : function() {
jq('#' + this.uuid + ' .first-timesheet-date').hide();
jq('#' + this.uuid + ' .last-timesheet-date').hide();
},
resizeCompletion2Advance : function(width){
jq('#' + this.uuid + ' .completion2:first').css('width', width);
},

View file

@ -14,6 +14,8 @@ function(out){
out.push('<div class="completionMoneyCostBar"></div>');
out.push('<div class="completion"></div>');
out.push('<div class="completion2"></div>');
out.push('<div class="timesheet-date-mark first-timesheet-date">|</div>');
out.push('<div class="timesheet-date-mark last-timesheet-date">|</div>');
out.push('<div id="tasktooltip', this.uuid,'" class="task_tooltip">',
this.getTooltipText(),

View file

@ -1616,4 +1616,18 @@ public abstract class OrderElement extends IntegrationEntity implements
return taskElement.isUpdatedFromTimesheets();
}
public Date getFirstTimesheetDate() {
if (sumChargedEffort == null) {
return null;
}
return sumChargedEffort.getFirstTimesheetDate();
}
public Date getLastTimesheetDate() {
if (sumChargedEffort == null) {
return null;
}
return sumChargedEffort.getLastTimesheetDate();
}
}

View file

@ -1228,6 +1228,24 @@ _(
return taskElement.isUpdatedFromTimesheets();
}
@Override
public Date getFirstTimesheetDate() {
OrderElement orderElement = taskElement.getOrderElement();
if (orderElement != null) {
return orderElement.getFirstTimesheetDate();
}
return null;
}
@Override
public Date getLastTimesheetDate() {
OrderElement orderElement = taskElement.getOrderElement();
if (orderElement != null) {
return orderElement.getLastTimesheetDate();
}
return null;
}
}
@Override

View file

@ -92,10 +92,9 @@ public class AdaptPlanningCommand implements IAdaptPlanningCommand {
taskElement.setUpdatedFromTimesheets(false);
if (orderElement.hasTimesheetsReportingHours()) {
setStartDateAndConstraint(taskElement, orderElement
.getSumChargedEffort().getFirstTimesheetDate());
Date lastTimesheetDate = orderElement.getSumChargedEffort()
.getLastTimesheetDate();
setStartDateAndConstraint(taskElement,
orderElement.getFirstTimesheetDate());
Date lastTimesheetDate = orderElement.getLastTimesheetDate();
setEndDateIfNeeded(taskElement, lastTimesheetDate);
if (orderElement.isFinishedTimesheets()) {

View file

@ -274,6 +274,24 @@ div.box.limiting-unassigned {
margin-top: 1px;
}
.timesheet-date-mark {
color: #F21CFF;
font-size: 8px;
font-weight: bold;
/* By default marks are hidden */
display: none;
}
.first-timesheet-date {
position: absolute;
margin-top: -19px;
}
.last-timesheet-date {
position: absolute;
margin-top: -19px;
}
.completion2 {
width: 0%;
height: 6px;