Kantoor. Tasks
(Kantoor v1.0.0)
Tasks (iCalendar VTODO) for the signed-in user.
Tasks are ordinary calendar object resources in the user's task lists (calendar
collections whose components include VTODO), stored by Kantoor.Dav.Local:
exactly the resources a phone syncing over CalDAV sees, and a task created on a
phone shows up here. Every function takes a Kantoor.Accounts.Scope and only
touches that user's data and the task lists shared with them.
Task lists shared with the user (Kantoor.Sharing) are listed next to their
own. The permission is read from the database on every call and checked again
by Kantoor.Dav.Local, as on the DAV path: with a read-only share a task
cannot be created, changed, completed or deleted ({:error, :forbidden}).
Summary
Functions
Creates a task. attrs (string keys): "summary" (required), "description",
"due_date" (YYYY-MM-DD), "due_time" (HH:MM), "priority" (0-9),
"list" (slug; default: the first task list).
The list a new task goes to when none is named, from views/1: the user's own
task list that holds nothing but tasks ("Tasks"), else their first own
writable list, else any writable one. The calendar "Calendar" accepts tasks
too, but a task made without a choice belongs on the task list, in the web
pages and over the API alike. nil when nothing is writable.
Deletes a task. {:error, :forbidden} in a read-only shared list.
One of the user's tasks.
The user's tasks. Options: :status (:open default, :done, :all),
:list (a list's ref: its slug, or shared-<id>), :due (:all, :overdue, :today, :week, :none),
:q (text matched against the title), :today (a Date, for tests).
The task lists (calendars that accept VTODO) of the user.
The tasks that belong on the calendar between two dates (inclusive), read with
one query. A task sits on the day of its DUE, or of its DTSTART when it has
no DUE, shown in the user's time zone exactly as events are: a time in UTC
or in a named zone is converted (daylight saving included), a floating time
and a date are shown as they are. Tasks without either are not placed (see
undated_count/1). A repeating task (RRULE) is not expanded: the Tasks page
does not create or show repetition either, so it sits once on its own day.
Marks a task completed (or open again).
Sets a task's status to one of statuses/0. Completing sets the same fields as
the checkbox (set_done/3): COMPLETED, PERCENT-COMPLETE:100; going back to
NEEDS-ACTION clears them; IN-PROCESS and CANCELLED clear the completion
date and percentage.
The statuses a task can have, in the order of a board: NEEDS-ACTION (to do),
IN-PROCESS (in progress), COMPLETED and CANCELLED: the four values of
the iCalendar VTODO STATUS that CalDAV clients write.
How many undone tasks have neither a DUE nor a DTSTART: the ones the
calendar cannot place on a day.
Updates a task's title, notes, due date, priority and (optionally) status.
The task lists as Kantoor.Dav.Views: the user's own, then those shared with
them (read-only or read-write).
Types
@type scope() :: Kantoor.Accounts.Scope.t() | nil
Functions
@spec create(scope(), map()) :: {:ok, Kantoor.Tasks.Task.t()} | {:error, [String.t()]}
Creates a task. attrs (string keys): "summary" (required), "description",
"due_date" (YYYY-MM-DD), "due_time" (HH:MM), "priority" (0-9),
"list" (slug; default: the first task list).
@spec default_view([Kantoor.Dav.View.t()]) :: Kantoor.Dav.View.t() | nil
The list a new task goes to when none is named, from views/1: the user's own
task list that holds nothing but tasks ("Tasks"), else their first own
writable list, else any writable one. The calendar "Calendar" accepts tasks
too, but a task made without a choice belongs on the task list, in the web
pages and over the API alike. nil when nothing is writable.
Deletes a task. {:error, :forbidden} in a read-only shared list.
@spec get(scope(), term()) :: {:ok, Kantoor.Tasks.Task.t()} | {:error, :not_found}
One of the user's tasks.
@spec list(scope(), keyword()) :: [Kantoor.Tasks.Task.t()]
The user's tasks. Options: :status (:open default, :done, :all),
:list (a list's ref: its slug, or shared-<id>), :due (:all, :overdue, :today, :week, :none),
:q (text matched against the title), :today (a Date, for tests).
@spec lists(scope()) :: [Kantoor.Dav.Collection.t()]
The task lists (calendars that accept VTODO) of the user.
@spec on_calendar(scope(), Date.t(), Date.t(), keyword()) :: %{ placed: [Kantoor.Tasks.Placement.t()], overdue: [Kantoor.Tasks.Placement.t()] }
The tasks that belong on the calendar between two dates (inclusive), read with
one query. A task sits on the day of its DUE, or of its DTSTART when it has
no DUE, shown in the user's time zone exactly as events are: a time in UTC
or in a named zone is converted (daylight saving included), a floating time
and a date are shown as they are. Tasks without either are not placed (see
undated_count/1). A repeating task (RRULE) is not expanded: the Tasks page
does not create or show repetition either, so it sits once on its own day.
Returns %{placed: [...], overdue: [...]}, both lists of Placements:
placed- the tasks whose day is in the range, earliest first (done ones included, for the page to strike through);overdue- every undone task whose day is before today, whatever the range (so a page that shows today can list them there too).
Options: :today (a Date, for tests; default today in the user's zone).
@spec set_done(scope(), term(), boolean()) :: {:ok, Kantoor.Tasks.Task.t()} | {:error, term()}
Marks a task completed (or open again).
@spec set_status(scope(), term(), String.t()) :: {:ok, Kantoor.Tasks.Task.t()} | {:error, term()}
Sets a task's status to one of statuses/0. Completing sets the same fields as
the checkbox (set_done/3): COMPLETED, PERCENT-COMPLETE:100; going back to
NEEDS-ACTION clears them; IN-PROCESS and CANCELLED clear the completion
date and percentage.
@spec statuses() :: [String.t()]
The statuses a task can have, in the order of a board: NEEDS-ACTION (to do),
IN-PROCESS (in progress), COMPLETED and CANCELLED: the four values of
the iCalendar VTODO STATUS that CalDAV clients write.
@spec undated_count(scope()) :: non_neg_integer()
How many undone tasks have neither a DUE nor a DTSTART: the ones the
calendar cannot place on a day.
@spec update(scope(), term(), map()) :: {:ok, Kantoor.Tasks.Task.t()} | {:error, [String.t()] | :not_found | :forbidden}
Updates a task's title, notes, due date, priority and (optionally) status.
@spec views(scope()) :: [Kantoor.Dav.View.t()]
The task lists as Kantoor.Dav.Views: the user's own, then those shared with
them (read-only or read-write).