Small cleanups

This commit is contained in:
Pieter Vander Vennet 2021-10-18 22:34:52 +02:00
parent 3f70892d75
commit 028767afe6
3 changed files with 7 additions and 5 deletions

View file

@ -43,9 +43,7 @@ export default abstract class ImageProvider {
const seenValues = new Set<string>()
allTags.addCallbackAndRunD(tags => {
for (const key in tags) {
console.log("Does ", key,"have images?")
if (!prefixes.some(prefix => key.startsWith(prefix))) {
console.log(key,": NO", this.constructor.name, "prefixes are", prefixes)
continue
}
const values = Utils.NoEmpty(tags[key]?.split(";")?.map(v => v.trim()) ?? [])

View file

@ -52,11 +52,11 @@ export default class WikidataPreviewBox extends VariableUiElement {
wikidata.id,
Svg.wikidata_ui().SetStyle("width: 2.5rem").SetClass("block")
]).SetClass("flex"),
Wikidata.IdToArticle(wikidata.id), true).SetClass("must-link")
Wikidata.IdToArticle(wikidata.id), true)?.SetClass("must-link")
let info = new Combine([
new Combine(
[Translation.fromMap(wikidata.labels).SetClass("font-bold"),
[Translation.fromMap(wikidata.labels)?.SetClass("font-bold"),
link]).SetClass("flex justify-between"),
Translation.fromMap(wikidata.descriptions),
WikidataPreviewBox.QuickFacts(wikidata)
@ -147,7 +147,6 @@ export default class WikidataPreviewBox extends VariableUiElement {
els.push(display.Subs({value: value.join(", ")}).SetClass("m-2"))
continue
}
console.log("Display:", display, "key:",key)
const constructors = Utils.NoNull(value.map(property => display.get(property)))
const elems = constructors.map(v => {
if(typeof v === "string"){

View file

@ -217,9 +217,14 @@ export class Translation extends BaseUIElement {
static fromMap(transl: Map<string, string>) {
const translations = {}
let hasTranslation = false;
transl?.forEach((value, key) => {
translations[key] = value
hasTranslation = true
})
if(!hasTranslation){
return undefined
}
return new Translation(translations);
}
}