Expand description
The action export: an item on the menus of the screens in the manifest entry’s places. Hammer
asks for any [[actions.field]]s first, then calls it, and every call returns a Reply as JSON.
A reply with a Page shows it in the action’s dialog; pressing one of the page’s buttons calls the
action again with the button’s id, the page’s values as Request::input, and the page’s state.
A reply with errors keeps the user on the page they were on, one with open ends the action and
goes to an item, and one with none of these ends the action. A message is shown briefly either way.
ⓘ
let page = Page {
title: Some("Who?".into()),
fields: vec![Field::text("name", "Name").required()],
buttons: vec![Button::new("back", "Back").skip_checks(), Button::new("next", "Next").primary()],
..Page::default()
}
.with_state(&Step { step: 2 })?;
Reply::page(page).to_json()Structs§
- Button
- A button of a page. Pressing it calls the action again with its id as Request::button. It sits in
the dialog’s footer, or with
inlineunder the markdown, for acting on something in it. - Choice
- One of a
choicefield’s options:valueis what comes back in the input,labelwhat is shown. - Context
- The screen an action was run from, and the id of the item it shows there (none on Project Home).
- Entity
Ref - An item of the project, as an
entityfield’s value:kindisscene,note,entry, orevent, andidthe item’s. Read one field asOption<EntityRef>and one with Field::multiple asVec<EntityRef>;Open::new(&it.kind, Some(it.id))goes to it. - Field
- A field of a page. Its value comes back in the next call’s input under its key: a string for
textandchoice, a bool, an integer, forscenesa list of scene ids (one id or null when Field::single), and forentityan EntityRef or null (a list of them when Field::multiple). Hammer checksrequired, anint’s bounds, achoice’s options, and that anentity’s picks exist and match its filters before calling, unless the button pressed skips them. - Open
- An item for Hammer to go to:
placeisproject,scene,note,entry, orevent, andidthe item’s (none forproject). An id that does not exist fails. - Page
- What the action’s dialog shows: a title, markdown, the fields in order, and buttons.
- Reply
- What an
actionexport returns, as Reply::to_json. Every part is optional; the default ends the action without a word. - Request
Enums§
- Field
Kind - Text
Format - What edits a
textfield: an ordinary text field, or the scene editor’s, whose value is markdown, with its format bar or the extended one (highlight, task lists, tables).