PhoenixKitProjects.Schemas.Assignment (PhoenixKitProjects v0.5.0)

Copy Markdown View Source

A task instance within a project. Copies description and duration from the task template at creation time — editable independently.

Tracks who completed the task via completed_by_uuid + completed_at.

Summary

Types

t()

JSONB map of secondary-language overrides. Same shape as Project.translations_map/Task.translations_map.

Functions

Form-facing changeset. Does NOT allow setting completed_by_uuid or completed_at — those are server-owned fields (use status_changeset/2).

Returns the assignment's description in the requested language, with primary-fallback semantics: empty/missing override → the primary description column, which itself may be nil (in which case the caller's typical pattern is to fall further back to the parent task's localized_description/2). The double-fallback chain keeps existing call sites like a.description || a.task.description working locale-aware: Assignment.localized_description(a, lang) || Task.localized_description(a.task, lang).

Server-trusted changeset that also allows setting completion fields. Use from context functions that own the completion transition, e.g. progress updates, explicit complete_assignment/2, or reopen_assignment/1.

DB-column field names that participate in the translations JSONB.

Types

t()

@type t() :: %PhoenixKitProjects.Schemas.Assignment{
  __meta__: term(),
  assigned_department:
    PhoenixKitStaff.Schemas.Department.t()
    | Ecto.Association.NotLoaded.t()
    | nil,
  assigned_department_uuid: UUIDv7.t() | nil,
  assigned_person:
    PhoenixKitStaff.Schemas.Person.t() | Ecto.Association.NotLoaded.t() | nil,
  assigned_person_uuid: UUIDv7.t() | nil,
  assigned_team:
    PhoenixKitStaff.Schemas.Team.t() | Ecto.Association.NotLoaded.t() | nil,
  assigned_team_uuid: UUIDv7.t() | nil,
  completed_at: DateTime.t() | nil,
  completed_by:
    PhoenixKit.Users.Auth.User.t() | Ecto.Association.NotLoaded.t() | nil,
  completed_by_uuid: UUIDv7.t() | nil,
  counts_weekends: boolean() | nil,
  dependencies:
    [PhoenixKitProjects.Schemas.Dependency.t()] | Ecto.Association.NotLoaded.t(),
  dependents: term(),
  description: String.t() | nil,
  estimated_duration: integer() | nil,
  estimated_duration_unit: String.t() | nil,
  inserted_at: DateTime.t() | nil,
  position: integer() | nil,
  progress_pct: integer() | nil,
  project:
    PhoenixKitProjects.Schemas.Project.t()
    | Ecto.Association.NotLoaded.t()
    | nil,
  project_uuid: UUIDv7.t() | nil,
  status: String.t() | nil,
  task:
    PhoenixKitProjects.Schemas.Task.t() | Ecto.Association.NotLoaded.t() | nil,
  task_uuid: UUIDv7.t() | nil,
  track_progress: boolean() | nil,
  translations: translations_map(),
  updated_at: DateTime.t() | nil,
  uuid: UUIDv7.t() | nil
}

translations_map()

@type translations_map() :: %{
  optional(String.t()) => %{optional(String.t()) => String.t()}
}

JSONB map of secondary-language overrides. Same shape as Project.translations_map/Task.translations_map.

Functions

changeset(assignment, attrs)

Form-facing changeset. Does NOT allow setting completed_by_uuid or completed_at — those are server-owned fields (use status_changeset/2).

localized_description(a, lang)

@spec localized_description(t(), String.t() | nil) :: String.t() | nil

Returns the assignment's description in the requested language, with primary-fallback semantics: empty/missing override → the primary description column, which itself may be nil (in which case the caller's typical pattern is to fall further back to the parent task's localized_description/2). The double-fallback chain keeps existing call sites like a.description || a.task.description working locale-aware: Assignment.localized_description(a, lang) || Task.localized_description(a.task, lang).

status_changeset(assignment, attrs)

Server-trusted changeset that also allows setting completion fields. Use from context functions that own the completion transition, e.g. progress updates, explicit complete_assignment/2, or reopen_assignment/1.

statuses()

translatable_fields()

@spec translatable_fields() :: [String.t()]

DB-column field names that participate in the translations JSONB.