Last active
January 4, 2017 11:28
-
-
Save acrolink/dba8a0a5e62dc49ee3c95d81e5139443 to your computer and use it in GitHub Desktop.
Revisions
-
acrolink revised this gist
Jan 4, 2017 . 1 changed file with 8 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,21 +1,19 @@ .. def index(conn, _params) do page = Policy |> QueryFilter.filter(%Policy{}, _params, [:client_id]) |> join(:left, [p], c in Client, p.client_id == c.id) |> where([p, c], c.user_id == ^conn.assigns.current_user.id) |> preload([p, c], [client: c]) |> Repo.paginate(_params) render conn, :index, policies: page.entries, page_number: page.page_number, page_size: page.page_size, total_pages: page.total_pages, total_entries: page.total_entries, page: page, end .. -
acrolink created this gist
Jan 4, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ <h2>Listing policies</h2> <form action="/policies" method="get"> <%= select nil, :client_id, @clients, name: 'client_id' %> <input type="submit" value="Submit"> </form> <%= pagination_links @page %> <!-- HTML displaying the data rows --> This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ .. def index(conn, _params) do page = Policy |> QueryFilter.filter(%Policy{}, _params, [:client_id]) |> join(:left, [p], c in Client, p.client_id == c.id) |> where([p, c], c.user_id == ^conn.assigns.current_user.id) |> preload([p, c], [client: c]) |> Repo.paginate(_params) render conn, :index, policies: page.entries, page_number: page.page_number, page_size: page.page_size, total_pages: page.total_pages, total_entries: page.total_entries, page: page, end ..