forked from MapComplete/MapComplete
Refactoring: switch specialVis constructor to an object
This commit is contained in:
parent
6bb33771b4
commit
be5bcd99d7
37 changed files with 302 additions and 559 deletions
|
|
@ -1,8 +1,4 @@
|
|||
import {
|
||||
SpecialVisualization,
|
||||
SpecialVisualizationState,
|
||||
SpecialVisualizationSvelte,
|
||||
} from "../SpecialVisualization"
|
||||
import { SpecialVisualisationParams, SpecialVisualization, SpecialVisualizationSvelte } from "../SpecialVisualization"
|
||||
import Constants from "../../Models/Constants"
|
||||
import { UIEventSource } from "../../Logic/UIEventSource"
|
||||
import { Feature } from "geojson"
|
||||
|
|
@ -57,11 +53,7 @@ class CloseNoteViz extends SpecialVisualizationSvelte {
|
|||
]
|
||||
public readonly group = "notes"
|
||||
|
||||
public constr(
|
||||
state: SpecialVisualizationState,
|
||||
tags: UIEventSource<Record<string, string>>,
|
||||
args: string[]
|
||||
): SvelteUIElement {
|
||||
public constr({ state, tags, args }: SpecialVisualisationParams): SvelteUIElement {
|
||||
const { text, icon, idkey, comment, minZoom, zoomButton } = Utils.ParseVisArgs(
|
||||
this.args,
|
||||
args
|
||||
|
|
@ -94,10 +86,7 @@ class AddNoteCommentViz extends SpecialVisualizationSvelte {
|
|||
]
|
||||
public readonly group = "notes"
|
||||
|
||||
public constr(
|
||||
state: SpecialVisualizationState,
|
||||
tags: UIEventSource<Record<string, string>>
|
||||
): SvelteUIElement {
|
||||
public constr({ state, tags }: SpecialVisualisationParams): SvelteUIElement {
|
||||
return new SvelteUIElement(AddNoteComment, { state, tags })
|
||||
}
|
||||
}
|
||||
|
|
@ -110,13 +99,8 @@ class OpenNote extends SpecialVisualizationSvelte {
|
|||
docs =
|
||||
"Creates a new map note on the given location. This options is placed in the 'last_click'-popup automatically if the 'notes'-layer is enabled"
|
||||
|
||||
constr(
|
||||
state: SpecialVisualizationState,
|
||||
tagSource: UIEventSource<Record<string, string>>,
|
||||
argument: string[],
|
||||
feature: Feature
|
||||
): SvelteUIElement {
|
||||
const [lon, lat] = GeoOperations.centerpointCoordinates(feature)
|
||||
constr({ state, feature }: SpecialVisualisationParams): SvelteUIElement {
|
||||
const [lon, lat] = GeoOperations.centerpointCoordinates(<Feature>feature)
|
||||
return new SvelteUIElement(CreateNewNote, {
|
||||
state,
|
||||
coordinate: new UIEventSource({ lon, lat }),
|
||||
|
|
@ -138,7 +122,7 @@ class AddImageToNote extends SpecialVisualizationSvelte {
|
|||
group = "notes"
|
||||
needsUrls = []
|
||||
|
||||
constr(state, tags, args, feature) {
|
||||
constr({ state, tags, args, feature }: SpecialVisualisationParams) {
|
||||
const id = tags.data[args[0] ?? "id"]
|
||||
tags = state.featureProperties.getStore(id)
|
||||
return new SvelteUIElement(UploadImage, { state, tags, feature })
|
||||
|
|
@ -164,7 +148,7 @@ class VisualiseNoteComment extends SpecialVisualization {
|
|||
]
|
||||
needsUrls = [Constants.osmAuthConfig]
|
||||
|
||||
constr(state, tags, args) {
|
||||
constr({ state, tags, args }: SpecialVisualisationParams) {
|
||||
return new VariableUiElement(
|
||||
tags
|
||||
.map((tags) => tags[args[0]])
|
||||
|
|
@ -191,7 +175,7 @@ class VisualiseNoteComment extends SpecialVisualization {
|
|||
}
|
||||
|
||||
export class NoteVisualisations {
|
||||
public static initList(): (SpecialVisualization & { group })[] {
|
||||
public static initList(): SpecialVisualization[] {
|
||||
return [
|
||||
new AddNoteCommentViz(),
|
||||
new CloseNoteViz(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue