From 6705d29dbac6e2f41206444e123767961514a58d Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Sat, 15 Jul 2023 17:53:36 +0200 Subject: [PATCH] Textareas for TXT records. --- src/App/ZoneInterface.purs | 13 ++++++------- src/Bulma.purs | 15 +++++++++++++++ src/CSSClasses.purs | 2 ++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/App/ZoneInterface.purs b/src/App/ZoneInterface.purs index 8486482..e5fc062 100644 --- a/src/App/ZoneInterface.purs +++ b/src/App/ZoneInterface.purs @@ -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) ] ] diff --git a/src/Bulma.purs b/src/Bulma.purs index 04eef77..5cec5cf 100644 --- a/src/Bulma.purs +++ b/src/Bulma.purs @@ -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 diff --git a/src/CSSClasses.purs b/src/CSSClasses.purs index 1383d90..2ebd9cf 100644 --- a/src/CSSClasses.purs +++ b/src/CSSClasses.purs @@ -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