Skip to content
Snippets Groups Projects
Commit b3617d72 authored by cramakri's avatar cramakri
Browse files

LMS-2881 Refactored toggleDisplayedVisualizations.

SVN: 24941
parent 0f144f69
No related branches found
No related tags found
No related merge requests found
...@@ -53,11 +53,15 @@ StrainWrapper.prototype = new AbstractThingWrapper(); ...@@ -53,11 +53,15 @@ StrainWrapper.prototype = new AbstractThingWrapper();
StrainWrapper.prototype.constructor = StrainWrapper; StrainWrapper.prototype.constructor = StrainWrapper;
StrainWrapper.prototype.isStrain = function() { return true; } StrainWrapper.prototype.isStrain = function() { return true; }
var presenterModeTypeDataSet = "DATA_SET", presenterModeTypeStrain = "STRAIN";
/** /**
* An object responsible for managing the view * An object responsible for managing the view
*/ */
function AppPresenter() { function AppPresenter() {
this.didCreateVis = false; this.didCreateVis = false;
this.presenterMode = presenterModeTypeDataSet;
this.visualizationContainers = [];
} }
/** Hides the explanation and shows the element to display the explanation again */ /** Hides the explanation and shows the element to display the explanation again */
...@@ -75,39 +79,47 @@ AppPresenter.prototype.showExplanation = function() { ...@@ -75,39 +79,47 @@ AppPresenter.prototype.showExplanation = function() {
/** Show the data sets grouped by type */ /** Show the data sets grouped by type */
AppPresenter.prototype.switchToDataSetTypeView = function() AppPresenter.prototype.switchToDataSetTypeView = function()
{ {
this.presenterMode = presenterModeTypeDataSet;
this.hideExplanation(); this.hideExplanation();
this.toggleDisplayedVisualizations(dataSetTypeVis, strainVis); this.toggleDisplayedVisualizations(dataSetTypeVis);
inspectorView.updateView();
} }
/** Show the data sets by strain*/ /** Show the data sets by strain*/
AppPresenter.prototype.switchToStrainView = function() AppPresenter.prototype.switchToStrainView = function()
{ {
this.presenterMode = presenterModeTypeDataSet;
this.hideExplanation(); this.hideExplanation();
this.toggleDisplayedVisualizations(strainVis, dataSetTypeVis); this.toggleDisplayedVisualizations(strainVis);
inspectorView.updateView();
} }
/** Show the data sets by strains with OD600 data*/ /** Show the data sets by strains with OD600 data*/
AppPresenter.prototype.switchToOD600View = function() AppPresenter.prototype.switchToOD600View = function()
{ {
this.presenterMode = presenterModeTypeStrain;
this.hideExplanation(); this.hideExplanation();
this.toggleDisplayedVisualizations(strainVis, dataSetTypeVis); this.toggleDisplayedVisualizations(strainVis);
inspectorView.removeAll(250);
} }
/** Utility function to gracefully switch from one visualization to another */ /** Utility function to gracefully switch from one visualization to another */
AppPresenter.prototype.toggleDisplayedVisualizations = function(visToShow, visToHide) AppPresenter.prototype.toggleDisplayedVisualizations = function(visToShow)
{ {
// TODO: Only include visToShow and hide all other visualizations, since we know what they are this.visualizationContainers.forEach(function(vis) {
visToShow if (vis == visToShow) {
.style("display", "inline") vis.style("display", "inline")
.transition() .transition()
.duration(1000) .duration(1000)
.style("opacity", 1); .style("opacity", 1);
} else {
visToHide vis
.transition() .transition()
.duration(1000) .duration(1000)
.style("opacity", 0) .style("opacity", 0)
.style("display", "none"); .style("display", "none")
}
});
} }
/** /**
...@@ -182,6 +194,8 @@ AppPresenter.prototype.createVis = function() ...@@ -182,6 +194,8 @@ AppPresenter.prototype.createVis = function()
strainVis.style("width", w + "px"); strainVis.style("width", w + "px");
strainView = new StrainView(); strainView = new StrainView();
this.visualizationContainers = [dataSetTypeVis, strainVis];
inspectorView = new InspectorView(); inspectorView = new InspectorView();
this.didCreateVis = true; this.didCreateVis = true;
...@@ -189,7 +203,12 @@ AppPresenter.prototype.createVis = function() ...@@ -189,7 +203,12 @@ AppPresenter.prototype.createVis = function()
AppPresenter.prototype.updateInspectors = function(duration) AppPresenter.prototype.updateInspectors = function(duration)
{ {
inspectorView.updateView(duration); if (this.presenterMode == presenterModeTypeDataSet)
{
inspectorView.updateView(duration);
} else {
// Do nothing.
}
} }
/** Download a file referenced in a table. */ /** Download a file referenced in a table. */
...@@ -607,6 +626,16 @@ InspectorView.prototype.updateView = function(duration) ...@@ -607,6 +626,16 @@ InspectorView.prototype.updateView = function(duration)
.remove(); .remove();
} }
/** Removes all nodes from the view, without affecting the model */
InspectorView.prototype.removeAll = function(duration)
{
var inspector = inspectors.selectAll("div.inspector").data([]);
inspector.exit().transition()
.duration(duration)
.style("opacity", "0")
.remove();
}
function dataSetLabel(d) { return d.bis.dataSetTypeCode + " registered on " + timeformat(new Date(d.bis.registrationDetails.registrationDate)); } function dataSetLabel(d) { return d.bis.dataSetTypeCode + " registered on " + timeformat(new Date(d.bis.registrationDetails.registrationDate)); }
function downloadTableFile(d) { presenter.downloadTableFile(d) } function downloadTableFile(d) { presenter.downloadTableFile(d) }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment