module Web.View.Items.New where
import Web.View.Prelude
import Text.Blaze.Html.Renderer.Text
data NewView = NewView { item :: Include "tags" Item }
instance View NewView where
html NewView { .. } = [hsx|
{breadcrumb}
New Item
{renderForm item}
|]
where
breadcrumb = renderBreadcrumb
[ breadcrumbLink "Items" ItemsAction
, breadcrumbText "New Item"
]
renderForm :: Include "tags" Item -> Html
renderForm item = formFor item [hsx|
{textField #wikidataId}
{textField #description}
{submitButton}
|]
prototypeFor :: _ => _ -> _ -> Text
prototypeFor field record =
cs $ renderHtml prototype
where
parentFormContext = ?formContext
prototype :: Html
prototype = let ?formContext = parentFormContext { model = parentFormContext.model |> set field [record] } in nestedFormFor field renderTagForm
renderTagForm :: (?formContext :: FormContext Tag) => Html
renderTagForm = [hsx|
{(textField #name) { disableLabel = True, placeholder = "Tag name" } }
{(textField #value) { disableLabel = True, placeholder = "Tag value" } }
|]