Add contact info to profiles and listings

This commit is contained in:
Daniel J. Summers 2023-01-16 21:26:49 -05:00
parent 683506d735
commit 266e265b7f
8 changed files with 43 additions and 15 deletions

View File

@ -340,7 +340,7 @@ module Listings =
let private toListingForView row =
{ Listing = toDocument<Listing> row
ContinentName = row.string "continent_name"
ListedBy = Citizen.name (toDocumentFrom<Citizen> "cit_data" row)
Citizen = toDocumentFrom<Citizen> "cit_data" row
}
/// Find all job listings posted by the given citizen

View File

@ -13,8 +13,8 @@ type ListingForView =
/// The name of the continent for the listing
ContinentName : string
/// The display name of the citizen who owns the listing
ListedBy : string
/// The citizen who owns the listing
Citizen : Citizen
}

View File

@ -716,9 +716,7 @@ module Profile =
let! continent = Continents.findById profile.ContinentId
let continentName = match continent with Some c -> c.Name | None -> "not found"
let title = $"Employment Profile for {Citizen.name citizen}"
return!
Profile.view citizen profile continentName title currentCitizen
|> render title next ctx
return! Profile.view citizen profile continentName currentCitizen |> render title next ctx
| None -> return! Error.notFound next ctx
| None -> return! Error.notFound next ctx
}

View File

@ -21,9 +21,12 @@ let contactEdit (contacts : OtherContactForm array) =
div [ _class "form-floating" ] [
select [ _id $"contactType{idx}"; _name $"Contacts[{idx}].ContactType"; _class "form-control"
_value contact.ContactType; _placeholder "Type"; _required ] [
option [ _value "Website" ] [ rawText "Website" ]
option [ _value "Email" ] [ rawText "E-mail Address" ]
option [ _value "Phone" ] [ rawText "Phone Number" ]
let optionFor value label =
let typ = ContactType.toString value
option [ _value typ; if contact.ContactType = typ then _selected ] [ rawText label ]
optionFor Website "Website"
optionFor Email "E-mail Address"
optionFor Phone "Phone Number"
]
label [ _class "jjj-required"; _for $"contactType{idx}" ] [ rawText "Type" ]
]

View File

@ -101,6 +101,28 @@ let yesOrNo value =
let md2html value =
rawText (MarkdownString.toHtml value)
/// Display a citizen's contact information
let contactInfo citizen isPublic =
citizen.OtherContacts
|> List.filter (fun it -> (isPublic && it.IsPublic) || not isPublic)
|> List.collect (fun contact ->
match contact.ContactType with
| Website ->
[ i [ _class "mdi mdi-sm mdi-web" ] []; rawText " "
a [ _href contact.Value; _target "_blank"; _rel "noopener"; _class "me-4" ] [
str (defaultArg contact.Name "Website")
]
]
| Email ->
[ i [ _class "mdi mdi-sm mdi-email-outline" ] []; rawText " "
a [ _href $"mailto:{contact.Value}"; _class "me-4" ] [ str (defaultArg contact.Name "E-mail") ]
]
| Phone ->
[ span [ _class "me-4" ] [
i [ _class "mdi mdi-sm mdi-phone" ] []; rawText " "; str contact.Value
match contact.Name with Some name -> str $" ({name})" | None -> ()
]
])
open NodaTime
open NodaTime.Text

View File

@ -234,7 +234,8 @@ let view (it : ListingForView) =
strong [] [ em [] [ rawText "NEEDED BY "; str ((neededBy needed).ToUpperInvariant ()) ] ]
rawText " &bull; "
| None -> ()
rawText "Listed by "; str it.ListedBy //<!-- a :href="profileUrl" target="_blank" -->{{citizenName(citizen)}}<!-- /a -->
rawText "Listed by "; strong [ _class "me-4" ] [ str (Citizen.name it.Citizen) ]; br []
span [ _class "ms-3" ] []; yield! contactInfo it.Citizen false
]
hr []
div [] [ md2html it.Listing.Text ]

View File

@ -290,18 +290,18 @@ let search (m : ProfileSearchForm) continents tz (results : ProfileSearchResult
/// Profile view template
let view (citizen : Citizen) (profile : Profile) (continentName : string) pageTitle currentId =
let view (citizen : Citizen) (profile : Profile) (continentName : string) currentId =
article [] [
h3 [ _class "pb-3" ] [ str pageTitle ]
h2 [] [
// TODO: link to preferred profile
a [ _href "#"; _target "_blank"; _rel "noopener" ] [ str (Citizen.name citizen) ]
str (Citizen.name citizen)
if profile.IsSeekingEmployment then
span [ _class "jjj-heading-label" ] [
rawText "&nbsp; &nbsp;"; span [ _class "badge bg-dark" ] [ rawText "Currently Seeking Employment" ]
]
]
h4 [ _class "pb-3" ] [ str $"{continentName}, {profile.Region}" ]
h4 [] [ str $"{continentName}, {profile.Region}" ]
contactInfo citizen (Option.isNone currentId)
|> div [ _class "pb-3" ]
p [] [
rawText (if profile.IsFullTime then "I" else "Not i"); rawText "nterested in full-time employment"
rawText " &bull; "

View File

@ -84,6 +84,10 @@ label.jjj-required::after {
top: 3px;
left: -3px
}
.mdi-sm::before {
font-size: 1rem;
line-height: unset;
}
/* Layout styling */
.jjj-app {
display: flex;