From ce017e0341261bd68c5ad8a01f6b1684a225cfd1 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Thu, 10 Mar 2022 23:20:50 +0100 Subject: [PATCH] Tweaks to import flow --- .../Conversion/CreateNoteImportLayer.ts | 15 +- UI/Popup/ImportButton.ts | 2 +- UI/Popup/NewNoteUi.ts | 2 +- UI/SpecialVisualizations.ts | 146 +- assets/svg/duplicate.svg | 8868 +++++++++++++++++ assets/svg/license_info.json | 8 + 6 files changed, 8970 insertions(+), 71 deletions(-) create mode 100644 assets/svg/duplicate.svg diff --git a/Models/ThemeConfig/Conversion/CreateNoteImportLayer.ts b/Models/ThemeConfig/Conversion/CreateNoteImportLayer.ts index 49d7af5b9..14bf63688 100644 --- a/Models/ThemeConfig/Conversion/CreateNoteImportLayer.ts +++ b/Models/ThemeConfig/Conversion/CreateNoteImportLayer.ts @@ -46,15 +46,7 @@ export default class CreateNoteImportLayer extends Conversion l.zoom >= 18) ), pleaseLoginButton, diff --git a/UI/Popup/NewNoteUi.ts b/UI/Popup/NewNoteUi.ts index 71fe2d7b9..0511002e6 100644 --- a/UI/Popup/NewNoteUi.ts +++ b/UI/Popup/NewNoteUi.ts @@ -71,7 +71,7 @@ export default class NewNoteUi extends Toggle { new Combine([new Toggle(undefined, t.warnAnonymous.SetClass("alert"), state?.osmConnection?.isLoggedIn), new Toggle(postNote, t.textNeeded.SetClass("alert"), - text.GetValue().map(txt => txt.length > 3) + text.GetValue().map(txt => txt?.length > 3) ) ]).SetClass("flex justify-end items-center") diff --git a/UI/SpecialVisualizations.ts b/UI/SpecialVisualizations.ts index 9f1fc857a..1b4cf7f41 100644 --- a/UI/SpecialVisualizations.ts +++ b/UI/SpecialVisualizations.ts @@ -46,6 +46,7 @@ import FileSelectorButton from "./Input/FileSelectorButton"; import {LoginToggle} from "./Popup/LoginButton"; import {start} from "repl"; import {SubstitutedTranslation} from "./SubstitutedTranslation"; +import {Feature} from "@turf/turf"; export interface SpecialVisualization { funcName: string, @@ -95,6 +96,88 @@ export class AllTagsPanel extends VariableUiElement { } } +class CloseNoteButton implements SpecialVisualization { + public readonly funcName = "close_note" + public readonly docs = "Button to close a note. A predifined text can be defined to close the note with. If the note is already closed, will show a small text." + public readonly args = [ + { + name: "text", + doc: "Text to show on this button", + }, + { + name: "icon", + doc: "Icon to show", + defaultValue: "checkmark.svg" + }, + { + name: "idkey", + doc: "The property name where the ID of the note to close can be found", + defaultValue: "id" + }, + { + name: "comment", + doc: "Text to add onto the note when closing", + }, + { + name: "minZoom", + doc: "If set, only show the closenote button if zoomed in enough" + }, + { + name: "zoomButton", + doc: "Text to show if not zoomed in enough" + } + ] + + public constr(state: FeaturePipelineState, tags, args): BaseUIElement { + const t = Translations.t.notes; + + const params: { + text: string, + icon: string, + idkey: string, + comment: string, + minZoom: string, + zoomButton: string + } = Utils.ParseVisArgs(this.args, args) + + let icon = Svg.checkmark_svg() + if (params.icon !== "checkmark.svg" && (args[2] ?? "") !== "") { + icon = new Img(args[1]) + } + let textToShow = t.closeNote; + if ((params.text ?? "") !== "") { + textToShow = Translations.T(args[0]) + } + + let closeButton: BaseUIElement = new SubtleButton(icon, textToShow) + const isClosed = tags.map(tags => (tags["closed_at"] ?? "") !== ""); + closeButton.onClick(() => { + const id = tags.data[args[2] ?? "id"] + state.osmConnection.closeNote(id, args[3]) + ?.then(_ => { + tags.data["closed_at"] = new Date().toISOString(); + tags.ping() + }) + }) + + if((params.minZoom??"") !== "" && !isNaN(Number(params.minZoom))){ + closeButton = new Toggle( + closeButton, + params.zoomButton ?? "", + state. locationControl.map(l => l.zoom >= Number(params.minZoom)) + ) + } + + return new LoginToggle(new Toggle( + t.isClosed.SetClass("thanks"), + closeButton, + + isClosed + ), t.loginToClose, state) + } + +} + export default class SpecialVisualizations { public static specialVisualizations = SpecialVisualizations.init() @@ -655,58 +738,7 @@ export default class SpecialVisualizations { }) } }, - { - funcName: "close_note", - docs: "Button to close a note. A predifined text can be defined to close the note with. If the note is already closed, will show a small text.", - args: [ - { - name: "text", - doc: "Text to show on this button", - }, - { - name: "icon", - doc: "Icon to show", - defaultValue: "checkmark.svg" - }, - { - name: "Id-key", - doc: "The property name where the ID of the note to close can be found", - defaultValue: "id" - }, - { - name: "comment", - doc: "Text to add onto the note when closing", - } - ], - constr: (state, tags, args) => { - const t = Translations.t.notes; - - let icon = Svg.checkmark_svg() - if (args[1] !== "checkmark.svg" && (args[2] ?? "") !== "") { - icon = new Img(args[1]) - } - let textToShow = t.closeNote; - if ((args[0] ?? "") !== "") { - textToShow = Translations.T(args[0]) - } - - const closeButton = new SubtleButton(icon, textToShow) - const isClosed = tags.map(tags => (tags["closed_at"] ?? "") !== ""); - closeButton.onClick(() => { - const id = tags.data[args[2] ?? "id"] - state.osmConnection.closeNote(id, args[3]) - ?.then(_ => { - tags.data["closed_at"] = new Date().toISOString(); - tags.ping() - }) - }) - return new LoginToggle(new Toggle( - t.isClosed.SetClass("thanks"), - closeButton, - isClosed - ), t.loginToClose, state) - } - }, + new CloseNoteButton(), { funcName: "add_note_comment", docs: "A textfield to add a comment to a node (with the option to close the note).", @@ -778,7 +810,7 @@ export default class SpecialVisualizations { new Title("Add a comment"), textField, new Combine([ - new Toggle(addCommentButton, undefined, textField.GetValue().map(t => t !==undefined && t.length > 1)).SetClass("mr-2") + new Toggle(addCommentButton, undefined, textField.GetValue().map(t => t !== undefined && t.length > 1)).SetClass("mr-2") , stateButtons]).SetClass("flex justify-end") ]).SetClass("border-2 border-black rounded-xl p-4 block"), t.loginToAddComment, state) @@ -860,15 +892,15 @@ export default class SpecialVisualizations { }, { - funcName:"title", + funcName: "title", args: [], - docs:"Shows the title of the popup. Useful for some cases, e.g. 'What is phone number of {title()}?'", - example:"`What is the phone number of {title()}`, which might automatically become `What is the phone number of XYZ`.", + docs: "Shows the title of the popup. Useful for some cases, e.g. 'What is phone number of {title()}?'", + example: "`What is the phone number of {title()}`, which might automatically become `What is the phone number of XYZ`.", constr: (state, tagsSource, args, guistate) => new VariableUiElement(tagsSource.map(tags => { const layer = state.layoutToUse.getMatchingLayer(tags) const title = layer?.title?.GetRenderValue(tags) - if(title === undefined){ + if (title === undefined) { return undefined } return new SubstitutedTranslation(title, tagsSource, state) diff --git a/assets/svg/duplicate.svg b/assets/svg/duplicate.svg new file mode 100644 index 000000000..56565262d --- /dev/null +++ b/assets/svg/duplicate.svg @@ -0,0 +1,8868 @@ + + + + + OpenStreetMap logo 2011 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + OpenStreetMap logo 2011 + + + Ken Vermette + + + + April 2011 + + + OpenStreetMap.org + + + Replacement logo for OpenStreetMap Foundation + + + OSM openstreetmap logo + + + http://wiki.openstreetmap.org/wiki/File:Public-images-osm_logo.svg + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/svg/license_info.json b/assets/svg/license_info.json index 47eda4678..9b88eec4a 100644 --- a/assets/svg/license_info.json +++ b/assets/svg/license_info.json @@ -381,6 +381,14 @@ "https://commons.wikimedia.org/wiki/File:Download-icon.svg" ] }, + { + "path": "duplicate.svg", + "license": "CC0", + "authors": [ + "Pieter Vander Vennet" + ], + "sources": [] + }, { "path": "envelope.svg", "license": "CC0; trivial",