Skip to content

Commit

Permalink
Add prop ContactUs.showSchedule
Browse files Browse the repository at this point in the history
  • Loading branch information
ciukstar committed Nov 6, 2023
1 parent 8202ca7 commit 1dac3ab
Show file tree
Hide file tree
Showing 16 changed files with 55 additions and 17 deletions.
1 change: 1 addition & 0 deletions config/models.persistentmodels
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ Brand

ContactUs
business BusinessId OnDeleteCascade
showSchedule Bool
html Html
UniqueContactUs business

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 @@
ShowSchedule: Show schedule
NumberOfOrders: Number of orders
ValueOfOrders: Value of orders
TotalOrderValue: Total order value
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 @@
ShowSchedule: Afficher l'horaire de travail
NumberOfOrders: Nombre de commandes
ValueOfOrders: Valeur des commandes
TotalOrderValue: Valeur totale des commandes
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 @@
ShowSchedule: Afișează programul de lucru
NumberOfOrders: Numărul de comenzi
ValueOfOrders: Valoarea comenzilor
TotalOrderValue: Valoarea totală a comenzilor
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 @@
ShowSchedule: Показать график работы
NumberOfOrders: Количество заказов
ValueOfOrders: Стоимость заказов
TotalOrderValue: Общая стоимость заказов
Expand Down
37 changes: 33 additions & 4 deletions src/Admin/Business.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ import Yesod.Core.Widget (setTitleI, whamlet)
import Yesod.Form.Input (runInputGet, iopt)
import Yesod.Form.Fields
( textField, emailField, textareaField, intField, dayField, timeField
, hiddenField, htmlField
, hiddenField, htmlField, checkBoxField
)
import Yesod.Form.Functions
( generateFormPost, mreq, mopt, runFormPost, checkM, check )
Expand Down Expand Up @@ -123,7 +123,7 @@ import Foundation
, MsgList, MsgCalendar, MsgMon, MsgTue, MsgWed, MsgThu, MsgFri, MsgSat, MsgSun
, MsgSymbolHour, MsgSymbolMinute, MsgToday, MsgBusinessDay, MsgSortAscending
, MsgSortDescending, MsgAboutUs, MsgContactUs, MsgNoContentYet, MsgContent
, MsgAlreadyExists, MsgInvalidFormData, MsgWorkSchedule
, MsgAlreadyExists, MsgInvalidFormData, MsgWorkSchedule, MsgShowSchedule
)
)

