diff --git a/src/PrayerTracker.UI/Church.fs b/src/PrayerTracker.UI/Church.fs index 983f8c4..8ec25dc 100644 --- a/src/PrayerTracker.UI/Church.fs +++ b/src/PrayerTracker.UI/Church.fs @@ -54,7 +54,46 @@ let edit (m : EditChurch) ctx vi = /// View for church maintenance page let maintain (churches : Church list) (stats : Map) 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" ] [ br [] 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) ctx vi br [] ] tableSummary churches.Length s - 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 [] - ] + chTbl form [ _id "DeleteForm"; _action ""; _method "post" ] [ csrfToken ctx ] ] |> Layout.Content.wide diff --git a/src/PrayerTracker.UI/PrayerRequest.fs b/src/PrayerTracker.UI/PrayerRequest.fs index 2e7379c..ec44e2d 100644 --- a/src/PrayerTracker.UI/PrayerRequest.fs +++ b/src/PrayerTracker.UI/PrayerRequest.fs @@ -210,7 +210,7 @@ let maintain (reqs : PrayerRequest seq) (grp : SmallGroup) onlyActive (ctx : Htt ] ]) |> List.ofSeq - [ div [ _class "pt-center-text" ] [ + [ yield div [ _class "pt-center-text" ] [ br [] a [ _href (sprintf "/prayer-request/%s/edit" emptyGuid); _title s.["Add a New Request"].Value ] [ icon "add_circle"; rawText "  "; encLocText s.["Add a New Request"] ] @@ -220,20 +220,23 @@ let maintain (reqs : PrayerRequest seq) (grp : SmallGroup) onlyActive (ctx : Htt br [] br [] ] - tableSummary requests.Length s - table [ _class "pt-table pt-action-table" ] [ - thead [] [ - tr [] [ - th [] [ encLocText s.["Actions"] ] - th [] [ encLocText s.["Updated Date"] ] - th [] [ encLocText s.["Type"] ] - th [] [ encLocText s.["Requestor"] ] - th [] [ encLocText s.["Request"] ] + yield tableSummary requests.Length s + match requests.Length with + | 0 -> () + | _ -> + yield table [ _class "pt-table pt-action-table" ] [ + thead [] [ + tr [] [ + th [] [ encLocText s.["Actions"] ] + th [] [ encLocText s.["Updated Date"] ] + th [] [ encLocText s.["Type"] ] + th [] [ encLocText s.["Requestor"] ] + th [] [ encLocText s.["Request"] ] + ] + ] + tbody [] requests ] - ] - tbody [] requests - ] - div [ _class "pt-center-text" ] [ + yield div [ _class "pt-center-text" ] [ yield br [] match onlyActive with | true -> @@ -245,7 +248,7 @@ let maintain (reqs : PrayerRequest seq) (grp : SmallGroup) onlyActive (ctx : Htt yield br [] 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.standard vi "Maintain Requests" diff --git a/src/PrayerTracker.UI/SmallGroup.fs b/src/PrayerTracker.UI/SmallGroup.fs index 8650b78..c64ae4d 100644 --- a/src/PrayerTracker.UI/SmallGroup.fs +++ b/src/PrayerTracker.UI/SmallGroup.fs @@ -174,7 +174,40 @@ let logOn (grps : SmallGroup list) grpId ctx vi = /// View for the small group maintenance page 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" ] [ br [] 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 [] ] tableSummary grps.Length s - 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 [] - ] + grpTbl form [ _id "DeleteForm"; _action ""; _method "post" ] [ csrfToken ctx ] ] |> Layout.Content.standard @@ -223,7 +228,41 @@ let maintain (grps : SmallGroup list) ctx vi = /// View for the member maintenance page let members (mbrs : Member list) (emailTyps : Map) 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" ] [ br [] 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) ctx br [] ] tableSummary mbrs.Length s - 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 [] - ] + mbrTbl form [ _id "DeleteForm"; _action ""; _method "post" ] [ csrfToken ctx ] ] |> Layout.Content.standard diff --git a/src/PrayerTracker.UI/User.fs b/src/PrayerTracker.UI/User.fs index 8cbbca6..b0a92de 100644 --- a/src/PrayerTracker.UI/User.fs +++ b/src/PrayerTracker.UI/User.fs @@ -173,7 +173,44 @@ let logOn (m : UserLogOn) groups ctx vi = /// View for the user maintenance page 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" ] [ br [] 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 [] ] tableSummary users.Length s - 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 [] - ] + usrTbl form [ _id "DeleteForm"; _action ""; _method "post" ] [ csrfToken ctx ] ] |> Layout.Content.standard