Skip to content

Commit

Permalink
Use checkbox on boolean credential fields (#1513)
Browse files Browse the repository at this point in the history
* Use checkbox on boolean credential fields

* Changelog
  • Loading branch information
jyeshe authored Dec 3, 2023
1 parent 2fb3d25 commit ecccb06
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 31 deletions.
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -103,33 +103,44 @@ defmodule LightningWeb.CredentialLive.JsonSchemaBodyComponent do
type: type
)

~H"""
<LightningWeb.Components.Form.label_field
form={@form}
field={@field}
title={@title}
/>
<span :if={@required} class="text-sm text-secondary-700 text-right">
Required
</span>
<div class="col-span-2">
<%= 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)
]
]) %>
<span
:for={error <- @errors}
phx-feedback_for={Phoenix.HTML.Form.input_id(@form, @field)}
class="block w-full text-sm text-secondary-700"
>
<%= LightningWeb.Components.NewInputs.translate_error(error) %>
if type == :checkbox do
~H"""
<LightningWeb.Components.Form.check_box
form={@form}
field={@field}
label={@title}
value={@value}
/>
"""
else
~H"""
<LightningWeb.Components.Form.label_field
form={@form}
field={@field}
title={@title}
/>
<span :if={@required} class="text-sm text-secondary-700 text-right">
Required
</span>
</div>
"""
<div class="col-span-2">
<%= 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)
]
]) %>
<span
:for={error <- @errors}
phx-feedback_for={Phoenix.HTML.Form.input_id(@form, @field)}
class="block w-full text-sm text-secondary-700"
>
<%= LightningWeb.Components.NewInputs.translate_error(error) %>
</span>
</div>
"""
end
end
end

0 comments on commit ecccb06

Please sign in to comment.