Ga naar hoofdinhoud

CnTransitionInputFields

The declared inputs of a transition or an act, drawn wherever the host puts them. CnTransitionInputDialog draws them in their own dialog; a host that lists several acts and opens the chosen one's inputs in place, under its card, draws them with this component. Both read the same declarations and decide the same way whether the form is complete.

Import​

import { CnTransitionInputFields, readTransitionInputs } from '@conduction/nextcloud-vue'

Usage​

<CnTransitionInputFields
v-model="values"
:inputs="inputs"
:context="{ pauseReasons }"
:columns="2"
:mark-required="false"
:disabled="busy" />
// Whether the form may be confirmed, and what to send.
const { complete, data } = readTransitionInputs(inputs, values, { context: { pauseReasons } })

Input declarations​

Every key CnTransitionInputDialog reads (field, required, label, options, picker, fields), plus:

KeyDescription
widgettext, textarea, number, date, select or template, whatever the schema says.
optionsSourceA dot path into context holding the rows to pick from, read through optionValue (default value) and optionLabel (default label). With no rows the input is hidden and asks nothing.
other{ label, input }: adds an "Other" entry. The input it names is shown, and asked, only when this picker is hidden or Other is picked. Other is sent as ''.
helperFrom{ input, key }: the helper text is key of the row picked in that other input, such as the legal basis of a picked reason.
preview{ label, template, note, testid }: a line under the input once the template resolves. Tokens are {field}, {field|date}, {today|date} and {today+field|date} (today plus that many days); a token that resolves to nothing hides the line. The value carries the test id <testid>-value.
defaultThe starting value (CnTransitionInputDialog seeds it).
description, noteThe helper text under the field, and a muted line under it.
labelOutside, idDraw the label above the field as a <label for> tied to the field's id.
wide, rows, placeholder, testidSpan both columns; the text area's rows (default 4); the placeholder; the control's data-testid.

A template input renders CnTemplateSelect with its url, schema, params, mapOption and placeholder, and puts the chosen template's body (else presets.body) into the input named by applyTo. It never writes over text already typed there, and is never sent.

[
{ field: 'pauseReason', optionsSource: 'pauseReasons', optionValue: 'key', optionLabel: 'name',
required: true, label: 'Reason', other: { label: 'Other', input: 'reason' } },
{ field: 'reason', widget: 'text', required: true, label: 'Reason', labelOutside: true, id: 'act-reason' },
{ field: 'days', widget: 'number', label: 'Days given', helperFrom: { input: 'pauseReason', key: 'legalBasis' },
preview: { label: 'Comes back on', template: '{today+days|date}' } },
]

Summary and notice​

summary is a read-only block above the inputs about what the action works on: { when, card: { icon, title, meta: [], badge }, title, facts: [{ label, path, fallback }], testid }. when, the card's title, meta and badge, and each fact's path are dot paths into context; the block shows once when resolves. The card and the facts carry the test ids <testid>-card and <testid>-facts.

notice is a tinted box under the inputs: { type, heading, text, icon? }. type is info (the default), warning or error; icon names a CnIcon (default InformationOutline). It is drawn as its own box rather than an NcNoteCard, which disappears into the tinted card of a chosen act.

The summary's facts stack each label over its value, whatever Nextcloud's apps.css does to dt and dd.

Props​

PropTypeDefaultDescription
inputsArray[]The declared inputs
modelValueObject{}The values, keyed by field (v-model)
schemaObjectnullThe object's JSON Schema, for inputs that declare no widget
currentObjectObjectnullThe record: picker.excludeSelf and the object input's present value
registerString''Register the reference pickers fall back to
contextObject{}What optionsSource and the summary read
fieldErrorsArray[]Input keys a refusal named; an unoffered one is reported as a key the action does not accept
disabledBooleanfalseLocks the inputs, such as while the action posts
columnsNumber12 sets the inputs side by side; wide inputs, previews, the summary and the notice span both
markRequiredBooleantrueWhether a required input's label carries *
summaryObjectnullThe read-only block above the inputs
noticeObjectnullThe note under the inputs
markOptionalBooleanfalseMarks an input that is not required with (optional) after its label, as the boards do

Events​

EventPayloadDescription
update:modelValuethe valuesOne input changed. Two changes in one tick both survive.