forms

Form-parsing helpers for the web handlers.

struct NoteFormData

source

pub(crate) struct NoteFormData

Shared form body for note-add endpoints.

Field Type Description
body String The note’s Markdown text.

Implements Deserialize<'de>.

fn seen_from

source

fn seen_from(
    entity_type: EntityType,
    entity_id: &Id,
    rel: &relationship::Model,
) -> (RelationshipType, EntityType, Id)

A link as the edit form shows it from one entity: its relationship and the other end.

A link that starts at the entity reads as it is stored. A link that ends at the entity reads from the other side, with the inverse relationship: A blocks B reads from B as blocked-by A.

Parameter Type Description
entity_type EntityType the kind of the entity the link is seen from
entity_id &Id the entity the link is seen from
rel &relationship::Model a link that starts or ends at the entity
returns (RelationshipType, EntityType, Id) The relationship, and the kind and ID of the other end.

fn parse_tags

source

pub(crate) fn parse_tags(tags_str: &str) -> Vec<String>

Parse comma-separated tags string into trimmed, non-empty tag labels.

Parameter Type Description
tags_str &str the tags field of a form, such as "ui, bug"
returns Vec<String> The tag labels in input order; duplicates are kept.

fn sync_form_tags

source

pub(crate) async fn sync_form_tags(
    conn: &Connection,
    transaction_id: &Id,
    entity_type: EntityType,
    entity_id: &Id,
    labels: &[String],
) -> Result<(), String>

Make the entity’s tags match the form’s labels, recording each change in transaction_id.

A label that is stored and in the form is kept, one that is only stored is removed, and one that is only in the form is added. A form that keeps every tag records nothing.

Parameter Type Description
conn &Connection the database connection
transaction_id &Id the transaction the changes belong to
entity_type EntityType the kind of the tagged entity
entity_id &Id the entity
labels &[String] the form’s tag labels
returns Result<(), String> Ok(()) once the tags match, or the store error as text.

fn begin

source

pub(crate) async fn begin(
    state: &crate::web::AppState,
    conn: &Connection,
    command: &str,
) -> Result<crate::store::model::transaction::Model, crate::store::Error>

Open a transaction for a write from the web UI, under the server’s author when it has one.

Parameter Type Description
state &crate::web::AppState the shared server state, for the project and the author
conn &Connection the database connection
command &str the command name that gest undo shows, such as task update
returns Result<crate::store::model::transaction::Model, crate::store::Error> The new transaction, or the store error.