Expand All @@ -139,7 +139,7 @@ import Model
, businessHoursDayType
)
, AboutUsId, AboutUs (AboutUs, aboutUsHtml)
, ContactUsId, ContactUs (ContactUs, contactUsHtml)
, ContactUsId, ContactUs (ContactUs, contactUsHtml, contactUsShowSchedule)
, EntityField
( BusinessName, BusinessFullName, BusinessAddr, BusinessPhone, BusinessMobile
, BusinessEmail, BusinessId, BusinessTzo, BusinessTz, BusinessCurrency
Expand Down Expand Up @@ -221,14 +221,43 @@ getBusinessContactCreateR bid = do
formContact :: BusinessId -> Maybe (Entity ContactUs)
-> Html -> MForm Handler (FormResult ContactUs, Widget)
formContact bid e extra = do
(showScheduleR,showScheduleV) <- mreq checkBoxField FieldSettings
{ fsLabel = SomeMessage MsgShowSchedule
, fsTooltip = Nothing, fsId = Nothing, fsName = Nothing
, fsAttrs = [("class","mdc-checkbox__native-control")]
} (contactUsShowSchedule . entityVal <$> e)
(htmlR,htmlV) <- mreq uniqueField FieldSettings
{ fsLabel = SomeMessage MsgContent
, fsTooltip = Nothing, fsId = Nothing, fsName = Nothing
, fsAttrs = [("class","mdc-text-field__input"),("rows","12")]
} ( contactUsHtml . entityVal <$> e)
let r = ContactUs bid <$> htmlR
let r = ContactUs bid <$> showScheduleR <*> htmlR
let v = [whamlet|
#{extra}

<div.form-field.mdc-form-field data-mdc-auto-init=MDCFormField style="line-height:4;display:flex;flex-direction:row">
^{fvInput showScheduleV}
$with selected <- fromMaybe False ((contactUsShowSchedule . entityVal) <$> e)
<button.mdc-switch type=button role=switch #switchShowSchedule data-mdc-auto-init=MDCSwitch
:selected:.mdc-switch--selected :selected:aria-checked=true
:not selected:.mdc-switch--unselected :not selected:aria-checked=false
onclick="document.getElementById('#{fvId showScheduleV}').checked = !this.MDCSwitch.selected">
<div.mdc-switch__track>
<div.mdc-switch__handle-track>
<div.mdc-switch__handle>
<div.mdc-switch__shadow>
<div.mdc-elevation-overlay>
<div.mdc-switch__ripple>
<div.mdc-switch__icons>
<svg.mdc-switch__icon.mdc-switch__icon--on viewBox="0 0 24 24">
<path d="M19.69,5.23L8.96,15.96l-4.23-4.23L2.96,13.5l6,6L21.46,7L19.69,5.23z">
<svg.mdc-switch__icon.mdc-switch__icon--off viewBox="0 0 24 24">
<path d="M20 13H4v-2h16v2z">

<span.mdc-switch__focus-ring-wrapper>
<span.mdc-switch__focus-ring>
<label for=switchShowSchedule>_{MsgShowSchedule}

<div.form-field>
<label.mdc-text-field.mdc-text-field--filled.mdc-text-field--textarea data-mdc-auto-init=MDCTextField
:isJust (fvErrors htmlV):.mdc-text-field--invalid>
Expand Down
3 changes: 2 additions & 1 deletion src/Demo/DemoDataEN.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import Model
, businessHoursClose, businessHoursDayType
)
, AboutUs (AboutUs, aboutUsBusiness, aboutUsHtml)
, ContactUs (ContactUs, contactUsBusiness, contactUsHtml)
, ContactUs (ContactUs, contactUsBusiness, contactUsShowSchedule, contactUsHtml)
, DayType (Weekday, Holiday)
)

Expand Down Expand Up @@ -131,6 +131,7 @@ populateEN = do
}

insert_ $ ContactUs { contactUsBusiness = b
, contactUsShowSchedule = True
, contactUsHtml = [shamlet|
<section style="margin:0 1rem">
<h3 style="color:gray">Call Us
Expand Down
3 changes: 2 additions & 1 deletion src/Demo/DemoDataFR.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import Model
, businessHoursClose, businessHoursDayType
)
, AboutUs (AboutUs, aboutUsBusiness, aboutUsHtml)
, ContactUs (ContactUs, contactUsBusiness, contactUsHtml)
, ContactUs (ContactUs, contactUsBusiness, contactUsShowSchedule, contactUsHtml)
, DayType (Weekday, Holiday)
)
import Data.FileEmbed (embedFile)
Expand Down Expand Up @@ -130,6 +130,7 @@ populateFR = do
}

insert_ $ ContactUs { contactUsBusiness = b
, contactUsShowSchedule = True
, contactUsHtml = [shamlet|
<section style="margin:0 1rem">
<h3 style="color:gray">Appelez-nous
Expand Down
3 changes: 2 additions & 1 deletion src/Demo/DemoDataRO.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import Model
, businessHoursClose, businessHoursDayType
)
, AboutUs (AboutUs, aboutUsBusiness, aboutUsHtml)
, ContactUs (ContactUs, contactUsBusiness, contactUsHtml)
, ContactUs (ContactUs, contactUsBusiness, contactUsShowSchedule, contactUsHtml)
, DayType (Weekday, Holiday)
)
import Data.FileEmbed (embedFile)
Expand Down Expand Up @@ -130,6 +130,7 @@ populateRO = do
}

insert_ $ ContactUs { contactUsBusiness = b
, contactUsShowSchedule = True
, contactUsHtml = [shamlet|
<section style="margin:0 1rem">
<h3 style="color:gray">Sunați-ne
Expand Down
3 changes: 2 additions & 1 deletion src/Demo/DemoDataRU.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import Model
, businessHoursClose, businessHoursDayType
)
, AboutUs (AboutUs, aboutUsBusiness, aboutUsHtml)
, ContactUs (ContactUs, contactUsBusiness, contactUsHtml)
, ContactUs (ContactUs, contactUsBusiness, contactUsShowSchedule, contactUsHtml)
, DayType (Weekday, Holiday)
)
import Data.FileEmbed (embedFile)
Expand Down Expand Up @@ -125,6 +125,7 @@ populateRU = do
}

