From 1eac023af241b189d8d0d15c10b95bfdc5bd5001 Mon Sep 17 00:00:00 2001 From: Matthew Strasiotto <39424834+mstr3336@users.noreply.github.com> Date: Sun, 31 Mar 2019 18:01:50 +1100 Subject: [PATCH] Logging Statements Added, Squash Merge + Test (#5) * Added logger * Added logging statements * Initialize logger * Numerous logging statements * Added testcafe to package.json * Added jest to dependencies * .DS store added to gitignore * Added testcafe runner to scripts * Added UI test for nesting * Added test runner to scripts * Debug statements * Fixed nested Group collapse * fix whitespace * call to order groups after updating nested * Added test for group order * call to _orderGroups (Doesn't seem to work) * Update test_multinest.js * Added ordering loggin statement * Removed call to _orderGroups from _onGroupClick, added .visible check to orderGroups * Logging statements in ItemSet * Commented this.visible check from updateGroups * Logging statements * Fixed nest fold/unfold by call to markDirty * Removed commented code from group.js * Updated debug logs * Added comment * Revert "Added comment" This reverts commit a61b91163715679bd840efebfe8e049a53d298fe. * Revert "Fixed nest fold/unfold by call to markDirty" This reverts commit 3439dcfb71e713aa9ae58a7e70328e80c5b25cb6. * Revert "Removed call to _orderGroups from _onGroupClick, added .visible check to orderGroups" This reverts commit 25d0051489ba34a48a84db57c2a098f73879e7ca. * Revert "Update test_multinest.js" This reverts commit ceb8798d0cbc645c44389e7effd9e43edff96095. * Revert "call to _orderGroups (Doesn't seem to work)" This reverts commit 8ba982545e02c4cedb96b7cdc51a33022ecea9ba. * Revert "Added test for group order" This reverts commit 92fcc61e529fe4809d75bfed3c86d7fd4f502bc2. * Revert "call to order groups after updating nested" This reverts commit cc168a072554cfd14020d18bd26e1ac8589a5262. * Revert "Merge pull request #3 from mstr3336/nest_order" This reverts commit 724bc67d698305e41e7be72caf89134f57159da7, reversing changes made to a44dc9ab40b2d8ca6a2a49892b6589eb1837dea7. * Revert "Added test runner to scripts" This reverts commit ca7e1c31fe898cf6e8296c9c6b0b54caaa83b89f. * Revert "Added UI test for nesting" This reverts commit 6a444ba29874abc2c2e7e9e2f63e0b2566a93bae. * Revert "Added testcafe runner to scripts" This reverts commit 0f9d1b67758fee02a6dffb56f2ad4def119969e6. * Revert "Added jest to dependencies" This reverts commit 59e8ea0fbdfca1fa66a440d3c9002ec17e2bbfe1. * Revert "Added testcafe to package.json" This reverts commit b6cd77ae9d4de0da830deecc26d583ad3fcc24f6. --- .babelrc | 3 ++- .gitignore | 1 + lib/DataSet.js | 3 +++ lib/logger-init.js | 1 + lib/timeline/component/Group.js | 17 +++++++++++++++++ lib/timeline/component/ItemSet.js | 21 +++++++++++++++++++-- lib/util.js | 1 + package.json | 2 ++ 8 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 lib/logger-init.js 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/.gitignore b/.gitignore index 61658ad..34859fa 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ gen/ coverage/ package-lock.json yarn.lock +.DS_Store 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/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/timeline/component/Group.js b/lib/timeline/component/Group.js index f6db6cf..ed9e2f5 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,6 +138,11 @@ class Group { } else { content = data && data.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) { @@ -177,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) { @@ -232,6 +240,13 @@ class Group { util.addCssText(this.dom.label, data.style); this.style = data.style; } + + + if (this.visible == undefined){ + L.debug("" + this.groupId + ".visible: was undefined"); + this.visible = true; + } + L.debug("" + this.groupId + ".visible == " + this.visible); } /** @@ -588,6 +603,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); } @@ -610,6 +626,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 f06fc77..c53f222 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); @@ -951,6 +954,7 @@ class ItemSet extends Component { setGroups(groups) { const me = this; let ids; + L.debug("setGroups called"); // unsubscribe from current dataset if (this.groupsData) { @@ -1183,6 +1187,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); @@ -1255,15 +1260,22 @@ class ItemSet extends Component { * @private */ _orderGroups() { + L.info("_orderGroups called"); if (this.groupsData) { // reorder the groups let groupIds = this.groupsData.getIds({ order: this.options.groupOrder }); + L.debug("_orderGroups, before _orderNestedGroups: this.groupsData.getIds == " + groupIds); + L.debug("_orderGroups, before _orderNestedGroups: this.groupIds == " + this.groupIds); groupIds = this._orderNestedGroups(groupIds); - + + L.debug("_orderGroups, after _orderNestedGroups: this.groupsData.getIds == " + groupIds); + L.debug("_orderGroups, after _orderNestedGroups: this.groupIds == " + this.groupIds); + const changed = !util.equalArray(groupIds, this.groupIds); + if (changed) { // hide all groups, removes them from the DOM const groups = this.groups; @@ -1830,12 +1842,17 @@ 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: " + Object.keys(nestingGroup)); + + + // Handle styling of collapse/uncollapse tabs if (nestingGroup.showNested) { util.removeClassName(group.dom.label, 'collapsed'); util.addClassName(group.dom.label, 'expanded'); 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'; 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",