generated from coulomb/repo-seed
Int16→Int in score/stars functions; uuid-based readMay→UUID.fromText; autoRefresh do-notation fix; id→\x->x ambiguity in HubRoutingRules; MarketplaceDashboard replaced raw SQL with IHP query builder; optional hub selector in TypeRegistry views via CanSelect (Text, Maybe Id) instance added to Web.View.Prelude; import consolidations to Web.View.Prelude. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
43 lines
1.4 KiB
Haskell
43 lines
1.4 KiB
Haskell
module Web.View.WidgetOwnerships.New where
|
|
|
|
import Web.View.Prelude
|
|
import Web.Routes ()
|
|
|
|
data NewView = NewView
|
|
{ ownership :: !WidgetOwnership
|
|
, widgets :: ![Widget]
|
|
, hubs :: ![Hub]
|
|
}
|
|
|
|
instance View NewView where
|
|
html NewView { .. } = [hsx|
|
|
<div class="max-w-lg">
|
|
<h1 class="text-2xl font-semibold mb-6">Assign Ownership</h1>
|
|
{renderForm ownership widgets hubs}
|
|
</div>
|
|
|]
|
|
|
|
renderForm :: WidgetOwnership -> [Widget] -> [Hub] -> Html
|
|
renderForm ownership widgets hubs = formFor ownership [hsx|
|
|
{(selectField #widgetId (map (\w -> (w.name, w.id)) widgets)) { fieldLabel = "Widget" }}
|
|
{(selectField #ownerHubId (map (\h -> (h.name, h.id)) hubs)) { fieldLabel = "Owner Hub" }}
|
|
<div>
|
|
<label class="ihp-form-label">Steward Hub (optional)</label>
|
|
<select name="stewardHubId" class="ihp-form-field">
|
|
<option value="">— None —</option>
|
|
{forEach hubs renderHubOption}
|
|
</select>
|
|
</div>
|
|
{(selectField #ownershipType ownershipTypes){ fieldLabel = "Ownership Type" }}
|
|
{dateTimeField #effectiveFrom}
|
|
{dateTimeField #effectiveUntil}
|
|
{textareaField #notes}
|
|
{submitButton}
|
|
|]
|
|
where
|
|
ownershipTypes :: [(Text, Text)]
|
|
ownershipTypes = [("local","local"), ("delegated","delegated"), ("global","global")]
|
|
|
|
renderHubOption :: Hub -> Html
|
|
renderHubOption h = [hsx|<option value={tshow h.id}>{h.name}</option>|]
|