module IHP.IDE.SchemaDesigner.View.Enums.Edit where

import IHP.ViewPrelude
import IHP.IDE.SchemaDesigner.Types
import IHP.IDE.ToolServer.Types
import IHP.IDE.SchemaDesigner.View.Layout

data EditEnumView = EditEnumView
    { EditEnumView -> [Statement]
statements :: [Statement]
    , EditEnumView -> Text
enumName :: Text
    , EditEnumView -> Int
enumId :: Int
    }

instance View EditEnumView where
    html :: EditEnumView -> Html
html EditEnumView { Int
[Statement]
Text
enumId :: Int
enumName :: Text
statements :: [Statement]
$sel:enumId:EditEnumView :: EditEnumView -> Int
$sel:enumName:EditEnumView :: EditEnumView -> Text
$sel:statements:EditEnumView :: EditEnumView -> [Statement]
.. } = [hsx|
        <div class="row no-gutters bg-white" id="schema-designer-viewer">
            {renderObjectSelector (zip [0..] statements) Nothing}
            {emptyColumnSelectorContainer}
        </div>
        {migrationStatus}
        {renderModal modal}
    |]
        where
            modalContent :: Html
modalContent = [hsx|
                <form method="POST" action={UpdateEnumAction}>
                    <input type="hidden" name="enumId" value={tshow enumId}/>
                    <div class="form-group row">
                        <label class="col-sm-2 col-form-label">Name:</label>
                        <div class="col-sm-10">
                            <input id="nameInput" name="enumName" type="text" class="form-control" autofocus="autofocus" value={enumName}/>
                        </div>
                    </div>

                    <div class="text-right">
                        <button type="submit" class="btn btn-primary">Edit Table</button>
                    </div>
                </form>
            |]
            modalFooter :: Maybe Html
modalFooter = Maybe Html
forall a. Monoid a => a
mempty 
            modalCloseUrl :: Text
modalCloseUrl = TablesController -> Text
forall controller. HasPath controller => controller -> Text
pathTo TablesController
TablesAction
            modalTitle :: Text
modalTitle = Text
"Edit Enum"
            modal :: Modal
modal = Modal :: Html -> Maybe Html -> Text -> Text -> Modal
Modal { Html
$sel:modalContent:Modal :: Html
modalContent :: Html
modalContent, Maybe Html
$sel:modalFooter:Modal :: Maybe Html
modalFooter :: Maybe Html
modalFooter, Text
$sel:modalCloseUrl:Modal :: Text
modalCloseUrl :: Text
modalCloseUrl, Text
$sel:modalTitle:Modal :: Text
modalTitle :: Text
modalTitle }