diff --git a/UI/BigComponents/UserInformation.ts b/UI/BigComponents/UserInformation.ts index 455a697cb..66aca2699 100644 --- a/UI/BigComponents/UserInformation.ts +++ b/UI/BigComponents/UserInformation.ts @@ -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(/</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( - { - 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([ diff --git a/UI/Popup/EditableTagRendering.ts b/UI/Popup/EditableTagRendering.ts index 86ccbd4bb..6a86b9fab 100644 --- a/UI/Popup/EditableTagRendering.ts +++ b/UI/Popup/EditableTagRendering.ts @@ -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( diff --git a/assets/layers/usersettings/usersettings.json b/assets/layers/usersettings/usersettings.json new file mode 100644 index 000000000..3f8765194 --- /dev/null +++ b/assets/layers/usersettings/usersettings.json @@ -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 +} diff --git a/assets/tagRenderings/questions.json b/assets/tagRenderings/questions.json index 79f785069..bb175ae37 100644 --- a/assets/tagRenderings/questions.json +++ b/assets/tagRenderings/questions.json @@ -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 {internet_access:ssid}" } } -} \ No newline at end of file +} diff --git a/assets/themes/mapcomplete-changes/mapcomplete-changes.json b/assets/themes/mapcomplete-changes/mapcomplete-changes.json index 9cbbdc87c..137bb9260 100644 --- a/assets/themes/mapcomplete-changes/mapcomplete-changes.json +++ b/assets/themes/mapcomplete-changes/mapcomplete-changes.json @@ -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 {id}", - "de": "Änderungssatz {id}", - "nl": "Wijzigingenset {id}" + "en": "Changeset {id}" } }, { "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 {user}", - "de": "Änderung vorgenommen von {user}", - "fr": "Modification faite par {user}", - "nl": "Wijziging gemaakt door {user}" + "en": "Change made by {user}" } }, { "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 {theme}", - "de": "Geändert mit Thema {theme}", - "nl": "Wijziging met thema {theme}" + "en": "Change with theme {theme}" } }, { @@ -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 {host}", - "ca": "Canvi amb {host}", - "de": "Geändert über {host}", - "fr": "Changement avec {host}", - "nl": "Wijziging met {host}" + "en": "Change with with {host}" }, "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": "Not made by contributor {search}", - "de": "Nicht von Mitwirkendem {search}", - "fr": "Non réalisé par le contributeur{search}", - "nl": "Niet gemaakt door {search}" + "en": "Not 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 here", - "de": "Weitere Statistiken hier", - "nl": "Meer statistieken zijn hier te vinden" + "en": "More statistics can be found here" } }, {