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>() const seenValues = new Set<string>()
allTags.addCallbackAndRunD(tags => { allTags.addCallbackAndRunD(tags => {
for (const key in tags) { for (const key in tags) {
console.log("Does ", key,"have images?")
if (!prefixes.some(prefix => key.startsWith(prefix))) { if (!prefixes.some(prefix => key.startsWith(prefix))) {
console.log(key,": NO", this.constructor.name, "prefixes are", prefixes)
continue continue
} }
const values = Utils.NoEmpty(tags[key]?.split(";")?.map(v => v.trim()) ?? []) 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, wikidata.id,
Svg.wikidata_ui().SetStyle("width: 2.5rem").SetClass("block") Svg.wikidata_ui().SetStyle("width: 2.5rem").SetClass("block")
]).SetClass("flex"), ]).SetClass("flex"),
Wikidata.IdToArticle(wikidata.id), true).SetClass("must-link") Wikidata.IdToArticle(wikidata.id), true)?.SetClass("must-link")
let info = new Combine([ let info = new Combine([
new Combine( new Combine(
[Translation.fromMap(wikidata.labels).SetClass("font-bold"), [Translation.fromMap(wikidata.labels)?.SetClass("font-bold"),
link]).SetClass("flex justify-between"), link]).SetClass("flex justify-between"),
Translation.fromMap(wikidata.descriptions), Translation.fromMap(wikidata.descriptions),
WikidataPreviewBox.QuickFacts(wikidata) WikidataPreviewBox.QuickFacts(wikidata)
@ -147,7 +147,6 @@ export default class WikidataPreviewBox extends VariableUiElement {
els.push(display.Subs({value: value.join(", ")}).SetClass("m-2")) els.push(display.Subs({value: value.join(", ")}).SetClass("m-2"))
continue continue
} }
console.log("Display:", display, "key:",key)
const constructors = Utils.NoNull(value.map(property => display.get(property))) const constructors = Utils.NoNull(value.map(property => display.get(property)))
const elems = constructors.map(v => { const elems = constructors.map(v => {
if(typeof v === "string"){ if(typeof v === "string"){

View file

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