From e155f5c1c2d650669a307c44d30f09c9fc137449 Mon Sep 17 00:00:00 2001 From: turner Date: Mon, 13 Nov 2023 09:42:35 -0500 Subject: [PATCH] save ROI set visibility to session --- js/roi/ROIManager.js | 15 +++++++++++++++ js/roi/ROISet.js | 6 ++++-- js/roi/ROITable.js | 11 ++++++----- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/js/roi/ROIManager.js b/js/roi/ROIManager.js index 03ccd28ea..edfa6b923 100644 --- a/js/roi/ROIManager.js +++ b/js/roi/ROIManager.js @@ -36,6 +36,11 @@ class ROIManager { const records = await this.getTableRecords() this.roiTable.renderTable(records) + if (this.roiSets.length > 0) { + const isVisible = this.roiSets[ 0 ].isVisible + this.roiTable.setROIVisibility(isVisible) + } + } async loadROI(config, genome) { @@ -122,6 +127,16 @@ class ROIManager { this.browser.roiTableControl.setVisibility(this.browser.doShowROITableButton) } + toggleROIs() { + + const isVisible = !(this.roiSets[ 0 ].isVisible) + this.roiTable.setROIVisibility(isVisible) + + for (const roiSet of this.roiSets) { + roiSet.isVisible = isVisible + } + } + async renderAllROISets() { for (let roiSet of this.roiSets) { diff --git a/js/roi/ROISet.js b/js/roi/ROISet.js index f958751c5..fd54139c3 100644 --- a/js/roi/ROISet.js +++ b/js/roi/ROISet.js @@ -57,6 +57,8 @@ class ROISet { // this.headerColor = `rgba(${ r },${ g },${ b },${ 1.0 })` } + + this.isVisible = config.isVisible || true } async getFeatures(chr, start, end) { @@ -85,7 +87,7 @@ class ROISet { toJSON() { if (this.url) { - return {name: this.name, color: this.color, url: this.url, isUserDefined: this.isUserDefined} + return {name: this.name, color: this.color, url: this.url, isUserDefined: this.isUserDefined, isVisible: this.isVisible} } else { const featureMap = this.featureSource.getAllFeatures() const features = [] @@ -94,7 +96,7 @@ class ROISet { features.push(f) } } - return {name: this.name, color: this.color, features: features, isUserDefined: this.isUserDefined} + return {name: this.name, color: this.color, features: features, isUserDefined: this.isUserDefined, isVisible: this.isVisible} } } diff --git a/js/roi/ROITable.js b/js/roi/ROITable.js index 7dfdfe899..fcb9bdc45 100644 --- a/js/roi/ROITable.js +++ b/js/roi/ROITable.js @@ -78,7 +78,7 @@ class ROITable extends RegionTableBase { function toggleROIButtonHandler(event) { event.preventDefault() event.stopPropagation() - this.toggleROIs() + this.browser.roiManager.toggleROIs() } this.boundToggleDisplayButtonHandler = toggleROIButtonHandler.bind(this) @@ -87,16 +87,17 @@ class ROITable extends RegionTableBase { } - toggleROIs() { + setROIVisibility(isVisible) { + const elements = this.browser.columnContainer.querySelectorAll('.igv-roi-region') for (const el of elements) { - el.style.display = 'none' === el.style.display ? 'flex' : 'none' + el.style.display = false === isVisible ? 'none' : 'flex' } - const status = elements[ 0 ].style.display - this.toggleROIButton.textContent = 'none' === status ? 'Show all ROIs' : 'Hide all ROIs' + this.toggleROIButton.textContent = false === isVisible ? 'Show all ROIs' : 'Hide all ROIs' } + dispose() { document.removeEventListener('click', this.boundGotoButtonHandler)