Move 'usersettings' into separate pseudolayer

This commit is contained in:
Pieter Vander Vennet 2023-01-12 01:17:07 +01:00
parent e1cdb75001
commit ee575a9c42
5 changed files with 110 additions and 160 deletions

View file

@ -19,11 +19,9 @@ import EditableTagRendering from "../Popup/EditableTagRendering"
import TagRenderingConfig from "../../Models/ThemeConfig/TagRenderingConfig"
import { SaveButton } from "../Popup/SaveButton"
import { TagUtils } from "../../Logic/Tags/TagUtils"
import * as questions from "../../assets/tagRenderings/questions.json"
import { TagRenderingConfigJson } from "../../Models/ThemeConfig/Json/TagRenderingConfigJson"
import * as os from "os"
import * as usersettings from "../../assets/generated/layers/usersettings.json"
import { LoginToggle } from "../Popup/LoginButton"
import { userInfo } from "os"
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
export class ImportViewerLinks extends VariableUiElement {
constructor(osmConnection: OsmConnection) {
@ -45,6 +43,36 @@ export class ImportViewerLinks extends VariableUiElement {
}
}
class SingleUserSettingsPanel extends EditableTagRendering {
constructor(config: TagRenderingConfig, osmConnection: OsmConnection) {
const editMode = new UIEventSource(false)
super(
osmConnection.preferencesHandler.preferences,
config,
[],
{ osmConnection },
{
editMode,
createSaveButton: (store) =>
new SaveButton(
osmConnection.preferencesHandler.preferences,
osmConnection
).onClick(() => {
const prefs = osmConnection.preferencesHandler.preferences
const selection = TagUtils.FlattenMultiAnswer(
TagUtils.FlattenAnd(store.data, prefs.data)
).asChange(prefs.data)
for (const kv of selection) {
osmConnection.GetPreference(kv.k, "", "").setData(kv.v)
}
editMode.setData(false)
}),
}
)
}
}
class UserInformationMainPanel extends VariableUiElement {
constructor(
osmConnection: OsmConnection,
@ -78,7 +106,6 @@ class UserInformationMainPanel extends VariableUiElement {
.makeHtml(ud.description)
.replace(/>/g, ">")
.replace(/&lt;/g, "<")
console.log("Before:", ud.description, "after", htmlString)
description = new Combine([
new FixedUiElement(htmlString).SetClass("link-underline"),
editButton,
@ -108,36 +135,10 @@ class UserInformationMainPanel extends VariableUiElement {
})
}
const editMode = new UIEventSource(false)
const licensePicker = new EditableTagRendering(
osmConnection.preferencesHandler.preferences,
new TagRenderingConfig(
<TagRenderingConfigJson>{
source: "shared-questions",
...questions["picture-license"],
},
"shared-questions"
),
[],
{ osmConnection },
{
editMode,
createSaveButton: (store) =>
new SaveButton(
osmConnection.preferencesHandler.preferences,
osmConnection
).onClick(() => {
const prefs = osmConnection.preferencesHandler.preferences
const selection = TagUtils.FlattenMultiAnswer(
TagUtils.FlattenAnd(store.data, prefs.data)
).asChange(prefs.data)
for (const kv of selection) {
osmConnection.GetPreference(kv.k, "", "").setData(kv.v)
}
const usersettingsConfig = new LayerConfig(usersettings, "userinformationpanel")
editMode.setData(false)
}),
}
const questions = usersettingsConfig.tagRenderings.map((c) =>
new SingleUserSettingsPanel(c, osmConnection).SetClass("block my-4")
)
return new Combine([
@ -146,7 +147,7 @@ class UserInformationMainPanel extends VariableUiElement {
layout.language,
Translations.t.general.pickLanguage.Clone()
),
licensePicker.SetClass("block my-4"),
...questions,
new SubtleButton(
Svg.envelope_svg(),
new Combine([

View file

@ -9,9 +9,8 @@ import TagRenderingConfig from "../../Models/ThemeConfig/TagRenderingConfig"
import { Unit } from "../../Models/Unit"
import Lazy from "../Base/Lazy"
import { FixedUiElement } from "../Base/FixedUiElement"
import { EditButton, SaveButton } from "./SaveButton"
import { TagsFilter } from "../../Logic/Tags/TagsFilter"
import { TagUtils, UploadableTag } from "../../Logic/Tags/TagUtils"
import { EditButton } from "./SaveButton"
import { UploadableTag } from "../../Logic/Tags/TagUtils"
export default class EditableTagRendering extends Toggle {
constructor(

View file

@ -0,0 +1,47 @@
{
"id": "usersettings",
"description": {
"en": "A special layer which is not meant to be shown on a map, but which is used to set user settings"
},
"title": null,
"source": {
"osmTags": "id~*"
},
"tagRenderings": [
{
"id": "picture-license",
"description": "This question is not meant to be placed on an OpenStreetMap-element; however it is used in the user information panel to ask which license the user wants",
"question": {
"en": "Under what license do you want to publish your pictures?"
},
"mappings": [
{
"if": "mapcomplete-pictures-license=",
"then": {
"en": "No license has been chosen yet"
},
"hideInAnswer": true
},
{
"if": "mapcomplete-pictures-license=CC0",
"then": {
"en": "Pictures you take will be licensed with CC0 and added to the public domain. This means that everyone can use your pictures for any purpose."
}
},
{
"if": "mapcomplete-pictures-license=CC-BY 4.0",
"then": {
"en": "Pictures you take will be licensed with CC-BY 4.0 which requires everyone using your picture that they have to attribute you"
}
},
{
"if": "mapcomplete-pictures-license=CC-BY-SA 4.0",
"then": {
"en": "Pictures you take will be licensed with CC-BY-SA 4.0 which means that everyone using your picture must attribute you and that derivatives of your picture must be reshared with the same license."
}
}
]
}
],
"mapRendering": null
}

View file

@ -1493,40 +1493,7 @@
}
]
},
"picture-license": {
"description": "This question is not meant to be placed on an OpenStreetMap-element; however it is used in the user information panel to ask which license the user wants",
"question": {
"en": "Under what license do you want to publish your pictures?"
},
"mappings": [
{
"if": "mapcomplete-pictures-license=",
"then": {
"en": "No license has been chosen yet"
},
"hideInAnswer": true
},
{
"if": "mapcomplete-pictures-license=CC0",
"then": {
"en": "Pictures you take will be licensed with CC0 and added to the public domain. This means that everyone can use your pictures for any purpose."
}
},
{
"if": "mapcomplete-pictures-license=CC-BY 4.0",
"then": {
"en": "Pictures you take will be licensed with CC-BY 4.0 which requires everyone using your picture that they have to attribute you"
}
},
{
"if": "mapcomplete-pictures-license=CC-BY-SA 4.0",
"then": {
"en": "Pictures you take will be licensed with CC-BY-SA 4.0 which means that everyone using your picture must attribute you and that derivatives of your picture must be reshared with the same license."
}
}
]
},
"induction-loop": {
"induction-loop": {
"description": "An accessibility feature: induction loops are for hard-hearing persons which have an FM-receiver.",
"question": {
"en": "Does this place have an audio induction loop for people with reduced hearing?",
@ -1799,4 +1766,4 @@
"ca": "El nom de la xarxa és <b>{internet_access:ssid}</b>"
}
}
}
}

View file

@ -1,21 +1,13 @@
{
"id": "mapcomplete-changes",
"title": {
"en": "Changes made with MapComplete",
"de": "Mit MapComplete vorgenommene Änderungen",
"nl": "Wijzigingen gemaakt met MapComplete"
"en": "Changes made with MapComplete"
},
"shortDescription": {
"en": "Shows changes made by MapComplete",
"de": "Zeigt Änderungen, die von MapComplete vorgenommen wurden",
"nl": "Toont wijzigingen gemaakt met MapComplete"
"en": "Shows changes made by MapComplete"
},
"description": {
"en": "This map shows all the changes made with MapComplete",
"ca": "Aquest mapa mostra tots els canvis fets amb MapComplete",
"de": "Diese Karte zeigt alle mit MapComplete vorgenommenen Änderungen",
"fr": "Cette carte montre tous les changements faits avec MapComplete",
"nl": "Deze kaart toont alle wijzigingen gemaakt met MapComplete"
"en": "This maps shows all the changes made with MapComplete"
},
"icon": "./assets/svg/logo.svg",
"hideFromOverview": true,
@ -28,10 +20,7 @@
{
"id": "mapcomplete-changes",
"name": {
"en": "Changeset centers",
"de": "Zentrum der Änderungssätze",
"fr": "Centres de modifications de paramètres",
"nl": "Middelpunt van de wijzigingenset"
"en": "Changeset centers"
},
"minzoom": 0,
"source": {
@ -42,58 +31,41 @@
},
"title": {
"render": {
"en": "Changeset for {theme}",
"de": "Änderungssatz für {theme}",
"nl": "Changeset voor {theme}"
"en": "Changeset for {theme}"
}
},
"description": {
"en": "Shows all MapComplete changes",
"de": "Zeigt alle MapComplete-Änderungen",
"fr": "Montre tous les changements de MapComplete",
"nl": "Toon alle MapComplete wijzigingen"
"en": "Shows all MapComplete changes"
},
"tagRenderings": [
{
"id": "show_changeset_id",
"render": {
"en": "Changeset <a href='https://openstreetmap.org/changeset/{id}' target='_blank'>{id}</a>",
"de": "Änderungssatz <a href='https://openstreetmap.org/changeset/{id}' target='_blank'>{id}</a>",
"nl": "Wijzigingenset <a href='https://openstreetmap.org/changeset/{id}' target='_blank'>{id}</a>"
"en": "Changeset <a href='https://openstreetmap.org/changeset/{id}' target='_blank'>{id}</a>"
}
},
{
"id": "contributor",
"question": {
"en": "What contributor did make this change?",
"de": "Welcher Mitwirkende hat diese Änderung vorgenommen?",
"fr": "Quel contributeur a fait ce changement ?",
"nl": "Welke bijdrager maakte deze wijziging?"
"en": "What contributor did make this change?"
},
"freeform": {
"key": "user"
},
"render": {
"en": "Change made by <a href='https://openstreetmap.org/user/{user}' target='_blank'>{user}</a>",
"de": "Änderung vorgenommen von <a href='https://openstreetmap.org/user/{user}' target='_blank'>{user}</a>",
"fr": "Modification faite par <a href='https://openstreetmap.org/user/{user}' target='_blank'>{user}</a>",
"nl": "Wijziging gemaakt door <a href='https://openstreetmap.org/user/{user}' target='_blank'>{user}</a>"
"en": "Change made by <a href='https://openstreetmap.org/user/{user}' target='_blank'>{user}</a>"
}
},
{
"id": "theme-id",
"question": {
"en": "What theme was used to make this change?",
"de": "Welches Thema wurde für diese Änderung verwendet?",
"nl": "Welk thema is gebruikt voor deze wijziging?"
"en": "What theme was used to make this change?"
},
"freeform": {
"key": "theme"
},
"render": {
"en": "Change with theme <a href='https://mapcomplete.osm.be/{theme}'>{theme}</a>",
"de": "Geändert mit Thema <a href='https://mapcomplete.osm.be/{theme}'>{theme}</a>",
"nl": "Wijziging met thema <a href='https://mapcomplete.osm.be/{theme}'>{theme}</a>"
"en": "Change with theme <a href='https://mapcomplete.osm.be/{theme}'>{theme}</a>"
}
},
{
@ -102,32 +74,19 @@
"key": "locale"
},
"question": {
"en": "What locale (language) was this change made in?",
"de": "In welchem Gebietsschema (Sprache) wurde diese Änderung vorgenommen?",
"fr": "En quelle langue est-ce que ce changement a été fait ?",
"nl": "In welke taal (en cultuur) werd deze wijziging gemaakt?"
"en": "What locale (language) was this change made in?"
},
"render": {
"en": "User locale is {locale}",
"de": "Benutzergebietsschema ist {locale}",
"fr": "La langue de l'utilisateur est {locale}",
"nl": "De locale van de bijdrager is {locale}"
"en": "User locale is {locale}"
}
},
{
"id": "host",
"render": {
"en": "Change with <a href='{host}'>{host}</a>",
"ca": "Canvi amb <a href='{host}'>{host}</a>",
"de": "Geändert über <a href='{host}'>{host}</a>",
"fr": "Changement avec <a href='{host}'>{host}</a>",
"nl": "Wijziging met <a href='{host}'>{host}</a>"
"en": "Change with with <a href='{host}'>{host}</a>"
},
"question": {
"en": "What host (website) was this change made with?",
"de": "Über welchen Host (Webseite) wurde diese Änderung vorgenommen?",
"fr": "Depuis quel serveur (site web) ce changement a-t-il été fait ?",
"nl": "Op welk webadres werd deze wijziging gemaakt?"
"en": "What host (website) was this change made with?"
},
"freeform": {
"key": "host"
@ -468,10 +427,7 @@
}
],
"question": {
"en": "Themename contains {search}",
"de": "Themename enthält {search}",
"fr": "Nom de thème contenant {search}",
"nl": "Themanaam bevat {search}"
"en": "Themename contains {search}"
}
}
]
@ -487,10 +443,7 @@
}
],
"question": {
"en": "Made by contributor {search}",
"de": "Erstellt vom Mitwirkenden {search}",
"fr": "Fait par le contributeur {search}",
"nl": "Gemaakt door {search}"
"en": "Made by contributor {search}"
}
}
]
@ -506,10 +459,7 @@
}
],
"question": {
"en": "<b>Not</b> made by contributor {search}",
"de": "<b>Nicht</b> von Mitwirkendem {search}",
"fr": "<b>Non</b> réalisé par le contributeur{search}",
"nl": "<b>Niet</b> gemaakt door {search}"
"en": "<b>Not</b> made by contributor {search}"
}
}
]
@ -526,10 +476,7 @@
}
],
"question": {
"en": "Made before {search}",
"de": "Erstellt vor {search}",
"fr": "Fait avant {search}",
"nl": "Gemaakt voor {search}"
"en": "Made before {search}"
}
}
]
@ -546,10 +493,7 @@
}
],
"question": {
"en": "Made after {search}",
"de": "Erstellt nach {search}",
"fr": "Fait après {search}",
"nl": "Gemaakt na {search}"
"en": "Made after {search}"
}
}
]
@ -565,10 +509,7 @@
}
],
"question": {
"en": "User language (iso-code) {search}",
"de": "Benutzersprache (ISO-Code) {search}",
"fr": "Langage utilisateur (code-iso) {search}",
"nl": "Gebruikerstaal (iso-code) {search}"
"en": "User language (iso-code) {search}"
}
}
]
@ -584,10 +525,7 @@
}
],
"question": {
"en": "Made with host {search}",
"de": "Erstellt mit host {search}",
"fr": "Fait par le serveur {search}",
"nl": "Gemaakt met host {search}"
"en": "Made with host {search}"
}
}
]
@ -613,9 +551,7 @@
{
"id": "link_to_more",
"render": {
"en": "More statistics can be found <a href='https://github.com/pietervdvn/MapComplete/tree/develop/Docs/Tools/graphs' target='_blank'>here</a>",
"de": "Weitere Statistiken <a href='https://github.com/pietervdvn/MapComplete/tree/develop/Docs/Tools/graphs' target='_blank'>hier</a>",
"nl": "Meer statistieken zijn <a href='https://github.com/pietervdvn/MapComplete/tree/develop/Docs/Tools/graphs' target='_blank'>hier</a> te vinden"
"en": "More statistics can be found <a href='https://github.com/pietervdvn/MapComplete/tree/develop/Docs/Tools/graphs' target='_blank'>here</a>"
}
},
{