forked from MapComplete/MapComplete
Fix review form save button
This commit is contained in:
parent
b9b504aebc
commit
aa1c9d0398
2 changed files with 27 additions and 16 deletions
|
@ -28,7 +28,7 @@ export class SaveButton extends Toggle {
|
|||
super(
|
||||
save,
|
||||
pleaseLogin,
|
||||
osmConnection?.userDetails?.map(userDetails => userDetails.loggedIn) ?? new UIEventSource<any>(false)
|
||||
osmConnection?.isLoggedIn ?? new UIEventSource<any>(false)
|
||||
)
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import Toggle from "../Input/Toggle";
|
|||
|
||||
export default class ReviewForm extends InputElement<Review> {
|
||||
|
||||
IsSelected: UIEventSource<boolean> = new UIEventSource<boolean>(false);
|
||||
private readonly _value: UIEventSource<Review>;
|
||||
private readonly _comment: BaseUIElement;
|
||||
private readonly _stars: BaseUIElement;
|
||||
|
@ -22,7 +23,6 @@ export default class ReviewForm extends InputElement<Review> {
|
|||
private readonly _postingAs: BaseUIElement;
|
||||
private readonly _osmConnection: OsmConnection;
|
||||
|
||||
|
||||
constructor(onSave: ((r: Review, doneSaving: (() => void)) => void), osmConnection: OsmConnection) {
|
||||
super();
|
||||
this._osmConnection = osmConnection;
|
||||
|
@ -51,14 +51,27 @@ export default class ReviewForm extends InputElement<Review> {
|
|||
new VariableUiElement(osmConnection.userDetails.map((ud: UserDetails) => ud.name))
|
||||
.SetClass("review-author")])
|
||||
.SetStyle("display:flex;flex-direction: column;align-items: flex-end;margin-left: auto;")
|
||||
|
||||
|
||||
const reviewIsSaved = new UIEventSource<boolean>(false)
|
||||
const reviewIsSaving = new UIEventSource<boolean>(false)
|
||||
this._saveButton =
|
||||
new SaveButton(this._value.map(r => self.IsValid(r)), undefined)
|
||||
.onClick(() => {
|
||||
self._saveButton = Translations.t.reviews.saving_review.Clone();
|
||||
new Toggle(Translations.t.reviews.saved.Clone().SetClass("thanks"),
|
||||
new Toggle(
|
||||
Translations.t.reviews.saving_review.Clone(),
|
||||
new SaveButton(
|
||||
this._value.map(r => self.IsValid(r)), osmConnection
|
||||
).onClick(() => {
|
||||
reviewIsSaving.setData(true),
|
||||
onSave(this._value.data, () => {
|
||||
self._saveButton = Translations.t.reviews.saved.Clone().SetClass("thanks");
|
||||
reviewIsSaved.setData(true)
|
||||
});
|
||||
}).SetClass("break-normal")
|
||||
}),
|
||||
reviewIsSaving
|
||||
),
|
||||
reviewIsSaved
|
||||
).SetClass("break-normal")
|
||||
|
||||
|
||||
this._isAffiliated = new CheckBoxes([Translations.t.reviews.i_am_affiliated.Clone()])
|
||||
|
||||
|
@ -113,8 +126,6 @@ export default class ReviewForm extends InputElement<Review> {
|
|||
.ConstructElement()
|
||||
}
|
||||
|
||||
IsSelected: UIEventSource<boolean> = new UIEventSource<boolean>(false);
|
||||
|
||||
IsValid(r: Review): boolean {
|
||||
if (r === undefined) {
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue