From 948cdb40d2a1754e4abbec6a4cdb58128bb9862f Mon Sep 17 00:00:00 2001 From: matthew Date: Sat, 2 Feb 2019 17:53:14 +1100 Subject: [PATCH 01/12] Added logger --- .babelrc | 3 ++- package.json | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.babelrc b/.babelrc index cb22a73..8f1eafa 100644 --- a/.babelrc +++ b/.babelrc @@ -3,6 +3,7 @@ "plugins": [ "transform-es3-property-literals", "transform-es3-member-expression-literals", - "@babel/plugin-transform-runtime" + "@babel/plugin-transform-runtime", + ["js-logger", {"variable" : "L"}] ] } diff --git a/package.json b/package.json index c0520bf..5d362a2 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "dependencies": { "emitter-component": "^1.1.1", "hammerjs": "^2.0.8", + "js-logger": "^1.6.0", "keycharm": "^0.2.0", "moment": "^2.18.1", "propagating-hammerjs": "^1.4.6", @@ -51,6 +52,7 @@ "async": "^2.5.0", "babel-cli": "^6.26.0", "babel-loader": "^8.0.5", + "babel-plugin-js-logger": "^1.0.17", "babel-plugin-transform-es3-member-expression-literals": "^6.22.0", "babel-plugin-transform-es3-property-literals": "^6.22.0", "babelify": "^7.3.0", From fe2e59082b9f14c1594bb6f4c2904660aa940fbc Mon Sep 17 00:00:00 2001 From: matthew Date: Sat, 2 Feb 2019 17:56:22 +1100 Subject: [PATCH 02/12] Added logging statements --- lib/DataSet.js | 3 +++ lib/timeline/component/Group.js | 1 + lib/timeline/component/ItemSet.js | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/DataSet.js b/lib/DataSet.js index 46e1134..de5116a 100644 --- a/lib/DataSet.js +++ b/lib/DataSet.js @@ -168,6 +168,8 @@ class DataSet { if ('*' in this._subscribers) { subscribers = subscribers.concat(this._subscribers['*']); } + L.debug("Event: " + event + " params: " + params + + " Sender: " + senderId); for (let i = 0, len = subscribers.length; i < len; i++) { const subscriber = subscribers[i]; @@ -269,6 +271,7 @@ class DataSet { const props = { items: updatedIds, oldData, data: updatedData }; this._trigger('update', props, senderId); } + L.debug('Ids updated ' + addedIds.concat(updatedIds) + " sender: " + senderId); return addedIds.concat(updatedIds); } diff --git a/lib/timeline/component/Group.js b/lib/timeline/component/Group.js index f6db6cf..0e4c80c 100644 --- a/lib/timeline/component/Group.js +++ b/lib/timeline/component/Group.js @@ -137,6 +137,7 @@ class Group { } else { content = data && data.content; } + L.debug("Content is: " + content) if (content instanceof Element) { while (this.dom.inner.firstChild) { diff --git a/lib/timeline/component/ItemSet.js b/lib/timeline/component/ItemSet.js index f06fc77..c2139d8 100644 --- a/lib/timeline/component/ItemSet.js +++ b/lib/timeline/component/ItemSet.js @@ -1183,6 +1183,7 @@ class ItemSet extends Component { */ _onAddGroups(ids) { const me = this; + L.debug("Adding/Updating group ids: " + ids); ids.forEach(id => { const groupData = me.groupsData.get(id); @@ -1835,7 +1836,9 @@ class ItemSet extends Component { }); groupsData.update(nestedGroups.concat(nestingGroup)); - + L.debug("Nesting: " + nestingGroup.getGroupId); + + // Handle styling of collapse/uncollapse tabs if (nestingGroup.showNested) { util.removeClassName(group.dom.label, 'collapsed'); util.addClassName(group.dom.label, 'expanded'); From 373e44447ba1ea6862836aec10c9bb731e153fd6 Mon Sep 17 00:00:00 2001 From: matthew Date: Sat, 2 Feb 2019 18:28:03 +1100 Subject: [PATCH 03/12] Initialize logger --- lib/logger-init.js | 1 + lib/util.js | 1 + 2 files changed, 2 insertions(+) create mode 100644 lib/logger-init.js diff --git a/lib/logger-init.js b/lib/logger-init.js new file mode 100644 index 0000000..414b567 --- /dev/null +++ b/lib/logger-init.js @@ -0,0 +1 @@ +require('js-logger').useDefaults(); \ No newline at end of file diff --git a/lib/util.js b/lib/util.js index e0bed14..530d96f 100644 --- a/lib/util.js +++ b/lib/util.js @@ -3,6 +3,7 @@ // first check if moment.js is already loaded in the browser window, if so, // use this instance. Else, load via commonjs. +import './logger-init.js'; import moment from './module/moment'; From 17e9cf09b8bad2ffc108ca2704f7cdcd017d7016 Mon Sep 17 00:00:00 2001 From: matthew Date: Sat, 2 Feb 2019 18:28:24 +1100 Subject: [PATCH 04/12] Numerous logging statements --- lib/timeline/component/Group.js | 4 +++- lib/timeline/component/ItemSet.js | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/timeline/component/Group.js b/lib/timeline/component/Group.js index 0e4c80c..e632d80 100644 --- a/lib/timeline/component/Group.js +++ b/lib/timeline/component/Group.js @@ -137,7 +137,7 @@ class Group { } else { content = data && data.content; } - L.debug("Content is: " + content) + L.debug(this.groupId + ".setData: " + content) if (content instanceof Element) { while (this.dom.inner.firstChild) { @@ -589,6 +589,7 @@ class Group { * Show this group: attach to the DOM */ show() { + L.debug("Showing " + this.dom.label ) if (!this.dom.label.parentNode) { this.itemSet.dom.labelSet.appendChild(this.dom.label); } @@ -611,6 +612,7 @@ class Group { */ hide() { const label = this.dom.label; + L.debug("Hiding " + label ) if (label.parentNode) { label.parentNode.removeChild(label); } diff --git a/lib/timeline/component/ItemSet.js b/lib/timeline/component/ItemSet.js index c2139d8..4e191ed 100644 --- a/lib/timeline/component/ItemSet.js +++ b/lib/timeline/component/ItemSet.js @@ -185,6 +185,7 @@ class ItemSet extends Component { if (!updatedNestedGroup) { return; } updatedNestedGroup.nestedInGroup = groupData.id; if (groupData.showNested == false) { + L.debug("Setting " + nestedGroupId + ".visible to false"); updatedNestedGroup.visible = false; } updatedGroups = updatedGroups.concat(updatedNestedGroup); @@ -533,6 +534,7 @@ class ItemSet extends Component { * Hide the component from the DOM */ hide() { + L.debug("ItemSet: calling hide on " + this); // remove the frame containing the items if (this.dom.frame.parentNode) { this.dom.frame.parentNode.removeChild(this.dom.frame); @@ -553,6 +555,7 @@ class ItemSet extends Component { * Show the component in the DOM (when not already visible). */ show() { + L.debug("ItemSet: calling show on " + this); // show frame containing the items if (!this.dom.frame.parentNode) { this.body.dom.center.appendChild(this.dom.frame); From b6cd77ae9d4de0da830deecc26d583ad3fcc24f6 Mon Sep 17 00:00:00 2001 From: Matthew Mark Strasiotto Date: Mon, 4 Feb 2019 15:17:44 +1100 Subject: [PATCH 05/12] Added testcafe to package.json --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index c0520bf..4630922 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,7 @@ "mocha": "^5.2.0", "nyc": "^11.2.1", "rimraf": "^2.6.1", + "testcafe": "^0.23.3", "uglify-js": "^2.8.29", "uuid": "^3.1.0", "webpack": "^3.3.0", From 59e8ea0fbdfca1fa66a440d3c9002ec17e2bbfe1 Mon Sep 17 00:00:00 2001 From: Matthew Mark Strasiotto Date: Mon, 4 Feb 2019 15:25:59 +1100 Subject: [PATCH 06/12] Added jest to dependencies --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 43d69c0..8ed64ed 100644 --- a/package.json +++ b/package.json @@ -47,10 +47,11 @@ "@babel/core": "^7.2.2", "@babel/plugin-transform-runtime": "^7.2.0", "@babel/polyfill": "^7.2.5", - "@babel/preset-env": "^7.2.3", + "@babel/preset-env": "^7.3.1", "@babel/runtime": "^7.2.0", "async": "^2.5.0", "babel-cli": "^6.26.0", + "babel-jest": "^24.0.0", "babel-loader": "^8.0.5", "babel-plugin-js-logger": "^1.0.17", "babel-plugin-transform-es3-member-expression-literals": "^6.22.0", @@ -64,6 +65,7 @@ "gulp-eslint": "^4.0.0", "gulp-rename": "^1.2.2", "gulp-util": "^3.0.8", + "jest": "^24.0.0", "jsdoc": "^3.5.5", "jsdom": "11.3.0", "jsdom-global": "^3.0.2", From 20d668c10d8b316de5e74315b4fe561db42ed56a Mon Sep 17 00:00:00 2001 From: Matthew Mark Strasiotto Date: Mon, 4 Feb 2019 16:26:46 +1100 Subject: [PATCH 07/12] .DS store added to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 61658ad..34859fa 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ gen/ coverage/ package-lock.json yarn.lock +.DS_Store From 0f9d1b67758fee02a6dffb56f2ad4def119969e6 Mon Sep 17 00:00:00 2001 From: Matthew Mark Strasiotto Date: Mon, 4 Feb 2019 16:26:56 +1100 Subject: [PATCH 08/12] Added testcafe runner to scripts --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 8ed64ed..b181332 100644 --- a/package.json +++ b/package.json @@ -78,5 +78,8 @@ "uuid": "^3.1.0", "webpack": "^3.3.0", "yargs": "^8.0.2" + }, + "scripts" : { + "test" : "testcafe chrome tests/UI/" } } From 6a444ba29874abc2c2e7e9e2f63e0b2566a93bae Mon Sep 17 00:00:00 2001 From: Matthew Mark Strasiotto Date: Mon, 4 Feb 2019 17:40:41 +1100 Subject: [PATCH 09/12] Added UI test for nesting --- tests/UI/nesting.html | 33 +++++++++++++++++++++++++++++++++ tests/UI/test_nest.js | 14 ++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 tests/UI/nesting.html create mode 100644 tests/UI/test_nest.js diff --git a/tests/UI/nesting.html b/tests/UI/nesting.html new file mode 100644 index 0000000..16f8fdc --- /dev/null +++ b/tests/UI/nesting.html @@ -0,0 +1,33 @@ + + + + + + JS Bin + + + + +
+ + + \ No newline at end of file diff --git a/tests/UI/test_nest.js b/tests/UI/test_nest.js new file mode 100644 index 0000000..6c99802 --- /dev/null +++ b/tests/UI/test_nest.js @@ -0,0 +1,14 @@ +import { Selector } from 'testcafe'; + +fixture `nesting`.page `./nesting.html`; + +test('Do nested groups hide/unhide', async t => { + const groups = Selector('.timeline-label'); + const nesting = groups.withText('1'); + const nested = groups.withText('2'); + await t + .expect(groups.count).eql(2) + .click(nesting); + + await t.expect(groups.count).eql(1); +}) \ No newline at end of file From ca7e1c31fe898cf6e8296c9c6b0b54caaa83b89f Mon Sep 17 00:00:00 2001 From: Matthew Mark Strasiotto Date: Mon, 4 Feb 2019 18:38:13 +1100 Subject: [PATCH 10/12] Added test runner to scripts --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index b181332..d2fcfba 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,8 @@ "watch-dev": "gulp watch --bundle", "prepublishOnly": "npm run build", "predeploy": "npm run build --prefix ./docs", - "deploy": "gh-pages -d ./docs/build" + "deploy": "gh-pages -d ./docs/build", + "test" : "testcafe chrome tests/UI/" }, "dependencies": { "emitter-component": "^1.1.1", From 39d0df05c35bbc5b6ccf57841e5815b572cdcc02 Mon Sep 17 00:00:00 2001 From: Matthew Mark Strasiotto Date: Mon, 4 Feb 2019 19:17:45 +1100 Subject: [PATCH 11/12] Debug statements --- lib/timeline/component/Group.js | 11 ++++++++++- lib/timeline/component/ItemSet.js | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/timeline/component/Group.js b/lib/timeline/component/Group.js index e632d80..e74f4ac 100644 --- a/lib/timeline/component/Group.js +++ b/lib/timeline/component/Group.js @@ -22,6 +22,7 @@ class Group { this.subgroupOrderer = data && data.subgroupOrder; this.itemSet = itemSet; this.isVisible = null; + this.visible = true; this.stackDirty = true; // if true, items will be restacked on next redraw if (data && data.nestedGroups) { @@ -137,7 +138,11 @@ class Group { } else { content = data && data.content; } - L.debug(this.groupId + ".setData: " + content) + L.debug(this.groupId + ".setData: " + content); + L.debug(this.groupId + " being updated with data having props: "); + if (data) { + L.debug(Object.keys(data)); + } if (content instanceof Element) { while (this.dom.inner.firstChild) { @@ -178,6 +183,8 @@ class Group { } } + + util.addClassName(this.dom.label, 'timeline-nesting-group'); var collapsedDirClassName = this.itemSet.options.rtl ? 'collapsed-rtl' : 'collapsed' if (this.showNested) { @@ -233,6 +240,8 @@ class Group { util.addCssText(this.dom.label, data.style); this.style = data.style; } + + } /** diff --git a/lib/timeline/component/ItemSet.js b/lib/timeline/component/ItemSet.js index 4e191ed..faab661 100644 --- a/lib/timeline/component/ItemSet.js +++ b/lib/timeline/component/ItemSet.js @@ -1834,12 +1834,14 @@ class ItemSet extends Component { if (nestedGroup.visible == undefined) { nestedGroup.visible = true; } + L.debug(""+nestedGroup.id + ".visible was: " + nestedGroup.visible); nestedGroup.visible = !!nestingGroup.showNested; + L.debug(""+nestedGroup.id + ".visible is: " + nestedGroup.visible); return nestedGroup; }); groupsData.update(nestedGroups.concat(nestingGroup)); - L.debug("Nesting: " + nestingGroup.getGroupId); + L.debug("Nesting: " + nestingGroup.groupId); // Handle styling of collapse/uncollapse tabs if (nestingGroup.showNested) { From bf8cad3c7e02646276274a7feabd1a8c5b19f25e Mon Sep 17 00:00:00 2001 From: Matthew Mark Strasiotto Date: Mon, 4 Feb 2019 19:20:57 +1100 Subject: [PATCH 12/12] Fixed nested Group collapse --- lib/timeline/component/Group.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/timeline/component/Group.js b/lib/timeline/component/Group.js index e74f4ac..7d1719c 100644 --- a/lib/timeline/component/Group.js +++ b/lib/timeline/component/Group.js @@ -241,7 +241,21 @@ class Group { this.style = data.style; } + if (data && data.visible !== undefined){ + this.visible = data.visible; + } + if (this.visible == undefined){ + L.debug("" + this.groupId + ".visible: was undefined"); + this.visible = true; + } + // Hide if needed + L.debug("" + this.groupId + ".visible == " + this.visible); + if (this.visible){ + this.show(); + } else { + this.hide(); + } } /**