forked from MapComplete/MapComplete
Feature: add button to download mangrove identity
This commit is contained in:
parent
e48571a80a
commit
02203dd05b
5 changed files with 87 additions and 56 deletions
|
@ -24,6 +24,7 @@ export default class UserRelatedState {
|
|||
public static readonly usersettingsConfig = UserRelatedState.initUserRelatedState()
|
||||
public static readonly availableUserSettingsIds: string[] =
|
||||
UserRelatedState.usersettingsConfig?.tagRenderings?.map((tr) => tr.id) ?? []
|
||||
public static readonly SHOW_TAGS_VALUES = ["always", "yes", "full"] as const
|
||||
/**
|
||||
The user credentials
|
||||
*/
|
||||
|
@ -34,7 +35,6 @@ export default class UserRelatedState {
|
|||
public readonly mangroveIdentity: MangroveIdentity
|
||||
public readonly installedUserThemes: Store<string[]>
|
||||
public readonly showAllQuestionsAtOnce: UIEventSource<boolean>
|
||||
public static readonly SHOW_TAGS_VALUES = ["always", "yes", "full"] as const
|
||||
public readonly showTags: UIEventSource<"no" | undefined | "always" | "yes" | "full">
|
||||
public readonly homeLocation: FeatureSource
|
||||
public readonly language: UIEventSource<string>
|
||||
|
@ -178,6 +178,7 @@ export default class UserRelatedState {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
private InitInstalledUserThemes(): Store<string[]> {
|
||||
const prefix = "mapcomplete-unofficial-theme-"
|
||||
const postfix = "-combined-length"
|
||||
|
@ -247,9 +248,23 @@ export default class UserRelatedState {
|
|||
const osmConnection = this.osmConnection
|
||||
osmConnection.preferencesHandler.preferences.addCallback((newPrefs) => {
|
||||
for (const k in newPrefs) {
|
||||
const v = newPrefs[k]
|
||||
if (k.endsWith("-combined-length")) {
|
||||
const l = Number(v)
|
||||
const key = k.substring(0, k.length - "length".length)
|
||||
let combined = ""
|
||||
for (let i = 0; i < l; i++) {
|
||||
combined += newPrefs[key + i]
|
||||
}
|
||||
amendedPrefs.data[key.substring(0, key.length - "-combined-".length)] = combined
|
||||
|
||||
} else {
|
||||
amendedPrefs.data[k] = newPrefs[k]
|
||||
}
|
||||
}
|
||||
|
||||
amendedPrefs.ping()
|
||||
console.log("Amended prefs are:", amendedPrefs.data)
|
||||
})
|
||||
const usersettingsConfig = UserRelatedState.usersettingsConfig
|
||||
const translationMode = osmConnection.GetPreference("translation-mode")
|
||||
|
|
|
@ -2,7 +2,6 @@ import { UIEventSource } from "../Logic/UIEventSource"
|
|||
import { Translation } from "./i18n/Translation"
|
||||
import Locale from "./i18n/Locale"
|
||||
import { FixedUiElement } from "./Base/FixedUiElement"
|
||||
// import SpecialVisualizations from "./SpecialVisualizations"
|
||||
import { Utils } from "../Utils"
|
||||
import { VariableUiElement } from "./Base/VariableUIElement"
|
||||
import Combine from "./Base/Combine"
|
||||
|
|
38
Utils.ts
38
Utils.ts
|
@ -437,6 +437,11 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
|
|||
|
||||
/**
|
||||
* Given a piece of text, will replace any key occuring in 'tags' by the corresponding value
|
||||
*
|
||||
* Utils.SubstituteKeys("abc{def}ghi", {def: 'XYZ'}) // => "abcXYZghi"
|
||||
* Utils.SubstituteKeys("abc{def}{def}ghi", {def: 'XYZ'}) // => "abcXYZXYZghi"
|
||||
* Utils.SubstituteKeys("abc{def}ghi", {def: '{XYZ}'}) // => "abc{XYZ}ghi"
|
||||
*
|
||||
* @param txt
|
||||
* @param tags
|
||||
* @param useLang
|
||||
|
@ -450,12 +455,16 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
|
|||
if (txt === undefined) {
|
||||
return undefined
|
||||
}
|
||||
const regex = /.*{([^}]*)}.*/
|
||||
const regex = /(.*?){([^}]*)}(.*)/
|
||||
|
||||
let match = txt.match(regex)
|
||||
|
||||
if(!match){
|
||||
return txt
|
||||
}
|
||||
let result = ""
|
||||
while (match) {
|
||||
const key = match[1]
|
||||
const [_, normal, key, leftover] = match
|
||||
let v = tags === undefined ? undefined : tags[key]
|
||||
if (v !== undefined && v !== null) {
|
||||
if (v["toISOString"] != undefined) {
|
||||
|
@ -490,11 +499,14 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
|
|||
// v === undefined
|
||||
v = ""
|
||||
}
|
||||
txt = txt.replace("{" + key + "}", v)
|
||||
match = txt.match(regex)
|
||||
}
|
||||
|
||||
return txt
|
||||
result += normal + v
|
||||
match = leftover.match(regex)
|
||||
if(!match){
|
||||
result += leftover
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
public static LoadCustomCss(location: string) {
|
||||
|
@ -1443,13 +1455,6 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
|
|||
return false
|
||||
}
|
||||
|
||||
private static colorDiff(
|
||||
c0: { r: number; g: number; b: number },
|
||||
c1: { r: number; g: number; b: number }
|
||||
) {
|
||||
return Math.abs(c0.r - c1.r) + Math.abs(c0.g - c1.g) + Math.abs(c0.b - c1.b)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Utils.splitIntoSubstitutionParts("abc") // => [{message: "abc"}]
|
||||
|
@ -1476,4 +1481,11 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
|
|||
}
|
||||
return spec
|
||||
}
|
||||
|
||||
private static colorDiff(
|
||||
c0: { r: number; g: number; b: number },
|
||||
c1: { r: number; g: number; b: number }
|
||||
) {
|
||||
return Math.abs(c0.r - c1.r) + Math.abs(c0.g - c1.g) + Math.abs(c0.b - c1.b)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -221,6 +221,11 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{"id": "mangrove-keys",
|
||||
"render": {
|
||||
"en": "<a href='data:application/json,{mangroveidentity}' download='mangrove_private_key_{_name}'>Download the private key for your Mangrove Account</a> <p>Anyone possessing this file can make reviews with your identity</p>"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "translations-title",
|
||||
"label": [
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "mapcomplete",
|
||||
"version": "0.30.9",
|
||||
"version": "0.31.0",
|
||||
"repository": "https://github.com/pietervdvn/MapComplete",
|
||||
"description": "A small website to edit OSM easily",
|
||||
"bugs": "https://github.com/pietervdvn/MapComplete/issues",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue