Skip to main content

forms/
template.rs

1//! The template form descriptors.
2
3use crate::descriptor::{Action, Form, Kind, TEXT, field};
4
5pub(crate) const SOURCE: Kind = Kind::Text {
6    multiline: true,
7    suggest: None,
8};
9
10/// Create a template from an optional name and its source.
11pub const TEMPLATE_CREATE: Form = Form {
12    name: "template-create",
13    title: "Create template",
14    fields: &[
15        field("name", "Name", TEXT, false),
16        field("source", "Source", SOURCE, true),
17    ],
18    action: Action::Mutation,
19};
20
21/// Replace the name and the source of a template; the revision covers both.
22pub const TEMPLATE_EDIT: Form = Form {
23    name: "template-edit",
24    title: "Edit template",
25    fields: &[
26        field("id", "Id", Kind::Hidden, true),
27        field("revision", "Revision", Kind::Hidden, true),
28        field("name", "Name", TEXT, false),
29        field("source", "Source", SOURCE, true),
30    ],
31    action: Action::LoadMutation,
32};
33
34/// Render a template source against the user's data without saving it.
35pub const TEMPLATE_TEST: Form = Form {
36    name: "template-test",
37    title: "Test template",
38    fields: &[field("source", "Source", SOURCE, true)],
39    action: Action::Query,
40};