forked from MapComplete/MapComplete
Refactoring: remove unused maproulette layer, move SpecialVisualizations into subfiles
This commit is contained in:
parent
78e9b8a277
commit
01bcaff093
9 changed files with 161 additions and 240 deletions
|
|
@ -0,0 +1,92 @@
|
|||
import { SpecialVisualizationSvelte } from "../SpecialVisualization"
|
||||
import Maproulette from "../../Logic/Maproulette"
|
||||
import SvelteUIElement from "../Base/SvelteUIElement"
|
||||
import MaprouletteSetStatus from "../MapRoulette/MaprouletteSetStatus.svelte"
|
||||
|
||||
export class MapRouletteSpecialVisualisations {
|
||||
public static initList(): SpecialVisualizationSvelte[] {
|
||||
return [
|
||||
{
|
||||
funcName: "maproulette_set_status",
|
||||
group: "maproulette",
|
||||
docs: "Change the status of the given MapRoulette task",
|
||||
needsUrls: [Maproulette.defaultEndpoint],
|
||||
example:
|
||||
" The following example sets the status to '2' (false positive)\n" +
|
||||
"\n" +
|
||||
"```json\n" +
|
||||
"{\n" +
|
||||
" \"id\": \"mark_duplicate\",\n" +
|
||||
" \"render\": {\n" +
|
||||
" \"special\": {\n" +
|
||||
" \"type\": \"maproulette_set_status\",\n" +
|
||||
" \"message\": {\n" +
|
||||
" \"en\": \"Mark as not found or false positive\"\n" +
|
||||
" },\n" +
|
||||
" \"status\": \"2\",\n" +
|
||||
" \"image\": \"close\"\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"}\n" +
|
||||
"```",
|
||||
args: [
|
||||
{
|
||||
name: "message",
|
||||
doc: "A message to show to the user"
|
||||
},
|
||||
{
|
||||
name: "image",
|
||||
doc: "Image to show",
|
||||
defaultValue: "confirm"
|
||||
},
|
||||
{
|
||||
name: "message_confirm",
|
||||
doc: "What to show when the task is closed, either by the user or was already closed."
|
||||
},
|
||||
{
|
||||
name: "status",
|
||||
doc: "A statuscode to apply when the button is clicked. 1 = `close`, 2 = `false_positive`, 3 = `skip`, 4 = `deleted`, 5 = `already fixed` (on the map, e.g. for duplicates), 6 = `too hard`",
|
||||
defaultValue: "1"
|
||||
},
|
||||
{
|
||||
name: "maproulette_id",
|
||||
doc: "The property name containing the maproulette id",
|
||||
defaultValue: "mr_taskId"
|
||||
},
|
||||
{
|
||||
name: "ask_feedback",
|
||||
doc: "If not an empty string, this will be used as question to ask some additional feedback. A text field will be added",
|
||||
defaultValue: ""
|
||||
}
|
||||
],
|
||||
|
||||
constr: (state, tagsSource, args) => {
|
||||
let [
|
||||
message,
|
||||
image,
|
||||
message_closed,
|
||||
statusToSet,
|
||||
maproulette_id_key,
|
||||
askFeedback
|
||||
] = args
|
||||
if (image === "") {
|
||||
image = "confirm"
|
||||
}
|
||||
if (maproulette_id_key === "" || maproulette_id_key === undefined) {
|
||||
maproulette_id_key = "mr_taskId"
|
||||
}
|
||||
statusToSet = statusToSet ?? "1"
|
||||
return new SvelteUIElement(MaprouletteSetStatus, {
|
||||
state,
|
||||
tags: tagsSource,
|
||||
message,
|
||||
image,
|
||||
message_closed,
|
||||
statusToSet,
|
||||
maproulette_id_key,
|
||||
askFeedback
|
||||
})
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
|
@ -8,13 +8,35 @@ import ThemeViewState from "../../Models/ThemeViewState"
|
|||
import OrientationDebugPanel from "../Debug/OrientationDebugPanel.svelte"
|
||||
import AllTagsPanel from "../Popup/AllTagsPanel.svelte"
|
||||
import { UIEventSource } from "../../Logic/UIEventSource"
|
||||
import { Feature } from "geojson"
|
||||
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
|
||||
import ClearCaches from "../Popup/ClearCaches.svelte"
|
||||
import Locale from "../i18n/Locale"
|
||||
import LanguageUtils from "../../Utils/LanguageUtils"
|
||||
import LanguagePicker from "../InputElement/LanguagePicker.svelte"
|
||||
import PendingChangesIndicator from "../BigComponents/PendingChangesIndicator.svelte"
|
||||
|
||||
export class SettingsVisualisations {
|
||||
public static initList(): SpecialVisualizationSvelte[] {
|
||||
return [
|
||||
{
|
||||
funcName: "language_picker",
|
||||
args: [],
|
||||
group: "settings",
|
||||
docs: "A component to set the language of the user interface",
|
||||
constr(state: SpecialVisualizationState): SvelteUIElement {
|
||||
const availableLanguages = Locale.showLinkToWeblate.map((showTranslations) =>
|
||||
showTranslations
|
||||
? LanguageUtils.usedLanguagesSorted
|
||||
: state.theme.language)
|
||||
return new SvelteUIElement(LanguagePicker, {
|
||||
assignTo: state.userRelatedState.language,
|
||||
availableLanguages,
|
||||
preferredLanguages: state.osmConnection.userDetails.map(
|
||||
(ud) => ud?.languages ?? []
|
||||
)
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
funcName: "disabled_questions",
|
||||
group: "settings",
|
||||
|
|
@ -65,13 +87,11 @@ export class SettingsVisualisations {
|
|||
],
|
||||
group: "settings",
|
||||
constr(
|
||||
state: SpecialVisualizationState,
|
||||
tagSource: UIEventSource<Record<string, string>>,
|
||||
_: SpecialVisualizationState,
|
||||
__: UIEventSource<Record<string, string>>,
|
||||
argument: string[],
|
||||
feature: Feature,
|
||||
layer: LayerConfig
|
||||
): SvelteUIElement {
|
||||
return new SvelteUIElement<any, any, any>(ClearCaches, {
|
||||
return new SvelteUIElement(ClearCaches, {
|
||||
msg: argument[0] ?? "Clear local caches"
|
||||
})
|
||||
}
|
||||
|
|
@ -96,8 +116,16 @@ export class SettingsVisualisations {
|
|||
constr(state: SpecialVisualizationState): SvelteUIElement {
|
||||
return new SvelteUIElement(LogoutButton, { osmConnection: state.osmConnection })
|
||||
}
|
||||
},
|
||||
{
|
||||
funcName: "pending_changes",
|
||||
docs: "A module showing the pending changes, with the option to clear the pending changes",
|
||||
group: "settings",
|
||||
args: [],
|
||||
constr(state: SpecialVisualizationState): SvelteUIElement {
|
||||
return new SvelteUIElement(PendingChangesIndicator, { state, compact: false })
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ import DeleteWizard from "../Popup/DeleteFlow/DeleteWizard.svelte"
|
|||
import QrCode from "../Popup/QrCode.svelte"
|
||||
import NothingKnown from "../Popup/NothingKnown.svelte"
|
||||
import { ShareLinkViz } from "../Popup/ShareLinkViz"
|
||||
import { GeoOperations } from "../../Logic/GeoOperations"
|
||||
import AddNewPoint from "../Popup/AddNewPoint/AddNewPoint.svelte"
|
||||
|
||||
/**
|
||||
* Thin wrapper around QuestionBox.svelte to include it into the special Visualisations
|
||||
|
|
@ -198,7 +200,20 @@ export class UISpecialVisualisations {
|
|||
})
|
||||
}
|
||||
},
|
||||
new ShareLinkViz()
|
||||
new ShareLinkViz(),
|
||||
{
|
||||
funcName: "add_new_point",
|
||||
docs: "An element which allows to add a new point on the 'last_click'-location. Only makes sense in the layer `last_click`",
|
||||
args: [],
|
||||
group: "default",
|
||||
constr(state: SpecialVisualizationState, _, __, feature): SvelteUIElement {
|
||||
const [lon, lat] = GeoOperations.centerpointCoordinates(feature)
|
||||
return new SvelteUIElement(AddNewPoint, {
|
||||
state,
|
||||
coordinate: { lon, lat }
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue