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

Search by name #23

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Search by name #23

wants to merge 3 commits into from

Conversation

Divoolej
Copy link
Contributor

Add a simple filtering functionality

@Divoolej Divoolej requested review from olgad0110 and kamil89 June 19, 2018 13:24
defp fetch_assets(page) do
Sejfguru.Assets.list_assets_with_users(page: page)
defp fetch_assets(page, query) do
if query do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be done by pattern matching in function, which I think is more elixir style than using conditions ;)

defp fetch_assets(page, %{} = query), do: Sejfguru.Assets.filter_assets_with_users(query: query, page: page)
defp fetch_assets(page, nil), do: Sejfguru.Assets.list_assets_with_users(page: page)

@@ -1,4 +1,10 @@
<div class="container">
<%= form_for @conn, asset_path(@conn, :index), [method: :get, class: "navbar-form navbar-left search"], fn f-> %>
<div class="form-group">
<input type="text" name="search" class="form-control" placeholder="Search">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use form helpers for generating text input and button? https://hexdocs.pm/phoenix_html/Phoenix.HTML.Form.html#module-with-connection-data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants