From ecccb06f734a71abb761c16a9ab8a163a697e877 Mon Sep 17 00:00:00 2001 From: Rogerio Pontual <44991200+jyeshe@users.noreply.github.com> Date: Sun, 3 Dec 2023 12:43:37 +0000 Subject: [PATCH] Use checkbox on boolean credential fields (#1513) * Use checkbox on boolean credential fields * Changelog --- CHANGELOG.md | 9 ++- .../json_schema_body_component.ex | 67 +++++++++++-------- 2 files changed, 45 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 334e92824c..b9d7030965 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ and this project adheres to ### Fixed +- Use checkbox on boolean credential fields + [#1430](https://github.com/OpenFn/Lightning/issues/1430) + ## [v0.10.5] - 2023-12-03 ### Added @@ -22,11 +25,11 @@ and this project adheres to - Only add history page filters when needed for simpler multi-select status interface and shorter page URLs - [#1331](https://github.com/OpenFn/Lightning/pull/1331) + [#1331](https://github.com/OpenFn/Lightning/issues/1331) - Use dynamic Endpoint config only on prod - [#1494](https://github.com/OpenFn/Lightning/pull/1494) + [#1435](https://github.com/OpenFn/Lightning/issues/1435) - Validate schema field with any of expected values - [#1502](https://github.com/OpenFn/Lightning/pull/1502) + [#1502](https://github.com/OpenFn/Lightning/issues/1502) ### Fixed diff --git a/lib/lightning_web/live/credential_live/json_schema_body_component.ex b/lib/lightning_web/live/credential_live/json_schema_body_component.ex index be905a8dbf..6984de5eef 100644 --- a/lib/lightning_web/live/credential_live/json_schema_body_component.ex +++ b/lib/lightning_web/live/credential_live/json_schema_body_component.ex @@ -87,7 +87,7 @@ defmodule LightningWeb.CredentialLive.JsonSchemaBodyComponent do %{"type" => "string", "writeOnly" => true} -> :password_input %{"type" => "string"} -> :text_input %{"type" => "integer"} -> :text_input - %{"type" => "boolean"} -> :text_input + %{"type" => "boolean"} -> :checkbox %{"anyOf" => [%{"type" => "string"}, %{"type" => "null"}]} -> :text_input end @@ -103,33 +103,44 @@ defmodule LightningWeb.CredentialLive.JsonSchemaBodyComponent do type: type ) - ~H""" - - - Required - -
- <%= apply(Phoenix.HTML.Form, @type, [ - @form, - @field, - [ - value: @value || "", - class: ~w(mt-1 focus:ring-primary-500 focus:border-primary-500 block - w-full shadow-sm sm:text-sm border-secondary-300 rounded-md) - ] - ]) %> - - <%= LightningWeb.Components.NewInputs.translate_error(error) %> + if type == :checkbox do + ~H""" + + """ + else + ~H""" + + + Required -
- """ +
+ <%= apply(Phoenix.HTML.Form, @type, [ + @form, + @field, + [ + value: @value || "", + class: ~w(mt-1 focus:ring-primary-500 focus:border-primary-500 block + w-full shadow-sm sm:text-sm border-secondary-300 rounded-md) + ] + ]) %> + + <%= LightningWeb.Components.NewInputs.translate_error(error) %> + +
+ """ + end end end