From 83c5733732ed31af86adcf2be21bd0fcec383514 Mon Sep 17 00:00:00 2001 From: Mario Mol Date: Tue, 1 Jan 2019 20:41:04 -0200 Subject: [PATCH 1/8] Complete variable for groups instead of calculated 2.0.10 --- docs/fixes/data.json | 2 +- docs/jsgantt.js | 8 ++++++-- package.json | 2 +- src/task.ts | 8 ++++---- src/utils.ts | 1 - 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/docs/fixes/data.json b/docs/fixes/data.json index 4e73743a..434c9c2e 100644 --- a/docs/fixes/data.json +++ b/docs/fixes/data.json @@ -260,7 +260,7 @@ "pLink": "", "pMile": 0, "pRes": "Anybody", - "pComp": 60, + "pComp": 67, "pGroup": 1, "pParent": 3, "pOpen": 0, diff --git a/docs/jsgantt.js b/docs/jsgantt.js index 500b85f9..cc9f44da 100644 --- a/docs/jsgantt.js +++ b/docs/jsgantt.js @@ -2387,6 +2387,7 @@ exports.TaskItem = function (pID, pName, pStart, pEnd, pClass, pLink, pMile, pRe var vCost = parseInt(document.createTextNode(pCost).data); var vGroup = parseInt(document.createTextNode(pGroup).data); var vDataObject = pDataObject; + var vCompVal; var parent = document.createTextNode(pParent).data; if (parent && parent !== '0') { parent = utils_1.hashKey(parent).toString(); @@ -2514,10 +2515,14 @@ exports.TaskItem = function (pID, pName, pStart, pEnd, pClass, pLink, pMile, pRe return '\u00A0'; }; this.getCompVal = function () { if (vComp) return vComp; + else if (vCompVal) + return vCompVal; else return 0; }; this.getCompStr = function () { if (vComp) return vComp + '%'; + else if (vCompVal) + return vCompVal + '%'; else return ''; }; this.getNotes = function () { return vNotes; }; @@ -2624,7 +2629,7 @@ exports.TaskItem = function (pID, pName, pStart, pEnd, pClass, pLink, pMile, pRe this.setLevel = function (pLevel) { vLevel = parseInt(document.createTextNode(pLevel).data); }; this.setNumKid = function (pNumKid) { vNumKid = parseInt(document.createTextNode(pNumKid).data); }; this.setWeight = function (pWeight) { vWeight = parseInt(document.createTextNode(pWeight).data); }; - this.setCompVal = function (pCompVal) { vComp = parseFloat(document.createTextNode(pCompVal).data); }; + this.setCompVal = function (pCompVal) { vCompVal = parseFloat(document.createTextNode(pCompVal).data); }; this.setCost = function (pCost) { vComp = parseInt(document.createTextNode(pCost).data); }; @@ -3067,7 +3072,6 @@ exports.formatDateStr = function (pDate, pDateFormatArr, pL) { return vDateStr; }; exports.parseDateFormatStr = function (pFormatStr) { - var vDateStr = ''; var vComponantStr = ''; var vCurrChar = ''; var vSeparators = new RegExp('[\/\\ -.,\'":]'); diff --git a/package.json b/package.json index 85d1b98c..dbc4d35f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jsgantt-improved", - "version": "2.0.9", + "version": "2.0.10", "description": "jsgantt-improved", "main": "dist/index.js", "scripts": { diff --git a/src/task.ts b/src/task.ts index d1e35cf6..984dd58c 100644 --- a/src/task.ts +++ b/src/task.ts @@ -176,6 +176,7 @@ export const TaskItem = function (pID, pName, pStart, pEnd, pClass, pLink, pMile let vCost = parseInt(document.createTextNode(pCost).data) let vGroup = parseInt(document.createTextNode(pGroup).data); let vDataObject = pDataObject; + let vCompVal; let parent = document.createTextNode(pParent).data; if (parent && parent !== '0') { @@ -295,12 +296,11 @@ export const TaskItem = function (pID, pName, pStart, pEnd, pClass, pLink, pMile if (vDepend) return vDepend; else return null; }; this.getDataObject = function () { return vDataObject; }; - this.getDepType = function () { if (vDependType) return vDependType; else return null; }; this.getCaption = function () { if (vCaption) return vCaption; else return ''; }; this.getResource = function () { if (vRes) return vRes; else return '\u00A0'; }; - this.getCompVal = function () { if (vComp) return vComp; else return 0; }; - this.getCompStr = function () { if (vComp) return vComp + '%'; else return ''; }; + this.getCompVal = function () { if (vComp) return vComp; else if(vCompVal) return vCompVal; else return 0; }; + this.getCompStr = function () { if (vComp) return vComp + '%'; else if (vCompVal) return vCompVal + '%'; else return ''; }; this.getNotes = function () { return vNotes; }; this.getSortIdx = function () { return vSortIdx; }; this.getToDelete = function () { return vToDelete; }; @@ -378,7 +378,7 @@ export const TaskItem = function (pID, pName, pStart, pEnd, pClass, pLink, pMile this.setLevel = function (pLevel) { vLevel = parseInt(document.createTextNode(pLevel).data); }; this.setNumKid = function (pNumKid) { vNumKid = parseInt(document.createTextNode(pNumKid).data); }; this.setWeight = function (pWeight) { vWeight = parseInt(document.createTextNode(pWeight).data); }; - this.setCompVal = function (pCompVal) { vComp = parseFloat(document.createTextNode(pCompVal).data); }; + this.setCompVal = function (pCompVal) { vCompVal = parseFloat(document.createTextNode(pCompVal).data); }; this.setCost = function (pCost) { vComp = parseInt(document.createTextNode(pCost).data); }; diff --git a/src/utils.ts b/src/utils.ts index 0c892c52..6fd0d418 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -214,7 +214,6 @@ export const formatDateStr = function (pDate, pDateFormatArr, pL) { }; export const parseDateFormatStr = function (pFormatStr) { - let vDateStr = ''; let vComponantStr = ''; let vCurrChar = ''; let vSeparators = new RegExp('[\/\\ -.,\'":]'); From d52f0de34be630bfe4ee5d28bd4c9e9d1c1710bc Mon Sep 17 00:00:00 2001 From: Mario Mol Date: Tue, 1 Jan 2019 20:42:11 -0200 Subject: [PATCH 2/8] including 2.0.10 in docs --- docs/index.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/index.html b/docs/index.html index c84b35d8..41eaadf1 100644 --- a/docs/index.html +++ b/docs/index.html @@ -83,7 +83,7 @@

jsGanttImproved

-

latest v2.0.8

+

latest v2.0.10

Download View on GitHub @@ -231,6 +231,10 @@

Current Known Issues:

Changelog:

Check the full list of changes on GitHub releases page.

+

2.0.10:

+
    +
  • Use complete value from task group from data instead of calculated
  • +

v2.0.9:

  • Editing data in gantt table
  • From d226d7dc55d2b6f4f5638c811e19c86393f4caad Mon Sep 17 00:00:00 2001 From: Mario Mol Date: Wed, 2 Jan 2019 10:21:58 -0200 Subject: [PATCH 3/8] 2.1 release with new way of rendering the gantt --- docs/jsgantt.css | 36 ++++++++++++++++++++--- docs/jsgantt.js | 59 +++++++++++++++++++++++++++++--------- package.json | 2 +- src/draw.ts | 74 +++++++++++++++++++++++++++++++++++++++--------- src/jsgantt.css | 36 ++++++++++++++++++++--- 5 files changed, 172 insertions(+), 35 deletions(-) diff --git a/docs/jsgantt.css b/docs/jsgantt.css index 0fc702f5..2ec80d49 100644 --- a/docs/jsgantt.css +++ b/docs/jsgantt.css @@ -636,7 +636,8 @@ div.gtaskbarcontainer { padding-top: 0px; background-color: #ffffff; position: relative; - overflow: auto; + /* overflow: auto; */ + overflow: unset; min-height: 0%; } @@ -647,7 +648,7 @@ div.gtaskbarcontainer { padding-top: 0px; background-color: #ffffff; position: relative; - overflow: hidden; + overflow: unset; } /* Old Internet Explorer version hacks */ @@ -777,7 +778,7 @@ td.gspanning div { .gchartgrid { overflow: unset !important; } - .glistgrid{ + .glistgrid { float: none !important; } } @@ -798,4 +799,31 @@ td.gspanning div { .ggroupquarter td, .gmilequarter td, .gitemquarter td { background-size: 19px 1px; background-image: linear-gradient(to left, #efefef, transparent 1px, transparent 18px); width: 100%; height: 19px; } -*/ \ No newline at end of file +*/ + +.gmain { + width: 50%; + display: inline-block; + height: 100%; +} + +.gmainright { + /* position: absolute; */ + overflow-x: scroll; + overflow-y: hidden; + top: 0; +} + +.gmainleft{ + overflow-x: scroll; +} + +.gtasktableh tr, +.gcharttable tr , +.gtasktable tr { + height: 22px !important; +} + +.gtasktable{ + margin-bottom: 14px; +} \ No newline at end of file diff --git a/docs/jsgantt.js b/docs/jsgantt.js index cc9f44da..14eadd41 100644 --- a/docs/jsgantt.js +++ b/docs/jsgantt.js @@ -350,6 +350,13 @@ exports.GanttChart = function (pDiv, pFormat) { vColWidth = this.vHourColWidth; // DRAW the Left-side of the chart (names, resources, comp%) var vLeftHeader = document.createDocumentFragment(); + /** + * LIST HEAD + * + * + * + * HEADINGS + */ var vTmpDiv = this.newNode(vLeftHeader, 'div', this.vDivId + 'glisthead', 'glistlbl gcontainercol'); var vTmpTab = this.newNode(vTmpDiv, 'table', null, 'gtasktableh'); var vTmpTBody = this.newNode(vTmpTab, 'tbody'); @@ -407,11 +414,17 @@ exports.GanttChart = function (pDiv, pFormat) { this.newNode(vTmpRow, 'td', null, "gtaskheading gadditional " + css, text); } } - var vLeftTable = document.createDocumentFragment(); - var vTmpDiv2 = this.newNode(vLeftTable, 'div', this.vDivId + 'glistbody', 'glistgrid gcontainercol'); - this.setListBody(vTmpDiv2); - vTmpTab = this.newNode(vTmpDiv2, 'table', null, 'gtasktable'); - vTmpTBody = this.newNode(vTmpTab, 'tbody'); + /** + * LIST BODY + * + * + */ + // let vLeftTable = document.createDocumentFragment(); + // let vTmpDiv2 = this.newNode(vLeftTable, 'div', this.vDivId + 'glistbody', 'glistgrid gcontainercol'); + // this.setListBody(vTmpDiv2); + // vTmpTab = this.newNode(vTmpDiv2, 'table', null, 'gtasktable'); + // vTmpTBody = this.newNode(vTmpTab, 'tbody'); + var vTmpDiv2 = void 0; var _loop_1 = function (i_1) { var vBGColor = void 0; if (this_1.vTaskList[i_1].getGroup() == 1) @@ -576,9 +589,14 @@ exports.GanttChart = function (pDiv, pFormat) { } // Add some white space so the vertical scroll distance should always be greater // than for the right pane (keep to a minimum as it is seen in unconstrained height designs) - this.newNode(vTmpDiv2, 'br'); - this.newNode(vTmpDiv2, 'br'); - // Draw the Chart Rows + // this.newNode(vTmpDiv2, 'br'); + // this.newNode(vTmpDiv2, 'br'); + /** + * CHART HEAD + * + * + * HEADINGS + */ var vRightHeader = document.createDocumentFragment(); vTmpDiv = this.newNode(vRightHeader, 'div', this.vDivId + 'gcharthead', 'gchartlbl gcontainercol'); this.setChartHead(vTmpDiv); @@ -710,6 +728,12 @@ exports.GanttChart = function (pDiv, pFormat) { vSingleCell = true; this.newNode(vTmpDiv, 'div', null, 'rhscrpad', null, null, vTaskLeftPx + 1); vTmpDiv = this.newNode(vRightHeader, 'div', null, 'glabelfooter'); + /** + * CHART GRID + * + * + * + */ var vRightTable = document.createDocumentFragment(); vTmpDiv = this.newNode(vRightTable, 'div', this.vDivId + 'gchartbody', 'gchartgrid gcontainercol'); this.setChartBody(vTmpDiv); @@ -890,13 +914,22 @@ exports.GanttChart = function (pDiv, pFormat) { } if (!vSingleCell) vTmpTBody.appendChild(vDateRow.cloneNode(true)); + // MAIN VIEW: Appending all generated components to main view while (this.vDiv.hasChildNodes()) this.vDiv.removeChild(this.vDiv.firstChild); vTmpDiv = this.newNode(this.vDiv, 'div', null, 'gchartcontainer'); - vTmpDiv.appendChild(vLeftHeader); - vTmpDiv.appendChild(vRightHeader); - vTmpDiv.appendChild(vLeftTable); - vTmpDiv.appendChild(vRightTable); + var leftvTmpDiv = this.newNode(vTmpDiv, 'div', null, 'gmain gmainleft'); + leftvTmpDiv.appendChild(vLeftHeader); + // leftvTmpDiv.appendChild(vLeftTable); + var rightvTmpDiv = this.newNode(vTmpDiv, 'div', null, 'gmain gmainright'); + rightvTmpDiv.appendChild(vRightHeader); + rightvTmpDiv.appendChild(vRightTable); + vTmpDiv.appendChild(leftvTmpDiv); + vTmpDiv.appendChild(rightvTmpDiv); + //vTmpDiv.appendChild(vLeftHeader); + // vTmpDiv.appendChild(vRightHeader); + // vTmpDiv.appendChild(vLeftTable); + // vTmpDiv.appendChild(vRightTable); this.newNode(vTmpDiv, 'div', null, 'ggridfooter'); vTmpDiv2 = this.newNode(this.getChartBody(), 'div', this.vDivId + 'Lines', 'glinediv'); vTmpDiv2.style.visibility = 'hidden'; @@ -906,7 +939,7 @@ exports.GanttChart = function (pDiv, pFormat) { tmpGenSrc.appendChild(document.createTextNode(vTmpDiv.innerHTML)); vDiv.appendChild(tmpGenSrc); //*/ - // Now all the content exists, register scroll listeners + // LISTENERS: Now all the content exists, register scroll listeners events_1.addScrollListeners(this); // now check if we are actually scrolling the pane if (this.vScrollTo != '') { diff --git a/package.json b/package.json index dbc4d35f..e939487a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jsgantt-improved", - "version": "2.0.10", + "version": "2.1.0", "description": "jsgantt-improved", "main": "dist/index.js", "scripts": { diff --git a/src/draw.ts b/src/draw.ts index f70dbb6b..ed20ea82 100644 --- a/src/draw.ts +++ b/src/draw.ts @@ -354,6 +354,14 @@ export const GanttChart = function (pDiv, pFormat) { // DRAW the Left-side of the chart (names, resources, comp%) let vLeftHeader = document.createDocumentFragment(); + + /** + * LIST HEAD + * + * + * + * HEADINGS + */ let vTmpDiv = this.newNode(vLeftHeader, 'div', this.vDivId + 'glisthead', 'glistlbl gcontainercol'); let vTmpTab = this.newNode(vTmpDiv, 'table', null, 'gtasktableh'); let vTmpTBody = this.newNode(vTmpTab, 'tbody'); @@ -397,11 +405,18 @@ export const GanttChart = function (pDiv, pFormat) { } } - let vLeftTable = document.createDocumentFragment(); - let vTmpDiv2 = this.newNode(vLeftTable, 'div', this.vDivId + 'glistbody', 'glistgrid gcontainercol'); - this.setListBody(vTmpDiv2); - vTmpTab = this.newNode(vTmpDiv2, 'table', null, 'gtasktable'); - vTmpTBody = this.newNode(vTmpTab, 'tbody'); + + /** + * LIST BODY + * + * + */ + // let vLeftTable = document.createDocumentFragment(); + // let vTmpDiv2 = this.newNode(vLeftTable, 'div', this.vDivId + 'glistbody', 'glistgrid gcontainercol'); + // this.setListBody(vTmpDiv2); + // vTmpTab = this.newNode(vTmpDiv2, 'table', null, 'gtasktable'); + // vTmpTBody = this.newNode(vTmpTab, 'tbody'); + let vTmpDiv2; for (let i = 0; i < this.vTaskList.length; i++) { let vBGColor; @@ -560,10 +575,19 @@ export const GanttChart = function (pDiv, pFormat) { // Add some white space so the vertical scroll distance should always be greater // than for the right pane (keep to a minimum as it is seen in unconstrained height designs) - this.newNode(vTmpDiv2, 'br'); - this.newNode(vTmpDiv2, 'br'); + // this.newNode(vTmpDiv2, 'br'); + // this.newNode(vTmpDiv2, 'br'); + + + - // Draw the Chart Rows + + /** + * CHART HEAD + * + * + * HEADINGS + */ let vRightHeader = document.createDocumentFragment(); vTmpDiv = this.newNode(vRightHeader, 'div', this.vDivId + 'gcharthead', 'gchartlbl gcontainercol'); this.setChartHead(vTmpDiv); @@ -707,6 +731,14 @@ export const GanttChart = function (pDiv, pFormat) { vTmpDiv = this.newNode(vRightHeader, 'div', null, 'glabelfooter'); + + + /** + * CHART GRID + * + * + * + */ let vRightTable = document.createDocumentFragment(); vTmpDiv = this.newNode(vRightTable, 'div', this.vDivId + 'gchartbody', 'gchartgrid gcontainercol'); this.setChartBody(vTmpDiv); @@ -896,12 +928,26 @@ export const GanttChart = function (pDiv, pFormat) { } if (!vSingleCell) vTmpTBody.appendChild(vDateRow.cloneNode(true)); + + // MAIN VIEW: Appending all generated components to main view while (this.vDiv.hasChildNodes()) this.vDiv.removeChild(this.vDiv.firstChild); vTmpDiv = this.newNode(this.vDiv, 'div', null, 'gchartcontainer'); - vTmpDiv.appendChild(vLeftHeader); - vTmpDiv.appendChild(vRightHeader); - vTmpDiv.appendChild(vLeftTable); - vTmpDiv.appendChild(vRightTable); + + let leftvTmpDiv = this.newNode(vTmpDiv, 'div', null, 'gmain gmainleft'); + leftvTmpDiv.appendChild(vLeftHeader); + // leftvTmpDiv.appendChild(vLeftTable); + + let rightvTmpDiv = this.newNode(vTmpDiv, 'div', null, 'gmain gmainright'); + rightvTmpDiv.appendChild(vRightHeader); + rightvTmpDiv.appendChild(vRightTable); + + vTmpDiv.appendChild(leftvTmpDiv); + vTmpDiv.appendChild(rightvTmpDiv); + + //vTmpDiv.appendChild(vLeftHeader); + // vTmpDiv.appendChild(vRightHeader); + // vTmpDiv.appendChild(vLeftTable); + // vTmpDiv.appendChild(vRightTable); this.newNode(vTmpDiv, 'div', null, 'ggridfooter'); vTmpDiv2 = this.newNode(this.getChartBody(), 'div', this.vDivId + 'Lines', 'glinediv'); vTmpDiv2.style.visibility = 'hidden'; @@ -912,7 +958,9 @@ export const GanttChart = function (pDiv, pFormat) { tmpGenSrc.appendChild(document.createTextNode(vTmpDiv.innerHTML)); vDiv.appendChild(tmpGenSrc); //*/ - // Now all the content exists, register scroll listeners + + + // LISTENERS: Now all the content exists, register scroll listeners addScrollListeners(this); // now check if we are actually scrolling the pane diff --git a/src/jsgantt.css b/src/jsgantt.css index 0fc702f5..2ec80d49 100644 --- a/src/jsgantt.css +++ b/src/jsgantt.css @@ -636,7 +636,8 @@ div.gtaskbarcontainer { padding-top: 0px; background-color: #ffffff; position: relative; - overflow: auto; + /* overflow: auto; */ + overflow: unset; min-height: 0%; } @@ -647,7 +648,7 @@ div.gtaskbarcontainer { padding-top: 0px; background-color: #ffffff; position: relative; - overflow: hidden; + overflow: unset; } /* Old Internet Explorer version hacks */ @@ -777,7 +778,7 @@ td.gspanning div { .gchartgrid { overflow: unset !important; } - .glistgrid{ + .glistgrid { float: none !important; } } @@ -798,4 +799,31 @@ td.gspanning div { .ggroupquarter td, .gmilequarter td, .gitemquarter td { background-size: 19px 1px; background-image: linear-gradient(to left, #efefef, transparent 1px, transparent 18px); width: 100%; height: 19px; } -*/ \ No newline at end of file +*/ + +.gmain { + width: 50%; + display: inline-block; + height: 100%; +} + +.gmainright { + /* position: absolute; */ + overflow-x: scroll; + overflow-y: hidden; + top: 0; +} + +.gmainleft{ + overflow-x: scroll; +} + +.gtasktableh tr, +.gcharttable tr , +.gtasktable tr { + height: 22px !important; +} + +.gtasktable{ + margin-bottom: 14px; +} \ No newline at end of file From 396fe5993da6bc0300f433ee6c4e279e76ed4dc4 Mon Sep 17 00:00:00 2001 From: Mario Mol Date: Wed, 2 Jan 2019 10:41:59 -0200 Subject: [PATCH 4/8] better printing --- docs/jsgantt.css | 143 +++++++++++++++++++++++++---------------------- src/jsgantt.css | 143 +++++++++++++++++++++++++---------------------- 2 files changed, 152 insertions(+), 134 deletions(-) diff --git a/docs/jsgantt.css b/docs/jsgantt.css index 2ec80d49..10a300ce 100644 --- a/docs/jsgantt.css +++ b/docs/jsgantt.css @@ -397,69 +397,6 @@ span.gfoldercollapse { margin-top: 4px; } -/* Printer friendly styles - we could use these all the time but they are not as pretty! */ - -/* note that "@media print" is not supported in IE6 or 7. Fully patched IE8 should be OK */ - -@media print { - .ggroupblack { - height: 0px; - border-top: 7px solid; - border-color: #000000; - } - .gtaskblue { - height: 0px; - border-top: 13px solid; - border-color: rgb(58, 132, 195); - } - .gtaskred { - height: 0px; - border-top: 13px solid; - border-color: rgb(196, 58, 58); - } - .gtaskgreen { - height: 0px; - border-top: 13px solid; - border-color: rgb(80, 193, 58); - } - .gtaskyellow { - height: 0px; - border-top: 13px solid; - border-color: rgb(247, 228, 56); - } - .gtaskpurple { - height: 0px; - border-top: 13px solid; - border-color: rgb(193, 58, 193); - } - .gtaskpink { - height: 0px; - border-top: 13px solid; - border-color: rgb(249, 177, 245); - } - .gtaskbluecomplete, - .gtaskredcomplete, - .gtaskgreencomplete, - .gtaskyellowcomplete, - .gtaskpurplecomplete, - .gtaskpinkcomplete { - height: 0px; - filter: alpha(opacity=40); - opacity: 0.4; - margin-top: -9px; - border-top: 5px solid; - border-color: #000000; - } - .ggroupblackcomplete { - height: 0px; - filter: alpha(opacity=80); - opacity: 0.8; - margin-top: -5px; - border-top: 3px solid; - border-color: #777777; - } -} - /* END Task bar styles */ .glinev { @@ -808,22 +745,94 @@ td.gspanning div { } .gmainright { - /* position: absolute; */ overflow-x: scroll; overflow-y: hidden; top: 0; } -.gmainleft{ +.gmainleft { overflow-x: scroll; } .gtasktableh tr, -.gcharttable tr , +.gcharttable tr, .gtasktable tr { height: 22px !important; } -.gtasktable{ +.gtasktable { margin-bottom: 14px; +} + +/* Printer friendly styles - we could use these all the time but they are not as pretty! */ + +/* note that "@media print" is not supported in IE6 or 7. Fully patched IE8 should be OK */ + +@media print { + .ggroupblack { + height: 0px; + border-top: 7px solid; + border-color: #000000; + } + .gtaskblue { + height: 0px; + border-top: 13px solid; + border-color: rgb(58, 132, 195); + } + .gtaskred { + height: 0px; + border-top: 13px solid; + border-color: rgb(196, 58, 58); + } + .gtaskgreen { + height: 0px; + border-top: 13px solid; + border-color: rgb(80, 193, 58); + } + .gtaskyellow { + height: 0px; + border-top: 13px solid; + border-color: rgb(247, 228, 56); + } + .gtaskpurple { + height: 0px; + border-top: 13px solid; + border-color: rgb(193, 58, 193); + } + .gtaskpink { + height: 0px; + border-top: 13px solid; + border-color: rgb(249, 177, 245); + } + .gtaskbluecomplete, + .gtaskredcomplete, + .gtaskgreencomplete, + .gtaskyellowcomplete, + .gtaskpurplecomplete, + .gtaskpinkcomplete { + height: 0px; + filter: alpha(opacity=40); + opacity: 0.4; + margin-top: -9px; + border-top: 5px solid; + border-color: #000000; + } + .ggroupblackcomplete { + height: 0px; + filter: alpha(opacity=80); + opacity: 0.8; + margin-top: -5px; + border-top: 3px solid; + border-color: #777777; + } + .gmainright, + .gmainleft { + overflow: hidden; + width: auto; + } + table { page-break-after:auto } + tr { page-break-inside:avoid; page-break-after:auto } + td { page-break-inside:avoid; page-break-after:auto } + thead { display:table-header-group } + tfoot { display:table-footer-group } } \ No newline at end of file diff --git a/src/jsgantt.css b/src/jsgantt.css index 2ec80d49..10a300ce 100644 --- a/src/jsgantt.css +++ b/src/jsgantt.css @@ -397,69 +397,6 @@ span.gfoldercollapse { margin-top: 4px; } -/* Printer friendly styles - we could use these all the time but they are not as pretty! */ - -/* note that "@media print" is not supported in IE6 or 7. Fully patched IE8 should be OK */ - -@media print { - .ggroupblack { - height: 0px; - border-top: 7px solid; - border-color: #000000; - } - .gtaskblue { - height: 0px; - border-top: 13px solid; - border-color: rgb(58, 132, 195); - } - .gtaskred { - height: 0px; - border-top: 13px solid; - border-color: rgb(196, 58, 58); - } - .gtaskgreen { - height: 0px; - border-top: 13px solid; - border-color: rgb(80, 193, 58); - } - .gtaskyellow { - height: 0px; - border-top: 13px solid; - border-color: rgb(247, 228, 56); - } - .gtaskpurple { - height: 0px; - border-top: 13px solid; - border-color: rgb(193, 58, 193); - } - .gtaskpink { - height: 0px; - border-top: 13px solid; - border-color: rgb(249, 177, 245); - } - .gtaskbluecomplete, - .gtaskredcomplete, - .gtaskgreencomplete, - .gtaskyellowcomplete, - .gtaskpurplecomplete, - .gtaskpinkcomplete { - height: 0px; - filter: alpha(opacity=40); - opacity: 0.4; - margin-top: -9px; - border-top: 5px solid; - border-color: #000000; - } - .ggroupblackcomplete { - height: 0px; - filter: alpha(opacity=80); - opacity: 0.8; - margin-top: -5px; - border-top: 3px solid; - border-color: #777777; - } -} - /* END Task bar styles */ .glinev { @@ -808,22 +745,94 @@ td.gspanning div { } .gmainright { - /* position: absolute; */ overflow-x: scroll; overflow-y: hidden; top: 0; } -.gmainleft{ +.gmainleft { overflow-x: scroll; } .gtasktableh tr, -.gcharttable tr , +.gcharttable tr, .gtasktable tr { height: 22px !important; } -.gtasktable{ +.gtasktable { margin-bottom: 14px; +} + +/* Printer friendly styles - we could use these all the time but they are not as pretty! */ + +/* note that "@media print" is not supported in IE6 or 7. Fully patched IE8 should be OK */ + +@media print { + .ggroupblack { + height: 0px; + border-top: 7px solid; + border-color: #000000; + } + .gtaskblue { + height: 0px; + border-top: 13px solid; + border-color: rgb(58, 132, 195); + } + .gtaskred { + height: 0px; + border-top: 13px solid; + border-color: rgb(196, 58, 58); + } + .gtaskgreen { + height: 0px; + border-top: 13px solid; + border-color: rgb(80, 193, 58); + } + .gtaskyellow { + height: 0px; + border-top: 13px solid; + border-color: rgb(247, 228, 56); + } + .gtaskpurple { + height: 0px; + border-top: 13px solid; + border-color: rgb(193, 58, 193); + } + .gtaskpink { + height: 0px; + border-top: 13px solid; + border-color: rgb(249, 177, 245); + } + .gtaskbluecomplete, + .gtaskredcomplete, + .gtaskgreencomplete, + .gtaskyellowcomplete, + .gtaskpurplecomplete, + .gtaskpinkcomplete { + height: 0px; + filter: alpha(opacity=40); + opacity: 0.4; + margin-top: -9px; + border-top: 5px solid; + border-color: #000000; + } + .ggroupblackcomplete { + height: 0px; + filter: alpha(opacity=80); + opacity: 0.8; + margin-top: -5px; + border-top: 3px solid; + border-color: #777777; + } + .gmainright, + .gmainleft { + overflow: hidden; + width: auto; + } + table { page-break-after:auto } + tr { page-break-inside:avoid; page-break-after:auto } + td { page-break-inside:avoid; page-break-after:auto } + thead { display:table-header-group } + tfoot { display:table-footer-group } } \ No newline at end of file From c000a326160360f84c62def66671da1835fe4428 Mon Sep 17 00:00:00 2001 From: Mario Mol Date: Wed, 2 Jan 2019 10:56:51 -0200 Subject: [PATCH 5/8] remove scroll listener --- docs/jsgantt.js | 4 ---- src/events.ts | 4 ---- 2 files changed, 8 deletions(-) diff --git a/docs/jsgantt.js b/docs/jsgantt.js index 14eadd41..e32b6a94 100644 --- a/docs/jsgantt.js +++ b/docs/jsgantt.js @@ -1240,10 +1240,6 @@ exports.addFormatListeners = function (pGanttChart, pFormat, pObj) { exports.addListener('click', function () { utils_1.changeFormat(pFormat, pGanttChart); }, pObj); }; exports.addScrollListeners = function (pGanttChart) { - exports.addListener('scroll', function () { pGanttChart.getChartBody().scrollTop = pGanttChart.getListBody().scrollTop; }, pGanttChart.getListBody()); - exports.addListener('scroll', function () { pGanttChart.getListBody().scrollTop = pGanttChart.getChartBody().scrollTop; }, pGanttChart.getChartBody()); - exports.addListener('scroll', function () { pGanttChart.getChartHead().scrollLeft = pGanttChart.getChartBody().scrollLeft; }, pGanttChart.getChartBody()); - exports.addListener('scroll', function () { pGanttChart.getChartBody().scrollLeft = pGanttChart.getChartHead().scrollLeft; }, pGanttChart.getChartHead()); exports.addListener('resize', function () { pGanttChart.getChartHead().scrollLeft = pGanttChart.getChartBody().scrollLeft; }, window); exports.addListener('resize', function () { pGanttChart.getListBody().scrollTop = pGanttChart.getChartBody().scrollTop; }, window); }; diff --git a/src/events.ts b/src/events.ts index 96213a83..0b486b5d 100644 --- a/src/events.ts +++ b/src/events.ts @@ -140,10 +140,6 @@ export const addFormatListeners = function (pGanttChart, pFormat, pObj) { }; export const addScrollListeners = function (pGanttChart) { - addListener('scroll', function () { pGanttChart.getChartBody().scrollTop = pGanttChart.getListBody().scrollTop; }, pGanttChart.getListBody()); - addListener('scroll', function () { pGanttChart.getListBody().scrollTop = pGanttChart.getChartBody().scrollTop; }, pGanttChart.getChartBody()); - addListener('scroll', function () { pGanttChart.getChartHead().scrollLeft = pGanttChart.getChartBody().scrollLeft; }, pGanttChart.getChartBody()); - addListener('scroll', function () { pGanttChart.getChartBody().scrollLeft = pGanttChart.getChartHead().scrollLeft; }, pGanttChart.getChartHead()); addListener('resize', function () { pGanttChart.getChartHead().scrollLeft = pGanttChart.getChartBody().scrollLeft; }, window); addListener('resize', function () { pGanttChart.getListBody().scrollTop = pGanttChart.getChartBody().scrollTop; }, window); }; From 857b1a8cb6093a994e3687ff255e21fbefa0759b Mon Sep 17 00:00:00 2001 From: Mario Mol Date: Thu, 3 Jan 2019 11:28:56 -0200 Subject: [PATCH 6/8] fixing hack for g compability --- docs/index.js | 16 ++++++++++++++++ docs/jsgantt.js | 7 +++++-- package.json | 2 +- server.js | 4 ++-- src/task.ts | 9 +++++---- src/utils.ts | 1 + 6 files changed, 30 insertions(+), 9 deletions(-) diff --git a/docs/index.js b/docs/index.js index 8daa640b..d2351d06 100644 --- a/docs/index.js +++ b/docs/index.js @@ -103,6 +103,22 @@ function start(e) { }); //DELAY FROM INPUT + // Teste manual add task + // g.AddTaskItemObject({ + // pID: 100, + // pName: "Task 1", + // pStart: "2018-09-05", + // pEnd: "2018-09-11", + // pLink:"", + // pClass: "gtaskgreen", + // pMile: 0, + // pComp: 100, + // pGroup: 0, + // pParent: 0, + // pOpen: 1, + // pNotes: "", + // }); + if (vDebug) { bd = new Date(); console.log('before reloading', bd); diff --git a/docs/jsgantt.js b/docs/jsgantt.js index e32b6a94..5b99b103 100644 --- a/docs/jsgantt.js +++ b/docs/jsgantt.js @@ -2398,7 +2398,7 @@ exports.TaskItem = function (pID, pName, pStart, pEnd, pClass, pLink, pMile, pRe if (pPlanStart === void 0) { pPlanStart = null; } if (pPlanEnd === void 0) { pPlanEnd = null; } if (pDataObject === void 0) { pDataObject = null; } - var vGantt = pGantt ? pGantt : g; // hack for backwards compatibility + var vGantt = pGantt ? pGantt : this; var _id = document.createTextNode(pID).data; var vID = utils_1.hashKey(document.createTextNode(pID).data); var vName = document.createTextNode(pName).data; @@ -2468,7 +2468,6 @@ exports.TaskItem = function (pID, pName, pStart, pEnd, pClass, pLink, pMile, pRe var vDependStr = pDepend + ''; var vDepList = vDependStr.split(','); var n = vDepList.length; - var vGantt_1 = pGantt ? pGantt : g; for (var k = 0; k < n; k++) { if (vDepList[k].toUpperCase().indexOf('SS') != -1) { vDepend[k] = vDepList[k].substring(0, vDepList[k].toUpperCase().indexOf('SS')); @@ -2757,6 +2756,9 @@ exports.AddTaskItem = function (value) { } }; exports.AddTaskItemObject = function (object) { + if (!object.pGantt) { + object.pGantt = this; + } return this.AddTaskItem(exports.TaskItemObject(object)); }; exports.RemoveTaskItem = function (pID) { @@ -3321,6 +3323,7 @@ exports.criticalPath = function (tasks) { childrens: [] }; } + console.log(path); if (!path[task.pID].childrens) { path[task.pID].childrens = []; } diff --git a/package.json b/package.json index e939487a..c8de0690 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jsgantt-improved", - "version": "2.1.0", + "version": "2.1.1", "description": "jsgantt-improved", "main": "dist/index.js", "scripts": { diff --git a/server.js b/server.js index 967ebf24..5d7d8c5a 100644 --- a/server.js +++ b/server.js @@ -3,5 +3,5 @@ const express = require('express'); const app = new express(); app.use(express.static('docs')); - -app.listen(8080, ()=>{ console.log('listening to port 8080')}); \ No newline at end of file +const port = 8081; +app.listen(port, ()=>{ console.log(`listening to port ${port}`)}); \ No newline at end of file diff --git a/src/task.ts b/src/task.ts index 984dd58c..b0c258cf 100644 --- a/src/task.ts +++ b/src/task.ts @@ -158,7 +158,7 @@ export const TaskItemObject = function (object) { export const TaskItem = function (pID, pName, pStart, pEnd, pClass, pLink, pMile, pRes, pComp, pGroup, pParent, pOpen, pDepend, pCaption, pNotes, pGantt, pCost = null, pPlanStart = null, pPlanEnd = null, pDataObject = null) { - let vGantt = pGantt ? pGantt : g; // hack for backwards compatibility + let vGantt = pGantt ? pGantt : this; let _id = document.createTextNode(pID).data; let vID = hashKey(document.createTextNode(pID).data); let vName = document.createTextNode(pName).data; @@ -238,8 +238,6 @@ export const TaskItem = function (pID, pName, pStart, pEnd, pClass, pLink, pMile let vDepList = vDependStr.split(','); let n = vDepList.length; - let vGantt = pGantt ? pGantt : g; - for (let k = 0; k < n; k++) { if (vDepList[k].toUpperCase().indexOf('SS') != -1) { vDepend[k] = vDepList[k].substring(0, vDepList[k].toUpperCase().indexOf('SS')); @@ -299,7 +297,7 @@ export const TaskItem = function (pID, pName, pStart, pEnd, pClass, pLink, pMile this.getDepType = function () { if (vDependType) return vDependType; else return null; }; this.getCaption = function () { if (vCaption) return vCaption; else return ''; }; this.getResource = function () { if (vRes) return vRes; else return '\u00A0'; }; - this.getCompVal = function () { if (vComp) return vComp; else if(vCompVal) return vCompVal; else return 0; }; + this.getCompVal = function () { if (vComp) return vComp; else if (vCompVal) return vCompVal; else return 0; }; this.getCompStr = function () { if (vComp) return vComp + '%'; else if (vCompVal) return vCompVal + '%'; else return ''; }; this.getNotes = function () { return vNotes; }; this.getSortIdx = function () { return vSortIdx; }; @@ -470,6 +468,9 @@ export const AddTaskItem = function (value) { }; export const AddTaskItemObject = function (object) { + if (!object.pGantt) { + object.pGantt = this; + } return this.AddTaskItem(TaskItemObject(object)); } diff --git a/src/utils.ts b/src/utils.ts index 6fd0d418..136fe609 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -454,6 +454,7 @@ export const criticalPath = function (tasks) { childrens: [] } } + console.log(path); if (!path[task.pID].childrens) { path[task.pID].childrens = []; } From d37476c5bd90b96303e0ef2144d887e92f799d8b Mon Sep 17 00:00:00 2001 From: Mario Mol Date: Thu, 3 Jan 2019 11:39:10 -0200 Subject: [PATCH 7/8] Fixed links on docs --- Documentation.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Documentation.md b/Documentation.md index 5b7e3fe1..e1a907e9 100644 --- a/Documentation.md +++ b/Documentation.md @@ -32,9 +32,9 @@ Method definition: **GanttChart(_pDiv_, _pFormat_)** | _pFormat:_ | (required) used to indicate whether chart should be drawn in "hour", "day", "week", "month", or "quarter" format | ## Customize the look and feel using configuration methods ## -see [Configuration Options](Documentation#user-content-options) below +see [Configuration Options](#user-content-options) below -## Add Tasks ## +## Add Tasks ## ### a) Using Method() ### @@ -131,7 +131,7 @@ The structure of the JSON file: ``` -### c) using parseXML() with an external XML file ### +### c) using parseXML() with an external XML file ### ```javascript JSGantt.parseXML("project.xml",g); ``` @@ -170,9 +170,9 @@ The structure of the native XML file: ``` -Field definitions are as described for the parameters to [TaskItem](Documentation#user-content-a-using-addtaskitem) above. The pClass element is optional in XML files and will default to "ggroupblack" for group tasks, "gtaskblue" for normal tasks and "gmilestone" for milestones. The pGantt element is not required for XML import. +Field definitions are as described for the parameters to [TaskItem](#user-content-a-using-addtaskitem) above. The pClass element is optional in XML files and will default to "ggroupblack" for group tasks, "gtaskblue" for normal tasks and "gmilestone" for milestones. The pGantt element is not required for XML import. -JSGannt Improved will also test the provided XML file to see if it appears to be in Microsoft Project XML format. If so an attempt will be made to load up the project. This feature is experimental, the import is best effort and not guaranteed. Once loaded the project as interpreted by JSGantt Improved can be extracted using the [XML Export methods](Documentation#user-content-xml-export) provided. +JSGannt Improved will also test the provided XML file to see if it appears to be in Microsoft Project XML format. If so an attempt will be made to load up the project. This feature is experimental, the import is best effort and not guaranteed. Once loaded the project as interpreted by JSGantt Improved can be extracted using the [XML Export methods](#user-content-xml-export) provided. ### c) using parseXMLString() with XML held in a javascript string object ### @@ -189,10 +189,10 @@ Method definition: |_pGanttObj:_|(required) a GanttChart object returned by a call to JSGantt.GanttChart()| -The XML provided will be parsed in exactly the same way as the contents of an external XML file and hence must match the format as described for [parseXML](Documentation#user-content-b-using-parsexml-with-an-external-xml-file) above +The XML provided will be parsed in exactly the same way as the contents of an external XML file and hence must match the format as described for [parseXML](#user-content-b-using-parsexml-with-an-external-xml-file) above -### XML Export ### +### XML Export ### The following methods can be used to extract details of tasks in the project in XML format @@ -273,7 +273,7 @@ The following options take a single numeric parameter; a value of 1 will enable |_setShowTaskInfoEndDate():_|Controls whether the Task End Date information is displayed in the task tool tip, defaults to 1 (show information)| |_setShowTaskInfoLink():_|Controls whether the More Information link is displayed in the task tool tip, defaults to 0 (do NOT show link)| |_setShowTaskInfoNotes():_|Controls whether the Additional Notes data is displayed in the task tool tip, defaults to 1 (show notes)| -|_setShowEndWeekDate():_|Controls whether the major heading in "Day" view displays the week end-date in the appropriate format (see [below](Documentation#user-content-display-date-formats)), defaults to 1 (show date)| +|_setShowEndWeekDate():_|Controls whether the major heading in "Day" view displays the week end-date in the appropriate format (see [below](#user-content-display-date-formats)), defaults to 1 (show date)| |_setShowDeps():_ |Controls display of dependancy lines, defaults to 1 (show dependencies)| |_setEvents():_ |Controls events when a task is click in table data. You have to pass an object with the column and function. ex.: ` { taskname: console.log, res: console.log }`| |_setEventClickRow():_ |Controls events when a task row is cliked. Pass a function to exercute ex.: `function(e){console.log(e)}`| @@ -295,7 +295,7 @@ The following options enable functionality using a set of specific key values |_setDateInputFormat():_|Defines the input format used for dates in task creation, accepts a single parameter. Valid parameter values are "yyyy-mm-dd", "dd/mm/yyyy", "mm/dd/yyyy". Defaults to "yyyy-mm-dd"| |_setScrollTo():_ |Sets the date the Gantt Chart will be scrolled to, specified in the date input format set by setDateInputFormat() above. Also accepts the special value "today". Defaults to minimum display date| |_setUseSingleCell():_|Sets the threshold total number of cells at which the task list will use a single table cell for each row rather than one cell per period. Useful to improve performance on large charts. Numeric, a value of 0 disables this functionality (always use multiple cells), defaults to 25000| -|_setLang():_ |Sets translation to use when drawing the chart. Defaults to "en" as this is the only language provided in the base installation (see [Internationalisation](Documentation#user-content-internationalisation) below for details on how to add more translations.)| +|_setLang():_ |Sets translation to use when drawing the chart. Defaults to "en" as this is the only language provided in the base installation (see [Internationalisation](#user-content-internationalisation) below for details on how to add more translations.)| ## Layout ## Most of the look and feel of the Gantt Chart can be controlled using CSS however, as the length of a task bar is determined by column width, the following methods take a single numeric parameter that defines the appropriate column width in pixels. @@ -311,7 +311,7 @@ Note that the task bar sizing code assumes the use of collapsed table borders 1p |_setRowHeight():_|Height of Gantt Chart rows in pixels. Used to route dependency lines near end points. Defaults to 20.| |_setMinGpLen():_ |Group tasks have their task bars embellished with end points, this value specifies the width of one of these end points in pixels. A short task bar's length will be rounded up to display either a single or both endpoints correctly. Defaults to 8.| -## Display Date Formats ## +## Display Date Formats ## Date display formats can be individually controlled. The methods used to set these display formats each take a single format string parameter. The format string can be made up of the following components (case sensitive) | Component | Description | @@ -342,7 +342,7 @@ Date display formats can be individually controlled. The methods used to set the separated by one of the following characters: **"/\-.,'`:** -Any text between separators that does not match one of the components above will be checked using a case insensitive match for a valid internationalised string (see [Internationalisation](Documentation#user-content-internationalisation) below). If the value is still not found the text will be output unchanged. +Any text between separators that does not match one of the components above will be checked using a case insensitive match for a valid internationalised string (see [Internationalisation](#user-content-internationalisation) below). If the value is still not found the text will be output unchanged. The available date display methods are @@ -361,7 +361,7 @@ The available date display methods are |_setMonthMinorDateDisplayFormat():_|Date format used for Gantt Chart minor date headings displayed in "Month" format. Defaults to 'mon'.| |_setQuarterMinorDateDisplayFormat():_|Date format used for Gantt Chart minor date headings displayed in "Year" format. Defaults to 'qq'.| -## Internationalisation ## +## Internationalisation ## jsGanttImproved only provides English text however all hard coded strings can be replaced by calling the addLang() method available on the GanttChart object returned by a call to JSGantt.GanttChart() The addLang() method takes two parameters. The first is a string identifier for the language, the second is a javascript object containing all the replacement text pairs, the default English settings are: From c06b6a972fa9321de3ed029157059fe9140487fa Mon Sep 17 00:00:00 2001 From: Mario Mol Date: Thu, 10 Jan 2019 08:47:04 -0300 Subject: [PATCH 8/8] issues #137 and #136 --- docs/index.html | 9 +++++++++ docs/index.js | 11 ++++++----- docs/jsgantt.js | 36 ++++++++++++++++++++++++++++-------- package.json | 2 +- src/events.ts | 6 ++++-- src/options.ts | 14 +++++++------- src/task.ts | 12 +++++++++--- src/utils.ts | 3 +++ 8 files changed, 67 insertions(+), 26 deletions(-) diff --git a/docs/index.html b/docs/index.html index 41eaadf1..371d08b2 100644 --- a/docs/index.html +++ b/docs/index.html @@ -231,6 +231,15 @@

    Current Known Issues:

    Changelog:

    Check the full list of changes on GitHub releases page.

    +

    2.1.2:

    +
      +
    • Fix for adding custom columns in object
    • +
    • IE compatible with dependencies highlight
    • +
    +

    2.1.1:

    +
      +
    • New way for rendering gantt where it works better scroll
    • +

    2.0.10:

    • Use complete value from task group from data instead of calculated
    • diff --git a/docs/index.js b/docs/index.js index d2351d06..2204f198 100644 --- a/docs/index.js +++ b/docs/index.js @@ -109,15 +109,16 @@ function start(e) { // pName: "Task 1", // pStart: "2018-09-05", // pEnd: "2018-09-11", - // pLink:"", + // pLink: "", // pClass: "gtaskgreen", // pMile: 0, // pComp: 100, - // pGroup: 0, - // pParent: 0, - // pOpen: 1, + // pGroup: 0, + // pParent: 0, + // pOpen: 1, // pNotes: "", - // }); + // category: 'test' + // }); if (vDebug) { bd = new Date(); diff --git a/docs/jsgantt.js b/docs/jsgantt.js index 5b99b103..7e33edd1 100644 --- a/docs/jsgantt.js +++ b/docs/jsgantt.js @@ -1274,14 +1274,16 @@ exports.addListenerInputCell = function (vTmpCell, vEventsChange, callback, task } }; exports.addListenerDependencies = function () { - document.querySelectorAll('.gtaskbarcontainer').forEach(function (taskDiv) { + var elements = document.querySelectorAll('.gtaskbarcontainer'); + for (var i = 0; i < elements.length; i++) { + var taskDiv = elements[i]; taskDiv.addEventListener('mouseover', function (e) { toggleDependencies(e); }); taskDiv.addEventListener('mouseout', function (e) { toggleDependencies(e); }); - }); + } }; var toggleDependencies = function (e) { var target = e.currentTarget; @@ -2075,17 +2077,18 @@ exports.includeGetSet = function () { for (var i = 0; i < keys.length; i++) { var key = keys[i]; var val = options[key]; - var ev = void 0; if (key === 'vResources') { - ev = "this.set" + key.substr(1) + "(val)"; + // ev = `this.set${key.substr(1)}(val)`; + this['set' + key.substr(1)](val); } else if (val instanceof Array) { - ev = "this.set" + key.substr(1) + "(...val)"; + // ev = `this.set${key.substr(1)}(...val)`; + this['set' + key.substr(1)].apply(this, val); } else { - ev = "this.set" + key.substr(1) + "(val)"; + // ev = `this.set${key.substr(1)}(val)`; + this['set' + key.substr(1)](val); } - eval(ev); } }; this.setUseFade = function (pVal) { this.vUseFade = pVal; }; @@ -2256,6 +2259,17 @@ exports.includeGetSet = function () { },{"./utils":9}],8:[function(require,module,exports){ "use strict"; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = require("./utils"); // Function to open/close and hide/show children of specified task @@ -2391,7 +2405,11 @@ exports.sortTasks = function (pList, pID, pIdx) { return sortIdx; }; exports.TaskItemObject = function (object) { - return new exports.TaskItem(object.pID, object.pName, object.pStart, object.pEnd, object.pClass, object.pLink, object.pMile, object.pRes, object.pComp, object.pGroup, object.pParent, object.pOpen, object.pDepend, object.pCaption, object.pNotes, object.pGantt, object.pCost, object.pPlanStart, object.pPlanEnd); + var pDataObject = __assign({}, object); + utils_1.internalProperties.forEach(function (property) { + delete pDataObject[property]; + }); + return new exports.TaskItem(object.pID, object.pName, object.pStart, object.pEnd, object.pClass, object.pLink, object.pMile, object.pRes, object.pComp, object.pGroup, object.pParent, object.pOpen, object.pDepend, object.pCaption, object.pNotes, object.pGantt, object.pCost, object.pPlanStart, object.pPlanEnd, object); }; exports.TaskItem = function (pID, pName, pStart, pEnd, pClass, pLink, pMile, pRes, pComp, pGroup, pParent, pOpen, pDepend, pCaption, pNotes, pGantt, pCost, pPlanStart, pPlanEnd, pDataObject) { if (pCost === void 0) { pCost = null; } @@ -2878,6 +2896,8 @@ exports.processRows = function (pList, pID, pRow, pLevel, pOpen, pUseSort, vDebu },{"./utils":9}],9:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.internalProperties = ['pID', 'pName', 'pStart', 'pEnd', 'pClass', 'pLink', 'pMile', 'pRes', 'pComp', 'pGroup', 'pParent', + 'pOpen', 'pDepend', 'pCaption', 'pNotes', 'pGantt', 'pCost', 'pPlanStart', 'pPlanEnd']; exports.getMinDate = function (pList, pFormat) { var vDate = new Date(); vDate.setTime(pList[0].getStart().getTime()); diff --git a/package.json b/package.json index c8de0690..b93aad22 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jsgantt-improved", - "version": "2.1.1", + "version": "2.1.2", "description": "jsgantt-improved", "main": "dist/index.js", "scripts": { diff --git a/src/events.ts b/src/events.ts index 0b486b5d..70184022 100644 --- a/src/events.ts +++ b/src/events.ts @@ -173,14 +173,16 @@ export const addListenerInputCell = function (vTmpCell, vEventsChange, callback, } export const addListenerDependencies = function () { - document.querySelectorAll('.gtaskbarcontainer').forEach(taskDiv => { + const elements = document.querySelectorAll('.gtaskbarcontainer'); + for (let i = 0; i < elements.length; i++) { + const taskDiv = elements[i]; taskDiv.addEventListener('mouseover', e => { toggleDependencies(e); }); taskDiv.addEventListener('mouseout', e => { toggleDependencies(e); }); - }); + } } const toggleDependencies = function (e) { diff --git a/src/options.ts b/src/options.ts index 78fa9909..e33dce7a 100644 --- a/src/options.ts +++ b/src/options.ts @@ -11,16 +11,16 @@ export const includeGetSet = function () { for (let i = 0; i < keys.length; i++) { const key = keys[i]; const val = options[key]; - let ev; if (key === 'vResources') { - ev = `this.set${key.substr(1)}(val)`; + // ev = `this.set${key.substr(1)}(val)`; + this['set' + key.substr(1)](val); } else if (val instanceof Array) { - ev = `this.set${key.substr(1)}(...val)`; + // ev = `this.set${key.substr(1)}(...val)`; + this['set' + key.substr(1)].apply(this, val); } else { - ev = `this.set${key.substr(1)}(val)`; - + // ev = `this.set${key.substr(1)}(val)`; + this['set' + key.substr(1)](val); } - eval(ev); } } this.setUseFade = function (pVal) { this.vUseFade = pVal; }; @@ -86,7 +86,7 @@ export const includeGetSet = function () { this.vFormat = pFormat; this.Draw(); }; - this.setWorkingDays = function(workingDays) { this.vWorkingDays = workingDays; }; + this.setWorkingDays = function (workingDays) { this.vWorkingDays = workingDays; }; this.setMinGpLen = function (pMinGpLen) { this.vMinGpLen = pMinGpLen; }; this.setScrollTo = function (pDate) { this.vScrollTo = pDate; }; this.setHourColWidth = function (pWidth) { this.vHourColWidth = pWidth; }; diff --git a/src/task.ts b/src/task.ts index b0c258cf..7b84ca00 100644 --- a/src/task.ts +++ b/src/task.ts @@ -1,4 +1,4 @@ -import { parseDateStr, isIE, stripUnwanted, getOffset, formatDateStr, hashKey } from "./utils"; +import { parseDateStr, isIE, stripUnwanted, getOffset, formatDateStr, hashKey, internalProperties } from "./utils"; declare let g: any; @@ -132,8 +132,13 @@ export const sortTasks = function (pList, pID, pIdx) { return sortIdx; }; - export const TaskItemObject = function (object) { + const pDataObject = { ...object}; + + internalProperties.forEach(property=>{ + delete pDataObject[property]; + }); + return new TaskItem(object.pID, object.pName, object.pStart, @@ -152,7 +157,8 @@ export const TaskItemObject = function (object) { object.pGantt, object.pCost, object.pPlanStart, - object.pPlanEnd + object.pPlanEnd, + object ); } diff --git a/src/utils.ts b/src/utils.ts index 136fe609..ca1a5dcb 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,4 +1,7 @@ +export const internalProperties = ['pID','pName','pStart','pEnd','pClass','pLink','pMile','pRes','pComp','pGroup','pParent', +'pOpen','pDepend','pCaption','pNotes','pGantt','pCost','pPlanStart','pPlanEnd']; + export const getMinDate = function (pList, pFormat) { let vDate = new Date(); vDate.setTime(pList[0].getStart().getTime());