Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove automatic formatting of integer values #541

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion demo/lib/demo_web/live/post_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,12 @@ defmodule DemoWeb.PostLive do
_assigns ->
true
end,
searchable: true
searchable: true,
render: fn assigns ->
~H"""
<p><%= Number.Delimit.number_to_delimited(@value, precision: 0, delimiter: ".") %></p>
"""
end
},
user: %{
module: Backpex.Fields.BelongsTo,
Expand Down
5 changes: 5 additions & 0 deletions demo/lib/demo_web/live/product_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ defmodule DemoWeb.ProductLive do

error ->
error
end,
render: fn assigns ->
~H"""
<p><%= Number.Delimit.number_to_delimited(@value, precision: 0, delimiter: ".") %></p>
"""
end
},
price: %{
Expand Down
5 changes: 1 addition & 4 deletions lib/backpex/html/html.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defmodule Backpex.HTML do
"—"

iex> Backpex.HTML.pretty_value(1_000_000)
"1.000.000"
1000000

iex> Backpex.HTML.pretty_value(1.11)
1.11
Expand All @@ -27,8 +27,5 @@ defmodule Backpex.HTML do

def pretty_value(""), do: "—"

def pretty_value(input) when is_integer(input),
do: Number.Delimit.number_to_delimited(input, precision: 0, delimiter: ".")

def pretty_value(input), do: input
end