add clothes type to clothes

This commit is contained in:
2021-09-24 14:43:41 +02:00
parent 2486143842
commit a8d30550ab
8 changed files with 432 additions and 428 deletions
+4 -3
View File
@@ -5,9 +5,9 @@ defmodule PokemonCouture.Shops.Clothes do
schema "clothes" do
field :name, :string
field :color, :string
field :type, :string # shirt, pants, socks, shoes, bag, hat, glasses, accessory
field :game, :string
field :location, :string
many_to_many :users, PokemonCouture.Accounts.User, join_through: "ownerships", unique: :true, on_replace: :delete
timestamps()
@@ -16,7 +16,8 @@ defmodule PokemonCouture.Shops.Clothes do
@doc false
def changeset(clothes, attrs) do
clothes
|> cast(attrs, [:name, :location, :game, :color])
|> validate_required([:name, :location, :game, :color])
|> cast(attrs, [:name, :location, :type, :game, :color])
|> validate_required([:name, :location, :type, :game, :color])
|> validate_format(:type, ~r/(shirt)|(pants)|(socks)|(shoes)|(bag)|(hat)|(glasses)|(accessory)/)
end
end
@@ -6,6 +6,7 @@
<tr>
<th>Name</th>
<th>Color</th>
<th>Type</th>
<th>Game</th>
<th></th>
</tr>
@@ -8,6 +8,7 @@ defmodule PokemonCoutureWeb.Components.ClothesComponent do
<tr>
<td><%= @clothes.name %></td>
<td><%= @clothes.color %></td>
<td><%= @clothes.type %></td>
<td><%= @clothes.game %></td>
<td>