-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[patch] EHealth-249: refactored list filter by ids, added ids params …
…for employees and divisions
- Loading branch information
1 parent
8970fac
commit 03da4a9
Showing
11 changed files
with
95 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
defmodule PRM.CommaParamsUUID do | ||
@moduledoc false | ||
|
||
@behaviour Ecto.Type | ||
|
||
alias Ecto.UUID | ||
|
||
def type, do: :string | ||
|
||
def cast(string) when is_binary(string) do | ||
string | ||
|> String.split(",") | ||
|> valid_uuid_params?() | ||
|> case do | ||
true -> {:ok, string} | ||
false -> :error | ||
end | ||
end | ||
|
||
def cast(_), do: :error | ||
|
||
def load(string) when is_binary(string), do: {:ok, string} | ||
|
||
def dump(string) when is_binary(string), do: {:ok, string} | ||
def dump(_), do: :error | ||
|
||
def valid_uuid_params?(comma_params) do | ||
Enum.reduce_while(comma_params, true, fn (i, acc) -> | ||
case UUID.cast(i) do | ||
{:ok, _} -> {:cont, acc} | ||
_ -> {:halt, false} | ||
end | ||
end) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters