Bug fixes with new admin forms
This commit is contained in:
parent
54e46fdeb6
commit
4301788344
@ -46,7 +46,7 @@ let delete pgId : HttpHandler = requireAccess WebLogAdmin >=> fun next ctx -> ta
|
|||||||
do! PageListCache.update ctx
|
do! PageListCache.update ctx
|
||||||
do! addMessage ctx { UserMessage.Success with Message = "Page deleted successfully" }
|
do! addMessage ctx { UserMessage.Success with Message = "Page deleted successfully" }
|
||||||
| false -> do! addMessage ctx { UserMessage.Error with Message = "Page not found; nothing deleted" }
|
| false -> do! addMessage ctx { UserMessage.Error with Message = "Page not found; nothing deleted" }
|
||||||
return! redirectToGet "admin/pages" next ctx
|
return! all 1 next ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET /admin/page/{id}/permalinks
|
// GET /admin/page/{id}/permalinks
|
||||||
@ -96,7 +96,7 @@ let purgeRevisions pgId : HttpHandler = requireAccess Author >=> fun next ctx ->
|
|||||||
| Some pg ->
|
| Some pg ->
|
||||||
do! data.Page.Update { pg with Revisions = [ List.head pg.Revisions ] }
|
do! data.Page.Update { pg with Revisions = [ List.head pg.Revisions ] }
|
||||||
do! addMessage ctx { UserMessage.Success with Message = "Prior revisions purged successfully" }
|
do! addMessage ctx { UserMessage.Success with Message = "Prior revisions purged successfully" }
|
||||||
return! redirectToGet $"admin/page/{pgId}/revisions" next ctx
|
return! editRevisions pgId next ctx
|
||||||
| None -> return! Error.notFound next ctx
|
| None -> return! Error.notFound next ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,6 +273,7 @@ let edit postId : HttpHandler = requireAccess Author >=> fun next ctx -> task {
|
|||||||
let! templates = templatesForTheme ctx "post"
|
let! templates = templatesForTheme ctx "post"
|
||||||
let model = EditPostModel.FromPost ctx.WebLog post
|
let model = EditPostModel.FromPost ctx.WebLog post
|
||||||
let ratings = [
|
let ratings = [
|
||||||
|
{ Name = ""; Value = "– Default –" }
|
||||||
{ Name = string Yes; Value = "Yes" }
|
{ Name = string Yes; Value = "Yes" }
|
||||||
{ Name = string No; Value = "No" }
|
{ Name = string No; Value = "No" }
|
||||||
{ Name = string Clean; Value = "Clean" }
|
{ Name = string Clean; Value = "Clean" }
|
||||||
@ -338,7 +339,7 @@ let purgeRevisions postId : HttpHandler = requireAccess Author >=> fun next ctx
|
|||||||
| Some post when canEdit post.AuthorId ctx ->
|
| Some post when canEdit post.AuthorId ctx ->
|
||||||
do! data.Post.Update { post with Revisions = [ List.head post.Revisions ] }
|
do! data.Post.Update { post with Revisions = [ List.head post.Revisions ] }
|
||||||
do! addMessage ctx { UserMessage.Success with Message = "Prior revisions purged successfully" }
|
do! addMessage ctx { UserMessage.Success with Message = "Prior revisions purged successfully" }
|
||||||
return! redirectToGet $"admin/post/{postId}/revisions" next ctx
|
return! editRevisions postId next ctx
|
||||||
| Some _ -> return! Error.notAuthorized next ctx
|
| Some _ -> return! Error.notAuthorized next ctx
|
||||||
| None -> return! Error.notFound next ctx
|
| None -> return! Error.notFound next ctx
|
||||||
}
|
}
|
||||||
@ -427,7 +428,7 @@ let editChapter (postId, index) : HttpHandler = requireAccess Author >=> fun nex
|
|||||||
// POST /admin/post/{id}/chapter/{idx}
|
// POST /admin/post/{id}/chapter/{idx}
|
||||||
let saveChapter (postId, index) : HttpHandler = requireAccess Author >=> fun next ctx -> task {
|
let saveChapter (postId, index) : HttpHandler = requireAccess Author >=> fun next ctx -> task {
|
||||||
let data = ctx.Data
|
let data = ctx.Data
|
||||||
match! data.Post.FindById (PostId postId) ctx.WebLog.Id with
|
match! data.Post.FindFullById (PostId postId) ctx.WebLog.Id with
|
||||||
| Some post
|
| Some post
|
||||||
when Option.isSome post.Episode
|
when Option.isSome post.Episode
|
||||||
&& Option.isSome post.Episode.Value.Chapters
|
&& Option.isSome post.Episode.Value.Chapters
|
||||||
@ -447,7 +448,7 @@ let saveChapter (postId, index) : HttpHandler = requireAccess Author >=> fun nex
|
|||||||
do! addMessage ctx { UserMessage.Success with Message = "Chapter saved successfully" }
|
do! addMessage ctx { UserMessage.Success with Message = "Chapter saved successfully" }
|
||||||
return!
|
return!
|
||||||
Views.Post.chapterList form.AddAnother (ManageChaptersModel.Create updatedPost)
|
Views.Post.chapterList form.AddAnother (ManageChaptersModel.Create updatedPost)
|
||||||
|> adminPage "Manage Chapters" true next ctx
|
|> adminBarePage "Manage Chapters" true next ctx
|
||||||
with
|
with
|
||||||
| ex -> return! Error.server ex.Message next ctx
|
| ex -> return! Error.server ex.Message next ctx
|
||||||
else return! Error.notFound next ctx
|
else return! Error.notFound next ctx
|
||||||
|
@ -132,8 +132,8 @@ let textField attrs name labelText value extra =
|
|||||||
inputField "text" attrs name labelText value extra
|
inputField "text" attrs name labelText value extra
|
||||||
|
|
||||||
/// Create a number input field
|
/// Create a number input field
|
||||||
let numberField attrs name labelText (value: int) extra =
|
let numberField attrs name labelText value extra =
|
||||||
inputField "number" attrs name labelText (string value) extra
|
inputField "number" attrs name labelText value extra
|
||||||
|
|
||||||
/// Create an e-mail input field
|
/// Create an e-mail input field
|
||||||
let emailField attrs name labelText value extra =
|
let emailField attrs name labelText value extra =
|
||||||
@ -450,7 +450,7 @@ let managePermalinks (model: ManagePermalinksModel) app = [
|
|||||||
div [ _id "permalinks"; _class "container g-0" ] [
|
div [ _id "permalinks"; _class "container g-0" ] [
|
||||||
yield! Array.mapi linkDetail model.Prior
|
yield! Array.mapi linkDetail model.Prior
|
||||||
script [] [
|
script [] [
|
||||||
raw """document.addEventListener(\"DOMContentLoaded\", """
|
raw """document.addEventListener("DOMContentLoaded", """
|
||||||
raw $"() => Admin.setPermalinkIndex({model.Prior.Length}))"
|
raw $"() => Admin.setPermalinkIndex({model.Prior.Length}))"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -514,7 +514,7 @@ let manageRevisions (model: ManageRevisionsModel) app = [
|
|||||||
if model.Revisions.Length > 1 then
|
if model.Revisions.Length > 1 then
|
||||||
div [ _class "row mb-3" ] [
|
div [ _class "row mb-3" ] [
|
||||||
div [ _class "col" ] [
|
div [ _class "col" ] [
|
||||||
button [ _type "button"; _class "btn btn-sm btn-danger"; _hxDelete $"{revUrlBase}s/purge"
|
button [ _type "button"; _class "btn btn-sm btn-danger"; _hxDelete $"{revUrlBase}s"
|
||||||
_hxConfirm "This will remove all revisions but the current one; are you sure this is what you wish to do?" ] [
|
_hxConfirm "This will remove all revisions but the current one; are you sure this is what you wish to do?" ] [
|
||||||
raw "Delete All Prior Revisions"
|
raw "Delete All Prior Revisions"
|
||||||
]
|
]
|
||||||
|
@ -325,7 +325,7 @@ let postEdit (model: EditPostModel) templates (ratings: MetaItem list) app = [
|
|||||||
div [ _class "row pb-3" ] [
|
div [ _class "row pb-3" ] [
|
||||||
div [ _class "col" ] [
|
div [ _class "col" ] [
|
||||||
numberField [ _required ] (nameof model.Length) "Media Length (bytes)"
|
numberField [ _required ] (nameof model.Length) "Media Length (bytes)"
|
||||||
0 (* TODO: string model.Length *) [
|
(string model.Length) [
|
||||||
div [ _class "form-text" ] [ raw "TODO: derive from above file name" ]
|
div [ _class "form-text" ] [ raw "TODO: derive from above file name" ]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -409,14 +409,16 @@ let postEdit (model: EditPostModel) templates (ratings: MetaItem list) app = [
|
|||||||
]
|
]
|
||||||
div [ _class "row" ] [
|
div [ _class "row" ] [
|
||||||
div [ _class "col-12 col-md-8 pb-3" ] [
|
div [ _class "col-12 col-md-8 pb-3" ] [
|
||||||
textField [] (nameof model.TranscriptUrl) "Transcript URL" model.TranscriptUrl [
|
textField [ _onkeyup "Admin.requireTranscriptType()" ] (nameof model.TranscriptUrl)
|
||||||
|
"Transcript URL" model.TranscriptUrl [
|
||||||
div [ _class "form-text" ] [
|
div [ _class "form-text" ] [
|
||||||
raw "Optional; relative URL served from this web log"
|
raw "Optional; relative URL served from this web log"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
div [ _class "col-12 col-md-4 pb-3" ] [
|
div [ _class "col-12 col-md-4 pb-3" ] [
|
||||||
textField [] (nameof model.TranscriptType) "Transcript MIME Type"
|
textField [ if model.TranscriptUrl <> "" then _required ]
|
||||||
|
(nameof model.TranscriptType) "Transcript MIME Type"
|
||||||
model.TranscriptType [
|
model.TranscriptType [
|
||||||
div [ _class "form-text" ] [ raw "Required if transcript URL provided" ]
|
div [ _class "form-text" ] [ raw "Required if transcript URL provided" ]
|
||||||
]
|
]
|
||||||
@ -436,7 +438,8 @@ let postEdit (model: EditPostModel) templates (ratings: MetaItem list) app = [
|
|||||||
]
|
]
|
||||||
div [ _class "row pb-3" ] [
|
div [ _class "row pb-3" ] [
|
||||||
div [ _class "col col-md-4" ] [
|
div [ _class "col col-md-4" ] [
|
||||||
numberField [] (nameof model.SeasonNumber) "Season Number" model.SeasonNumber [
|
numberField [] (nameof model.SeasonNumber) "Season Number"
|
||||||
|
(string model.SeasonNumber) [
|
||||||
div [ _class "form-text" ] [ raw "Optional" ]
|
div [ _class "form-text" ] [ raw "Optional" ]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -450,7 +453,7 @@ let postEdit (model: EditPostModel) templates (ratings: MetaItem list) app = [
|
|||||||
div [ _class "row pb-3" ] [
|
div [ _class "row pb-3" ] [
|
||||||
div [ _class "col col-md-4" ] [
|
div [ _class "col col-md-4" ] [
|
||||||
numberField [ _step "0.01" ] (nameof model.EpisodeNumber) "Episode Number"
|
numberField [ _step "0.01" ] (nameof model.EpisodeNumber) "Episode Number"
|
||||||
0 (* TODO: model.EpisodeNumber *) [
|
model.EpisodeNumber [
|
||||||
div [ _class "form-text" ] [ raw "Optional; up to 2 decimal points" ]
|
div [ _class "form-text" ] [ raw "Optional; up to 2 decimal points" ]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
@ -281,7 +281,8 @@ let feedEdit (model: EditCustomFeedModel) (ratings: MetaItem list) (mediums: Met
|
|||||||
textField [] (nameof model.Subtitle) "Podcast Subtitle" model.Subtitle []
|
textField [] (nameof model.Subtitle) "Podcast Subtitle" model.Subtitle []
|
||||||
]
|
]
|
||||||
div [ _class "col-12 col-md-3 col-lg-2 pb-3" ] [
|
div [ _class "col-12 col-md-3 col-lg-2 pb-3" ] [
|
||||||
numberField [ _required ] (nameof model.ItemsInFeed) "# Episodes" model.ItemsInFeed []
|
numberField [ _required ] (nameof model.ItemsInFeed) "# Episodes"
|
||||||
|
(string model.ItemsInFeed) []
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
div [ _class "row" ] [
|
div [ _class "row" ] [
|
||||||
@ -775,7 +776,7 @@ let webLogSettings
|
|||||||
]
|
]
|
||||||
div [ _class "col-12 col-md-4 col-xl-2 pb-3" ] [
|
div [ _class "col-12 col-md-4 col-xl-2 pb-3" ] [
|
||||||
numberField [ _required; _min "0"; _max "50" ] (nameof model.PostsPerPage) "Posts per Page"
|
numberField [ _required; _min "0"; _max "50" ] (nameof model.PostsPerPage) "Posts per Page"
|
||||||
model.PostsPerPage []
|
(string model.PostsPerPage) []
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
div [ _class "row" ] [
|
div [ _class "row" ] [
|
||||||
@ -827,7 +828,8 @@ let webLogSettings
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
div [ _class "col-12 col-sm-6 col-md-4 col-xl-2 pb-3" ] [
|
div [ _class "col-12 col-sm-6 col-md-4 col-xl-2 pb-3" ] [
|
||||||
numberField [ _required; _min "0" ] (nameof rss.ItemsInFeed) "Items in Feed" rss.ItemsInFeed [
|
numberField [ _required; _min "0" ] (nameof rss.ItemsInFeed) "Items in Feed"
|
||||||
|
(string rss.ItemsInFeed) [
|
||||||
span [ _class "form-text" ] [
|
span [ _class "form-text" ] [
|
||||||
raw "Set to “0” to use “Posts per Page” setting ("
|
raw "Set to “0” to use “Posts per Page” setting ("
|
||||||
raw (string app.WebLog.PostsPerPage); raw ")"
|
raw (string app.WebLog.PostsPerPage); raw ")"
|
||||||
|
@ -375,9 +375,7 @@ this.Admin = {
|
|||||||
*/
|
*/
|
||||||
showPreRenderedMessages() {
|
showPreRenderedMessages() {
|
||||||
[...document.querySelectorAll(".toast")].forEach(el => {
|
[...document.querySelectorAll(".toast")].forEach(el => {
|
||||||
if (el.getAttribute("data-mwl-shown") === "true" && el.className.indexOf("hide") >= 0) {
|
if (el.getAttribute("data-mwl-shown") !== "true") {
|
||||||
document.removeChild(el)
|
|
||||||
} else {
|
|
||||||
const toast = new bootstrap.Toast(el,
|
const toast = new bootstrap.Toast(el,
|
||||||
el.getAttribute("data-bs-autohide") === "false"
|
el.getAttribute("data-bs-autohide") === "false"
|
||||||
? { autohide: false } : { delay: 6000, autohide: true })
|
? { autohide: false } : { delay: 6000, autohide: true })
|
||||||
|
Loading…
Reference in New Issue
Block a user