Ga naar hoofdinhoud

CnNcDashboardQuickCreate

A short create form for a Nextcloud Dashboard widget ("New lead", "Start a request"): a few fields, a submit that writes one OpenRegister object, and a link to what was made. A required field left empty is marked, and a failed create says so and keeps what was typed. Option labels are shown translated while the stored value stays the option's value.

registerNcDashboardWidgets mounts it for a widget declared { id, type: "quick-create", config }, and CnNcDashboardList opens it inline from a row action or its create button.

Usage​

registerNcDashboardWidgets([
{
id: 'pipelinq_create_lead_widget',
type: 'quick-create',
config: {
register: 'pipelinq',
schema: 'lead',
fields: [
{ key: 'title', label: 'Title', required: true },
{ key: 'client', label: 'Client', type: 'object', register: 'pipelinq', schema: 'client' },
{ key: 'pipeline', label: 'Pipeline', type: 'select', optionsFrom: { register: 'pipelinq', schema: 'pipeline' }, default: 'first' },
{ key: 'value', label: 'Value', type: 'number' },
],
defaults: { status: 'open' },
derive: { stage: { from: 'pipeline', path: 'stages', sortBy: 'order', field: 'name' } },
submitLabel: 'Create lead',
successText: 'Lead created',
successLinkText: 'View lead',
successHref: '/apps/pipelinq/leads/{id}',
},
},
], { appId: 'pipelinq' })

Config​

KeyDescription
register, schemaWhere the object is created
fields[{ key, label, type?, required?, placeholder?, options?, optionsFrom?, default?, labelField? }]. type is text (default), number, select or object. A select takes options: [{ value, label }] (labels through the app's translate) or optionsFrom: { register, schema, filter?, valueField?, labelField? }; default: "first" picks the first option. An object field searches register/schema objects on the server as the user types, stores the id and shows labelField (default name). Any other default is the field's starting value
defaultsValues written with every create. Filter tokens resolve (@now, @me) and string templates fill from context ("{id}")
derive{ target: { from, path, sortBy?, field } }: a value read from the option chosen for field from; { stage: { from: "pipeline", path: "stages", sortBy: "order", field: "name" } } writes the first stage of the chosen pipeline
headingA line above the form, filled from context ("New request for {name}")
submitLabel, successText, successLinkText, againLabelTexts, through the app's translate
successHrefA template for the created object's page; an app path goes through generateUrl
openAfterCreateGo to successHref at once instead of showing the success note
listA CnNcDashboardList config shown under the form, read again after a create
listHeadingThe heading above that list ("Recent requests"), through the app's translate

Props​

PropTypeDefaultDescription
configObject{}The configuration above
contextObject{}The record the form was opened on, for defaults and heading templates
cancelableBooleanfalseShow a Cancel button that emits cancel

Events​

EventPayloadDescription
createdThe created object, with its idAfter a successful create
cancelnoneThe Cancel button was pressed