Merge develop

This commit is contained in:
Pieter Vander Vennet 2023-08-10 16:25:25 +02:00
commit 04ecdad1bb
61 changed files with 702 additions and 705 deletions

View file

@ -4,14 +4,13 @@
import { UIEventSource } from "../UIEventSource"
import Hash from "./Hash"
import { Utils } from "../../Utils"
import doc = Mocha.reporters.doc
export class QueryParameters {
static defaults: Record<string, string> = {}
static documentation: Map<string, string> = new Map<string, string>()
private static order: string[] = ["layout", "test", "z", "lat", "lon"]
protected static readonly _wasInitialized: Set<string> = new Set()
protected static readonly knownSources: Record<string, UIEventSource<string>> = {}
private static order: string[] = ["layout", "test", "z", "lat", "lon"]
private static initialized = false
public static GetQueryParameter(
@ -74,6 +73,7 @@ export class QueryParameters {
this.init()
return QueryParameters._wasInitialized.has(key)
}
public static initializedParameters(): ReadonlyArray<string> {
return Array.from(QueryParameters._wasInitialized.keys())
}
@ -108,14 +108,12 @@ export class QueryParameters {
}
}
/**
* Set the query parameters of the page location
* @constructor
* @private
*/
private static Serialize() {
const parts = []
public static GetParts(exclude?: Set<string>) {
const parts: string[] = []
for (const key of QueryParameters.order) {
if (exclude?.has(key)) {
continue
}
if (QueryParameters.knownSources[key]?.data === undefined) {
continue
}
@ -134,6 +132,16 @@ export class QueryParameters {
encodeURIComponent(QueryParameters.knownSources[key].data)
)
}
return parts
}
/**
* Set the query parameters of the page location
* @constructor
* @private
*/
private static Serialize() {
const parts = QueryParameters.GetParts()
if (!Utils.runningFromConsole) {
// Don't pollute the history every time a parameter changes
try {
@ -151,4 +159,8 @@ export class QueryParameters {
QueryParameters._wasInitialized.clear()
QueryParameters.order = []
}
static GetDefaultFor(key: string): string {
return QueryParameters.defaults[key]
}
}

View file

@ -1,9 +1,25 @@
import ThemeViewState from "../../Models/ThemeViewState"
import Hash from "./Hash"
import { MenuState } from "../../Models/MenuState"
export default class ThemeViewStateHashActor {
private readonly _state: ThemeViewState
public static readonly documentation = [
"The URL-hash can contain multiple values:",
"",
"- The id of the currently selected object, e.g. `node/1234`",
"- The currently opened menu view",
"- The base64-encoded JSON-file specifying a custom theme (only when loading)",
"",
"### Possible hashes to open a menu",
"",
"The possible hashes are:",
"",
MenuState._menuviewTabs.map((tab) => "`menu:" + tab + "`").join(","),
MenuState._themeviewTabs.map((tab) => "`theme-menu:" + tab + "`").join(","),
]
/**
* Converts the hash to the appropriate themeview state and, vice versa, sets the hash.
*
@ -100,7 +116,7 @@ export default class ThemeViewStateHashActor {
private loadStateFromHash(hash: string) {
const state = this._state
const parts = hash.split(";")
const parts = hash.split(":")
outer: for (const { toggle, name, showOverOthers, submenu } of state.guistate.allToggles) {
for (const part of parts) {
if (part === name) {