Skip to content

Commit

Permalink
Add new property offerPublished
Browse files Browse the repository at this point in the history
  • Loading branch information
ciukstar committed Nov 13, 2023
1 parent 52362b4 commit bfe3a5d
Show file tree
Hide file tree
Showing 34 changed files with 1,326 additions and 775 deletions.
1 change: 1 addition & 0 deletions config/models.persistentmodels
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Thumbnail
Offer
service ServiceId OnDeleteCascade
name Text
published Bool
price Centi
prefix Text Maybe
suffix Text Maybe
Expand Down
1 change: 1 addition & 0 deletions messages/en.msg
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
NoAppointmentsForThisDay: You have no appointments for this day
Completed: Completed
Pending: Pending
NoBusinessAddressFound: No business address found
Expand Down
1 change: 1 addition & 0 deletions messages/fr.msg
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
NoAppointmentsForThisDay: Vous n'avez pas de rendez-vous pour ce jour
Completed: Terminée
Pending: En attente
NoBusinessAddressFound: Aucune adresse trouvée
Expand Down
1 change: 1 addition & 0 deletions messages/ro.msg
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
NoAppointmentsForThisDay: Nu aveți programări pentru această zi
Completed: Finalizată
Pending: În așteptare
NoBusinessAddressFound: Nu a fost găsită nicio adresă
Expand Down
1 change: 1 addition & 0 deletions messages/ru.msg
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
NoAppointmentsForThisDay: У вас нет записи на этот день
Completed: Выполнена
Pending: В ожидании
NoBusinessAddressFound: Адрес не найден
Expand Down
35 changes: 33 additions & 2 deletions src/Admin/Services.hs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ import Model
, ServiceDescr, ServicePublished, ThumbnailAttribution, RoleStaff, StaffId
, RoleService, RoleName, RoleId, BusinessCurrency
)
, Offer (Offer, offerName, offerPrice, offerPrefix, offerSuffix, offerDescr)
, Offer (Offer, offerName, offerPrice, offerPrefix, offerSuffix, offerDescr, offerPublished)
, OfferId
, ServiceStatus (ServiceStatusPulished, ServiceStatusUnpublished)
, Role (Role, roleStaff, roleName, roleDuration, roleRating), StaffId
Expand Down Expand Up @@ -428,6 +428,11 @@ formOffer sid offer extra = do
, fsTooltip = Nothing, fsId = Nothing, fsName = Nothing
, fsAttrs = [("class","mdc-text-field__input")]
} (offerName . entityVal <$> offer)
(publishedR,publishedV) <- mreq (mdcBoolField (optionsPairs [(MsgYes,True),(MsgNo,False)])) FieldSettings
{ fsLabel = SomeMessage MsgPublished
, fsTooltip = Nothing, fsId = Nothing, fsName = Nothing
, fsAttrs = [("class","mdc-radio__native-control")]
} (offerPublished . entityVal <$> offer)
(priceR,priceV) <- mreq doubleField FieldSettings
{ fsLabel = SomeMessage MsgPrice
, fsTooltip = Nothing, fsId = Nothing, fsName = Nothing
Expand All @@ -449,10 +454,21 @@ formOffer sid offer extra = do
, fsAttrs = [("class","mdc-text-field__input")]
} (offerDescr . entityVal <$> offer)

let r = Offer sid <$> nameR <*> (realToFrac <$> priceR) <*> prefR <*> suffR <*> descrR
let r = Offer sid <$> nameR <*> publishedR <*> (realToFrac <$> priceR) <*> prefR <*> suffR <*> descrR
let w = [whamlet|
#{extra}

<div.form-field>
<div style="padding-left:1rem;display:flex;align-items:center">
<small style="padding;opacity:0.6">
_{MsgPublished}<sup>*
^{fvInput publishedV}
$maybe errs <- fvErrors publishedV
<label.mdc-text-field.mdc-text-field--invalid>
<div.mdc-text-field-helper-line>
<div.mdc-text-field-helper-text.mdc-text-field-helper-text--validation-msg aria-hidden=true>
#{errs}

$forall v <- [nameV,priceV,prefV,suffV]
<div.form-field>
<label.mdc-text-field.mdc-text-field--filled data-mdc-auto-init=MDCTextField
Expand Down Expand Up @@ -501,6 +517,21 @@ $forall v <- [nameV,priceV,prefV,suffV]
Just (Entity pid' _) | pid == pid' -> Right name
| otherwise -> Left MsgPriceAlreadyInTheList

mdcBoolField :: Handler (OptionList Bool) -> Field Handler Bool
mdcBoolField = withRadioField
(\_ _ -> [whamlet||])
(\theId value _isSel text optionW -> [whamlet|
<div.mdc-form-field.mdc-touch-target-wrapper>
<div.mdc-radio.mdc-radio--touch>
^{optionW}
<div.mdc-radio__background>
<div.mdc-radio__outer-circle>
<div.mdc-radio__inner-circle>
<div.mdc-radio__ripple>
<div.mdc-radio__focus-ring>
<label for=#{theId}-#{value}>#{text}
|])


getAdmServiceImageR :: ServiceId -> Handler TypedContent
getAdmServiceImageR sid = do
Expand Down
Loading

0 comments on commit bfe3a5d

Please sign in to comment.