mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-20 06:37:59 +01:00
ensure commission items are sorted by price
This commit is contained in:
parent
5650f09bc0
commit
2e7937cbc3
2 changed files with 8 additions and 4 deletions
|
@ -16,13 +16,17 @@ defmodule PhilomenaWeb.Profile.CommissionController do
|
||||||
def show(conn, _params) do
|
def show(conn, _params) do
|
||||||
commission = conn.assigns.user.commission
|
commission = conn.assigns.user.commission
|
||||||
|
|
||||||
item_descriptions =
|
items =
|
||||||
commission.items
|
commission.items
|
||||||
|
|> Enum.sort(&Decimal.cmp(&1.base_price, &2.base_price) != :gt)
|
||||||
|
|
||||||
|
item_descriptions =
|
||||||
|
items
|
||||||
|> Enum.map(&%{body: &1.description })
|
|> Enum.map(&%{body: &1.description })
|
||||||
|> Renderer.render_collection(conn)
|
|> Renderer.render_collection(conn)
|
||||||
|
|
||||||
item_add_ons =
|
item_add_ons =
|
||||||
commission.items
|
items
|
||||||
|> Enum.map(&%{body: &1.add_ons})
|
|> Enum.map(&%{body: &1.add_ons})
|
||||||
|> Renderer.render_collection(conn)
|
|> Renderer.render_collection(conn)
|
||||||
|
|
||||||
|
@ -45,7 +49,7 @@ defmodule PhilomenaWeb.Profile.CommissionController do
|
||||||
will_not_create: will_not_create
|
will_not_create: will_not_create
|
||||||
}
|
}
|
||||||
|
|
||||||
items = Enum.zip([item_descriptions, item_add_ons, commission.items])
|
items = Enum.zip([item_descriptions, item_add_ons, items])
|
||||||
|
|
||||||
render(conn, "show.html", title: "Showing Commission", rendered: rendered, commission: commission, items: items, layout_class: "layout--wide")
|
render(conn, "show.html", title: "Showing Commission", rendered: rendered, commission: commission, items: items, layout_class: "layout--wide")
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ defmodule Textile.Parser do
|
||||||
def parse(parser, input) do
|
def parse(parser, input) do
|
||||||
parser = Map.put(parser, :state, %{})
|
parser = Map.put(parser, :state, %{})
|
||||||
|
|
||||||
with {:ok, tokens, _1, _2, _3, _4} <- Lexer.lex(String.trim(input)),
|
with {:ok, tokens, _1, _2, _3, _4} <- Lexer.lex(String.trim(input || "")),
|
||||||
{:ok, tree, []} <- repeat(&textile/2, parser, tokens)
|
{:ok, tree, []} <- repeat(&textile/2, parser, tokens)
|
||||||
do
|
do
|
||||||
partial_flatten(tree)
|
partial_flatten(tree)
|
||||||
|
|
Loading…
Reference in a new issue