PhoenixKitStaff.Schemas.Skill (PhoenixKitStaff v0.5.0)

Copy Markdown View Source

A skill that can be assigned to staff people.

A flat, translatable taxonomy entry (no parent — unlike Team, which belongs to a Department). Names are globally unique, case-insensitively (a lower(name) expression index in the DB). See Department for the translations shape and read-path semantics — Skill uses the same pattern.

People are assigned skills many-to-many via PhoenixKitStaff.Schemas.PersonSkill, which carries the per-assignment proficiency level.

Summary

Types

A single proficiency level on a skill. id is a stable short identifier that PersonSkill.proficiency_levels references; translations maps a locale to a translated name (flat lang => name, primary fallback to name).

t()

Functions

The level map for id, or nil.

Generates a stable short (8-hex) level id.

The skill's level ids, in order.

Levels as [{localized_name, id}] for <select>/chip options in lang.

The skill's level maps (always a list).

Translated name for a level id in lang (primary name fallback). Returns nil for an unknown id so callers can drop stray ids without crashing — never raises.

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

Types

level()

@type level() :: %{
  required(String.t()) => String.t() | %{optional(String.t()) => String.t()}
}

A single proficiency level on a skill. id is a stable short identifier that PersonSkill.proficiency_levels references; translations maps a locale to a translated name (flat lang => name, primary fallback to name).

t()

@type t() :: %PhoenixKitStaff.Schemas.Skill{
  __meta__: term(),
  allow_multiple_levels: boolean(),
  description: String.t() | nil,
  inserted_at: DateTime.t() | nil,
  levels: [level()],
  name: String.t() | nil,
  person_skills:
    [PhoenixKitStaff.Schemas.PersonSkill.t()] | Ecto.Association.NotLoaded.t(),
  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()}
}

Functions

changeset(skill, attrs)

@spec changeset(t() | Ecto.Changeset.t(t()), map()) :: Ecto.Changeset.t(t())

find_level(skill, id)

@spec find_level(t(), String.t()) :: level() | nil

The level map for id, or nil.

gen_level_id()

@spec gen_level_id() :: String.t()

Generates a stable short (8-hex) level id.

level_ids(skill)

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

The skill's level ids, in order.

level_options(skill, lang)

@spec level_options(t(), String.t() | nil) :: [{String.t(), String.t()}]

Levels as [{localized_name, id}] for <select>/chip options in lang.

levels(arg1)

@spec levels(t()) :: [level()]

The skill's level maps (always a list).

localized_description(s, lang)

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

localized_level_name(skill, id, lang)

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

Translated name for a level id in lang (primary name fallback). Returns nil for an unknown id so callers can drop stray ids without crashing — never raises.

localized_name(s, lang)

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

translatable_fields()

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

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