feat(elixir): storage location system
This commit is contained in:
@@ -8,18 +8,20 @@ defmodule ComponentsElixir.Inventory.Component do
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
alias ComponentsElixir.Inventory.Category
|
||||
alias ComponentsElixir.Inventory.{Category, StorageLocation}
|
||||
|
||||
schema "components" do
|
||||
field :name, :string
|
||||
field :description, :string
|
||||
field :keywords, :string
|
||||
field :position, :string
|
||||
field :legacy_position, :string
|
||||
field :count, :integer, default: 0
|
||||
field :datasheet_url, :string
|
||||
field :image_filename, :string
|
||||
|
||||
belongs_to :category, Category
|
||||
belongs_to :storage_location, StorageLocation
|
||||
|
||||
timestamps()
|
||||
end
|
||||
@@ -27,7 +29,7 @@ defmodule ComponentsElixir.Inventory.Component do
|
||||
@doc false
|
||||
def changeset(component, attrs) do
|
||||
component
|
||||
|> cast(attrs, [:name, :description, :keywords, :position, :count, :datasheet_url, :image_filename, :category_id])
|
||||
|> cast(attrs, [:name, :description, :keywords, :position, :count, :datasheet_url, :image_filename, :category_id, :storage_location_id])
|
||||
|> validate_required([:name, :category_id])
|
||||
|> validate_length(:name, min: 1, max: 255)
|
||||
|> validate_length(:description, max: 2000)
|
||||
|
||||
Reference in New Issue
Block a user