First draft of loading 'notes'

This commit is contained in:
Pieter Vander Vennet 2022-01-07 04:14:53 +01:00
parent bafaba7011
commit ebb510da04
20 changed files with 580 additions and 199 deletions

View file

@ -43,7 +43,7 @@ export default class UserBadge extends Toggle {
if (home === undefined) {
return;
}
state.leafletMap.data.setView([home.lat, home.lon], 16);
state.leafletMap.data?.setView([home.lat, home.lon], 16);
});
const linkStyle = "flex items-baseline"

View file

@ -298,12 +298,16 @@ export class OH {
}
}
static Parse(rules: string) {
public static simplify(str: string): string{
return OH.ToString(OH.MergeTimes(OH.Parse(str)))
}
public static Parse(rules: string) : OpeningHour[] {
if (rules === undefined || rules === "") {
return []
}
const ohs = []
const ohs : OpeningHour[] = []
const split = rules.split(";");

View file

@ -44,7 +44,7 @@ export default class FeatureInfoBox extends ScrollableFullScreen {
.SetClass("break-words font-bold sm:p-0.5 md:p-1 sm:p-1.5 md:p-2");
const titleIcons = new Combine(
layerConfig.titleIcons.map(icon => new TagRenderingAnswer(tags, icon,
"block w-8 h-8 align-baseline box-content sm:p-0.5", "width: 2rem;")
"block w-8 h-8 max-h-8 align-baseline box-content sm:p-0.5", "width: 2rem;")
))
.SetClass("flex flex-row flex-wrap pt-0.5 sm:pt-1 items-center mr-2")
@ -193,9 +193,9 @@ export default class FeatureInfoBox extends ScrollableFullScreen {
const config_download: TagRenderingConfig = new TagRenderingConfig({render: "{export_as_geojson()}"}, "");
const config_id: TagRenderingConfig = new TagRenderingConfig({render: "{open_in_iD()}"}, "");
return new Combine([new TagRenderingAnswer(tags, config_all_tags, "all_tags"),
new TagRenderingAnswer(tags, config_download, ""),
new TagRenderingAnswer(tags, config_id, "")])
return new Combine([new TagRenderingAnswer(tags, config_all_tags, State.state),
new TagRenderingAnswer(tags, config_download, State.state),
new TagRenderingAnswer(tags, config_id, State.state)])
}
})
)

View file

@ -38,6 +38,7 @@ import TagApplyButton from "./Popup/TagApplyButton";
import AutoApplyButton from "./Popup/AutoApplyButton";
import * as left_right_style_json from "../assets/layers/left_right_style/left_right_style.json";
import {OpenIdEditor} from "./BigComponents/CopyrightPanel";
import Toggle from "./Input/Toggle";
export interface SpecialVisualization {
funcName: string,
@ -607,6 +608,39 @@ export default class SpecialVisualizations {
Hash.hash.setData(undefined)
})
}
},
{
funcName: "close_note",
docs: "Button to close a note",
args:[
{
name:"text",
doc: "Text to show on this button",
},
{
name:"Id-key",
doc: "The property name where the ID of the note to close can be found",
defaultValue: "id"
}
],
constr: (state, tags, args, guiState) => {
const t = Translations.t.notes;
const closeButton = new SubtleButton( Svg.checkmark_svg(), t.closeNote)
const isClosed = new UIEventSource(false);
closeButton.onClick(() => {
const id = tags.data[args[1] ?? "id"]
if(state.featureSwitchIsTesting.data){
console.log("Not actually closing note...")
return;
}
state.osmConnection.closeNote(id).then(_ => isClosed.setData(true))
})
return new Toggle(
t.isClosed.SetClass("thanks"),
closeButton,
isClosed
)
}
}
]