Skip to main content

Form

Struct Form 

Source
pub struct Form {
    pub fields: Vec<Field>,
    pub focus: usize,
    pub kind: FormKind,
    pub entity_id: Option<String>,
}
Expand description

A generic multi-field input form.

Fields§

§fields: Vec<Field>§focus: usize

Index of the currently focused field. Always < fields.len().

§kind: FormKind§entity_id: Option<String>

Entity id for tag forms; None for all other kinds.

Implementations§

Source§

impl Form

Source

pub fn config_set(name: Editor, value: Editor) -> Self

Two-field form for the config set command.

Source

pub fn report_params( from: Editor, to: Editor, chart: Editor, kind: ReportKind, ) -> Self

Three-field form for the reports activity/breakdown commands.

Source

pub fn commodity_create(mode: EditMode) -> Self

Two-field form for commodity create (symbol required, name required).

Source

pub fn commodity_convert(mode: EditMode) -> Self

Three-field form for commodity conversion: amount, from-commodity, to-commodity.

The two Select fields are empty on construction; call fetch_commodity_convert_form_options to populate them asynchronously.

Source

pub fn account_create(mode: EditMode, parent_options: Vec<SelectOption>) -> Self

Two-field form for account create (name required, parent Select optional).

parent_options seeds the parent Select; include a leading (none) entry with empty id so “no parent” is the default.

Source

pub fn transaction_create(mode: EditMode) -> Self

Three-field form for transaction create: date, note, splits.

Source

pub fn transaction_edit(mode: EditMode, et: &EditableTransaction) -> Self

Three-field form for editing an existing transaction, pre-filled from et.

Each split row’s Selects start with a single-entry list holding the stored uuid as both id and label; after the async fetch_transaction_form_options reply arrives, set_account_options / set_commodity_options replace the lists while set_options_preserving_id keeps the stored selection.

Source

pub fn account_tag(mode: EditMode, account_id: String) -> Self

Two-field form for set-account-tag: tag name (required) and value.

The account_id is stored in entity_id and used at validation time.

Source

pub fn transaction_tag(mode: EditMode, transaction_id: String) -> Self

Two-field form for set-transaction-tag: tag name (required) and value.

The transaction_id is stored in entity_id and used at validation time.

Source

pub fn cycle(&mut self, forward: bool)

Advance or retreat focus by one step, wrapping around.

Source

pub fn focused_field_mut(&mut self) -> Option<&mut Field>

Mutable reference to the currently focused field, if any.

Source

pub fn focused_editor_mut(&mut self) -> Option<&mut Editor>

Mutable reference to the inner Editor of the focused field.

Returns None when the form is empty or the focused widget is not Text, Amount, or Date (i.e. a Select or Splits).

Source

pub fn focused_widget_kind(&self) -> Option<WidgetKind>

Widget kind of the focused field, or None when the form is empty.

Source

pub fn focused_splits_sub_kind(&self) -> Option<WidgetKind>

When the focused field is a Splits widget, returns the kind of its focused sub-widget (for nested widget-first key routing).

Source

pub fn focused_splits_boundary(&self) -> Option<(bool, bool)>

When the focused field is a Splits widget, returns (at_first_cell, at_last_cell) so the key layer can yield Tab/BackTab to the outer field cycle at the editor’s boundaries.

Trait Implementations§

Source§

impl Debug for Form

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Form

§

impl RefUnwindSafe for Form

§

impl Send for Form

§

impl Sync for Form

§

impl Unpin for Form

§

impl UnsafeUnpin for Form

§

impl UnwindSafe for Form

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,