forked from MapComplete/MapComplete
Refactoring: use special rendering for mangrove key download in usersettings
This commit is contained in:
parent
3e46334767
commit
a3c249474d
7 changed files with 49 additions and 10 deletions
|
@ -264,9 +264,21 @@
|
||||||
{
|
{
|
||||||
"id": "mangrove-keys",
|
"id": "mangrove-keys",
|
||||||
"render": {
|
"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>",
|
"special": {
|
||||||
"de": "<a href='data:application/json,{mangroveidentity}' download='mangrove_private_key_{_name}'>Laden Sie den privaten Schlüssel für Ihr Mangrove-Konto herunter</a> <p>Jeder, der diese Datei besitzt, kann mit Ihrer Identität Rezensionen vornehmen</p>",
|
"type": "link",
|
||||||
"da": "<a href='data:application/json,{mangroveidentity}' download='mangrove_private_key_{_name}'>Hent den private nøgle til din Mangrove-konto</a> <p>Enhver, der har denne fil, kan lave ændringer med din identitet</p>"
|
"href": "data:application/json,{mangroveidentity}",
|
||||||
|
"download": "mangrove_private_key_{_name}",
|
||||||
|
"text": {
|
||||||
|
"en": "Download the private key for your Mangrove Account",
|
||||||
|
"de": "Laden Sie den privaten Schlüssel für Ihr Mangrove-Konto herunter",
|
||||||
|
"da": "Hent den private nøgle til din Mangrove-konto"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"after": {
|
||||||
|
"en": "Anyone possessing this file can make reviews with your identity",
|
||||||
|
"de": "Jeder, der diese Datei besitzt, kann mit Ihrer Identität Rezensionen vornehmen",
|
||||||
|
"da": "Enhver, der har denne fil, kan lave ændringer med din identitet"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -2966,7 +2966,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mangrove-keys": {
|
"mangrove-keys": {
|
||||||
"render": "<a href='data:application/json,{mangroveidentity}' download='mangrove_private_key_{_name}'>Hent den private nøgle til din Mangrove-konto</a> <p>Enhver, der har denne fil, kan lave ændringer med din identitet</p>"
|
"render": {
|
||||||
|
"after": "Enhver, der har denne fil, kan lave ændringer med din identitet",
|
||||||
|
"special": {
|
||||||
|
"text": "Hent den private nøgle til din Mangrove-konto"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"picture-license": {
|
"picture-license": {
|
||||||
"mappings": {
|
"mappings": {
|
||||||
|
|
|
@ -9592,7 +9592,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mangrove-keys": {
|
"mangrove-keys": {
|
||||||
"render": "<a href='data:application/json,{mangroveidentity}' download='mangrove_private_key_{_name}'>Laden Sie den privaten Schlüssel für Ihr Mangrove-Konto herunter</a> <p>Jeder, der diese Datei besitzt, kann mit Ihrer Identität Rezensionen vornehmen</p>"
|
"render": {
|
||||||
|
"after": "Jeder, der diese Datei besitzt, kann mit Ihrer Identität Rezensionen vornehmen",
|
||||||
|
"special": {
|
||||||
|
"text": "Laden Sie den privaten Schlüssel für Ihr Mangrove-Konto herunter"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"picture-license": {
|
"picture-license": {
|
||||||
"mappings": {
|
"mappings": {
|
||||||
|
|
|
@ -9680,7 +9680,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mangrove-keys": {
|
"mangrove-keys": {
|
||||||
"render": "<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>"
|
"render": {
|
||||||
|
"after": "Anyone possessing this file can make reviews with your identity",
|
||||||
|
"special": {
|
||||||
|
"text": "Download the private key for your Mangrove Account"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"picture-license": {
|
"picture-license": {
|
||||||
"mappings": {
|
"mappings": {
|
||||||
|
|
|
@ -1,18 +1,22 @@
|
||||||
import Translations from "../i18n/Translations"
|
import Translations from "../i18n/Translations"
|
||||||
import BaseUIElement from "../BaseUIElement"
|
import BaseUIElement from "../BaseUIElement"
|
||||||
import { Store } from "../../Logic/UIEventSource"
|
import { Store } from "../../Logic/UIEventSource"
|
||||||
|
import { Utils } from "../../Utils"
|
||||||
|
|
||||||
export default class Link extends BaseUIElement {
|
export default class Link extends BaseUIElement {
|
||||||
private readonly _href: string | Store<string>
|
private readonly _href: string | Store<string>
|
||||||
private readonly _embeddedShow: BaseUIElement
|
private readonly _embeddedShow: BaseUIElement
|
||||||
private readonly _newTab: boolean
|
private readonly _newTab: boolean
|
||||||
|
private readonly _download: string
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
embeddedShow: BaseUIElement | string,
|
embeddedShow: BaseUIElement | string,
|
||||||
href: string | Store<string>,
|
href: string | Store<string>,
|
||||||
newTab: boolean = false
|
newTab: boolean = false,
|
||||||
|
download: string = undefined
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
|
this._download = download
|
||||||
this._embeddedShow = Translations.W(embeddedShow)
|
this._embeddedShow = Translations.W(embeddedShow)
|
||||||
this._href = href
|
this._href = href
|
||||||
this._newTab = newTab
|
this._newTab = newTab
|
||||||
|
@ -58,6 +62,9 @@ export default class Link extends BaseUIElement {
|
||||||
if (this._newTab) {
|
if (this._newTab) {
|
||||||
el.target = "_blank"
|
el.target = "_blank"
|
||||||
}
|
}
|
||||||
|
if (this._download) {
|
||||||
|
el.download = this._download
|
||||||
|
}
|
||||||
el.appendChild(embeddedShow)
|
el.appendChild(embeddedShow)
|
||||||
return el
|
return el
|
||||||
}
|
}
|
||||||
|
|
|
@ -1155,19 +1155,24 @@ export default class SpecialVisualizations {
|
||||||
name: "class",
|
name: "class",
|
||||||
doc: "CSS-classes to add to the element",
|
doc: "CSS-classes to add to the element",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "download",
|
||||||
|
doc: "If set, this link will act as a download-button. The contents of `href` will be offered for download; this parameter will act as the proposed filename",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
constr(
|
constr(
|
||||||
state: SpecialVisualizationState,
|
state: SpecialVisualizationState,
|
||||||
tagSource: UIEventSource<Record<string, string>>,
|
tagSource: UIEventSource<Record<string, string>>,
|
||||||
args: string[]
|
args: string[]
|
||||||
): BaseUIElement {
|
): BaseUIElement {
|
||||||
const [text, href, classnames] = args
|
const [text, href, classnames, download] = args
|
||||||
return new VariableUiElement(
|
return new VariableUiElement(
|
||||||
tagSource.map((tags) =>
|
tagSource.map((tags) =>
|
||||||
new Link(
|
new Link(
|
||||||
Utils.SubstituteKeys(text, tags),
|
Utils.SubstituteKeys(text, tags),
|
||||||
Utils.SubstituteKeys(href, tags),
|
Utils.SubstituteKeys(href, tags),
|
||||||
true
|
download === undefined,
|
||||||
|
Utils.SubstituteKeys(download, tags)
|
||||||
).SetClass(classnames)
|
).SetClass(classnames)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -451,7 +451,7 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
|
||||||
*/
|
*/
|
||||||
public static SubstituteKeys(
|
public static SubstituteKeys(
|
||||||
txt: string | undefined,
|
txt: string | undefined,
|
||||||
tags?: Record<string, any>,
|
tags: Record<string, any> | undefined,
|
||||||
useLang?: string
|
useLang?: string
|
||||||
): string | undefined {
|
): string | undefined {
|
||||||
if (txt === undefined) {
|
if (txt === undefined) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue