Don't show headings for empty tables (#6)

This commit is contained in:
Daniel J. Summers 2019-03-14 22:59:07 -05:00
parent d80c5eb4ed
commit 05985189e7
4 changed files with 169 additions and 146 deletions

View File

@ -54,7 +54,46 @@ let edit (m : EditChurch) ctx vi =
/// View for church maintenance page /// View for church maintenance page
let maintain (churches : Church list) (stats : Map<string, ChurchStats>) ctx vi = let maintain (churches : Church list) (stats : Map<string, ChurchStats>) ctx vi =
let s = I18N.localizer.Force () let s = I18N.localizer.Force ()
let chTbl =
match churches with
| [] -> space
| _ ->
table [ _class "pt-table pt-action-table" ] [
thead [] [
tr [] [
th [] [ encLocText s.["Actions"] ]
th [] [ encLocText s.["Name"] ]
th [] [ encLocText s.["Location"] ]
th [] [ encLocText s.["Groups"] ]
th [] [ encLocText s.["Requests"] ]
th [] [ encLocText s.["Users"] ]
th [] [ encLocText s.["Interface?"] ]
]
]
churches
|> List.map (fun ch ->
let chId = flatGuid ch.churchId
let delAction = sprintf "/church/%s/delete" chId
let delPrompt = s.["Are you want to delete this {0}? This action cannot be undone.",
sprintf "%s (%s)" (s.["Church"].Value.ToLower ()) ch.name]
tr [] [
td [] [
a [ _href (sprintf "/church/%s/edit" chId); _title s.["Edit This Church"].Value ] [ icon "edit" ]
a [ _href delAction
_title s.["Delete This Church"].Value
_onclick (sprintf "return PT.confirmDelete('%s','%A')" delAction delPrompt) ]
[ icon "delete_forever" ]
]
td [] [ encodedText ch.name ]
td [] [ encodedText ch.city; rawText ", "; encodedText ch.st ]
td [ _class "pt-right-text" ] [ rawText (stats.[chId].smallGroups.ToString "N0") ]
td [ _class "pt-right-text" ] [ rawText (stats.[chId].prayerRequests.ToString "N0") ]
td [ _class "pt-right-text" ] [ rawText (stats.[chId].users.ToString "N0") ]
td [ _class "pt-center-text" ] [ encLocText s.[match ch.hasInterface with true -> "Yes" | false -> "No"] ]
])
|> tbody []
]
[ div [ _class "pt-center-text" ] [ [ div [ _class "pt-center-text" ] [
br [] br []
a [ _href (sprintf "/church/%s/edit" emptyGuid); _title s.["Add a New Church"].Value ] a [ _href (sprintf "/church/%s/edit" emptyGuid); _title s.["Add a New Church"].Value ]
@ -63,41 +102,7 @@ let maintain (churches : Church list) (stats : Map<string, ChurchStats>) ctx vi
br [] br []
] ]
tableSummary churches.Length s tableSummary churches.Length s
table [ _class "pt-table pt-action-table" ] [ chTbl
thead [] [
tr [] [
th [] [ encLocText s.["Actions"] ]
th [] [ encLocText s.["Name"] ]
th [] [ encLocText s.["Location"] ]
th [] [ encLocText s.["Groups"] ]
th [] [ encLocText s.["Requests"] ]
th [] [ encLocText s.["Users"] ]
th [] [ encLocText s.["Interface?"] ]
]
]
churches
|> List.map (fun ch ->
let chId = flatGuid ch.churchId
let delAction = sprintf "/church/%s/delete" chId
let delPrompt = s.["Are you want to delete this {0}? This action cannot be undone.",
sprintf "%s (%s)" (s.["Church"].Value.ToLower ()) ch.name]
tr [] [
td [] [
a [ _href (sprintf "/church/%s/edit" chId); _title s.["Edit This Church"].Value ] [ icon "edit" ]
a [ _href delAction
_title s.["Delete This Church"].Value
_onclick (sprintf "return PT.confirmDelete('%s','%A')" delAction delPrompt) ]
[ icon "delete_forever" ]
]
td [] [ encodedText ch.name ]
td [] [ encodedText ch.city; rawText ", "; encodedText ch.st ]
td [ _class "pt-right-text" ] [ rawText (stats.[chId].smallGroups.ToString "N0") ]
td [ _class "pt-right-text" ] [ rawText (stats.[chId].prayerRequests.ToString "N0") ]
td [ _class "pt-right-text" ] [ rawText (stats.[chId].users.ToString "N0") ]
td [ _class "pt-center-text" ] [ encLocText s.[match ch.hasInterface with true -> "Yes" | false -> "No"] ]
])
|> tbody []
]
form [ _id "DeleteForm"; _action ""; _method "post" ] [ csrfToken ctx ] form [ _id "DeleteForm"; _action ""; _method "post" ] [ csrfToken ctx ]
] ]
|> Layout.Content.wide |> Layout.Content.wide

