summaryrefslogtreecommitdiff
path: root/Form
diff options
context:
space:
mode:
authorFélix Sipma <felix.sipma@no-log.org>2015-01-29 00:30:11 +0100
committerFélix Sipma <felix.sipma@no-log.org>2015-01-30 15:17:54 +0100
commitebca3f6e472ac35da8df087ad8f73d7e78391a43 (patch)
tree17d398c7c6a2fb1f23654e7693a90e6f06897195 /Form
parentb0c426bc619489be1eab29d698da4a671f2d51a0 (diff)
use ShopDelivery instead of Shop in Item
* modify config/models * renamed Handler.ShopDeliveryList to Handler.ShopShopDelivery * add Handler.ShopDelivery * add Handler.ShopDeliveryAdmin * Form.Item.FormItem: use ShopDeliveryId instead of ShopId * Widget.Item.itemAddWidget: use ShopDeliveryId instead of ShopId * add Handler.ShopPlaceDeliveryList * add corresponding routes * Handler.ItemEdit: use ShopDeliveryId instead of ShopId * Handler.ItemDelete: use ShopDeliveryId instead of ShopId * templates/item-add.hamlet: post form to ShopDeliveryAdminR * templates/shop-admin.hamlet: remove item part * templates/shop.hamlet: remove item part * templates/shopdelivery-add.hamlet: post form to ShopShopDeliveryR * add templates/shop-place-delivery-list-admin.{cassius,julius,hamlet} * add templates/shop-place-delivery-list.{cassius,julius,hamlet} * add templates/shopdelivery-admin.hamlet * add templates/shopdelivery.hamlet * Handler.Delivery, templates/delivery.hamlet: display shops * leaflet.julius common leaflet config: Handler.Delivery, templates/delivery.julius Handler.PlaceList, templates/place-list.julius Handler.Place, templates/place.julius * use ident map#{rawJS mapid} in leaflet julius files: templates/delivery.julius templates/place-list.julius templates/place.julius * fix deliveries query bug in Handler.Place * Handler.ShopAdmin: remove post, display placedeliveries instead of items (Handler.ShopDeliveryAdmin) * Handler.Shop: display placedeliveries instead of items (Handler.ShopDeliveryAdmin) * Widget.Shop: add shopPlaceDeliveryListWidget and shopPlaceDeliveryListAdminWidget * Foundation: modify ShopAdminR type * Handler.Cart: display shopdelivery information in cart * templates/cart.hamlet: add shopdelivery information * add Handler.ItemFormCart
Diffstat (limited to 'Form')
-rw-r--r--Form/Cart.hs4
-rw-r--r--Form/Item.hs8
-rw-r--r--Form/ShopDelivery.hs4
3 files changed, 8 insertions, 8 deletions
diff --git a/Form/Cart.hs b/Form/Cart.hs
index cdc192b..422f2f5 100644
--- a/Form/Cart.hs
+++ b/Form/Cart.hs
@@ -4,8 +4,6 @@ import Import
import Form.Fields.Quantity (cartField)
import Model.Quantity (Quantity (..))
-type ItemFormCart = (Key Item, Widget, Enctype)
-
-- | Render a form using Bootstrap-friendly shamlet syntax.
--
-- Sample Hamlet:
@@ -24,7 +22,7 @@ type ItemFormCart = (Key Item, Widget, Enctype)
renderCartBootstrap :: Entity Item
-> Quantity
-> Maybe CartItem
- -> FormRender (HandlerT App IO) a
+ -> FormRender Handler a
renderCartBootstrap (Entity itemid item) quantitymax mcitem aform fragment = do
(res, views') <- aFormToForm aform
let views = views' []
diff --git a/Form/Item.hs b/Form/Item.hs
index 899c836..629bc24 100644
--- a/Form/Item.hs
+++ b/Form/Item.hs
@@ -10,7 +10,7 @@ import Form.Fields.Quantity (quantityField)
data FormItem = FormItem
{ fiIdent :: Text
- , fiShopId :: ShopId
+ , fiShopDeliveryId :: ShopDeliveryId
, fiQuantity :: Quantity
, fiUnit :: Unit
, fiPrice :: Amount
@@ -21,12 +21,12 @@ data FormItem = FormItem
}
itemForm :: Maybe Item
- -> ShopId
+ -> ShopDeliveryId
-> Html
-> MForm Handler (FormResult FormItem, Widget)
-itemForm mitem shopid = renderBootstrap3 formLayout $ FormItem
+itemForm mitem shopdid = renderBootstrap3 formLayout $ FormItem
<$> areq textField (bfs MsgItemIdent) (itemIdent <$> mitem)
- <*> pure shopid
+ <*> pure shopdid
<*> areq quantityField (bfs MsgItemQuantity) (itemQuantity <$> mitem)
<*> areq (selectFieldList units) (bfs MsgItemUnit) (itemUnit <$> mitem)
<*> areq amountField (bfs MsgItemPrice) (itemPrice <$> mitem)
diff --git a/Form/ShopDelivery.hs b/Form/ShopDelivery.hs
index b4cd8fc..55ab744 100644
--- a/Form/ShopDelivery.hs
+++ b/Form/ShopDelivery.hs
@@ -22,10 +22,12 @@ shopDeliveryForm mshopid mdeliveryid = renderBootstrap3 formLayout $ FormShopDel
, entityKey shop))
entities
deliveries = do
+ now <- lift getCurrentTime
options <- runDB $
E.select $
E.from $ \(p, d) -> do
- E.where_ ( d E.^. DeliveryPlace E.==. p E.^. PlaceId
+ E.where_ ( d E.^. DeliveryPlace E.==. p E.^. PlaceId
+ E.&&. d E.^. DeliveryFrom E.>. E.val now
)
E.orderBy [ E.asc (p E.^. PlaceIdent)
, E.asc (d E.^. DeliveryFrom)