New wizard editor component #320
No reviewers
Labels
No labels
bug
config
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
orinoco/shacl-vue!320
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "wizardeditor"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
closes datalink/shacl-vue#152
This feature allows custom form dialog construction via config, as well as TTL template
specification, which is then string-serialized using the user inputs upon form save, followed
by adding the parsed quads to the graph store. This is a powerful feature that allows
arbitrarily complex user input and metadata linkage via relatively simple primitive form
input configuration. These wizard editors can be configured to appear for any class.
These are the working principles:
wizard_editorsoption, which allowsseveral standard options along with the important: an array of
inputsand thetemplateinputshave to specify thetype, among other rendering options; currently supportedtypes includetext,text-paragraph, andboolean. The plan is to extend thesesubstantially, possibly driven by LinkML types provided by a specific schema, but also
allowing already supported
shacl-vueeditors. Eachinputconfigures the associatedinput component in the wizard form, and they will render in the order provided via
configuration.
inputs also have to specify a uniqueprop, which becomes the field name through whichthis input is referenced, both in
shacl-vueinternals and inside the TTL template.templateshould be a TTL string, with to-be-populated field names inside{curly brackets}. Field names include allprops configured forinputs, as well as{pid}, which refers to the identifty of the current record being edited and from whichthe wizard is launched. TTL can either be supplied directly as a string, or as a URL via
the existing
contentoption.wizard_editor_selection.mdi-string which will render any of the standard freemdiiconscontent:pointer to an SVG file, which will be loaded and rendered as isImportantly, any SVG used in this context should have a viewport or width/height of 24x24 px
This commit includes a documentation update that covers all details related to the wizard
editor feature, extensively.
To achieve the above, the following major code changes were done:
NodeShapeEditor, which renders for a given record when it is being created or editedinside the
FormEditor, will check thewizard_editor_selectionto see if any wizards needto be made available for the current record type (a.k.a. class). If yes, it will render those
as buttons at the top of the form below the
All fieldsbutton. The wizards render as clickablebuttons, with customizable tooltips and icons, which will open a dialog when clicked, passing
along all config options related to the selected wizard
WizardEditorwill render inside the dialog. It will display all general configoptions of the wizard, and will then render a row per input. Inputs have their own descriptions
and validation rules embedded (taken from config). Reset and Cancel buttons are self-explanatory.
The save button will run validation on all inputs, and on successful validation will emit a
saveevent to the parent component (
NodeShapeEditor), also passing along all entered input values.saveevent from a wizard, theNodeShapeEditorwill:wizardDatawizardDataunder thepidfield, which is howthe record can be referenced inside the TTL template
wizardDatato the existingfillStringTemplateutility function to render valid TTLoutput
rdfDS.parseTTLandDedup(newTTL)that outputs quads and adds them to the graphstore
rdfDS.parseTTLandDedup(newTTL)returns all the quads that were parsed and added to the graphstore. These are now process individually. Importantly, if an added quad has a subject value that
is identical
to the current node ID, we delete it from the graph store, because it uses a nonsense named node
(the node ID of the record, which is not reproducibly identical to the record PID). However, we
also add the quad's object to the
formDataunder the index of the current node and the quad'spredicate, in order to keep linkage to the TTL-parsed quads. Importantly, the existing standard
functionality that runs when saving a form (for record creation or editing) will then take care
of adding the correct quads to the graph store to replace those that were deleted.
store, if an added quad has a subject value that is NOT identical to the current node ID, AND it
is a named node, this means that a new record has been added to the graph store and it is therefore
eligible for submission. This is added to
savedNodesandnodesToSubmit, as well as a separateNodeShapeEditor-specific tracker of all wizard-added quads.but the form was then subsequently cancelled. To deal with this,
NodeShapeEditorregisters a formcancel handler via the existing
registerHandlerfunctionality, which will delete all the relevantquads.
Lastly, for improved UI the headings of "property groups" in the
NodeShapeEditorhave beenremoved. This is in anticipation of the complete removal of parent-class-based grouping of
properties inside the
NodeShapeEditor.This feature allows custom form dialog construction via config, as well as TTL template specification, which is then string-serialized using the user inputs upon form save, followed by adding the parsed quads to the graph store. This is a powerful feature that allows arbitrarily complex user input and metadata linkage via relatively simple primitive form input configuration. These wizard editors can be configured to appear for any class. These are the working principles: - a new wizard is declared and configured via the new 'wizard_editors' option, which allows several standard options along with the important: an array of 'inputs' and the 'template' - 'inputs' have to specify the 'type', among other rendering options; currently supported 'type's include 'text', 'text-paragraph', and 'boolean'. The plan is to extend these substantially, possibly driven by LinkML types provided by a specific schema, but also allowing already supported 'shacl-vue' editors. Each 'input' configures the associated input component in the wizard form, and they will render in the order provided via configuration. - 'input's also have to specify a unique 'prop', which becomes the field name through which this input is referenced, both in 'shacl-vue' internals and inside the TTL template. - the 'template' should be a TTL string, with to-be-populated field names inside 'curly brackets'. Field names include all 'prop's configured for 'input's, as well as 'pid', which refers to the identifty of the current record being edited and from which the wizard is launched. TTL can either be supplied directly as a string, or as a URL via the existing 'content' option. - declared wizards are configured for rendering for specific classes via the new option 'wizard_editor_selection'. - wizards can be supplied with icons via configuration; these can come in different formats: - an 'mdi-' string which will render any of the standard free 'mdi' icons - 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 SVG used in this context should have a viewport or width/height of 24x24 px This commit includes a documentation update that covers all details related to the wizard editor feature, extensively. To achieve the above, the following major code changes were done: - The 'NodeShapeEditor', which renders for a given record when it is being created or edited inside the 'FormEditor', will check the 'wizard_editor_selection' to see if any wizards need to be made available for the current record type (a.k.a. class). If yes, it will render those as buttons at the top of the form below the 'All fields' button. The wizards render as clickable buttons, with customizable tooltips and icons, which will open a dialog when clicked, passing along all config options related to the selected wizard - The new 'WizardEditor' will render inside the dialog. It will display all general config options of the wizard, and will then render a row per input. Inputs have their own descriptions and validation rules embedded (taken from config). Reset and Cancel buttons are self-explanatory. The save button will run validation on all inputs, and on successful validation will emit a 'save' event to the parent component ('NodeShapeEditor'), also passing along all entered input values. - On detecting a 'save' event from a wizard, the 'NodeShapeEditor' will: - receive the input values and declare them as 'wizardData' - add the node ID of the current record to the 'wizardData' under the 'pid' field, which is how the record can be referenced inside the TTL template - pass 'wizardData' to the existing 'fillStringTemplate' utility function to render valid TTL output - pass the TTL to 'rdfDS.parseTTLandDedup(newTTL)' that outputs quads and adds them to the graph store - 'rdfDS.parseTTLandDedup(newTTL)' returns all the quads that were parsed and added to the graph store. These are now process individually. Importantly, if an added quad has a subject value that is identical to the current node ID, we delete it from the graph store, because it uses a nonsense named node (the node ID of the record, which is not reproducibly identical to the record PID). However, we also add the quad's object to the 'formData' under the index of the current node and the quad's predicate, in order to keep linkage to the TTL-parsed quads. Importantly, the existing standard functionality that runs when saving a form (for record creation or editing) will then take care of adding the correct quads to the graph store to replace those that were deleted. - Continuing with the individual processing of quads that were parsed from TTL and added to the graph store, if an added quad has a subject value that is NOT identical to the current node ID, AND it is a named node, this means that a new record has been added to the graph store and it is therefore eligible for submission. This is added to 'savedNodes' and 'nodesToSubmit', as well as a separate 'NodeShapeEditor'-specific tracker of all wizard-added quads. - Garbage cleanup is also necessary in the case where quads were added to the graph store by a wizard but the form was then subsequently cancelled. To deal with this, 'NodeShapeEditor' registers a form cancel handler via the existing 'registerHandler' functionality, which will delete all the relevant quads. Lastly, for improved UI the headings of 'property groups' in the 'NodeShapeEditor' have been removed. This is in anticipation of the complete removal of parent-class-based grouping of properties inside the 'NodeShapeEditor'.