forked from MapComplete/MapComplete
refactoring
This commit is contained in:
parent
b94a8f5745
commit
5d0fe31c41
114 changed files with 2412 additions and 2958 deletions
|
@ -1,13 +1,13 @@
|
|||
import { UIEventSource } from "../Logic/UIEventSource"
|
||||
import { QueryParameters } from "../Logic/Web/QueryParameters"
|
||||
import Hash from "../Logic/Web/Hash"
|
||||
|
||||
export class DefaultGuiState {
|
||||
static state: DefaultGuiState
|
||||
|
||||
public readonly welcomeMessageIsOpened: UIEventSource<boolean> = new UIEventSource<boolean>(
|
||||
false
|
||||
)
|
||||
|
||||
public readonly menuIsOpened: UIEventSource<boolean> = new UIEventSource<boolean>(false)
|
||||
|
||||
public readonly downloadControlIsOpened: UIEventSource<boolean> = new UIEventSource<boolean>(
|
||||
false
|
||||
)
|
||||
|
@ -22,25 +22,17 @@ export class DefaultGuiState {
|
|||
public readonly userInfoFocusedQuestion: UIEventSource<string> = new UIEventSource<string>(
|
||||
undefined
|
||||
)
|
||||
public readonly welcomeMessageOpenedTab: UIEventSource<number>
|
||||
|
||||
private readonly sources: Record<string, UIEventSource<boolean>> = {
|
||||
welcome: this.welcomeMessageIsOpened,
|
||||
download: this.downloadControlIsOpened,
|
||||
filters: this.filterViewIsOpened,
|
||||
copyright: this.copyrightViewIsOpened,
|
||||
currentview: this.currentViewControlIsOpened,
|
||||
userinfo: this.userInfoIsOpened,
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.welcomeMessageOpenedTab = UIEventSource.asFloat(
|
||||
QueryParameters.GetQueryParameter(
|
||||
"tab",
|
||||
"0",
|
||||
`The tab that is shown in the welcome-message.`
|
||||
)
|
||||
)
|
||||
const sources = {
|
||||
welcome: this.welcomeMessageIsOpened,
|
||||
download: this.downloadControlIsOpened,
|
||||
filters: this.filterViewIsOpened,
|
||||
copyright: this.copyrightViewIsOpened,
|
||||
currentview: this.currentViewControlIsOpened,
|
||||
userinfo: this.userInfoIsOpened,
|
||||
}
|
||||
|
||||
const self = this
|
||||
this.userInfoIsOpened.addCallback((isOpen) => {
|
||||
if (!isOpen) {
|
||||
|
@ -49,10 +41,16 @@ export class DefaultGuiState {
|
|||
}
|
||||
})
|
||||
|
||||
sources[Hash.hash.data?.toLowerCase()]?.setData(true)
|
||||
this.sources[Hash.hash.data?.toLowerCase()]?.setData(true)
|
||||
|
||||
if (Hash.hash.data === "" || Hash.hash.data === undefined) {
|
||||
this.welcomeMessageIsOpened.setData(true)
|
||||
}
|
||||
}
|
||||
|
||||
public closeAll() {
|
||||
for (const sourceKey in this.sources) {
|
||||
this.sources[sourceKey].setData(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue