forked from MapComplete/MapComplete
Reformat all files with prettier
This commit is contained in:
parent
e22d189376
commit
b541d3eab4
382 changed files with 50893 additions and 35566 deletions
|
@ -1,37 +1,33 @@
|
|||
import {ImmutableStore, Store} from "../../Logic/UIEventSource";
|
||||
import Translations from "../i18n/Translations";
|
||||
import {OsmConnection} from "../../Logic/Osm/OsmConnection";
|
||||
import Toggle from "../Input/Toggle";
|
||||
import BaseUIElement from "../BaseUIElement";
|
||||
import { ImmutableStore, Store } from "../../Logic/UIEventSource"
|
||||
import Translations from "../i18n/Translations"
|
||||
import { OsmConnection } from "../../Logic/Osm/OsmConnection"
|
||||
import Toggle from "../Input/Toggle"
|
||||
import BaseUIElement from "../BaseUIElement"
|
||||
|
||||
export class SaveButton extends Toggle {
|
||||
|
||||
constructor(value: Store<any>, osmConnection: OsmConnection, textEnabled ?: BaseUIElement, textDisabled ?: BaseUIElement) {
|
||||
constructor(
|
||||
value: Store<any>,
|
||||
osmConnection: OsmConnection,
|
||||
textEnabled?: BaseUIElement,
|
||||
textDisabled?: BaseUIElement
|
||||
) {
|
||||
if (value === undefined) {
|
||||
throw "No event source for savebutton, something is wrong"
|
||||
}
|
||||
|
||||
const pleaseLogin = Translations.t.general.loginToStart.Clone()
|
||||
const pleaseLogin = Translations.t.general.loginToStart
|
||||
.Clone()
|
||||
.SetClass("login-button-friendly")
|
||||
.onClick(() => osmConnection?.AttemptLogin())
|
||||
|
||||
const isSaveable = value.map((v) => v !== false && (v ?? "") !== "")
|
||||
|
||||
const isSaveable = value.map(v => v !== false && (v ?? "") !== "")
|
||||
|
||||
const saveEnabled = (textEnabled ?? Translations.t.general.save.Clone()).SetClass(`btn`);
|
||||
const saveDisabled = (textDisabled ?? Translations.t.general.save.Clone()).SetClass(`btn btn-disabled`);
|
||||
|
||||
const save = new Toggle(
|
||||
saveEnabled,
|
||||
saveDisabled,
|
||||
isSaveable
|
||||
)
|
||||
super(
|
||||
save,
|
||||
pleaseLogin,
|
||||
osmConnection?.isLoggedIn ?? new ImmutableStore(false)
|
||||
const saveEnabled = (textEnabled ?? Translations.t.general.save.Clone()).SetClass(`btn`)
|
||||
const saveDisabled = (textDisabled ?? Translations.t.general.save.Clone()).SetClass(
|
||||
`btn btn-disabled`
|
||||
)
|
||||
|
||||
const save = new Toggle(saveEnabled, saveDisabled, isSaveable)
|
||||
super(save, pleaseLogin, osmConnection?.isLoggedIn ?? new ImmutableStore(false))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue