datalovelace/src/Models/FocusTable.js
ysandler 7a541cf09a refact: FocusTable Singleton Model
no longer "selectedTable" in Tables Model
2020-07-30 10:38:03 -05:00

27 lines
585 B
JavaScript

let instance = null
class FocusTable {
constructor (table) {
if (instance === null) instance = this
this._value = table
return instance
}
set table (table) {
if (table.type === 'Nodule' || table.type === 'Table') this._value = table
else {
this._value = null
console.error('Focus Tablw value must be of type "Nodule" or "Table"')
}
}
get table () {
if (this._value.type === 'Table') return this._value
else if (this._value.type === 'Nodule') return this._value.asTable()
else return {}
}
}
export default FocusTable