This commit is contained in:
parent
967a89b18d
commit
156cdb24d0
5 changed files with 62 additions and 4 deletions
|
|
@ -9,14 +9,28 @@ defmodule Mv.Membership.Property do
|
|||
end
|
||||
|
||||
actions do
|
||||
defaults [:create, :read, :update, :destroy]
|
||||
defaults [:read, :destroy]
|
||||
default_accept [:value, :member_id, :property_type_id]
|
||||
|
||||
create :create_property do
|
||||
primary? true
|
||||
load [:property_type]
|
||||
end
|
||||
|
||||
update :update_property do
|
||||
primary? true
|
||||
require_atomic? false
|
||||
load [:property_type]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
attributes do
|
||||
uuid_primary_key :id
|
||||
|
||||
attribute :value, :union,
|
||||
allow_nil?: true,
|
||||
constraints: [
|
||||
storage: :type_and_value,
|
||||
types: [
|
||||
|
|
@ -39,4 +53,15 @@ defmodule Mv.Membership.Property do
|
|||
calculations do
|
||||
calculate :value_to_string, :string, expr(value[:value] <> "")
|
||||
end
|
||||
|
||||
aggregates do
|
||||
first :property_type_required,
|
||||
:property_type,
|
||||
:required
|
||||
end
|
||||
|
||||
validations do
|
||||
validate {Mv.Membership.Validations.ValidateProperty, attribute: :value}
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue