generated from coulomb/repo-seed
feat(T02-T11): IHF Phase 1 schema, controllers, views, and helpers
- Schema: hubs, widgets, widget_versions, interaction_events (append-only trigger), annotations, users — single migration file - Web layer: Types, Routes, FrontController with auth + AutoRefresh layout - Controllers: Hubs (CRUD), Widgets (CRUD + versioning), InteractionEvents (JSON capture, canonical event_type validation), Annotations (threaded, append-only) - Sessions controller for IHP auth - Views: Hubs (index/show/new/edit), Widgets (index/show/new/edit), Annotations (index/new), Sessions (login) - widgetEnvelope helper with full data-* governance attributes - Integration tests: Hub CRUD, Widget versioning, event capture, append-only guard, annotation threading, validation Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
59
Web/View/Widgets/New.hs
Normal file
59
Web/View/Widgets/New.hs
Normal file
@@ -0,0 +1,59 @@
|
||||
module Web.View.Widgets.New where
|
||||
|
||||
import Web.Types
|
||||
import Generated.Types
|
||||
import IHP.Prelude
|
||||
import IHP.ViewPrelude
|
||||
|
||||
data NewView = NewView
|
||||
{ widget :: !Widget
|
||||
, hubs :: ![Hub]
|
||||
}
|
||||
|
||||
instance View NewView where
|
||||
html NewView { .. } = [hsx|
|
||||
<div class="max-w-lg">
|
||||
<h1 class="text-2xl font-semibold mb-6">Register Widget</h1>
|
||||
{renderForm widget hubs}
|
||||
</div>
|
||||
|]
|
||||
|
||||
renderForm :: Widget -> [Hub] -> Html
|
||||
renderForm widget hubs = formFor widget [hsx|
|
||||
{textField #name}
|
||||
{selectField #widgetType widgetTypeOptions}
|
||||
{selectField #hubId (hubOptions hubs)}
|
||||
{textField #capabilityRef}
|
||||
{textField #viewContext}
|
||||
{selectField #policyScope policyScopeOptions}
|
||||
{selectField #status statusOptions}
|
||||
{submitButton}
|
||||
|]
|
||||
|
||||
hubOptions :: [Hub] -> [(Text, Id Hub)]
|
||||
hubOptions hubs = map (\h -> (h.name, h.id)) hubs
|
||||
|
||||
widgetTypeOptions :: [(Text, Text)]
|
||||
widgetTypeOptions =
|
||||
[ ("Chart", "chart")
|
||||
, ("Form", "form")
|
||||
, ("Table", "table")
|
||||
, ("Action", "action")
|
||||
, ("Panel", "panel")
|
||||
, ("Navigation", "nav")
|
||||
, ("Other", "other")
|
||||
]
|
||||
|
||||
policyScopeOptions :: [(Text, Text)]
|
||||
policyScopeOptions =
|
||||
[ ("Internal", "internal")
|
||||
, ("Hub", "hub")
|
||||
, ("Public", "public")
|
||||
]
|
||||
|
||||
statusOptions :: [(Text, Text)]
|
||||
statusOptions =
|
||||
[ ("Active", "active")
|
||||
, ("Deprecated", "deprecated")
|
||||
, ("Draft", "draft")
|
||||
]
|
||||
Reference in New Issue
Block a user