mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-20 06:37:59 +01:00
add show view
This commit is contained in:
parent
d02390d847
commit
7c68e5d033
6 changed files with 187 additions and 2 deletions
|
@ -18,7 +18,7 @@ defmodule Philomena.Textile.Renderer do
|
||||||
parsed =
|
parsed =
|
||||||
posts
|
posts
|
||||||
|> Enum.map(fn post ->
|
|> Enum.map(fn post ->
|
||||||
Parser.parse(@parser, post.body)
|
Parser.parse(@parser, post[:body])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
images =
|
images =
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
defmodule PhilomenaWeb.CommissionController do
|
defmodule PhilomenaWeb.CommissionController do
|
||||||
use PhilomenaWeb, :controller
|
use PhilomenaWeb, :controller
|
||||||
|
|
||||||
|
alias Philomena.Textile.Renderer
|
||||||
alias Philomena.Commissions.{Item, Commission}
|
alias Philomena.Commissions.{Item, Commission}
|
||||||
alias Philomena.Repo
|
alias Philomena.Repo
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
|
||||||
plug PhilomenaWeb.FilterBannedUsersPlug when action in [:new, :create, :edit, :update, :destroy]
|
plug PhilomenaWeb.FilterBannedUsersPlug when action in [:new, :create, :edit, :update, :destroy]
|
||||||
plug :load_and_authorize_resource, model: Commission
|
plug :load_and_authorize_resource, model: Commission, preload: [sheet_image: :tags, user: [awards: :badge], items: [example_image: :tags]]
|
||||||
|
|
||||||
def index(conn, params) do
|
def index(conn, params) do
|
||||||
commissions =
|
commissions =
|
||||||
|
@ -16,6 +17,40 @@ defmodule PhilomenaWeb.CommissionController do
|
||||||
render(conn, "index.html", commissions: commissions, layout_class: "layout--wide")
|
render(conn, "index.html", commissions: commissions, layout_class: "layout--wide")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show(conn, _params) do
|
||||||
|
commission = conn.assigns.commission
|
||||||
|
|
||||||
|
item_descriptions =
|
||||||
|
commission.items
|
||||||
|
|> Enum.map(&[body: &1.description])
|
||||||
|
|> Renderer.render_collection()
|
||||||
|
|
||||||
|
item_add_ons =
|
||||||
|
commission.items
|
||||||
|
|> Enum.map(&[body: &1.add_ons])
|
||||||
|
|> Renderer.render_collection()
|
||||||
|
|
||||||
|
[information, contact, will_create, will_not_create] =
|
||||||
|
Renderer.render_collection([
|
||||||
|
[body: commission.information],
|
||||||
|
[body: commission.contact],
|
||||||
|
[body: commission.will_create],
|
||||||
|
[body: commission.will_not_create]
|
||||||
|
])
|
||||||
|
|
||||||
|
rendered =
|
||||||
|
%{
|
||||||
|
information: information,
|
||||||
|
contact: contact,
|
||||||
|
will_create: will_create,
|
||||||
|
will_not_create: will_not_create
|
||||||
|
}
|
||||||
|
|
||||||
|
items = Enum.zip([item_descriptions, item_add_ons, commission.items])
|
||||||
|
|
||||||
|
render(conn, "show.html", rendered: rendered, commission: conn.assigns.commission, items: items, layout_class: "layout--wide")
|
||||||
|
end
|
||||||
|
|
||||||
defp commission_search(attrs) when is_map(attrs) do
|
defp commission_search(attrs) when is_map(attrs) do
|
||||||
item_type = presence(attrs["item_type"])
|
item_type = presence(attrs["item_type"])
|
||||||
categories = presence(attrs["category"])
|
categories = presence(attrs["category"])
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
.block
|
||||||
|
.block__header
|
||||||
|
span.block__header__title Available Items and Prices
|
||||||
|
|
||||||
|
.block__content
|
||||||
|
table.table
|
||||||
|
thead
|
||||||
|
tr
|
||||||
|
th Example
|
||||||
|
th Description
|
||||||
|
th Base Price
|
||||||
|
th Add-Ons
|
||||||
|
tbody
|
||||||
|
= for {description, add_ons, item} <- @items do
|
||||||
|
tr
|
||||||
|
td
|
||||||
|
= if item.example_image do
|
||||||
|
= render PhilomenaWeb.ImageView, "_image_container.html", image: item.example_image, size: :thumb_small, conn: @conn
|
||||||
|
- else
|
||||||
|
| (No example)
|
||||||
|
|
||||||
|
td
|
||||||
|
strong
|
||||||
|
= item.item_type
|
||||||
|
|
||||||
|
br
|
||||||
|
br
|
||||||
|
|
||||||
|
== description
|
||||||
|
td
|
||||||
|
| $
|
||||||
|
= Decimal.round(item.base_price, 2)
|
||||||
|
|
||||||
|
td
|
||||||
|
== add_ons
|
|
@ -0,0 +1,6 @@
|
||||||
|
= if @commission.sheet_image do
|
||||||
|
.block
|
||||||
|
.block__header
|
||||||
|
span.block__header__title Commissions Sheet
|
||||||
|
.block__content.center
|
||||||
|
= render PhilomenaWeb.ImageView, "_image_container.html", image: @commission.sheet_image, size: :tall, conn: @conn
|
|
@ -0,0 +1,91 @@
|
||||||
|
/ General information block
|
||||||
|
.block
|
||||||
|
.block__header
|
||||||
|
span.block__header__title General information
|
||||||
|
.block__content.commission__block_body
|
||||||
|
strong> Profile:
|
||||||
|
= render PhilomenaWeb.UserAttributionView, "_user.html", object: @commission
|
||||||
|
br
|
||||||
|
|
||||||
|
strong> Status:
|
||||||
|
= if @commission.open, do: "Open", else: "Closed"
|
||||||
|
|
||||||
|
br
|
||||||
|
|
||||||
|
strong> Price Range:
|
||||||
|
- {min, max} = Enum.min_max_by(@commission.items, & &1.base_price)
|
||||||
|
| $
|
||||||
|
=> Decimal.round(min.base_price, 2) |> Decimal.to_string()
|
||||||
|
| - $
|
||||||
|
=> Decimal.round(max.base_price, 2) |> Decimal.to_string()
|
||||||
|
' USD
|
||||||
|
|
||||||
|
br
|
||||||
|
br
|
||||||
|
|
||||||
|
== @rendered.information
|
||||||
|
|
||||||
|
/ Contact information block
|
||||||
|
.block
|
||||||
|
.block__header
|
||||||
|
span.block__header__title Contact information
|
||||||
|
.block__content.commission__block_body
|
||||||
|
== @rendered.contact
|
||||||
|
|
||||||
|
/ Categories block
|
||||||
|
.block
|
||||||
|
.block__header
|
||||||
|
span.block__header__title Art Categories
|
||||||
|
.block__content
|
||||||
|
= for cat <- @commission.categories do
|
||||||
|
span.commission__category
|
||||||
|
= cat
|
||||||
|
|
||||||
|
/ Will create block
|
||||||
|
= if @user.commission.will_create not in [nil, ""] do
|
||||||
|
.block
|
||||||
|
.block__header
|
||||||
|
span.block__header__title Will draw/create
|
||||||
|
.block__content.commission__block_body
|
||||||
|
== @rendered.will_create
|
||||||
|
|
||||||
|
/ Will not create block
|
||||||
|
= if @user.commission.will_not_create not in [nil, ""] do
|
||||||
|
.block
|
||||||
|
.block__header
|
||||||
|
span.block__header__title Will not draw/create
|
||||||
|
.block__content.commission__block_body
|
||||||
|
== @rendered.will_not_create
|
||||||
|
|
||||||
|
/ User link block
|
||||||
|
/.block
|
||||||
|
.block__header: span.block__header__title User Links
|
||||||
|
- is_current = (current_user && current_user.id == @user.id)
|
||||||
|
- if @links.present? || is_current
|
||||||
|
= render partial: 'profiles/user_link_area'
|
||||||
|
|
||||||
|
/ Options block
|
||||||
|
/.block
|
||||||
|
.block__header
|
||||||
|
span.block__header__title Options
|
||||||
|
.block__content
|
||||||
|
- if can? :edit, @user.commission
|
||||||
|
= link_to 'Edit this listing', edit_commission_path(@user.commission)
|
||||||
|
br
|
||||||
|
= link_to 'Delete this listing', commission_path(@user.commission), data: { confirm: t('commissions.confirm_delete_listing') }, method: :delete
|
||||||
|
br
|
||||||
|
= link_to 'Report this listing', new_report_path(reportable_class: 'commission', reportable_id: @user.commission.id)
|
||||||
|
|
||||||
|
/ Share block
|
||||||
|
.block
|
||||||
|
.block__header
|
||||||
|
span.block__header__title Share this listing
|
||||||
|
.block__content
|
||||||
|
- url = Routes.commission_url(@conn, :show, @commission)
|
||||||
|
|
||||||
|
.field
|
||||||
|
label> for="commission_url" URL
|
||||||
|
a href="#" data-click-copy="#commission_url"
|
||||||
|
i.fa.fa-clipboard>
|
||||||
|
' Copy
|
||||||
|
= text_input :commission_url, url, class: "input input--wide input--separate-top", readonly: true
|
18
lib/philomena_web/templates/commission/show.html.slime
Normal file
18
lib/philomena_web/templates/commission/show.html.slime
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
h1
|
||||||
|
= @commission.user.name
|
||||||
|
| 's Commisisons
|
||||||
|
|
||||||
|
.column-layout
|
||||||
|
|
||||||
|
/ Side column
|
||||||
|
.column-layout__left
|
||||||
|
= render PhilomenaWeb.CommissionView, "_listing_sidebar.html", commission: @commission, rendered: @rendered, conn: @conn
|
||||||
|
|
||||||
|
/ Main column
|
||||||
|
.column-layout__main
|
||||||
|
|
||||||
|
/ Commission sheet block
|
||||||
|
= render PhilomenaWeb.CommissionView, "_listing_sheet.html", commission: @commission, conn: @conn
|
||||||
|
|
||||||
|
/ Types and prices block
|
||||||
|
= render PhilomenaWeb.CommissionView, "_listing_items.html", commission: @commission, items: @items, conn: @conn
|
Loading…
Reference in a new issue