Skip to content

Commit 710ff11

Browse files
author
jsGanttImproved
committed
Honour dates on standard group tasks if they fall outside of the calculated range
1 parent b00ebb5 commit 710ff11

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

jsgantt.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
_ ___ _____ _ _____ ____ _
3-
(_) / _ \ \_ \ / ||___ | ___| / |
4-
| |/ /_\/ / /\/ | | / /|___ \ | |
5-
| / /_\\/\/ /_ | |_ / /_ ___) || |
6-
_/ \____/\____/ |_(_)_/(_)____(_)_|
2+
_ ___ _____ _ _____ ____ ____
3+
(_) / _ \ \_ \ / ||___ | ___| |___ \
4+
| |/ /_\/ / /\/ | | / /|___ \ __) |
5+
| / /_\\/\/ /_ | |_ / /_ ___) | / __/
6+
_/ \____/\____/ |_(_)_/(_)____(_)_____|
77
|__/
8-
jsGanttImproved 1.7.5.1
8+
jsGanttImproved 1.7.5.2
99
Copyright (c) 2013-2016, Paul Geldart All rights reserved.
1010
1111
The current version of this code can be found at https://code.google.com/p/jsgantt-improved/
@@ -85,6 +85,8 @@ JSGantt.TaskItem=function(pID, pName, pStart, pEnd, pClass, pLink, pMile, pRes,
8585
var vName=document.createTextNode(pName).data;
8686
var vStart=new Date(0);
8787
var vEnd=new Date(0);
88+
var vGroupMinStart=null;
89+
var vGroupMinEnd=null;
8890
var vClass=document.createTextNode(pClass).data;
8991
var vLink=document.createTextNode(pLink).data;
9092
var vMile=parseInt(document.createTextNode(pMile).data);
@@ -121,10 +123,16 @@ JSGantt.TaskItem=function(pID, pName, pStart, pEnd, pClass, pLink, pMile, pRes,
121123
JSGantt.stripUnwanted(vNotes);
122124
}
123125

124-
if (vGroup!=1)
126+
if (pStart!=null && pStart!='')
125127
{
126128
vStart=(pStart instanceof Date)?pStart:JSGantt.parseDateStr(document.createTextNode(pStart).data,vGantt.getDateInputFormat());
129+
vGroupMinStart=vStart;
130+
}
131+
132+
if (pEnd!=null && pEnd!='')
133+
{
127134
vEnd =(pEnd instanceof Date)?pEnd:JSGantt.parseDateStr(document.createTextNode(pEnd).data,vGantt.getDateInputFormat());
135+
vGroupMinEnd=vEnd;
128136
}
129137

130138
if (pDepend!=null)
@@ -167,6 +175,8 @@ JSGantt.TaskItem=function(pID, pName, pStart, pEnd, pClass, pLink, pMile, pRes,
167175
this.getName=function(){return vName;};
168176
this.getStart=function(){return vStart;};
169177
this.getEnd=function(){return vEnd;};
178+
this.getGroupMinStart=function(){return vGroupMinStart;};
179+
this.getGroupMinEnd=function(){return vGroupMinEnd;};
170180
this.getClass=function(){return vClass;};
171181
this.getLink=function(){return vLink;};
172182
this.getMile=function(){return vMile;};
@@ -235,6 +245,8 @@ JSGantt.TaskItem=function(pID, pName, pStart, pEnd, pClass, pLink, pMile, pRes,
235245
this.getGroupSpan=function(){return vGroupSpan;};
236246
this.setStart=function(pStart){if(pStart instanceof Date)vStart=pStart;};
237247
this.setEnd=function(pEnd){if(pEnd instanceof Date)vEnd=pEnd;};
248+
this.setGroupMinStart=function(pStart){if(pStart instanceof Date)vGroupMinStart=pStart;};
249+
this.setGroupMinEnd=function(pEnd){if(pEnd instanceof Date)vGroupMinEnd=pEnd;};
238250
this.setLevel=function(pLevel){vLevel=parseInt(document.createTextNode(pLevel).data);};
239251
this.setNumKid=function(pNumKid){vNumKid=parseInt(document.createTextNode(pNumKid).data);};
240252
this.setCompVal=function(pCompVal){vComp=parseFloat(document.createTextNode(pCompVal).data);};
@@ -1755,6 +1767,15 @@ JSGantt.processRows=function(pList, pID, pRow, pLevel, pOpen, pUseSort)
17551767

17561768
if(pRow>=0)
17571769
{
1770+
if(pList[pRow].getGroupMinStart()!=null && pList[pRow].getGroupMinStart()<vMinDate)
1771+
{
1772+
vMinDate=pList[pRow].getGroupMinStart();
1773+
}
1774+
1775+
if(pList[pRow].getGroupMinEnd()!=null && pList[pRow].getGroupMinEnd()>vMaxDate)
1776+
{
1777+
vMaxDate=pList[pRow].getGroupMinEnd();
1778+
}
17581779
pList[pRow].setStart(vMinDate);
17591780
pList[pRow].setEnd(vMaxDate);
17601781
pList[pRow].setNumKid(vNumKid);

0 commit comments

Comments
 (0)