View File

@ -210,7 +210,7 @@ let maintain (reqs : PrayerRequest seq) (grp : SmallGroup) onlyActive (ctx : Htt
] ]
]) ])
|> List.ofSeq |> List.ofSeq
[ div [ _class "pt-center-text" ] [ [ yield div [ _class "pt-center-text" ] [
br [] br []
a [ _href (sprintf "/prayer-request/%s/edit" emptyGuid); _title s.["Add a New Request"].Value ] a [ _href (sprintf "/prayer-request/%s/edit" emptyGuid); _title s.["Add a New Request"].Value ]
[ icon "add_circle"; rawText " &nbsp;"; encLocText s.["Add a New Request"] ] [ icon "add_circle"; rawText " &nbsp;"; encLocText s.["Add a New Request"] ]
@ -220,20 +220,23 @@ let maintain (reqs : PrayerRequest seq) (grp : SmallGroup) onlyActive (ctx : Htt
br [] br []
br [] br []
] ]
tableSummary requests.Length s yield tableSummary requests.Length s
table [ _class "pt-table pt-action-table" ] [ match requests.Length with
thead [] [ | 0 -> ()
tr [] [ | _ ->
th [] [ encLocText s.["Actions"] ] yield table [ _class "pt-table pt-action-table" ] [
th [] [ encLocText s.["Updated Date"] ] thead [] [
th [] [ encLocText s.["Type"] ] tr [] [
th [] [ encLocText s.["Requestor"] ] th [] [ encLocText s.["Actions"] ]
th [] [ encLocText s.["Request"] ] th [] [ encLocText s.["Updated Date"] ]
th [] [ encLocText s.["Type"] ]
th [] [ encLocText s.["Requestor"] ]
th [] [ encLocText s.["Request"] ]
]
]
tbody [] requests
] ]
] yield div [ _class "pt-center-text" ] [
tbody [] requests
]
div [ _class "pt-center-text" ] [
yield br [] yield br []
match onlyActive with match onlyActive with
| true -> | true ->
@ -245,7 +248,7 @@ let maintain (reqs : PrayerRequest seq) (grp : SmallGroup) onlyActive (ctx : Htt
yield br [] yield br []
yield a [ _href "/prayer-requests" ] [ encLocText s.["Do Not Show Inactive Requests"] ] yield a [ _href "/prayer-requests" ] [ encLocText s.["Do Not Show Inactive Requests"] ]
] ]
form [ _id "DeleteForm"; _action ""; _method "post" ] [ csrfToken ctx ] yield form [ _id "DeleteForm"; _action ""; _method "post" ] [ csrfToken ctx ]
] ]
|> Layout.Content.wide |> Layout.Content.wide
|> Layout.standard vi "Maintain Requests" |> Layout.standard vi "Maintain Requests"

View File

@ -174,7 +174,40 @@ let logOn (grps : SmallGroup list) grpId ctx vi =
/// View for the small group maintenance page /// View for the small group maintenance page
let maintain (grps : SmallGroup list) ctx vi = let maintain (grps : SmallGroup list) ctx vi =
let s = I18N.localizer.Force () let s = I18N.localizer.Force ()
let grpTbl =
match grps with
| [] -> space
| _ ->
table [ _class "pt-table pt-action-table" ] [
thead [] [
tr [] [
th [] [ encLocText s.["Actions"] ]
th [] [ encLocText s.["Name"] ]
th [] [ encLocText s.["Church"] ]
th [] [ encLocText s.["Time Zone"] ]
]
]
grps
|> List.map (fun g ->
let grpId = flatGuid g.smallGroupId
let delAction = sprintf "/small-group/%s/delete" grpId
let delPrompt = s.["Are you want to delete this {0}? This action cannot be undone.",
sprintf "%s (%s)" (s.["Small Group"].Value.ToLower ()) g.name].Value
tr [] [
td [] [
a [ _href (sprintf "/small-group/%s/edit" grpId); _title s.["Edit This Group"].Value ] [ icon "edit" ]
a [ _href delAction
_title s.["Delete This Group"].Value
_onclick (sprintf "return PT.confirmDelete('%s','%s')" delAction delPrompt) ]
[ icon "delete_forever" ]
]
td [] [ encodedText g.name ]
td [] [ encodedText g.church.name ]
td [] [ encLocText (TimeZones.name g.preferences.timeZoneId s) ]
])
|> tbody []
]
[ div [ _class "pt-center-text" ] [ [ div [ _class "pt-center-text" ] [
br [] br []
a [ _href (sprintf "/small-group/%s/edit" emptyGuid); _title s.["Add a New Group"].Value ] [ a [ _href (sprintf "/small-group/%s/edit" emptyGuid); _title s.["Add a New Group"].Value ] [
@ -186,35 +219,7 @@ let maintain (grps : SmallGroup list) ctx vi =
br [] br []
] ]
tableSummary grps.Length s tableSummary grps.Length s
table [ _class "pt-table pt-action-table" ] [ grpTbl
thead [] [
tr [] [
th [] [ encLocText s.["Actions"] ]
th [] [ encLocText s.["Name"] ]
th [] [ encLocText s.["Church"] ]
th [] [ encLocText s.["Time Zone"] ]
]
]
grps
|> List.map (fun g ->
let grpId = flatGuid g.smallGroupId
let delAction = sprintf "/small-group/%s/delete" grpId
let delPrompt = s.["Are you want to delete this {0}? This action cannot be undone.",
sprintf "%s (%s)" (s.["Small Group"].Value.ToLower ()) g.name].Value
tr [] [
td [] [
a [ _href (sprintf "/small-group/%s/edit" grpId); _title s.["Edit This Group"].Value ] [ icon "edit" ]
a [ _href delAction
_title s.["Delete This Group"].Value
_onclick (sprintf "return PT.confirmDelete('%s','%s')" delAction delPrompt) ]
[ icon "delete_forever" ]
]
td [] [ encodedText g.name ]
td [] [ encodedText g.church.name ]
td [] [ encLocText (TimeZones.name g.preferences.timeZoneId s) ]
])
|> tbody []
]
form [ _id "DeleteForm"; _action ""; _method "post" ] [ csrfToken ctx ] form [ _id "DeleteForm"; _action ""; _method "post" ] [ csrfToken ctx ]
] ]
|> Layout.Content.standard |> Layout.Content.standard
@ -223,7 +228,41 @@ let maintain (grps : SmallGroup list) ctx vi =
/// View for the member maintenance page /// View for the member maintenance page
let members (mbrs : Member list) (emailTyps : Map<string, LocalizedString>) ctx vi = let members (mbrs : Member list) (emailTyps : Map<string, LocalizedString>) ctx vi =
let s = I18N.localizer.Force () let s = I18N.localizer.Force ()
let mbrTbl =
match mbrs with
| [] -> space
| _ ->
table [ _class "pt-table pt-action-table" ] [
thead [] [
tr [] [
th [] [ encLocText s.["Actions"] ]
th [] [ encLocText s.["Name"] ]
th [] [ encLocText s.["E-mail Address"] ]
th [] [ encLocText s.["Format"] ]
]
]
mbrs
|> List.map (fun mbr ->
let mbrId = flatGuid mbr.memberId
let delAction = sprintf "/small-group/member/%s/delete" mbrId
let delPrompt = s.["Are you want to delete this {0} ({1})? This action cannot be undone.",
s.["group member"], mbr.memberName].Value
tr [] [
td [] [
a [ _href (sprintf "/small-group/member/%s/edit" mbrId); _title s.["Edit This Group Member"].Value ]
[ icon "edit" ]
a [ _href delAction
_title s.["Delete This Group Member"].Value
_onclick (sprintf "return PT.confirmDelete('%s','%s')" delAction delPrompt) ]
[ icon "delete_forever" ]
]
td [] [ encodedText mbr.memberName ]
td [] [ encodedText mbr.email ]
td [] [ encLocText emailTyps.[defaultArg mbr.format ""] ]
])
|> tbody []
]
[ div [ _class"pt-center-text" ] [ [ div [ _class"pt-center-text" ] [
br [] br []
a [ _href (sprintf "/small-group/member/%s/edit" emptyGuid); _title s.["Add a New Group Member"].Value ] a [ _href (sprintf "/small-group/member/%s/edit" emptyGuid); _title s.["Add a New Group Member"].Value ]
@ -232,36 +271,7 @@ let members (mbrs : Member list) (emailTyps : Map<string, LocalizedString>) ctx
br [] br []
] ]
tableSummary mbrs.Length s tableSummary mbrs.Length s
table [ _class "pt-table pt-action-table" ] [ mbrTbl
thead [] [
tr [] [
th [] [ encLocText s.["Actions"] ]
th [] [ encLocText s.["Name"] ]
th [] [ encLocText s.["E-mail Address"] ]
th [] [ encLocText s.["Format"] ]
]
]
mbrs
|> List.map (fun mbr ->
let mbrId = flatGuid mbr.memberId
let delAction = sprintf "/small-group/member/%s/delete" mbrId
let delPrompt = s.["Are you want to delete this {0} ({1})? This action cannot be undone.",
s.["group member"], mbr.memberName].Value
tr [] [
td [] [
a [ _href (sprintf "/small-group/member/%s/edit" mbrId); _title s.["Edit This Group Member"].Value ]
[ icon "edit" ]
a [ _href delAction
_title s.["Delete This Group Member"].Value
_onclick (sprintf "return PT.confirmDelete('%s','%s')" delAction delPrompt) ]
[ icon "delete_forever" ]
]
td [] [ encodedText mbr.memberName ]
td [] [ encodedText mbr.email ]
td [] [ encLocText emailTyps.[defaultArg mbr.format ""] ]
])
|> tbody []
]
form [ _id "DeleteForm"; _action ""; _method "post" ] [ csrfToken ctx ] form [ _id "DeleteForm"; _action ""; _method "post" ] [ csrfToken ctx ]
] ]
|> Layout.Content.standard |> Layout.Content.standard

View File

@ -173,7 +173,44 @@ let logOn (m : UserLogOn) groups ctx vi =
/// View for the user maintenance page /// View for the user maintenance page
let maintain (users : User list) ctx vi = let maintain (users : User list) ctx vi =
let s = I18N.localizer.Force () let s = I18N.localizer.Force ()
let usrTbl =
match users with
| [] -> space
| _ ->
table [ _class "pt-table pt-action-table" ] [
thead [] [
tr [] [
th [] [ encLocText s.["Actions"] ]
th [] [ encLocText s.["Name"] ]
th [] [ encLocText s.["Admin?"] ]
]
]
users
|> List.map (fun user ->
let userId = flatGuid user.userId
let delAction = sprintf "/user/%s/delete" userId
let delPrompt = s.["Are you want to delete this {0}? This action cannot be undone.",
(sprintf "%s (%s)" (s.["User"].Value.ToLower()) user.fullName)].Value
tr [] [
td [] [
a [ _href (sprintf "/user/%s/edit" userId); _title s.["Edit This User"].Value ] [ icon "edit" ]
a [ _href (sprintf "/user/%s/small-groups" userId); _title s.["Assign Groups to This User"].Value ]
[ icon "group" ]
a [ _href delAction
_title s.["Delete This User"].Value
_onclick (sprintf "return PT.confirmDelete('%s','%s')" delAction delPrompt) ]
[ icon "delete_forever" ]
]
td [] [ encodedText user.fullName ]
td [ _class "pt-center-text" ] [
match user.isAdmin with
| true -> yield strong [] [ encLocText s.["Yes"] ]
| false -> yield encLocText s.["No"]
]
])
|> tbody []
]
[ div [ _class "pt-center-text" ] [ [ div [ _class "pt-center-text" ] [
br [] br []
a [ _href (sprintf "/user/%s/edit" emptyGuid); _title s.["Add a New User"].Value ] a [ _href (sprintf "/user/%s/edit" emptyGuid); _title s.["Add a New User"].Value ]
@ -182,39 +219,7 @@ let maintain (users : User list) ctx vi =
br [] br []
] ]
tableSummary users.Length s tableSummary users.Length s
table [ _class "pt-table pt-action-table" ] [ usrTbl
thead [] [
tr [] [
th [] [ encLocText s.["Actions"] ]
th [] [ encLocText s.["Name"] ]
th [] [ encLocText s.["Admin?"] ]
]
]
users
|> List.map (fun user ->
let userId = flatGuid user.userId
let delAction = sprintf "/user/%s/delete" userId
let delPrompt = s.["Are you want to delete this {0}? This action cannot be undone.",
(sprintf "%s (%s)" (s.["User"].Value.ToLower()) user.fullName)].Value
tr [] [
td [] [
a [ _href (sprintf "/user/%s/edit" userId); _title s.["Edit This User"].Value ] [ icon "edit" ]
a [ _href (sprintf "/user/%s/small-groups" userId); _title s.["Assign Groups to This User"].Value ]
[ icon "group" ]
a [ _href delAction
_title s.["Delete This User"].Value
_onclick (sprintf "return PT.confirmDelete('%s','%s')" delAction delPrompt) ]
[ icon "delete_forever" ]
]
td [] [ encodedText user.fullName ]
td [ _class "pt-center-text" ] [
match user.isAdmin with
| true -> yield strong [] [ encLocText s.["Yes"] ]
| false -> yield encLocText s.["No"]
]
])
|> tbody []
]
form [ _id "DeleteForm"; _action ""; _method "post" ] [ csrfToken ctx ] form [ _id "DeleteForm"; _action ""; _method "post" ] [ csrfToken ctx ]
] ]
|> Layout.Content.standard |> Layout.Content.standard