Add icons, add validation, add phone and email types, add css fixes

This commit is contained in:
Pieter Vander Vennet 2020-07-26 02:01:34 +02:00
parent eb4dda1ba2
commit 1372027dac
56 changed files with 2794 additions and 3474 deletions

View file

@ -32,7 +32,7 @@ export class ImgurImage extends UIElement {
}
protected InnerRender(): string {
InnerRender(): string {
const image = "<img src='" + this._imageLocation + "' " + "alt='' >";
if(this._imageMeta.data === null){

View file

@ -8,7 +8,7 @@ export class SimpleImageElement extends UIElement {
super(source);
}
protected InnerRender(): string {
InnerRender(): string {
return "<img src='" + this._source.data + "' alt='img'>";
}

View file

@ -29,7 +29,7 @@ export class WikimediaImage extends UIElement {
}
protected InnerRender(): string {
InnerRender(): string {
let url = Wikimedia.ImageNameToUrl(this._imageLocation, 500, 400);
url = url.replace(/'/g, '%27');

View file

@ -26,10 +26,6 @@ export class InputElementWrapper<T> extends InputElement<T>{
return this.input.GetValue();
}
ShowValue(t: T) {
return this.input.ShowValue(t);
}
InnerRender(): string {
return this.pre.Render() + this.input.Render() + this.post.Render();
}

View file

@ -39,7 +39,7 @@ export class SlideShow extends UIElement {
}
protected InnerRender(): string {
InnerRender(): string {
if (this._embeddedElements.data.length == 0) {
return this._noimages.Render();
}

View file

@ -8,6 +8,9 @@ export abstract class UIElement {
public readonly _source: UIEventSource<any>;
private _hideIfEmpty = false;
// WOrkaround as document is not defined
public static runningFromConsole = false;
protected constructor(source: UIEventSource<any>) {
this.id = "ui-element-" + UIElement.nextId;
@ -37,9 +40,10 @@ export abstract class UIElement {
}
Update(): void {
if(document === undefined){
return ; // Running from console
if(UIElement.runningFromConsole){
return;
}
let element = document.getElementById(this.id);
if (element === undefined || element === null) {
// The element is not painted

View file

@ -18,13 +18,11 @@ export default class Translation extends UIElement {
const parts = template.split("{" + k + "}");
const el: string | UIElement = text[k];
let rtext: string = "";
console.log(parts)
if (typeof (el) === "string") {
rtext = el;
} else {
Translation.forcedLanguage = lang; // This is a very dirty hack - it'll bite me one day
rtext = el.InnerRender();
console.log(rtext)
}
for (let i = 0; i < parts.length - 1; i++) {
combined.push(parts[i]);

View file

@ -14,14 +14,14 @@ export default class Translations {
static t = {
cyclofix: {
title: new T({
en: 'Cyclofix bicycle infrastructure',
nl: 'Cyclofix fietsinfrastructuur',
en: 'Cyclofix - an open map for cyclists',
nl: 'Cyclofix - een open kaart voor fietsers',
fr: 'TODO: FRENCH TRANSLATION'
}),
description: new T({
en: "On this map we want to collect data about the whereabouts of bicycle pumps and public racks in Brussels." +
en: "On this map we want to collect data about the whereabouts of bicycle pumps and public racks in Brussels and everywhere else." +
"As a result, cyclists will be able to quickly find the nearest infrastructure for their needs.",
nl: "Op deze kaart willen we gegevens verzamelen over de locatie van fietspompen en openbare stelplaatsen in Brussel." +
nl: "Op deze kaart willen we gegevens verzamelen over de locatie van fietspompen en openbare stelplaatsen in Brussel en overal ter wereld." +
"Hierdoor kunnen fietsers snel de dichtstbijzijnde infrastructuur vinden die voldoet aan hun behoeften.",
fr: "Sur cette carte, nous voulons collecter des données sur la localisation des pompes à vélo et des supports publics à Bruxelles." +
"Les cyclistes pourront ainsi trouver rapidement l'infrastructure la plus proche de leurs besoins."
@ -293,9 +293,21 @@ export default class Translations {
only: new T({en: 'This shop only sells second-hand bikes', nl: 'Deze winkel verkoopt enkel tweedehands fietsen', fr: 'TODO: fr'}),
},
diy: {
question: new T({en: 'Are there tools here to repair your own bike?', nl: 'Biedt deze winkel gereedschap aan om je fiets zelf te herstellen?', fr: 'TODO: fr'}),
yes: new T({en: 'This shop offers tools for DIY repair', nl: 'Deze winkel biedt gereedschap aan om je fiets zelf te herstellen', fr: 'TODO: fr'}),
no: new T({en: 'This shop doesn\'t offer tools for DIY repair', nl: 'Deze winkel biedt geen gereedschap aan om je fiets zelf te herstellen', fr: 'TODO: fr'}),
question: new T({
en: 'Are there tools here to repair your own bike?',
nl: 'Biedt deze winkel gereedschap aan om je fiets zelf te herstellen?',
fr: 'TODO: fr'
}),
yes: new T({
en: 'This shop offers tools for DIY repair',
nl: 'Deze winkel biedt gereedschap aan om je fiets zelf te herstellen',
fr: 'TODO: fr'
}),
no: new T({
en: 'This shop doesn\'t offer tools for DIY repair',
nl: 'Deze winkel biedt geen gereedschap aan om je fiets zelf te herstellen',
fr: 'TODO: fr'
}),
}
},
drinking_water: {
@ -305,6 +317,20 @@ export default class Translations {
})
}
},
bookcases: {
title: new T({en: "Open Bookcase Map", nl: "Open Boekenkastjes kaart"}),
description: new T({
en: "Search a bookcase near you and add information about them in the biggest shared map of the world.",
nl: "Help mee met het creëeren van een volledige kaart met alle boekenruilkastjes!" +
"Een boekenruilkastje is een vaste plaats in publieke ruimte waar iedereen een boek in kan zetten of uit kan meenemen." +
"Meestal een klein kastje of doosje dat op straat staat, maar ook een oude telefooncellen of een schap in een station valt hieronder."
}
),
bookcase: new T({
nl: "Boekenruilkastje"
})
},
image: {
addPicture: new T({en: 'Add picture', nl: 'Voeg foto toe', fr: 'TODO: fr'}),
uploadingPicture: new T({
@ -424,8 +450,19 @@ export default class Translations {
pickLanguage: new T({
en: "Choose a language",
nl: "Kies je taal"
}),
about: new T({
en: "Easily edit and add OpenStreetMap for a certain theme",
nl: "Easily edit and add OpenStreetMap for a certain theme"
}),
nameInlineQuestion: new T({
nl: "De naam van dit {category} is $$$"
}),
noNameCategory: new T({
nl: "{category} zonder naam"
})
}
}
}
public static W(s: string | UIElement): UIElement {
@ -435,4 +472,35 @@ export default class Translations {
return new FixedUiElement(s);
}
public static CountTranslations() {
const queue: any = [Translations.t];
const tr: Translation[] = [];
while (queue.length > 0) {
const item = queue.pop();
if (item instanceof Translation || item.translations !== undefined) {
tr.push(item);
} else {
for (const t in item) {
const x = item[t];
queue.push(x)
}
}
}
const langaugeCounts = {};
for (const translation of tr) {
for (const language in translation.translations) {
if (langaugeCounts[language] === undefined) {
langaugeCounts[language] = 1
} else {
langaugeCounts[language]++;
}
}
}
for (const language in langaugeCounts) {
console.log("Total translations in ", language, langaugeCounts[language], "/", tr.length)
}
}
}