, key: string) {
super(tags);
this._key = key;
- this.ListenTo(UIEventSource.Chronic(60*1000)); // Automatically reload every minute
+ this.ListenTo(UIEventSource.Chronic(60 * 1000)); // Automatically reload every minute
this.ListenTo(UIEventSource.Chronic(500, () => {
return tags.data._country === undefined;
}));
-
-
- }
-
+ }
+
private static GetRanges(oh: any, from: Date, to: Date): ({
isOpen: boolean,
isSpecial: boolean,
@@ -38,7 +45,7 @@ export default class OpeningHoursVisualization extends UIElement {
const start = new Date(from);
// We go one day more into the past, in order to force rendering of holidays in the start of the period
start.setDate(from.getDate() - 1);
-
+
const iterator = oh.getIterator(start);
let prevValue = undefined;
@@ -63,8 +70,8 @@ export default class OpeningHoursVisualization extends UIElement {
// simply closed, nothing special here
continue;
}
-
- if(value.startDate < from){
+
+ if (value.startDate < from) {
continue;
}
// Get day: sunday is 0, monday is 1. We move everything so that monday == 0
@@ -80,8 +87,190 @@ export default class OpeningHoursVisualization extends UIElement {
return new Date(d.setDate(diff));
}
+ InnerRender(): string | UIElement {
- private allChangeMoments(ranges: {
+
+ const today = new Date();
+ today.setHours(0, 0, 0, 0);
+
+ const lastMonday = OpeningHoursVisualization.getMonday(today);
+ const nextSunday = new Date(lastMonday);
+ nextSunday.setDate(nextSunday.getDate() + 7);
+
+ const tags = this._source.data;
+ if (tags._country === undefined) {
+ return "Loading country information...";
+ }
+ let oh = null;
+
+ try {
+ // noinspection JSPotentiallyInvalidConstructorUsage
+ oh = new opening_hours(tags[this._key], {
+ lat: tags._lat,
+ lon: tags._lon,
+ address: {
+ country_code: tags._country
+ }
+ }, {tag_key: this._key});
+ } catch (e) {
+ console.log(e);
+ return new Combine([Translations.t.general.opening_hours.error_loading,
+ State.state?.osmConnection?.userDetails?.data?.csCount >= Constants.userJourney.tagsVisibleAndWikiLinked ?
+ `${e}`
+ : ""
+ ]);
+ }
+
+ if (!oh.getState() && !oh.getUnknown()) {
+ // POI is currently closed
+ const nextChange: Date = oh.getNextChange();
+ if (
+ // Shop isn't gonna open anymore in this timerange
+ nextSunday < nextChange
+ // And we are already in the weekend to show next week
+ && (today.getDay() == 0 || today.getDay() == 6)
+ ) {
+ // We mover further along
+ lastMonday.setDate(lastMonday.getDate() + 7);
+ nextSunday.setDate(nextSunday.getDate() + 7);
+ }
+ }
+
+ // ranges[0] are all ranges for monday
+ const ranges = OpeningHoursVisualization.GetRanges(oh, lastMonday, nextSunday);
+ if (ranges.map(r => r.length).reduce((a, b) => a + b, 0) == 0) {
+ // Closed!
+ const opensAtDate = oh.getNextChange();
+ if (opensAtDate === undefined) {
+ const comm = oh.getComment() ?? oh.getUnknown();
+ if (!!comm) {
+ return new FixedUiElement(comm).SetClass("ohviz-closed");
+ }
+
+ if (oh.getState()) {
+ return Translations.t.general.opening_hours.open_24_7.SetClass("ohviz-closed")
+ }
+ return Translations.t.general.opening_hours.closed_permanently.SetClass("ohviz-closed")
+ }
+ const moment = `${opensAtDate.getDate()}/${opensAtDate.getMonth() + 1} ${OH.hhmm(opensAtDate.getHours(), opensAtDate.getMinutes())}`
+ return Translations.t.general.opening_hours.closed_until.Subs({date: moment}).SetClass("ohviz-closed")
+ }
+
+ const isWeekstable = oh.isWeekStable();
+
+ let [changeHours, changeHourText] = OpeningHoursVisualization.allChangeMoments(ranges);
+
+ // By default, we always show the range between 8 - 19h, in order to give a stable impression
+ // Ofc, a bigger range is used if needed
+ const earliestOpen = Math.min(8 * 60 * 60, ...changeHours);
+ let latestclose = Math.max(...changeHours);
+ // We always make sure there is 30m of leeway in order to give enough room for the closing entry
+ latestclose = Math.max(19 * 60 * 60, latestclose + 30 * 60)
+
+
+ const rows: UIElement[] = [];
+ const availableArea = latestclose - earliestOpen;
+ // @ts-ignore
+ const now = (100 * (((new Date() - today) / 1000) - earliestOpen)) / availableArea;
+
+
+ let header: UIElement[] = [];
+
+ if (now >= 0 && now <= 100) {
+ header.push(new FixedUiElement("").SetStyle(`left:${now}%;`).SetClass("ohviz-now"))
+ }
+ for (const changeMoment of changeHours) {
+ const offset = 100 * (changeMoment - earliestOpen) / availableArea;
+ if (offset < 0 || offset > 100) {
+ continue;
+ }
+ const el = new FixedUiElement("").SetStyle(`left:${offset}%;`).SetClass("ohviz-line");
+ header.push(el);
+ }
+
+ for (let i = 0; i < changeHours.length; i++) {
+ let changeMoment = changeHours[i];
+ const offset = 100 * (changeMoment - earliestOpen) / availableArea;
+ if (offset < 0 || offset > 100) {
+ continue;
+ }
+ const el = new FixedUiElement(
+ `${changeHourText[i]}
`
+ )
+ .SetStyle(`left:${offset}%`)
+ .SetClass("ohviz-time-indication");
+ header.push(el);
+ }
+
+ rows.push(new Combine([`  | `,
+ ``,
+ new Combine(header), ` | `]));
+
+ for (let i = 0; i < 7; i++) {
+ const dayRanges = ranges[i];
+ const isToday = (new Date().getDay() + 6) % 7 === i;
+ let weekday = OpeningHoursVisualization.weekdays[i];
+
+ let dateToShow = ""
+ if (!isWeekstable) {
+ const day = new Date(lastMonday)
+ day.setDate(day.getDate() + i);
+ dateToShow = "" + day.getDate() + "/" + (day.getMonth() + 1);
+ }
+
+ let innerContent: (string | UIElement)[] = [];
+
+ // Add the lines
+ for (const changeMoment of changeHours) {
+ const offset = 100 * (changeMoment - earliestOpen) / availableArea;
+ innerContent.push(new FixedUiElement("").SetStyle(`left:${offset}%;`).SetClass("ohviz-line"))
+ }
+
+ // Add the actual ranges
+ for (const range of dayRanges) {
+ if (!range.isOpen && !range.isSpecial) {
+ innerContent.push(
+ new FixedUiElement(range.comment ?? dateToShow).SetClass("ohviz-day-off"))
+ continue;
+ }
+
+ const startOfDay: Date = new Date(range.startDate);
+ startOfDay.setHours(0, 0, 0, 0);
+ // @ts-ignore
+ const startpoint = (range.startDate - startOfDay) / 1000 - earliestOpen;
+ // @ts-ignore
+ const width = (100 * (range.endDate - range.startDate) / 1000) / (latestclose - earliestOpen);
+ const startPercentage = (100 * startpoint / availableArea);
+ innerContent.push(
+ new FixedUiElement(range.comment ?? dateToShow).SetStyle(`left:${startPercentage}%; width:${width}%`).SetClass("ohviz-range"))
+ }
+
+ // Add line for 'now'
+ if (now >= 0 && now <= 100) {
+ innerContent.push(new FixedUiElement("").SetStyle(`left:${now}%;`).SetClass("ohviz-now"))
+ }
+
+ let clss = ""
+ if (isToday) {
+ clss = "ohviz-today"
+ }
+
+ rows.push(new Combine(
+ [`${weekday} | `,
+ ``,
+ ...innerContent,
+ ` | `]))
+ }
+
+
+ return new Combine([
+ "",
+ ...rows.map(el => "" + el.Render() + "
"),
+ "
"
+ ]).SetClass("ohviz-container");
+ }
+
+ private static allChangeMoments(ranges: {
isOpen: boolean,
isSpecial: boolean,
comment: string,
@@ -131,194 +320,4 @@ export default class OpeningHoursVisualization extends UIElement {
return [changeHours, changeHourText]
}
- private static readonly weekdays = [
- Translations.t.general.weekdays.abbreviations.monday,
- Translations.t.general.weekdays.abbreviations.tuesday,
- Translations.t.general.weekdays.abbreviations.wednesday,
- Translations.t.general.weekdays.abbreviations.thursday,
- Translations.t.general.weekdays.abbreviations.friday,
- Translations.t.general.weekdays.abbreviations.saturday,
- Translations.t.general.weekdays.abbreviations.sunday,
- ]
-
- InnerRender(): string {
-
-
- const today = new Date();
- today.setHours(0, 0, 0, 0);
-
- const lastMonday = OpeningHoursVisualization.getMonday(today);
- const nextSunday = new Date(lastMonday);
- nextSunday.setDate(nextSunday.getDate() + 7);
-
- const tags = this._source.data;
- if (tags._country === undefined) {
- return "Loading country information...";
- }
- let oh = null;
-
- try {
- oh = new opening_hours(tags[this._key], {
- lat: tags._lat,
- lon: tags._lon,
- address: {
- country_code: tags._country
- }
- }, {tag_key: this._key});
- } catch (e) {
- console.log(e);
- const msg = new Combine([Translations.t.general.opening_hours.error_loading,
- State.state?.osmConnection?.userDetails?.data?.csCount >= Constants.userJourney.tagsVisibleAndWikiLinked ?
- `${e}`
- : ""
- ]);
- return msg.Render();
- }
-
- if (!oh.getState() && !oh.getUnknown()) {
- // POI is currently closed
- const nextChange: Date = oh.getNextChange();
- if (
- // Shop isn't gonna open anymore in this timerange
- nextSunday < nextChange
- // And we are already in the weekend to show next week
- && (today.getDay() == 0 || today.getDay() == 6)
- ) {
- // We mover further along
- lastMonday.setDate(lastMonday.getDate() + 7);
- nextSunday.setDate(nextSunday.getDate() + 7);
- }
- }
-
- // ranges[0] are all ranges for monday
- const ranges = OpeningHoursVisualization.GetRanges(oh, lastMonday, nextSunday);
- if (ranges.map(r => r.length).reduce((a, b) => a + b, 0) == 0) {
- // Closed!
- const opensAtDate = oh.getNextChange();
- if(opensAtDate === undefined){
- const comm = oh.getComment() ?? oh.getUnknown();
- if(!!comm){
- return new FixedUiElement(comm).SetClass("ohviz-closed").Render();
- }
-
- if(oh.getState()){
- return Translations.t.general.opening_hours.open_24_7.SetClass("ohviz-closed").Render()
- }
- return Translations.t.general.opening_hours.closed_permanently.SetClass("ohviz-closed").Render()
- }
- const moment = `${opensAtDate.getDate()}/${opensAtDate.getMonth() + 1} ${OH.hhmm(opensAtDate.getHours(), opensAtDate.getMinutes())}`
- return Translations.t.general.opening_hours.closed_until.Subs({date: moment}).SetClass("ohviz-closed").Render()
- }
-
- const isWeekstable = oh.isWeekStable();
-
- let [changeHours, changeHourText] = this.allChangeMoments(ranges);
-
- // By default, we always show the range between 8 - 19h, in order to give a stable impression
- // Ofc, a bigger range is used if needed
- const earliestOpen = Math.min(8 * 60 * 60, ...changeHours);
- let latestclose = Math.max(...changeHours);
- // We always make sure there is 30m of leeway in order to give enough room for the closing entry
- latestclose = Math.max(19 * 60 * 60, latestclose + 30 * 60)
-
-
- const rows: UIElement[] = [];
- const availableArea = latestclose - earliestOpen;
- // @ts-ignore
- const now = (100 * (((new Date() - today) / 1000) - earliestOpen)) / availableArea;
-
-
- let header = "";
-
- if (now >= 0 && now <= 100) {
- header += new FixedUiElement("").SetStyle(`left:${now}%;`).SetClass("ohviz-now").Render()
- }
- for (const changeMoment of changeHours) {
- const offset = 100 * (changeMoment - earliestOpen) / availableArea;
- if (offset < 0 || offset > 100) {
- continue;
- }
- const el = new FixedUiElement("").SetStyle(`left:${offset}%;`).SetClass("ohviz-line").Render();
- header += el;
- }
-
- for (let i = 0; i < changeHours.length; i++) {
- let changeMoment = changeHours[i];
- const offset = 100 * (changeMoment - earliestOpen) / availableArea;
- if (offset < 0 || offset > 100) {
- continue;
- }
- const el = new FixedUiElement(
- `${changeHourText[i]}
`
- )
- .SetStyle(`left:${offset}%`)
- .SetClass("ohviz-time-indication").Render();
- header += el;
- }
-
- rows.push(new Combine([`  | `,
- `${header} | `]));
-
- for (let i = 0; i < 7; i++) {
- const dayRanges = ranges[i];
- const isToday = (new Date().getDay() + 6) % 7 === i;
- let weekday = OpeningHoursVisualization.weekdays[i].Render();
-
- let dateToShow = ""
- if (!isWeekstable) {
- const day = new Date(lastMonday)
- day.setDate(day.getDate() + i);
- dateToShow = "" + day.getDate() + "/" + (day.getMonth() + 1);
- }
-
- let innerContent: string[] = [];
-
- // Add the lines
- for (const changeMoment of changeHours) {
- const offset = 100 * (changeMoment - earliestOpen) / availableArea;
- innerContent.push(new FixedUiElement("").SetStyle(`left:${offset}%;`).SetClass("ohviz-line").Render())
- }
-
- // Add the actual ranges
- for (const range of dayRanges) {
- if (!range.isOpen && !range.isSpecial) {
- innerContent.push(
- new FixedUiElement(range.comment ?? dateToShow).SetClass("ohviz-day-off").Render())
- continue;
- }
-
- const startOfDay: Date = new Date(range.startDate);
- startOfDay.setHours(0, 0, 0, 0);
- // @ts-ignore
- const startpoint = (range.startDate - startOfDay) / 1000 - earliestOpen;
- // @ts-ignore
- const width = (100 * (range.endDate - range.startDate) / 1000) / (latestclose - earliestOpen);
- const startPercentage = (100 * startpoint / availableArea);
- innerContent.push(
- new FixedUiElement(range.comment ?? dateToShow).SetStyle(`left:${startPercentage}%; width:${width}%`).SetClass("ohviz-range").Render())
- }
-
- // Add line for 'now'
- if (now >= 0 && now <= 100) {
- innerContent.push(new FixedUiElement("").SetStyle(`left:${now}%;`).SetClass("ohviz-now").Render())
- }
-
- let clss = ""
- if (isToday) {
- clss = "ohviz-today"
- }
-
- rows.push(new Combine(
- [`${weekday} | `,
- `${innerContent.join("")} | `]))
- }
-
-
- return new Combine([
- "",
- rows.map(el => "" + el.Render() + "
").join(""),
- "
"
- ]).SetClass("ohviz-container").Render();
- }
-
}
\ No newline at end of file
diff --git a/UI/OpeningHours/OpeningHoursInput.ts b/UI/OpeningHours/OpeningHoursInput.ts
index 8e9a7c9b8..1ac60467f 100644
--- a/UI/OpeningHours/OpeningHoursInput.ts
+++ b/UI/OpeningHours/OpeningHoursInput.ts
@@ -5,7 +5,6 @@
*/
import OpeningHoursPicker from "./OpeningHoursPicker";
import {UIEventSource} from "../../Logic/UIEventSource";
-import {UIElement} from "../UIElement";
import {VariableUiElement} from "../Base/VariableUIElement";
import Combine from "../Base/Combine";
import {FixedUiElement} from "../Base/FixedUiElement";
@@ -14,21 +13,20 @@ import {InputElement} from "../Input/InputElement";
import PublicHolidayInput from "./PublicHolidayInput";
import Translations from "../i18n/Translations";
import {Utils} from "../../Utils";
+import BaseUIElement from "../BaseUIElement";
export default class OpeningHoursInput extends InputElement {
+ public readonly IsSelected: UIEventSource = new UIEventSource(false);
private readonly _value: UIEventSource;
-
- private readonly _ohPicker: UIElement;
- private readonly _leftoverWarning: UIElement;
- private readonly _phSelector: UIElement;
+ private readonly _element: BaseUIElement;
constructor(value: UIEventSource = new UIEventSource("")) {
super();
-
+
const leftoverRules = value.map(str => {
if (str === undefined) {
return []
@@ -61,11 +59,11 @@ export default class OpeningHoursInput extends InputElement {
}
return "";
})
- this._phSelector = new PublicHolidayInput(ph);
+ const phSelector = new PublicHolidayInput(ph);
function update() {
const regular = OH.ToString(rulesFromOhPicker.data);
- const rules : string[] = [
+ const rules: string[] = [
regular,
...leftoverRules.data,
ph.data
@@ -76,39 +74,35 @@ export default class OpeningHoursInput extends InputElement {
rulesFromOhPicker.addCallback(update);
ph.addCallback(update);
- this._leftoverWarning = new VariableUiElement(leftoverRules.map((leftovers: string[]) => {
+ const leftoverWarning = new VariableUiElement(leftoverRules.map((leftovers: string[]) => {
if (leftovers.length == 0) {
return "";
}
return new Combine([
Translations.t.general.opening_hours.not_all_rules_parsed,
- new FixedUiElement(leftovers.map(r => `${r}
`).join("")).SetClass("subtle")
- ]).Render();
+ new FixedUiElement(leftovers.map(r => `${r}
`).join("")).SetClass("subtle")
+ ]);
}))
- this._ohPicker = new OpeningHoursPicker(rulesFromOhPicker);
-
+ const ohPicker = new OpeningHoursPicker(rulesFromOhPicker);
+ this._element = new Combine([
+ leftoverWarning,
+ ohPicker,
+ phSelector
+ ])
}
+ protected InnerConstructElement(): HTMLElement {
+ return this._element.ConstructElement()
+ }
GetValue(): UIEventSource {
return this._value;
}
- InnerRender(): string {
- return new Combine([
- this._leftoverWarning,
- this._ohPicker,
- this._phSelector
- ]).Render();
- }
-
-
- public readonly IsSelected: UIEventSource = new UIEventSource(false);
-
IsValid(t: string): boolean {
return true;
}
diff --git a/UI/OpeningHours/OpeningHoursPicker.ts b/UI/OpeningHours/OpeningHoursPicker.ts
index ad8c0cb5b..b620133ad 100644
--- a/UI/OpeningHours/OpeningHoursPicker.ts
+++ b/UI/OpeningHours/OpeningHoursPicker.ts
@@ -5,6 +5,7 @@ import Combine from "../Base/Combine";
import OpeningHoursPickerTable from "./OpeningHoursPickerTable";
import {OH, OpeningHour} from "./OpeningHours";
import {InputElement} from "../Input/InputElement";
+import BaseUIElement from "../BaseUIElement";
export default class OpeningHoursPicker extends InputElement {
private readonly _ohs: UIEventSource;
@@ -12,7 +13,7 @@ export default class OpeningHoursPicker extends InputElement {
private readonly _backgroundTable: OpeningHoursPickerTable;
- private readonly _weekdays: UIEventSource = new UIEventSource([]);
+ private readonly _weekdays: UIEventSource = new UIEventSource([]);
constructor(ohs: UIEventSource = new UIEventSource([])) {
super();
@@ -49,8 +50,12 @@ export default class OpeningHoursPicker extends InputElement {
}
- InnerRender(): string {
- return this._backgroundTable.Render();
+ InnerRender(): BaseUIElement {
+ return this._backgroundTable;
+ }
+
+ protected InnerConstructElement(): HTMLElement {
+ return this._backgroundTable.ConstructElement();
}
GetValue(): UIEventSource {
diff --git a/UI/OpeningHours/OpeningHoursPickerTable.ts b/UI/OpeningHours/OpeningHoursPickerTable.ts
index 5192e7bfc..794f2d28b 100644
--- a/UI/OpeningHours/OpeningHoursPickerTable.ts
+++ b/UI/OpeningHours/OpeningHoursPickerTable.ts
@@ -8,12 +8,13 @@ import {Utils} from "../../Utils";
import {OpeningHour} from "./OpeningHours";
import {InputElement} from "../Input/InputElement";
import Translations from "../i18n/Translations";
+import BaseUIElement from "../BaseUIElement";
export default class OpeningHoursPickerTable extends InputElement {
public readonly IsSelected: UIEventSource;
- private readonly weekdays: UIEventSource;
+ private readonly weekdays: UIEventSource;
- public static readonly days: UIElement[] =
+ public static readonly days: BaseUIElement[] =
[
Translations.t.general.weekdays.abbreviations.monday,
Translations.t.general.weekdays.abbreviations.tuesday,
@@ -28,8 +29,8 @@ export default class OpeningHoursPickerTable extends InputElement
private readonly source: UIEventSource;
- constructor(weekdays: UIEventSource, source?: UIEventSource) {
- super(weekdays);
+ constructor(weekdays: UIEventSource, source?: UIEventSource) {
+ super();
this.weekdays = weekdays;
this.source = source ?? new UIEventSource([]);
this.IsSelected = new UIEventSource(false);
diff --git a/UI/OpeningHours/OpeningHoursRange.ts b/UI/OpeningHours/OpeningHoursRange.ts
index 5f67f8e4a..68f73ea41 100644
--- a/UI/OpeningHours/OpeningHoursRange.ts
+++ b/UI/OpeningHours/OpeningHoursRange.ts
@@ -48,10 +48,10 @@ export default class OpeningHoursRange extends UIElement {
}
- InnerRender(): string {
+ InnerRender(): UIElement {
const oh = this._oh.data;
if (oh === undefined) {
- return "";
+ return undefined;
}
const height = this.getHeight();
@@ -62,7 +62,6 @@ export default class OpeningHoursRange extends UIElement {
return new Combine(content)
.SetClass("oh-timerange-inner")
- .Render();
}
private getHeight(): number {
diff --git a/UI/OpeningHours/PublicHolidayInput.ts b/UI/OpeningHours/PublicHolidayInput.ts
index bcdc3cef5..d61afdb31 100644
--- a/UI/OpeningHours/PublicHolidayInput.ts
+++ b/UI/OpeningHours/PublicHolidayInput.ts
@@ -143,7 +143,7 @@ export default class PublicHolidayInput extends InputElement {
}
}
- InnerRender(): string {
+ InnerRender(): UIElement {
const mode = this._mode.data;
if (mode === " ") {
return new Combine([this._dropdown,
@@ -154,9 +154,9 @@ export default class PublicHolidayInput extends InputElement {
" ",
Translations.t.general.opening_hours.openTill,
" ",
- this._endHour]).Render();
+ this._endHour]);
}
- return this._dropdown.Render();
+ return this._dropdown;
}
GetValue(): UIEventSource {
diff --git a/UI/Popup/FeatureInfoBox.ts b/UI/Popup/FeatureInfoBox.ts
index c3f249c0b..14025b905 100644
--- a/UI/Popup/FeatureInfoBox.ts
+++ b/UI/Popup/FeatureInfoBox.ts
@@ -39,7 +39,6 @@ export default class FeatureInfoBox extends ScrollableFullScreen {
const titleIcons = new Combine(
layerConfig.titleIcons.map(icon => new TagRenderingAnswer(tags, icon,
"block w-8 h-8 align-baseline box-content sm:p-0.5", "width: 2rem !important;")
- .HideOnEmpty(true)
))
.SetClass("flex flex-row flex-wrap pt-0.5 sm:pt-1 items-center mr-2")
diff --git a/UI/Popup/QuestionBox.ts b/UI/Popup/QuestionBox.ts
index 97d2d0fb9..76e8f8ed3 100644
--- a/UI/Popup/QuestionBox.ts
+++ b/UI/Popup/QuestionBox.ts
@@ -48,7 +48,7 @@ export default class QuestionBox extends UIElement {
this.SetClass("block mb-8")
}
- InnerRender(): string {
+ InnerRender() {
const allQuestions : UIElement[] = []
for (let i = 0; i < this._tagRenderingQuestions.length; i++) {
let tagRendering = this._tagRenderings[i];
@@ -72,7 +72,7 @@ export default class QuestionBox extends UIElement {
}
- return new Combine(allQuestions).Render();
+ return new Combine(allQuestions);
}
}
\ No newline at end of file
diff --git a/UI/Popup/SaveButton.ts b/UI/Popup/SaveButton.ts
index 2c277c7fc..d01382c70 100644
--- a/UI/Popup/SaveButton.ts
+++ b/UI/Popup/SaveButton.ts
@@ -21,15 +21,15 @@ export class SaveButton extends UIElement {
.onClick(() => osmConnection?.AttemptLogin())
}
- InnerRender(): string {
+ InnerRender() {
if(this._userDetails != undefined && !this._userDetails.data.loggedIn){
- return this._friendlyLogin.Render();
+ return this._friendlyLogin;
}
let inactive_class = ''
if (this._value.data === false || (this._value.data ?? "") === "") {
inactive_class = "btn-disabled";
}
- return Translations.t.general.save.Clone().SetClass(`btn ${inactive_class}`).Render();
+ return Translations.t.general.save.Clone().SetClass(`btn ${inactive_class}`);
}
}
\ No newline at end of file
diff --git a/UI/Popup/TagRenderingAnswer.ts b/UI/Popup/TagRenderingAnswer.ts
index 43966d4a4..1138da448 100644
--- a/UI/Popup/TagRenderingAnswer.ts
+++ b/UI/Popup/TagRenderingAnswer.ts
@@ -30,7 +30,7 @@ export default class TagRenderingAnswer extends UIElement {
this.SetStyle("word-wrap: anywhere;");
}
- InnerRender(): string {
+ InnerRender(): string | UIElement{
if (this._configuration.condition !== undefined) {
if (!this._configuration.condition.matchesProperties(this._tags.data)) {
return "";
@@ -80,14 +80,14 @@ export default class TagRenderingAnswer extends UIElement {
])
}
- return this._content.SetClass(this._contentClass).SetStyle(this._contentStyle).Render();
+ return this._content.SetClass(this._contentClass).SetStyle(this._contentStyle);
}
}
const tr = this._configuration.GetRenderValue(tags);
if (tr !== undefined) {
this._content = SubstitutedTranslation.construct(tr, this._tags);
- return this._content.SetClass(this._contentClass).SetStyle(this._contentStyle).Render();
+ return this._content.SetClass(this._contentClass).SetStyle(this._contentStyle);
}
return "";
diff --git a/UI/Popup/TagRenderingQuestion.ts b/UI/Popup/TagRenderingQuestion.ts
index d4c1ee104..44b1cb3c1 100644
--- a/UI/Popup/TagRenderingQuestion.ts
+++ b/UI/Popup/TagRenderingQuestion.ts
@@ -94,7 +94,7 @@ export default class TagRenderingQuestion extends UIElement {
).SetClass("block")
}
- InnerRender(): string {
+ InnerRender() {
return new Combine([
this._question,
this._inputElement,
@@ -103,7 +103,6 @@ export default class TagRenderingQuestion extends UIElement {
this._appliedTags]
)
.SetClass("question")
- .Render()
}
private GenerateInputElement(): InputElement {
diff --git a/UI/Reviews/ReviewElement.ts b/UI/Reviews/ReviewElement.ts
index 9f123a22b..cdf6659e9 100644
--- a/UI/Reviews/ReviewElement.ts
+++ b/UI/Reviews/ReviewElement.ts
@@ -26,7 +26,7 @@ export default class ReviewElement extends UIElement {
- InnerRender(): string {
+ InnerRender(): UIElement {
const elements = [];
const revs = this._reviews.data;
@@ -56,7 +56,7 @@ export default class ReviewElement extends UIElement {
.SetClass("review-attribution"))
- return new Combine(elements).SetClass("block").Render();
+ return new Combine(elements).SetClass("block");
}
}
\ No newline at end of file
diff --git a/UI/Reviews/ReviewForm.ts b/UI/Reviews/ReviewForm.ts
index 29cc9680e..59d86c792 100644
--- a/UI/Reviews/ReviewForm.ts
+++ b/UI/Reviews/ReviewForm.ts
@@ -86,10 +86,10 @@ export default class ReviewForm extends InputElement {
return this._value;
}
- InnerRender(): string {
+ InnerRender(): UIElement {
if(!this.userDetails.data.loggedIn){
- return Translations.t.reviews.plz_login.Render();
+ return Translations.t.reviews.plz_login;
}
return new Combine([
@@ -103,7 +103,6 @@ export default class ReviewForm extends InputElement {
Translations.t.reviews.tos.SetClass("subtle")
])
.SetClass("review-form")
- .Render();
}
IsSelected: UIEventSource = new UIEventSource(false);
diff --git a/UI/Reviews/SingleReview.ts b/UI/Reviews/SingleReview.ts
index 9a9edd819..b6f913add 100644
--- a/UI/Reviews/SingleReview.ts
+++ b/UI/Reviews/SingleReview.ts
@@ -26,7 +26,7 @@ export default class SingleReview extends UIElement{
scoreTen % 2 == 1 ? "
" : ""
]).SetClass("flex w-max")
}
- InnerRender(): string {
+ InnerRender(): UIElement {
const d = this._review.date;
let review = this._review;
const el= new Combine(
@@ -51,7 +51,7 @@ export default class SingleReview extends UIElement{
if(review.made_by_user.data){
el.SetClass("border-attention-catch")
}
- return el.Render();
+ return el;
}
}
\ No newline at end of file
diff --git a/UI/SubstitutedTranslation.ts b/UI/SubstitutedTranslation.ts
index 7b39e9ace..980503db0 100644
--- a/UI/SubstitutedTranslation.ts
+++ b/UI/SubstitutedTranslation.ts
@@ -6,11 +6,8 @@ import Combine from "./Base/Combine";
import State from "../State";
import {FixedUiElement} from "./Base/FixedUiElement";
import SpecialVisualizations from "./SpecialVisualizations";
-import {Utils} from "../Utils";
export class SubstitutedTranslation extends UIElement {
- private static cachedTranslations:
- Map, SubstitutedTranslation>>> = new Map, SubstitutedTranslation>>>();
private readonly tags: UIEventSource;
private readonly translation: Translation;
private content: UIElement[];
@@ -37,39 +34,24 @@ export class SubstitutedTranslation extends UIElement {
public static construct(
translation: Translation,
tags: UIEventSource