@@ -49,7 +49,14 @@ data AbstractTypeForm =
4949 , abstractTypeFormDuration :: Word64
5050 } deriving Show
5151
52- mkAbstractTypeForm :: Maybe Text -> Maybe Int -> Form AbstractTypeForm
52+ -- TODO have this function take abstract type and make a form for editing
53+ -- not sure if this should include the ID(?) probably not
54+ -- - seems like the id is not used in the "new" form
55+ -- so we don't need Entitity AbsTyp, only AbsTyp
56+ mkAbstractTypeForm' :: AbstractType -> Form AbstractTypeForm
57+ mkAbstractTypeForm' at = mkAbstractTypeForm (Just $ abstractTypeName at) (Just $ (unpackTalkDuration . abstractTypeDuration) at)
58+
59+ mkAbstractTypeForm :: Maybe Text -> Maybe Word64 -> Form AbstractTypeForm
5360mkAbstractTypeForm atName atDuration =
5461 renderDivs $
5562 AbstractTypeForm
@@ -91,6 +98,27 @@ renderConferenceAbstractTypes conf@(Entity conferenceId _)
9198 <li>^{renderAbstractTypeEdit conferenceId abstractType}
9299 |]
93100
101+ renderConferenceAbstractType ::
102+ Entity Conference
103+ -> Entity AbstractType
104+ -> Widget
105+ -> Handler Html
106+ renderConferenceAbstractType conf@ (Entity conferenceId _)
107+ abstractType@ (Entity abstractTypeId _) abstractTypeFormWidget = do
108+ baseLayout Nothing $ do
109+ setTitle " Conference Abstract Type"
110+ [whamlet |
111+ <article .grid-container>
112+ <div .medium-3 .cell>
113+ ^{renderConferenceWidget conf}
114+ <div .medium-3 .cell>
115+ <h1> Edit abstract type
116+ <div>
117+ <form method="POST" action=@{ConferenceAbstractTypeR conferenceId abstractTypeId }>
118+ ^{abstractTypeFormWidget}
119+ <input .button type="submit" value="Create">
120+ |]
121+
94122getConferenceAbstractTypesR :: ConferenceId -> Handler Html
95123getConferenceAbstractTypesR conferenceId = do
96124 (_, _, _, conference) <-
@@ -114,28 +142,34 @@ postConferenceAbstractTypesR conferenceId = do
114142 renderConferenceAbstractTypes conference abstractTypes abstractTypeFormWidget
115143 _ -> error " bluhhh"
116144
145+ -- TODO finish making this handler
117146getConferenceAbstractTypeR :: ConferenceId -> AbstractTypeId -> Handler Html
118147getConferenceAbstractTypeR conferenceId abstractTypeId = do
119- -- (_, _, _, conference) <-
120- -- requireOwnerForConference conferenceId
121- abstractType <- runDB $ getAbstractType abstractTypeId
122- (abstractTypeFormWidget, _) <- generateFormPost abstractTypeForm
123- renderConferenceAbstractTypes conference abstractTypes abstractTypeFormWidget
124-
125- postConferenceAbstractTypeR :: ConferenceId -> AbstractTypeId -> Handler Html
126- postConferenceAbstractTypeR conferenceId abstractTypeId = do
127148 (_, _, _, conference) <-
128149 requireOwnerForConference conferenceId
129- ((result, abstractTypeFormWidget), _) <- runFormPost abstractTypeForm
130- case result of
131- FormSuccess (AbstractTypeForm name duration) -> do
132- abstractTypes <- runDB $ do
133- void $
134- insertEntity $
135- AbstractType (entityKey conference) name (makeTalkDuration duration)
136- getAbstractTypes (entityKey conference)
137- renderConferenceAbstractTypes conference abstractTypes abstractTypeFormWidget
138- _ -> error " bluhhh"
150+ abstractType <- runDBOr404 $ getAbstractTypeByConferenceAndId conferenceId abstractTypeId
151+ (abstractTypeFormWidget, _) <- generateFormPost (mkAbstractTypeForm' (entityVal abstractType))
152+ renderConferenceAbstractType conference abstractType abstractTypeFormWidget
153+
154+
155+ -- TODO make this after building the form
156+ postConferenceAbstractTypeR :: ConferenceId -> AbstractTypeId -> Handler Html
157+ postConferenceAbstractTypeR conferenceId abstractTypeId = undefined
158+
159+ -- postConferenceAbstractTypeR :: ConferenceId -> AbstractTypeId -> Handler Html
160+ -- postConferenceAbstractTypeR conferenceId abstractTypeId = do
161+ -- (_, _, _, conference) <-
162+ -- requireOwnerForConference conferenceId
163+ -- ((result, abstractTypeFormWidget), _) <- runFormPost abstractTypeForm
164+ -- case result of
165+ -- FormSuccess (AbstractTypeForm name duration) -> do
166+ -- abstractTypes <- runDB $ do
167+ -- void $
168+ -- insertEntity $
169+ -- AbstractType (entityKey conference) name (makeTalkDuration duration)
170+ -- getAbstractTypes (entityKey conference)
171+ -- renderConferenceAbstractTypes conference abstractTypes abstractTypeFormWidget
172+ -- _ -> error "bluhhh"
139173
140174renderAbstractTypeEdit :: ConferenceId -> Entity AbstractType -> Widget
141175renderAbstractTypeEdit confId (Entity atId (AbstractType _ name td)) =
0 commit comments