diff --git a/Customizations/TagRendering.ts b/Customizations/TagRendering.ts index 9fd321a..6f31dcb 100644 --- a/Customizations/TagRendering.ts +++ b/Customizations/TagRendering.ts @@ -144,14 +144,15 @@ export class TagRendering extends UIElement implements TagDependantUIElement { self._questionElement.GetValue().map( (tags: TagsFilter) => { if (tags === undefined) { - return ""; + return Translations.t.general.noTagsSelected.SetClass("subtle").Render(); } const csCount = State.state.osmConnection.userDetails.data.csCount; if (csCount < State.userJourney.tagsVisibleAt) { return ""; } if (csCount < State.userJourney.tagsVisibleAndWikiLinked) { - return new FixedUiElement(tags.asHumanString(false)).SetClass("subtle").Render(); + const tagsStr = tags.asHumanString(false); + return new FixedUiElement(tagsStr).SetClass("subtle").Render(); } return tags.asHumanString(true); } @@ -407,16 +408,18 @@ export class TagRendering extends UIElement implements TagDependantUIElement { if (this.IsQuestioning() || this._editMode.data) { // Not yet known or questioning, we have to ask a question - const question = - this.ApplyTemplate(this._question).Render(); - return "
" + - "" + question + "" + - (question !== "" ? "" : "
") + - "
" + this._questionElement.Render() + "
" + - this._skipButton.Render() + - this._saveButton.Render() + - this._appliedTags.Render() + + new Combine([ + "", + this.ApplyTemplate(this._question), + "", + "
", + "
", this._questionElement , "
", + this._skipButton, + this._saveButton, + "
", + this._appliedTags + ]).Render() + "
" } diff --git a/Logic/TagsFilter.ts b/Logic/TagsFilter.ts index d58f861..b0f4d0f 100644 --- a/Logic/TagsFilter.ts +++ b/Logic/TagsFilter.ts @@ -1,3 +1,4 @@ +import {Utils} from "../Utils"; export abstract class TagsFilter { abstract matches(tags: { k: string, v: string }[]): boolean @@ -151,15 +152,23 @@ export class Tag extends TagsFilter { } asHumanString(linkToWiki: boolean) { + let v = "" + if (typeof (this.value) === "string") { + v = this.value; + }else{ + // value is a regex + v = this.value.source; + } + v = Utils.EllipsesAfter(v, 25); if (linkToWiki) { return `${this.key}` + `=` + - `${this.value}` + `${v}` } console.log("Humanizing", this) if (typeof (this.value) === "string") { - return this.key + (this.invertValue ? "!=": "=") + this.value; + return this.key + (this.invertValue ? "!=": "=") + v; }else{ // value is a regex return this.key + "~=" + this.value.source; diff --git a/UI/i18n/Translations.ts b/UI/i18n/Translations.ts index fb6dd1d..64c309b 100644 --- a/UI/i18n/Translations.ts +++ b/UI/i18n/Translations.ts @@ -901,6 +901,8 @@ export default class Translations { nl: " of maak een nieuwe account aan ", fr: " ou registrez vous" }), + noTagsSelected: new T({en: "No tags selected"}) + }, favourite: { title: new T({en: "Personal theme"}), diff --git a/Utils.ts b/Utils.ts index c3c5f63..ad78e05 100644 --- a/Utils.ts +++ b/Utils.ts @@ -65,5 +65,12 @@ export class Utils { } ), Locale.language); } + + public static EllipsesAfter(str : string, l : number = 100){ + if(str.length <= l){ + return str; + } + return str.substr(0, l - 3)+"..."; + } } diff --git a/index.ts b/index.ts index 37747ec..fb5964b 100644 --- a/index.ts +++ b/index.ts @@ -76,7 +76,6 @@ if (layoutFromBase64 !== "false") { // layoutFromBase64 contains the name of the theme. This is partly to do tracking with goat counter const dedicatedHashFromLocalStorage = LocalStorageSource.Get("user-layout-" + layoutFromBase64.replace(" ", "_")); - if(dedicatedHashFromLocalStorage.data?.length < 10){ dedicatedHashFromLocalStorage.setData(undefined); }