Formatting

This commit is contained in:
Pieter Vander Vennet 2022-11-08 14:37:48 +01:00
parent 99ba26e3a2
commit b251fd7b69
8 changed files with 69 additions and 62 deletions

View file

@ -27,7 +27,7 @@ class MetatagUpdater {
const self = this const self = this
this.params = { this.params = {
getFeatureById(id) { getFeatureById(id) {
return <any> state.allElements.ContainingFeatures.get(id) return <any>state.allElements.ContainingFeatures.get(id)
}, },
getFeaturesWithin(layerId, bbox) { getFeaturesWithin(layerId, bbox) {
// We keep track of the BBOX that this source needs // We keep track of the BBOX that this source needs

View file

@ -1,17 +1,17 @@
import {OsmNode, OsmObject, OsmRelation, OsmWay} from "./OsmObject" import { OsmNode, OsmObject, OsmRelation, OsmWay } from "./OsmObject"
import {UIEventSource} from "../UIEventSource" import { UIEventSource } from "../UIEventSource"
import Constants from "../../Models/Constants" import Constants from "../../Models/Constants"
import OsmChangeAction from "./Actions/OsmChangeAction" import OsmChangeAction from "./Actions/OsmChangeAction"
import {ChangeDescription, ChangeDescriptionTools} from "./Actions/ChangeDescription" import { ChangeDescription, ChangeDescriptionTools } from "./Actions/ChangeDescription"
import {Utils} from "../../Utils" import { Utils } from "../../Utils"
import {LocalStorageSource} from "../Web/LocalStorageSource" import { LocalStorageSource } from "../Web/LocalStorageSource"
import SimpleMetaTagger from "../SimpleMetaTagger" import SimpleMetaTagger from "../SimpleMetaTagger"
import FeatureSource from "../FeatureSource/FeatureSource" import FeatureSource from "../FeatureSource/FeatureSource"
import {ElementStorage} from "../ElementStorage" import { ElementStorage } from "../ElementStorage"
import {GeoLocationPointProperties} from "../Actors/GeoLocationHandler" import { GeoLocationPointProperties } from "../Actors/GeoLocationHandler"
import {GeoOperations} from "../GeoOperations" import { GeoOperations } from "../GeoOperations"
import {ChangesetHandler, ChangesetTag} from "./ChangesetHandler" import { ChangesetHandler, ChangesetTag } from "./ChangesetHandler"
import {OsmConnection} from "./OsmConnection" import { OsmConnection } from "./OsmConnection"
/** /**
* Handles all changes made to OSM. * Handles all changes made to OSM.

View file

@ -22,8 +22,8 @@ import { TiledStaticFeatureSource } from "../FeatureSource/Sources/StaticFeature
import { Translation, TypedTranslation } from "../../UI/i18n/Translation" import { Translation, TypedTranslation } from "../../UI/i18n/Translation"
import { Tag } from "../Tags/Tag" import { Tag } from "../Tags/Tag"
import { OsmConnection } from "../Osm/OsmConnection" import { OsmConnection } from "../Osm/OsmConnection"
import {Feature, GeoJSON, LineString} from "geojson"; import { Feature, GeoJSON, LineString } from "geojson"
import {OsmTags} from "../../Models/OsmFeature"; import { OsmTags } from "../../Models/OsmFeature"
export interface GlobalFilter { export interface GlobalFilter {
filter: FilterState filter: FilterState
@ -322,7 +322,7 @@ export default class MapState extends UserRelatedState {
return [] return []
} }
const feature : Feature<LineString, OsmTags> = { const feature: Feature<LineString, OsmTags> = {
type: "Feature", type: "Feature",
properties: { properties: {
id: "location_track", id: "location_track",

View file

@ -4,7 +4,7 @@ import { TagsFilter } from "./TagsFilter"
export class Tag extends TagsFilter { export class Tag extends TagsFilter {
public key: string public key: string
public value: string public value: string
public static newlyCreated = new Tag("_newly_created","yes") ; public static newlyCreated = new Tag("_newly_created", "yes")
constructor(key: string, value: string) { constructor(key: string, value: string) {
super() super()
this.key = key this.key = key

View file

@ -27,7 +27,7 @@ import Loading from "../Base/Loading"
import Hash from "../../Logic/Web/Hash" import Hash from "../../Logic/Web/Hash"
import { GlobalFilter } from "../../Logic/State/MapState" import { GlobalFilter } from "../../Logic/State/MapState"
import { WayId } from "../../Models/OsmFeature" import { WayId } from "../../Models/OsmFeature"
import {Tag} from "../../Logic/Tags/Tag"; import { Tag } from "../../Logic/Tags/Tag"
/* /*
* The SimpleAddUI is a single panel, which can have multiple states: * The SimpleAddUI is a single panel, which can have multiple states:
@ -111,7 +111,9 @@ export default class SimpleAddUI extends Toggle {
await state.changes.applyAction(newElementAction) await state.changes.applyAction(newElementAction)
selectedPreset.setData(undefined) selectedPreset.setData(undefined)
isShown.setData(false) isShown.setData(false)
const selectedFeature = state.allElements.ContainingFeatures.get(newElementAction.newElementId) const selectedFeature = state.allElements.ContainingFeatures.get(
newElementAction.newElementId
)
state.selectedElement.setData(selectedFeature) state.selectedElement.setData(selectedFeature)
Hash.hash.setData(newElementAction.newElementId) Hash.hash.setData(newElementAction.newElementId)
} }

View file

@ -1,24 +1,24 @@
import {UIEventSource} from "../../Logic/UIEventSource" import { UIEventSource } from "../../Logic/UIEventSource"
import {OsmConnection} from "../../Logic/Osm/OsmConnection" import { OsmConnection } from "../../Logic/Osm/OsmConnection"
import FeaturePipeline from "../../Logic/FeatureSource/FeaturePipeline" import FeaturePipeline from "../../Logic/FeatureSource/FeaturePipeline"
import BaseUIElement from "../BaseUIElement" import BaseUIElement from "../BaseUIElement"
import LocationInput from "../Input/LocationInput" import LocationInput from "../Input/LocationInput"
import AvailableBaseLayers from "../../Logic/Actors/AvailableBaseLayers" import AvailableBaseLayers from "../../Logic/Actors/AvailableBaseLayers"
import {BBox} from "../../Logic/BBox" import { BBox } from "../../Logic/BBox"
import {TagUtils} from "../../Logic/Tags/TagUtils" import { TagUtils } from "../../Logic/Tags/TagUtils"
import {SubtleButton} from "../Base/SubtleButton" import { SubtleButton } from "../Base/SubtleButton"
import Combine from "../Base/Combine" import Combine from "../Base/Combine"
import Translations from "../i18n/Translations" import Translations from "../i18n/Translations"
import Svg from "../../Svg" import Svg from "../../Svg"
import Toggle from "../Input/Toggle" import Toggle from "../Input/Toggle"
import SimpleAddUI, {PresetInfo} from "../BigComponents/SimpleAddUI" import SimpleAddUI, { PresetInfo } from "../BigComponents/SimpleAddUI"
import BaseLayer from "../../Models/BaseLayer" import BaseLayer from "../../Models/BaseLayer"
import Img from "../Base/Img" import Img from "../Base/Img"
import Title from "../Base/Title" import Title from "../Base/Title"
import {GlobalFilter} from "../../Logic/State/MapState" import { GlobalFilter } from "../../Logic/State/MapState"
import {VariableUiElement} from "../Base/VariableUIElement" import { VariableUiElement } from "../Base/VariableUIElement"
import {Tag} from "../../Logic/Tags/Tag" import { Tag } from "../../Logic/Tags/Tag"
import {WayId} from "../../Models/OsmFeature" import { WayId } from "../../Models/OsmFeature"
export default class ConfirmLocationOfPoint extends Combine { export default class ConfirmLocationOfPoint extends Combine {
constructor( constructor(
@ -46,7 +46,7 @@ export default class ConfirmLocationOfPoint extends Combine {
// Create location input // Create location input
// We uncouple the event source // We uncouple the event source
const zloc = {...loc, zoom: 19} const zloc = { ...loc, zoom: 19 }
const locationSrc = new UIEventSource(zloc) const locationSrc = new UIEventSource(zloc)
let backgroundLayer = new UIEventSource( let backgroundLayer = new UIEventSource(
@ -105,7 +105,7 @@ export default class ConfirmLocationOfPoint extends Combine {
state.featurePipeline state.featurePipeline
.GetFeaturesWithin(layerId, bbox) .GetFeaturesWithin(layerId, bbox)
?.forEach((feats) => ?.forEach((feats) =>
allFeatures.push(...feats.map((f) => ({feature: f}))) allFeatures.push(...feats.map((f) => ({ feature: f })))
) )
}) })
console.log("Snapping to", allFeatures) console.log("Snapping to", allFeatures)
@ -116,9 +116,7 @@ export default class ConfirmLocationOfPoint extends Combine {
let confirmButton: BaseUIElement = new SubtleButton( let confirmButton: BaseUIElement = new SubtleButton(
preset.icon(), preset.icon(),
new Combine([ new Combine([confirmText]).SetClass("flex flex-col")
confirmText,
]).SetClass("flex flex-col")
) )
.SetClass("font-bold break-words") .SetClass("font-bold break-words")
.onClick(() => { .onClick(() => {
@ -138,7 +136,9 @@ export default class ConfirmLocationOfPoint extends Combine {
) )
}) })
const warn = Translations.t.general.add.warnVisibleForEveryone.Clone().SetClass("alert w-full block"); const warn = Translations.t.general.add.warnVisibleForEveryone
.Clone()
.SetClass("alert w-full block")
if (preciseInput !== undefined) { if (preciseInput !== undefined) {
confirmButton = new Combine([preciseInput, warn, confirmButton]) confirmButton = new Combine([preciseInput, warn, confirmButton])
} else { } else {
@ -149,7 +149,7 @@ export default class ConfirmLocationOfPoint extends Combine {
Svg.layers_ui(), Svg.layers_ui(),
new Combine([ new Combine([
Translations.t.general.add.layerNotEnabled Translations.t.general.add.layerNotEnabled
.Subs({layer: preset.layerToAddTo.layerDef.name}) .Subs({ layer: preset.layerToAddTo.layerDef.name })
.SetClass("alert"), .SetClass("alert"),
Translations.t.general.add.openLayerControl, Translations.t.general.add.openLayerControl,
]) ])
@ -185,7 +185,7 @@ export default class ConfirmLocationOfPoint extends Combine {
const filterConfirmPanel = new VariableUiElement( const filterConfirmPanel = new VariableUiElement(
state.globalFilters.map((gfs) => { state.globalFilters.map((gfs) => {
const gf = gfs[i] const gf = gfs[i]
const confirm = gf.onNewPoint?.confirmAddNew?.Subs({preset: preset.title}) const confirm = gf.onNewPoint?.confirmAddNew?.Subs({ preset: preset.title })
return new Combine([ return new Combine([
gf.onNewPoint?.safetyCheck, gf.onNewPoint?.safetyCheck,
new SubtleButton(Svg.confirm_svg(), confirm).onClick(() => new SubtleButton(Svg.confirm_svg(), confirm).onClick(() =>

View file

@ -1,4 +1,4 @@
import {UIEventSource} from "../../Logic/UIEventSource" import { UIEventSource } from "../../Logic/UIEventSource"
import EditableTagRendering from "./EditableTagRendering" import EditableTagRendering from "./EditableTagRendering"
import QuestionBox from "./QuestionBox" import QuestionBox from "./QuestionBox"
import Combine from "../Base/Combine" import Combine from "../Base/Combine"
@ -7,19 +7,19 @@ import ScrollableFullScreen from "../Base/ScrollableFullScreen"
import Constants from "../../Models/Constants" import Constants from "../../Models/Constants"
import SharedTagRenderings from "../../Customizations/SharedTagRenderings" import SharedTagRenderings from "../../Customizations/SharedTagRenderings"
import BaseUIElement from "../BaseUIElement" import BaseUIElement from "../BaseUIElement"
import {VariableUiElement} from "../Base/VariableUIElement" import { VariableUiElement } from "../Base/VariableUIElement"
import DeleteWizard from "./DeleteWizard" import DeleteWizard from "./DeleteWizard"
import SplitRoadWizard from "./SplitRoadWizard" import SplitRoadWizard from "./SplitRoadWizard"
import TagRenderingConfig from "../../Models/ThemeConfig/TagRenderingConfig" import TagRenderingConfig from "../../Models/ThemeConfig/TagRenderingConfig"
import LayerConfig from "../../Models/ThemeConfig/LayerConfig" import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
import {Utils} from "../../Utils" import { Utils } from "../../Utils"
import MoveWizard from "./MoveWizard" import MoveWizard from "./MoveWizard"
import Toggle from "../Input/Toggle" import Toggle from "../Input/Toggle"
import Lazy from "../Base/Lazy" import Lazy from "../Base/Lazy"
import FeaturePipelineState from "../../Logic/State/FeaturePipelineState" import FeaturePipelineState from "../../Logic/State/FeaturePipelineState"
import {Tag} from "../../Logic/Tags/Tag"; import { Tag } from "../../Logic/Tags/Tag"
import Svg from "../../Svg"; import Svg from "../../Svg"
import Translations from "../i18n/Translations"; import Translations from "../i18n/Translations"
export default class FeatureInfoBox extends ScrollableFullScreen { export default class FeatureInfoBox extends ScrollableFullScreen {
public constructor( public constructor(
@ -101,28 +101,33 @@ export default class FeatureInfoBox extends ScrollableFullScreen {
} }
} }
const withQuestion = layerConfig.tagRenderings.filter(tr => tr.question !== undefined).length const withQuestion = layerConfig.tagRenderings.filter(
(tr) => tr.question !== undefined
).length
const allRenderings: BaseUIElement[] = [ const allRenderings: BaseUIElement[] = [
new VariableUiElement( new VariableUiElement(
tags.map(data => data[Tag.newlyCreated.key]).map(isCreated => { tags
if (isCreated !== Tag.newlyCreated.value) { .map((data) => data[Tag.newlyCreated.key])
return undefined .map((isCreated) => {
} if (isCreated !== Tag.newlyCreated.value) {
const els = [] return undefined
const thanks = }
new Combine([ const els = []
Svg.party_svg().SetClass("w-12 h-12 shrink-0 p-1 m-1 bg-white rounded-full block"), const thanks = new Combine([
t.newlyCreated Svg.party_svg().SetClass(
"w-12 h-12 shrink-0 p-1 m-1 bg-white rounded-full block"
),
t.newlyCreated,
]).SetClass("flex w-full thanks content-center") ]).SetClass("flex w-full thanks content-center")
els.push(thanks) els.push(thanks)
if (withQuestion > 0) { if (withQuestion > 0) {
els.push(t.feelFreeToSkip) els.push(t.feelFreeToSkip)
} }
return new Combine(els).SetClass("pb-4 mb-4 border-b block border-black") return new Combine(els).SetClass("pb-4 mb-4 border-b block border-black")
}) })
) ),
] ]
for (let i = 0; i < allGroupNames.length; i++) { for (let i = 0; i < allGroupNames.length; i++) {
const groupName = allGroupNames[i] const groupName = allGroupNames[i]
@ -275,15 +280,15 @@ export default class FeatureInfoBox extends ScrollableFullScreen {
editElements.push( editElements.push(
Toggle.If(state.featureSwitchIsDebugging, () => { Toggle.If(state.featureSwitchIsDebugging, () => {
const config_all_tags: TagRenderingConfig = new TagRenderingConfig( const config_all_tags: TagRenderingConfig = new TagRenderingConfig(
{render: "{all_tags()}"}, { render: "{all_tags()}" },
"" ""
) )
const config_download: TagRenderingConfig = new TagRenderingConfig( const config_download: TagRenderingConfig = new TagRenderingConfig(
{render: "{export_as_geojson()}"}, { render: "{export_as_geojson()}" },
"" ""
) )
const config_id: TagRenderingConfig = new TagRenderingConfig( const config_id: TagRenderingConfig = new TagRenderingConfig(
{render: "{open_in_iD()}"}, { render: "{open_in_iD()}" },
"" ""
) )

View file

@ -121,7 +121,7 @@ export default class SplitRoadWizard extends Toggle {
} }
// Get nearest point on the road // Get nearest point on the road
const pointOnRoad = GeoOperations.nearestPoint(<any> roadElement, coordinates) // pointOnRoad is a geojson const pointOnRoad = GeoOperations.nearestPoint(<any>roadElement, coordinates) // pointOnRoad is a geojson
// Update point properties to let it match the layer // Update point properties to let it match the layer
pointOnRoad.properties["_split_point"] = "yes" pointOnRoad.properties["_split_point"] = "yes"