Remove empty spaces

Default Setting by my editor. Let me know I you want to keep them.
This commit is contained in:
Tobias 2021-01-21 05:52:36 +01:00
parent 8f8e5f7636
commit 61964a801f
6 changed files with 22 additions and 26 deletions

View file

@ -1,5 +1,5 @@
export class UIEventSource<T>{ export class UIEventSource<T>{
public data: T; public data: T;
private _callbacks = []; private _callbacks = [];
@ -7,7 +7,6 @@ export class UIEventSource<T>{
this.data = data; this.data = data;
} }
public addCallback(callback: ((latestData: T) => void)): UIEventSource<T> { public addCallback(callback: ((latestData: T) => void)): UIEventSource<T> {
if(callback === console.log){ if(callback === console.log){
// This ^^^ actually works! // This ^^^ actually works!
@ -49,19 +48,19 @@ export class UIEventSource<T>{
sink.setData(source.data?.data); sink.setData(source.data?.data);
}) })
} }
return sink; return sink;
} }
public map<J>(f: ((T) => J), public map<J>(f: ((T) => J),
extraSources: UIEventSource<any>[] = [], extraSources: UIEventSource<any>[] = [],
g: ((J) => T) = undefined ): UIEventSource<J> { g: ((J) => T) = undefined ): UIEventSource<J> {
const self = this; const self = this;
const newSource = new UIEventSource<J>( const newSource = new UIEventSource<J>(
f(this.data) f(this.data)
); );
const update = function () { const update = function () {
newSource.setData(f(self.data)); newSource.setData(f(self.data));
} }
@ -70,17 +69,17 @@ export class UIEventSource<T>{
for (const extraSource of extraSources) { for (const extraSource of extraSources) {
extraSource?.addCallback(update); extraSource?.addCallback(update);
} }
if(g !== undefined) { if(g !== undefined) {
newSource.addCallback((latest) => { newSource.addCallback((latest) => {
self.setData(g(latest)); self.setData(g(latest));
}) })
} }
return newSource; return newSource;
} }
public syncWith(otherSource: UIEventSource<T>, reverseOverride = false): UIEventSource<T> { public syncWith(otherSource: UIEventSource<T>, reverseOverride = false): UIEventSource<T> {
this.addCallback((latest) => otherSource.setData(latest)); this.addCallback((latest) => otherSource.setData(latest));
const self = this; const self = this;
@ -94,11 +93,11 @@ export class UIEventSource<T>{
} }
return this; return this;
} }
public stabilized(millisToStabilize) : UIEventSource<T>{ public stabilized(millisToStabilize) : UIEventSource<T>{
const newSource = new UIEventSource<T>(this.data); const newSource = new UIEventSource<T>(this.data);
let currentCallback = 0; let currentCallback = 0;
this.addCallback(latestData => { this.addCallback(latestData => {
currentCallback++; currentCallback++;
@ -109,10 +108,10 @@ export class UIEventSource<T>{
} }
}, millisToStabilize) }, millisToStabilize)
}); });
return newSource; return newSource;
} }
public static Chronic(millis: number, asLong: () => boolean = undefined): UIEventSource<Date> { public static Chronic(millis: number, asLong: () => boolean = undefined): UIEventSource<Date> {
const source = new UIEventSource<Date>(undefined); const source = new UIEventSource<Date>(undefined);
@ -125,7 +124,7 @@ export class UIEventSource<T>{
run(); run();
return source; return source;
} }
} }

View file

@ -28,5 +28,5 @@ export default class CheckBox extends UIElement{
return Translations.W(this._showDisabled).Render(); return Translations.W(this._showDisabled).Render();
} }
} }
} }

View file

@ -11,7 +11,7 @@ export class RadioButton<T> extends InputElement<T> {
private readonly value: UIEventSource<T>; private readonly value: UIEventSource<T>;
private readonly _elements: InputElement<T>[] private readonly _elements: InputElement<T>[]
private readonly _selectFirstAsDefault: boolean; private readonly _selectFirstAsDefault: boolean;
constructor(elements: InputElement<T>[], constructor(elements: InputElement<T>[],
selectFirstAsDefault = true) { selectFirstAsDefault = true) {
super(undefined); super(undefined);

View file

@ -40,7 +40,6 @@ export default class QuestionBox extends UIElement {
}) })
)); ));
this._skippedQuestionsButton = Translations.t.general.skippedQuestions.Clone() this._skippedQuestionsButton = Translations.t.general.skippedQuestions.Clone()
.onClick(() => { .onClick(() => {
self._skippedQuestions.setData([]); self._skippedQuestions.setData([]);
@ -64,19 +63,19 @@ export default class QuestionBox extends UIElement {
} }
} }
} }
if (tagRendering.GetRenderValue(this._tags.data) !== undefined) { if (tagRendering.GetRenderValue(this._tags.data) !== undefined) {
// This value is known and can be rendered // This value is known and can be rendered
return true; return true;
} }
return false; return false;
} }
InnerRender(): string { InnerRender(): string {
for (let i = 0; i < this._tagRenderingQuestions.length; i++) { for (let i = 0; i < this._tagRenderingQuestions.length; i++) {
let tagRendering = this._tagRenderings[i]; let tagRendering = this._tagRenderings[i];
if(this.IsKnown(tagRendering)){ if(this.IsKnown(tagRendering)){
continue; continue;
} }

View file

@ -78,7 +78,6 @@ export default class TagRenderingQuestion extends UIElement {
if (csCount < Constants.userJourney.tagsVisibleAt) { if (csCount < Constants.userJourney.tagsVisibleAt) {
return ""; return "";
} }
if (tags === undefined) { if (tags === undefined) {
return Translations.t.general.noTagsSelected.SetClass("subtle").Render(); return Translations.t.general.noTagsSelected.SetClass("subtle").Render();
} }
@ -89,8 +88,8 @@ export default class TagRenderingQuestion extends UIElement {
return tags.asHumanString(true, true); return tags.asHumanString(true, true);
} }
) )
)
).AddClass("block")
} }
private GenerateInputElement(): InputElement<TagsFilter> { private GenerateInputElement(): InputElement<TagsFilter> {
@ -268,7 +267,6 @@ export default class TagRenderingQuestion extends UIElement {
} }
InnerRender(): string { InnerRender(): string {
return new Combine([ return new Combine([
this._question, this._question,

View file

@ -87,11 +87,11 @@ export default class ReviewForm extends InputElement<Review> {
} }
InnerRender(): string { InnerRender(): string {
if(!this.userDetails.data.loggedIn){ if(!this.userDetails.data.loggedIn){
return Translations.t.reviews.plz_login.Render(); return Translations.t.reviews.plz_login.Render();
} }
return new Combine([ return new Combine([
new Combine([this._stars, this._postingAs]).SetClass("review-form-top"), new Combine([this._stars, this._postingAs]).SetClass("review-form-top"),
this._comment, this._comment,