A resource (a person, a team, a machine...) that tasks are assigned to.
:id- identifier referenced by task assignments. Required.:text- display name.:capacity- how many units it can work per working day (8 hours by default). Assignments use the same units.:color- an optional CSS color.
Tasks reference resources in their :resources field (see
cast_assignments/1), and GanttEx.ResourceLoad computes how loaded each
resource is.
iex> {:ok, resource} = GanttEx.Resource.new(%{"id" => "ana", "text" => "Ana", "capacity" => "6"})
iex> {resource.id, resource.text, resource.capacity}
{"ana", "Ana", 6}
iex> GanttEx.Resource.new(text: "Nobody")
{:error, {:missing, :id}}
Summary
Types
A task assignment: the resource and the units per working day (nil = full capacity).
Functions
Casts task assignments: a list of resource ids, or of maps with an id and a
value (%{resource_id: 1, value: 4}, %{"id" => 1, "value" => "4"}...).
Builds a resource from a map, keyword list or struct.
Like new/1 but raises ArgumentError.
Types
@type assignment() :: %{id: GanttEx.Task.id(), value: number() | nil}
A task assignment: the resource and the units per working day (nil = full capacity).
@type t() :: %GanttEx.Resource{ capacity: number(), color: String.t() | nil, id: GanttEx.Task.id(), text: String.t() }
Functions
@spec cast_assignments(term()) :: {:ok, [assignment()]} | :error
Casts task assignments: a list of resource ids, or of maps with an id and a
value (%{resource_id: 1, value: 4}, %{"id" => 1, "value" => "4"}...).
iex> GanttEx.Resource.cast_assignments([1, %{resource_id: 2, value: 4}, %{"id" => "3", "value" => "2.5"}])
{:ok, [%{id: 1, value: nil}, %{id: 2, value: 4}, %{id: "3", value: 2.5}]}
iex> GanttEx.Resource.cast_assignments(nil)
{:ok, []}
iex> GanttEx.Resource.cast_assignments([%{value: 1}])
:error
Builds a resource from a map, keyword list or struct.
Like new/1 but raises ArgumentError.