Wizard editors
Sometimes the standard shacl-vue approach of matching a dedicated editor component to a single modeled property shape does not fully address the use case at hand. Think of creating complicated, multi-jump linkages between a record being edited and some other records, perhaps multiple at a time.
Let's take the following example: a user might want to add a DOI (Digital Object Identifier) to a Publication record, but there is no doi property on the Publication class, and instead:
- a
Publicationhas anidentifiersslot, with the rangeIdentifier - the
Identifierclass has slots:notationandcreator - there is also a
DOIclass that subclasses fromIdentifier - to create a
DOIrecord, thenotationis important while thecreatoris already known
Ideally, all of these classes and slots and linkages are details that should be of no concern to the user. They just want to add a DOI for their publication (actually the only really required field to enter is notation!) and having to do that via the existing route (find the identifiers slot -> create a new DOI record -> add notation -> add the creator correctly! -> finally save and link the created DOI record) is unnecessarily complex and bad UX.
There should be simpler way to achieve this. And there is, using the "Wizard Editor"!
This is a powerful feature that allows specification of arbitrarily complex user input and metadata linkage via relatively simple configuration of primitive form inputs and metadata templates. Think of it as a way to:
- specify which arbitrary inputs should be shown in a form
- specify how those input values should feed into a TTL template
- autocreate arbitrarily complex and linked metadata upon saving the wizard form
A wizard editor can be configured to appear for any class, to use any of the supported inputs, and to use any TTL template. Specific configuration options are provided below.
Wizard configuration
This section will provide all currently available wizard configuration options using the DOI use case as a demonstrator, with the following config:
wizard_editor_selection:
xyzri:XYZPublication:
- DOIWizard
wizard_editors:
DOIWizard:
name: DOI Wizard
description: Enter the 'Notation' field and hit *Save* in order to create a DOI record
icon: mdi-identifier
tooltip: Add a DOI
inputs:
- prop: notation
name: Notation
description: This is the unique DOI identifier text usually following 'http://doi.org/'
type: text
placeholder: 'example: 10.21105/joss.03262'
required: true
pattern: # some XSD-compatible regular expression
default: # some default value
template: content:DOIWizardTemplate
content:
DOIWizardTemplate:
url: DOIWizardTemplate.ttlwizard_editor_selection
This option provides a means to specify which wizards should show up for which classes. It is an object with class IRIs as keys (in CURIE format) and associated values being lists of wizards to make available for the class identied by the key.
wizard_editors
This is the main config option that allows creation of a wizard editor and specification of its inputs, template, and other options. The wizard receives a key (here DOIWizard), and then its options:
Wizard options include:
name
This is a human-readable name for the wizard that will be displayed at the top of the wizard form.
description
This is human-readble descriptive text or instructions to help users understand the context and purpose of the form, and will render inside the initiated wizard form underneath the name.
icon
This provides a means to specify the icon image that will show up on records for which the specific wizard has been configured to render. Clicking on the icon is the primary and only way to open the associated wizard editor. Icons can be specified in different formats:
- an
mdi-string which will render any of the standard free icons from themdiicon library - an svg string, which will be rendered as is
- a
content:pointer to an SVG file, which will be loaded and rendered as is
Importantly, any SVGf file or string used in this context should have a viewport or width/height of 24x24 px.
tooltip
This is a short human-readable sentence that will show when the cursor hovers over the wizard icon and is intended to explain shortly what the wizard does.
inputs
The core of the wizard lies in its specification of inputs. An input can have several properties:
propis the field name through which this input is referenced, both inshacl-vueinternals and inside the TTL templatenamewill render as the input labeldescriptionis a further description of the input that will render when hovering over the input labeltypetellsshacl-vuewhich type of input component to render, for which the input value will be captured; currently onlytext,text-paragraphandbooleanare supported, and many more are in the pipelineplaceholderwill render if the field has no entered value yetrequiredwill make the field required (or not) for validation purposespatternwill apply a regular expression check to text-based inputs for validation purposesdefaultwill prepulate the value of the input
template
Another core part of the wizard specification is the TTL template string, which will be populated using the values entered for the wizard inputs. The TTL string format is the same as is already supported by shacl-vue. For example:
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix dlthings: <https://concepts.datalad.org/s/things/unreleased/> .
@prefix ror: <https://ror.org/> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<{pid}> dcterms:identifier _:n0-1.
_:n0-1 a dlthings:DOI;
skos:notation "{notation}";
dcterms:creator ror:01fyxcz70.Note the following inside the template:
{pid}is the standard way to refer to the record within the context of which the wizard editor is rendered, for example if theDOIWizardis initiated from a specificPublicationrecord, that record's identifier becomes available inside the TTL template.{notation}is an example of how thepropof a configuredinputis used to reference it inside the TTL template
The TTL template can be specified as a direct string inside the configuration, but also as a file via a content: pointer to the file URL.
Finally, another new config option wizard_editor_selection can be used to specify which wizards should be made available to which classes. The config above says: show the DOI Wizard for xyzri:XYZPublication records (during creation/editing).
Wizard editor demo
INFO
TODO