diff --git a/src/MyWebLog.Domain/ViewModels.fs b/src/MyWebLog.Domain/ViewModels.fs index 1a9ff82..098ee5c 100644 --- a/src/MyWebLog.Domain/ViewModels.fs +++ b/src/MyWebLog.Domain/ViewModels.fs @@ -392,6 +392,9 @@ type EditChapterModel = { /// An OpenStreetMap query for this location LocationOsm: string + + /// Whether to add another chapter after adding this one + AddAnother: bool } with /// Create a display chapter from a chapter @@ -406,7 +409,8 @@ type EditChapterModel = { EndTime = it.EndTime LocationName = it.LocationName LocationGeo = it.LocationGeo - LocationOsm = it.LocationOsm } + LocationOsm = it.LocationOsm + AddAnother = false } /// Create a chapter from the values in this model member this.ToChapter () = diff --git a/src/admin-theme/chapter-edit.liquid b/src/admin-theme/chapter-edit.liquid index bb13c16..d5e73a0 100644 --- a/src/admin-theme/chapter-edit.liquid +++ b/src/admin-theme/chapter-edit.liquid @@ -1,7 +1,9 @@

{% if model.index < 0 %}Add{% else %}Edit{% endif %} Chapter

Times may be entered as seconds; minutes and seconds; or hours, minutes and seconds. Fractional seconds are supported to two decimal places. -

+{% assign post_url = "admin/post/" | append: model.post_id | append: "/chapter/" | append: model.index | relative_link %} + +
@@ -45,24 +47,25 @@
+ {%- if model.location_name != "" -%}{% assign has_loc = true %}{% else %}{% assign has_loc = false %}{% endif -%}
- +
+ placeholder="Location Name" required{% unless has_loc %} disabled{% endunless %}>
+ placeholder="Location Geo URL"{% unless has_loc %} disabled{% endunless %}> Optional; @@ -74,7 +77,7 @@
+ placeholder="Location OSM Query"{% unless has_loc %} disabled{% endunless %}> Optional; get ID, @@ -87,11 +90,14 @@
{% if model.index < 0 -%} - - +
+ + +
{% else -%} - + {% endif %} + {% assign cancel_link = "admin/post/" | append: model.post_id | append: "/chapters" | relative_link %} Cancel
diff --git a/src/admin-theme/wwwroot/admin.js b/src/admin-theme/wwwroot/admin.js index 9575a54..4867539 100644 --- a/src/admin-theme/wwwroot/admin.js +++ b/src/admin-theme/wwwroot/admin.js @@ -305,6 +305,18 @@ this.Admin = { document.getElementById("transcriptType").required = document.getElementById("transcriptUrl").value.trim() !== "" }, + /** + * Enable/disable fields based on whether chapter location checkbox is checked + */ + checkChapterLocation() { + const isDisabled = !document.getElementById("has_location").checked + ;["location_name", "location_geo", "location_osm"].forEach(it => { + const elt = document.getElementById(it) + elt.disabled = isDisabled + if (isDisabled) elt.value = "" + }) + }, + /** * Show messages that may have come with an htmx response * @param {string} messages The messages from the response