Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

latest changes to Development #472

Merged
merged 6 commits into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 43 additions & 9 deletions components/VFBMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default class VFBMain extends React.Component {
this.idFromURL = undefined;
this.firstLoad = true;
this.idsFromURL = [];
this.urlQueryLoader = undefined;

this.UIElementsVisibility = {};

Expand Down Expand Up @@ -914,11 +915,15 @@ export default class VFBMain extends React.Component {
// Loading ids passed through the browser's url
if ((this.props.location.search.indexOf("id=VFB") == -1) && (this.props.location.search.indexOf("i=VFB") == -1)) {
this.idFromURL = "VFB_00017894";
var that = this;
var idList = this.props.location.search;
idList = idList.replace("?","").split("&");
for (let list in idList) {
if (idList[list].indexOf("q=") > -1) {
this.urlQueryLoader = idList[list].replace("q=","").replace("%20", " ").split(",");
}
}
console.log("Loading default Adult Brain VFB_00017894 template.");
GEPPETTO.on(GEPPETTO.Events.Model_loaded, function () {
that.addVfbId(that.idFromURL);
});
this.idsFinalList = this.idFromURL;
} else {
var idsList = "";
var idList = this.props.location.search;
Expand All @@ -935,6 +940,8 @@ export default class VFBMain extends React.Component {
idsList = "," + idsList;
}
idsList = idList[list].replace("i=","") + idsList;
} else if (idList[list].indexOf("q=") > -1) {
this.urlQueryLoader = idList[list].replace("q=","").replace("%20", " ").split(",");
}
}
if ((idsList.length > 0) && (this.state.modelLoaded == true) && (this.urlIdsLoaded == false)) {
Expand All @@ -952,14 +959,42 @@ export default class VFBMain extends React.Component {
}
this.idsFromURL.push(this.idFromURL);
this.idsFromURL = [... new Set(this.idsFromURL)];
var that = this;
this.idsFinalList = this.idsFromURL;
console.log("Loading IDS to add to the scene from url");
GEPPETTO.on(GEPPETTO.Events.Model_loaded, function () {
that.addVfbId(that.idsFromURL);
});
}
}

var that = this;
GEPPETTO.on(GEPPETTO.Events.Model_loaded, function () {
that.addVfbId(that.idsFinalList);

var callback = function () {
// check if any results with count flag
if (that.refs.querybuilderRef.props.model.count > 0) {
// runQuery if any results
that.refs.querybuilderRef.runQuery();
} else {
that.refs.querybuilderRef.switchView(false);
}
// show query component
that.refs.querybuilderRef.open();
$("body").css("cursor", "default");
GEPPETTO.trigger('stop_spin_logo');
};

if (that.urlQueryLoader !== undefined) {
if (window[that.urlQueryLoader[0]] == undefined) {
window.fetchVariableThenRun(that.urlQueryLoader[0], function () {
that.refs.querybuilderRef.addQueryItem({ term: "", id: that.urlQueryLoader[0], queryObj: Model[that.urlQueryLoader[1]] }, callback)
});
} else {
setTimeout(function () {
that.refs.querybuilderRef.addQueryItem({ term: "", id: that.urlQueryLoader[0], queryObj: Model[that.urlQueryLoader[1]] }, callback);
}, 100);
}
}
});

// wipe the history state:
window.history.replaceState({ s:4, n:"", b:"", f:"" }, "", window.location.pathname + window.location.search);

Expand Down Expand Up @@ -1093,7 +1128,6 @@ export default class VFBMain extends React.Component {
if (this.treeBrowserReference !== undefined && this.treeBrowserReference !== null) {
this.treeBrowserReference.updateTree(this.instanceOnFocus);
}

}

render () {
Expand Down
4 changes: 4 additions & 0 deletions components/interface/VFBTree/VFBTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,10 @@ export default class VFBTree extends React.Component {
GEPPETTO.on(GEPPETTO.Events.Instances_created, function () {
that.setState({ displayColorPicker: false });
});

GEPPETTO.on(GEPPETTO.Events.Color_set, function (instance) {
that.forceUpdate();
});
}

render () {
Expand Down