forked from MapComplete/MapComplete
Refactoring: put all special visualisations into their own class, add their location into the documentation
This commit is contained in:
parent
c0e7c9e8fa
commit
ae5205f92d
29 changed files with 2270 additions and 2075 deletions
|
@ -26,6 +26,7 @@ import { CombinedFetcher } from "../Logic/Web/NearbyImagesSearch"
|
|||
import UserRelatedState from "../Logic/State/UserRelatedState"
|
||||
import FeaturePropertiesStore from "../Logic/FeatureSource/Actors/FeaturePropertiesStore"
|
||||
import SvelteUIElement from "./Base/SvelteUIElement"
|
||||
import { Utils } from "../Utils"
|
||||
|
||||
/**
|
||||
* The state needed to render a special Visualisation.
|
||||
|
@ -85,17 +86,24 @@ export interface SpecialVisualizationState {
|
|||
reportError(message: string | Error | XMLHttpRequest, extramessage?: string): Promise<void>
|
||||
}
|
||||
|
||||
export interface SpecialVisualization {
|
||||
export abstract class SpecialVisualization {
|
||||
readonly funcName: string
|
||||
readonly docs: string | BaseUIElement
|
||||
/**
|
||||
* The 'group' is merely what association it has in the docs
|
||||
*/
|
||||
readonly group?: string
|
||||
readonly example?: string
|
||||
readonly needsUrls?: string[] | ((args: string[]) => string | string[])
|
||||
readonly definedIn = Utils.runningFromConsole ? Utils.getLocationInCode(2) : undefined;
|
||||
|
||||
/**
|
||||
* Indicates that this special visualisation will make requests to the 'alLNodesDatabase' and that it thus should be included
|
||||
*/
|
||||
readonly needsNodeDatabase?: boolean
|
||||
/**
|
||||
* Indicates that this special visualisation will make requests to the 'alLNodesDatabase' and that it thus should be included
|
||||
*/
|
||||
readonly args: {
|
||||
name: string
|
||||
defaultValue?: string
|
||||
|
@ -107,7 +115,7 @@ export interface SpecialVisualization {
|
|||
|
||||
structuredExamples?(): { feature: Feature<Geometry, Record<string, string>>; args: string[] }[]
|
||||
|
||||
constr(
|
||||
abstract constr(
|
||||
state: SpecialVisualizationState,
|
||||
tagSource: UIEventSource<Record<string, string>>,
|
||||
argument: string[],
|
||||
|
@ -116,32 +124,8 @@ export interface SpecialVisualization {
|
|||
): BaseUIElement
|
||||
}
|
||||
|
||||
export interface SpecialVisualizationSvelte extends SpecialVisualization {
|
||||
readonly funcName: string
|
||||
readonly docs: string
|
||||
/**
|
||||
* The 'group' is merely what association it has in the docs
|
||||
*/
|
||||
readonly group: string
|
||||
readonly example?: string
|
||||
readonly needsUrls?: string[] | ((args: string[]) => string | string[])
|
||||
|
||||
/**
|
||||
* Indicates that this special visualisation will make requests to the 'alLNodesDatabase' and that it thus should be included
|
||||
*/
|
||||
readonly needsNodeDatabase?: boolean
|
||||
readonly args: {
|
||||
name: string
|
||||
defaultValue?: string
|
||||
doc: string
|
||||
required?: false | boolean
|
||||
type?: "key" | string
|
||||
}[]
|
||||
readonly getLayerDependencies?: (argument: string[]) => string[]
|
||||
|
||||
structuredExamples?(): { feature: Feature<Geometry, Record<string, string>>; args: string[] }[]
|
||||
|
||||
constr(
|
||||
export abstract class SpecialVisualizationSvelte extends SpecialVisualization {
|
||||
abstract constr(
|
||||
state: SpecialVisualizationState,
|
||||
tagSource: UIEventSource<Record<string, string>>,
|
||||
argument: string[],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue