forked from MapComplete/MapComplete
Add buttons to quickly mark a note as imported or as not found
This commit is contained in:
parent
0f66d7f8cc
commit
c521533ec2
1 changed files with 68 additions and 32 deletions
|
@ -20,6 +20,8 @@ import Toggleable, {Accordeon} from "../Base/Toggleable";
|
||||||
import TableOfContents from "../Base/TableOfContents";
|
import TableOfContents from "../Base/TableOfContents";
|
||||||
import {LoginToggle} from "../Popup/LoginButton";
|
import {LoginToggle} from "../Popup/LoginButton";
|
||||||
import {QueryParameters} from "../../Logic/Web/QueryParameters";
|
import {QueryParameters} from "../../Logic/Web/QueryParameters";
|
||||||
|
import Lazy from "../Base/Lazy";
|
||||||
|
import {Button} from "../Base/Button";
|
||||||
|
|
||||||
interface NoteProperties {
|
interface NoteProperties {
|
||||||
"id": number,
|
"id": number,
|
||||||
|
@ -182,12 +184,34 @@ class MassAction extends Combine {
|
||||||
|
|
||||||
class NoteTable extends Combine {
|
class NoteTable extends Combine {
|
||||||
|
|
||||||
|
private static individualActions: [() => BaseUIElement, string][] = [
|
||||||
|
[Svg.not_found_svg, "This feature does not exist"],
|
||||||
|
[Svg.addSmall_svg, "imported"],
|
||||||
|
[Svg.duplicate_svg, "Already mapped"]
|
||||||
|
]
|
||||||
|
|
||||||
constructor(noteStates: NoteState[], state?: UserRelatedState) {
|
constructor(noteStates: NoteState[], state?: UserRelatedState) {
|
||||||
const typicalComment = noteStates[0].props.comments[0].html
|
const typicalComment = noteStates[0].props.comments[0].html
|
||||||
|
|
||||||
const table = new Table(
|
const table = new Table(
|
||||||
["id", "status", "last comment", "last modified by"],
|
["id", "status", "last comment", "last modified by", "actions"],
|
||||||
noteStates.map(ns => {
|
noteStates.map(ns => NoteTable.noteField(ns, state)),
|
||||||
|
{sortable: true}
|
||||||
|
).SetClass("zebra-table link-underline");
|
||||||
|
|
||||||
|
|
||||||
|
super([
|
||||||
|
new Title("Mass apply an action on " + noteStates.length + " notes below"),
|
||||||
|
state !== undefined ? new MassAction(state, noteStates.map(ns => ns.props)).SetClass("block") : undefined,
|
||||||
|
table,
|
||||||
|
new Title("Example note", 4),
|
||||||
|
new FixedUiElement(typicalComment).SetClass("literal-code link-underline"),
|
||||||
|
|
||||||
|
])
|
||||||
|
this.SetClass("flex flex-col")
|
||||||
|
}
|
||||||
|
|
||||||
|
private static noteField(ns: NoteState, state: UserRelatedState) {
|
||||||
const link = new Link(
|
const link = new Link(
|
||||||
"" + ns.props.id,
|
"" + ns.props.id,
|
||||||
"https://openstreetmap.org/note/" + ns.props.id, true
|
"https://openstreetmap.org/note/" + ns.props.id, true
|
||||||
|
@ -202,23 +226,35 @@ class NoteTable extends Combine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const statusIcon = BatchView.icons[ns.status]().SetClass("h-4 w-4 shrink-0")
|
const statusIcon = BatchView.icons[ns.status]().SetClass("h-4 w-4 shrink-0")
|
||||||
return [link, new Combine([statusIcon, ns.status]).SetClass("flex"), last_comment,
|
const togglestate = new UIEventSource(false);
|
||||||
new Link(last_comment_props.user, "https://www.openstreetmap.org/user/" + last_comment_props.user, true)
|
const changed = new UIEventSource<string>(undefined);
|
||||||
]
|
|
||||||
|
const lazyButtons = new Lazy(( ) => new Combine(
|
||||||
|
this.individualActions.map(([img, text]) =>
|
||||||
|
img().onClick(async () => {
|
||||||
|
if (ns.props.status === "closed") {
|
||||||
|
await state.osmConnection.reopenNote(ns.props.id)
|
||||||
|
}
|
||||||
|
await state.osmConnection.closeNote(ns.props.id, text)
|
||||||
|
changed.setData(text)
|
||||||
|
}).SetClass("h-8 w-8"))
|
||||||
|
).SetClass("flex"));
|
||||||
|
|
||||||
|
const appliedButtons = new VariableUiElement(changed.map(currentState => currentState === undefined ? lazyButtons : currentState));
|
||||||
|
|
||||||
|
const buttons = Toggle.If(state?.osmConnection?.isLoggedIn,
|
||||||
|
() => new ClickableToggle(
|
||||||
|
appliedButtons,
|
||||||
|
new Button("edit...", () => {
|
||||||
|
console.log("Enabling...")
|
||||||
|
togglestate.setData(true);
|
||||||
}),
|
}),
|
||||||
{sortable: true}
|
togglestate
|
||||||
).SetClass("zebra-table link-underline");
|
));
|
||||||
|
return [link, new Combine([statusIcon, ns.status]).SetClass("flex"), last_comment,
|
||||||
|
new Link(last_comment_props.user, "https://www.openstreetmap.org/user/" + last_comment_props.user, true),
|
||||||
super([
|
buttons
|
||||||
new Title("Mass apply an action on " + noteStates.length + " notes below"),
|
]
|
||||||
state !== undefined ? new MassAction(state, noteStates.map(ns => ns.props)).SetClass("block") : undefined,
|
|
||||||
table,
|
|
||||||
new Title("Example note", 4),
|
|
||||||
new FixedUiElement(typicalComment).SetClass("literal-code link-underline"),
|
|
||||||
|
|
||||||
])
|
|
||||||
this.SetClass("flex flex-col")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -396,7 +432,7 @@ class ImportInspector extends VariableUiElement {
|
||||||
intro: lines[0],
|
intro: lines[0],
|
||||||
theme,
|
theme,
|
||||||
dateStr,
|
dateStr,
|
||||||
status
|
status,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return perBatch;
|
return perBatch;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue