Skip to content

Commit

Permalink
rename variables to clearly state layout dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinebridge committed Mar 6, 2024
1 parent 1d571b7 commit 8355237
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function stateModelFactory() {
* #getter
* array of all block heights
*/
get blockHeights() {
get layoutBlockHeights() {
try {
const { blockDefinitions, blockState } = self
return blockDefinitions.map(block => {
Expand All @@ -121,8 +121,8 @@ function stateModelFactory() {
* #getter
* returns true if all blocks are defined
*/
get allBlocksRendered() {
return this.blockHeights.every(b => b !== undefined)
get allLayoutBlocksRendered() {
return this.layoutBlockHeights.every(b => b !== undefined)
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,22 @@ export default function TrackHeightMixin() {
* #getter
* returns the value of the track height setting from the view model
*/
get trackHeightSetting() {
const { trackHeightSetting } = getContainingView(
get adjustTrackLayoutHeightSetting() {
const { adjustTrackLayoutHeightSetting } = getContainingView(
self,
) as LinearGenomeViewModel

return trackHeightSetting
return adjustTrackLayoutHeightSetting
},
/**
* #getter
* the max height between the rendered blocks and the configured height
*/
get maxBlockHeight() {
get maxLayoutBlockHeight() {
// @ts-expect-error
const confHeight = getConf(self, 'height') as number
// @ts-expect-error
return max(self.blockHeights, confHeight)
return max(self.layoutBlockHeights, confHeight)
},
/**
* #getter
Expand All @@ -73,9 +73,9 @@ export default function TrackHeightMixin() {
get layoutMaxHeight() {
// @ts-expect-error
const confHeight = getConf(self, 'height') as number
return this.trackHeightSetting === 'on'
? this.maxBlockHeight
: this.trackHeightSetting === 'first_render'
return this.adjustTrackLayoutHeightSetting === 'on'
? this.maxLayoutBlockHeight
: this.adjustTrackLayoutHeightSetting === 'first_render'
? max([self.firstRenderHeight], confHeight)
: confHeight
},
Expand Down Expand Up @@ -117,9 +117,12 @@ export default function TrackHeightMixin() {
autorun(() => {
const ready =
// @ts-expect-error
self.allBlocksRendered && self.firstRenderHeight === 0
if (self.trackHeightSetting === 'first_render' && ready) {
self.setFirstRenderHeight(self.maxBlockHeight)
self.allLayoutBlocksRendered && self.firstRenderHeight === 0
if (
self.adjustTrackLayoutHeightSetting === 'first_render' &&
ready
) {
self.setFirstRenderHeight(self.maxLayoutBlockHeight)
}
}),
)
Expand Down
26 changes: 13 additions & 13 deletions plugins/linear-genome-view/src/LinearGenomeView/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ export function stateModelFactory(pluginManager: PluginManager) {
* #property
* setting to auto-adjust the layout height of tracks
*/
adjustLayoutHeight: types.optional(
adjustTrackLayoutHeight: types.optional(
types.string,
() => localStorageGetItem('lgv-adjustLayoutHeight') || 'off',
() => localStorageGetItem('lgv-adjustTrackLayoutHeight') || 'off',
),

/**
Expand Down Expand Up @@ -292,12 +292,12 @@ export function stateModelFactory(pluginManager: PluginManager) {
/**
* #getter
*/
get trackHeightSetting() {
get adjustTrackLayoutHeightSetting() {
const sessionSetting = getConf(getSession(self), [
'LinearGenomeViewPlugin',
'trackHeight',
])
return self.adjustLayoutHeight || sessionSetting
return self.adjustTrackLayoutHeight || sessionSetting
},
/**
* #getter
Expand Down Expand Up @@ -818,9 +818,9 @@ export function stateModelFactory(pluginManager: PluginManager) {
/**
* #action
*/
setAdjustLayoutHeight(setting: 'on' | 'off' | 'first_render') {
localStorage.setItem('lgv-adjustLayoutHeight', setting)
self.adjustLayoutHeight = setting
setadjustTrackLayoutHeight(setting: 'on' | 'off' | 'first_render') {
localStorage.setItem('lgv-adjustTrackLayoutHeight', setting)
self.adjustTrackLayoutHeight = setting
},

/**
Expand Down Expand Up @@ -1215,20 +1215,20 @@ export function stateModelFactory(pluginManager: PluginManager) {
{
label: 'Use default (from config)',
type: 'radio',
checked: self.trackHeightSetting === 'off',
onClick: () => self.setAdjustLayoutHeight('off'),
checked: self.adjustTrackLayoutHeightSetting === 'off',
onClick: () => self.setadjustTrackLayoutHeight('off'),
},
{
label: 'Auto-adjust to show all features on track',
type: 'radio',
checked: self.trackHeightSetting === 'on',
onClick: () => self.setAdjustLayoutHeight('on'),
checked: self.adjustTrackLayoutHeightSetting === 'on',
onClick: () => self.setadjustTrackLayoutHeight('on'),
},
{
label: 'Auto-adjust to show height of initial features',
type: 'radio',
checked: self.trackHeightSetting === 'first_render',
onClick: () => self.setAdjustLayoutHeight('first_render'),
checked: self.adjustTrackLayoutHeightSetting === 'first_render',
onClick: () => self.setadjustTrackLayoutHeight('first_render'),
},
],
},
Expand Down
6 changes: 3 additions & 3 deletions plugins/linear-genome-view/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ export default class LinearGenomeViewPlugin extends Plugin {
]),
},
/**
* #slot configuration.LinearGenomeViewPlugin.trackHeight
* #slot configuration.LinearGenomeViewPlugin.adjustTrackLayoutHeight
*/
trackHeight: {
adjustTrackLayoutHeight: {
type: 'string',
defaultValue: 'off',
model: types.enumeration('trackHeightOptions', [
model: types.enumeration('adjustTrackLayoutHeightOptions', [
'off',
'on',
'first_render',
Expand Down

0 comments on commit 8355237

Please sign in to comment.