New Special Button feature for record viewer #335
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!335
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "special-buttons"
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?
New
Special Buttonfeature for record viewerRecords might have properties (via RDF statements) that are best viewed as a button to click on, e.g. a download URL or a link to an external homepage or similar. This new feature allows buttons to be rendered for configured 'special properties', where the configuration includes identifying the special property, how to find it (relative to the parent record), which exact value to find, and how to turn it into a link. For example:
This configuration specifies the new config option
specialButtonsundercomponent_config -> NodeShapeViewer. It configures theDownloadUrlspecial button:slot: dlthings:characterized_by: start with thedlthings:characterized_byslot/property of the main recorddlthings:characterized_byslot, match them against keys and values provided in thematchlist. This means: find the related record for which therdf:typeisdlthings:StatementAND for which therdf:predicateisdcat:downloadUrl. The possibility of matching multiple records is supported.returntherdf:object(multiple return values per matched record is not yet supported)templateinto the already existingfillStringTemplatefunction that performs string serializationThe config should also contain an icon and tooltip in order to render a user-friendly button.
To achieve this, the main code changes include:
findBlankNodeLink, this interprets the config and finds the relevant informationNodeShapeViewerto call the new function if anyspecialButtonsare configuredSpecialButtonis rendered fromNodeShapeViewer; it fills the string template with matched values as input, and renders the buttonsgetIconfunction was generlized and moved to utils, and removed fromuseWizardcomposableSVGIconcomponent has updated styling to render an icon vertical centerNOTE: an additional unrelated change to
NodeShapeViewerwas also committed: this usesPromise.allinstead of a for loop to calladdRecordPropertyin an attempt to shorten the amount of time needed to render a single record.Sample configurations:
Records might have properties (via RDF statements) that are best viewed as a button to click on, e.g. a download URL or a link to an external homepage or similar. This new feature allows buttons to be rendered for configured 'special properties', where the configuration includes identifying the special property, how to find it (relative to the parent record), which exact value to find, and how to turn it into a link. For example: component_config: NodeShapeViewer: specialButtons: DownloadUrl: slot: dlthings:characterized_by match: - key: rdf:type val: dlthings:Statement - key: rdf:predicate val: dcat:downloadUrl return: rdf:object template: '{return}' icon: mdi-download tooltip: Download This configuration specifies the new config option 'specialButtons' under 'component_config -> NodeShapeViewer'. It configures the 'DownloadUrl' special button: - 'slot: dlthings:characterized_by': start with the 'dlthings:characterized_by' slot/property of the main record - for every related record referenced via the 'dlthings:characterized_by' slot, match them against keys and values provided in the 'match' list. This means: find the related record for which the 'rdf:type' is 'dlthings:Statement' AND for which the 'rdf:predicate' is 'dcat:downloadUrl'. The possibility of matching multiple records is supported. - for every matched record, 'return' the 'rdf:object' (multiple return values per matched record is not yet supported) - To ultimately get the link/href value(s), pass the returned value(s) together with the 'template' into the already existing 'fillStringTemplate' function that performs string serialization The config should also contain an icon and tooltip in order to render a user-friendly button. To achieve this, the main code changes include: - add the main work horse function to utils: 'findBlankNodeLink', this interprets the config and finds the relevant information - update 'NodeShapeViewer' to call the new function if any 'specialButtons' are configured - new comoponent 'SpecialButton' is rendered from 'NodeShapeViewer'; it fills the string template with matched values as input, and renders the buttons - the 'getIcon' function was generlized and moved to utils, and removed from 'useWizard' composable - 'SVGIcon' component has updated styling to render an icon vertical center NOTE: an additional unrelated change to 'NodeShapeViewer' was also committed: this uses 'Promise.all' instead of a for loop to call 'addRecordProperty' in an attempt to shorten the amount of time needed to render a single record.