insert_ $ ContactUs { contactUsBusiness = b
, contactUsShowSchedule = True
, contactUsHtml = [shamlet|
<section style="margin:0 1rem">
<h3 style="color:gray">Звоните нам
Expand Down
2 changes: 1 addition & 1 deletion src/Handler/Stats.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ import Foundation
)
, AppMessage
( MsgPopularOffers, MsgUserProfile, MsgPhoto, MsgNavigationMenu, MsgLogin
, MsgNoDataToDisplay, MsgService, MsgBookings, MsgNumberSign, MsgWorkload
, MsgNoDataToDisplay, MsgOffer, MsgBookings, MsgNumberSign, MsgWorkload
, MsgSelect, MsgCancel, MsgPeriod, MsgBetweenFrom, MsgBetweenTo, MsgBack
, MsgInvalidFormData, MsgInvalidTimeInterval, MsgNoDataFound, MsgMon
, MsgTue, MsgWed, MsgThu, MsgFri, MsgSat, MsgSun, MsgTotalBookedTime
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/business/contact/contacts.hamlet
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<main.mdc-top-app-bar--fixed-adjust>
<div.mdc-top-app-bar--fixed-adjust>

$maybe Entity _ (ContactUs _ html) <- info
$maybe Entity _ (ContactUs _ _ html) <- info
^{html}
$nothing
<figure style="text-align:center">
Expand Down
2 changes: 1 addition & 1 deletion templates/appointments/appointment.hamlet
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
<figcaption>
<small>(_{MsgUnassigned})

$maybe Entity _ (ContactUs _ html) <- location
$maybe Entity _ (ContactUs _ _ html) <- location
<details.mdc-list.mdc-card-wrapper__text-section
ontoggle="this.querySelector('summary i.expand').textContent = this.open ? 'expand_less' : 'expand_more'">
<summary.mdc-list-item.mdc-list-item--with-leading-icon.mdc-list-item--with-one-line
Expand Down
2 changes: 1 addition & 1 deletion templates/contacts/contact.hamlet
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


<main.mdc-top-app-bar--prominent-fixed-adjust>
$maybe Entity _ (ContactUs _ html) <- contacts
$maybe Entity _ (ContactUs _ _ html) <- contacts
^{html}
$nothing
<figure style="text-align:center">
Expand Down
2 changes: 1 addition & 1 deletion templates/requests/request.hamlet
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
<div>
<small>(_{MsgCustomer})

$maybe Entity _ (ContactUs _ html) <- location
$maybe Entity _ (ContactUs _ _ html) <- location
<details.mdc-list.mdc-card-wrapper__text-section
ontoggle="this.querySelector('summary i.expand').textContent = this.open ? 'expand_less' : 'expand_more'">
<summary.mdc-list-item.mdc-list-item--with-leading-icon
Expand Down
8 changes: 4 additions & 4 deletions templates/stats/offers/pop.hamlet
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<span.mdc-icon-button__ripple>
<span.mdc-icon-button__focus-ring>
<i.material-symbols-outlined>sort

$if null offers
<figure style="text-align:center">
<span style="font-size:4rem;line-eight:1;color:var(--mdc-theme-primary)">&varnothing;
Expand All @@ -63,7 +63,7 @@
<th.mdc-data-table__header-cell role=columnheader scope=col>
_{MsgNumberSign}
<th.mdc-data-table__header-cell role=columnheader scope=col>
_{MsgService}
_{MsgOffer}
<th.mdc-data-table__header-cell.mdc-data-table__header-cell--numeric role=columnheader scope=col>
_{MsgBookings}
<tbody.mdc-data-table__cotent>
Expand All @@ -84,7 +84,7 @@
action=@{StatsR PopOffersR}>
^{fw}
<input type=text name=sort value=#{pack $ show sort} hidden>

<div.mdc-dialog__actions>
<button.mdc-button type=button data-mdc-dialog-action=cancel>
<span.mdc-button__ripple>
Expand All @@ -94,5 +94,5 @@
<span.mdc-button__ripple>
<span.mdc-button__focus-ring>
<span.mdc-button__label>_{MsgSelect}

<div.mdc-dialog__scrim>

0 comments on commit 1dac3ab

Please sign in to comment.