import {UIElement} from "./UIElement"; import {UIEventSource} from "./UIEventSource"; import {Changes} from "../Logic/Changes"; export class PendingChanges extends UIElement { private _pendingChangesCount: UIEventSource; private _countdown: UIEventSource; private _isSaving: UIEventSource; constructor(changes: Changes, countdown: UIEventSource) { super(changes.pendingChangesES); this.ListenTo(changes.isSaving); this.ListenTo(countdown); this._pendingChangesCount = changes.pendingChangesES; this._countdown = countdown; this._isSaving = changes.isSaving; this.onClick(() => { changes.uploadAll(); }) } protected InnerRender(): string { if (this._isSaving.data) { return "Saving"; } if (this._pendingChangesCount.data == 0) { return ""; } var restingSeconds = this._countdown.data / 1000; var dots = ""; while (restingSeconds > 0) { dots += "."; restingSeconds = restingSeconds - 1; } return "Saving "+this._pendingChangesCount.data; } }