Further work on GRB, bugfixes
This commit is contained in:
parent
4e4e64ce13
commit
89004af7f9
16 changed files with 456 additions and 102 deletions
|
@ -553,7 +553,7 @@ export default class SpecialVisualizations {
|
|||
doc: "If specified, applies the the tags onto _another_ object. The id will be read from properties[id_of_object_to_apply_this_one] of the selected object. The tags are still calculated based on the tags of the _selected_ element"
|
||||
}
|
||||
],
|
||||
example: "`{tag_apply(survey_date:=$_now:date, Surveyed today!)}`",
|
||||
example: "`{tag_apply(survey_date=$_now:date, Surveyed today!)}`, `{tag_apply(addr:street=$addr:street, Apply the address, apply_icon.svg, _closest_osm_id)",
|
||||
constr: (state, tags, args) => {
|
||||
const tagsToApply = SpecialVisualizations.generateTagsToApply(args[0], tags)
|
||||
const msg = args[1]
|
||||
|
@ -650,6 +650,13 @@ export default class SpecialVisualizations {
|
|||
}
|
||||
return kv
|
||||
})
|
||||
|
||||
for (const spec of tgsSpec) {
|
||||
if(spec[0].endsWith(':')){
|
||||
throw "A tag specification for import or apply ends with ':'. The theme author probably wrote key:=otherkey instead of key=$otherkey"
|
||||
}
|
||||
}
|
||||
|
||||
return tagSource.map(tags => {
|
||||
const newTags: Tag [] = []
|
||||
for (const [key, value] of tgsSpec) {
|
||||
|
|
|
@ -124,45 +124,7 @@ export class Translation extends BaseUIElement {
|
|||
continue;
|
||||
}
|
||||
let template: string = this.translations[lang];
|
||||
for (const k in text) {
|
||||
if (!text.hasOwnProperty(k)) {
|
||||
continue
|
||||
}
|
||||
const combined: (string)[] = [];
|
||||
const parts = template.split("{" + k + "}");
|
||||
const el: string | BaseUIElement = text[k];
|
||||
if (el === undefined) {
|
||||
continue;
|
||||
}
|
||||
let rtext: string = "";
|
||||
if (typeof (el) === "string") {
|
||||
rtext = el;
|
||||
} else if (typeof (el) === "number") {
|
||||
// HUH? Where did that number come from? It might be a version number or something calculated
|
||||
rtext = "" + el;
|
||||
} else if (el["toISOString"] != undefined) {
|
||||
// This is a date, probably the timestamp of the object
|
||||
// @ts-ignore
|
||||
const date: Date = el;
|
||||
rtext = date.toLocaleString();
|
||||
} else if (el.ConstructElement === undefined) {
|
||||
console.error("ConstructElement is not defined", el);
|
||||
throw "ConstructElement is not defined, you are working with a " + (typeof el) + ":" + (el.constructor.name)
|
||||
} else if (el["textFor"] !== undefined) {
|
||||
// @ts-ignore
|
||||
rtext = el.textFor(lang)
|
||||
} else {
|
||||
rtext = el.ConstructElement().innerHTML;
|
||||
|
||||
}
|
||||
for (let i = 0; i < parts.length - 1; i++) {
|
||||
combined.push(parts[i]);
|
||||
combined.push(rtext)
|
||||
}
|
||||
combined.push(parts[parts.length - 1]);
|
||||
template = combined.join("")
|
||||
}
|
||||
newTranslations[lang] = template;
|
||||
newTranslations[lang] = Utils.SubstituteKeys(template, text);
|
||||
}
|
||||
return new Translation(newTranslations);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue