Textareas for TXT records.

beta
Philippe Pittoli 2023-07-15 17:53:36 +02:00
parent 3e358f04fc
commit 6705d29dba
3 changed files with 23 additions and 7 deletions

View File

@ -667,18 +667,14 @@ render_soa (Just soa) = Bulma.box [ Bulma.zone_rr_title "Start Of Authority (SOA
render_records :: forall (w :: Type). Hash.HashMap RRId Validation.Errors -> Array (SimpleRR ()) -> HH.HTML w Action
render_records _ []
= Bulma.box [ Bulma.zone_rr_title "NS, A, AAAA, CNAME"
, Bulma.subtitle "and TXT records"
= Bulma.box [ Bulma.zone_rr_title $ S.joinWith ", " baseRecords
, Bulma.subtitle "No records for now"
]
render_records errors records
= Bulma.box [ Bulma.zone_rr_title title_txt
, Bulma.subtitle subtitle_txt
= Bulma.box [ Bulma.zone_rr_title $ S.joinWith ", " baseRecords
, table_rr
]
where
title_txt = "NS, A, AAAA, CNAME"
subtitle_txt = "and TXT records"
-- subtitle_txt = "Each line is a resource record from your DNS zone."
-- <> " You can edit them, then click on the \"fix\" button to synchronize with the server."
table_rr = Bulma.table [] [ Bulma.simple_table_header, table_content ]
@ -689,7 +685,10 @@ render_records errors records
[ Bulma.txt_name rr.rrtype
, HH.td_ [ Bulma.input_domain ((UpdateLocalForm rr.rrid) <<< Update_Local_Form_SRR <<< Update_SRR_Domain) rr.name rr.valid ]
, HH.td_ [ Bulma.input_ttl ((UpdateLocalForm rr.rrid) <<< Update_Local_Form_SRR <<< Update_SRR_TTL ) rr.ttl rr.valid ]
, HH.td_ [ Bulma.input_target ((UpdateLocalForm rr.rrid) <<< Update_Local_Form_SRR <<< Update_SRR_Target) rr.target rr.valid ]
, HH.td_ [ case rr.rrtype of
"TXT" -> Bulma.textarea ((UpdateLocalForm rr.rrid) <<< Update_Local_Form_SRR <<< Update_SRR_Target) rr.target rr.valid
_ -> Bulma.input_target ((UpdateLocalForm rr.rrid) <<< Update_Local_Form_SRR <<< Update_SRR_Target) rr.target rr.valid
]
, HH.td_ [ Bulma.btn_change (SaveSRR rr.rrid) (TellSomethingWentWrong rr.rrid "cannot update") rr.modified rr.valid ]
, HH.td_ [ Bulma.btn_delete (\_ -> DeleteRRModal rr.rrid) ]
]

View File

@ -203,6 +203,21 @@ box_input_protocol action value validity = HH.label [ ]
, HH.div [HP.classes C.control ] [ input_protocol action value validity ]
]
-- | For textareas I don't use Bulma's "textarea" class since it doesn't allow to expand
-- | textareas horizontaly, which makes edition of TXT records painful.
textarea_classes :: Boolean -> Array HH.ClassName
textarea_classes true = C.input <> C.is_small <> C.is_info
textarea_classes false = C.input <> C.is_small <> C.is_danger
textarea :: forall w i. (String -> i) -> String -> Boolean -> HH.HTML w i
textarea action value validity
= HH.textarea
[ HE.onValueInput action
, HP.value value
, HP.placeholder "target"
, HP.classes $ textarea_classes validity
]
input_target :: forall w i. (String -> i) -> String -> Boolean -> HH.HTML w i
input_target action value validity
= HH.input

View File

@ -118,6 +118,8 @@ subtitle :: Array HH.ClassName
subtitle = [HH.ClassName "subtitle"]
table :: Array HH.ClassName
table = [HH.ClassName "table"]
textarea :: Array HH.ClassName
textarea = [HH.ClassName "textarea"]
tile :: Array HH.ClassName
tile = [HH.ClassName "tile"]
title :: Array HH.ClassName