feat(elixir): storage location system

This commit is contained in:
Schuwi
2025-09-14 15:20:25 +02:00
parent b9126c286f
commit 9d090859e8
14 changed files with 1517 additions and 160 deletions

View File

@@ -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)