SolidOS / SolidOS/solid-ui

Form: Add default properties for a new object?

Open
#460 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
153
Forks
46
Avg merge
1d 8h
Merged PRs (30d)
7

Description

When using ui:Multiple, currently a new object is created and linked to the subject with the specified ui:property.
https://github.com/solid/solid-ui/blob/c4ad302f361cc4a1de24941a475cb66333c43805/src/widgets/forms.js#L273

The form to use for the new object is then specified by ui:part

It appears there is currently no way to specify default properties for the new object, e.g. its rdf:type.
For rdf:type in particular, this means that forms for the new object will not be rendered by solid-panes, which discovers the relevant form based on its class.

Possible solutions

I don't whether there is a need for a more general templating mechanism, but at least for rdf:type, a solution could be to allow ui:Multiple to also use ui:category (as for ui:Classifier) or ui:targetClass (as for ui:Autocomplete)

Another option would be to specify ui:from (as for ui:Choice) instead of ui:part, and choose the ui:creationForm based on the specified rdfs:Class.

Example use case

Generating a new observation

sosa:Observation ui:annotationForm :ObsForm.
:ObservationList ui:annotationForm :ObsListForm.

:ObsListForm
    a ui:Multiple;
    ui:part :ObsForm;
    ui:property rdfs:member;
    ui:category sosa:Observation.

:ThisObsList a :ObservationList.

Creating a new object in :ThisObsList would generate:

:ThisObsList rdfs:member :id1639432788935.
:id1639432788935 a sosa:Observation.

Edit: I've got an patch using ui:category here: https://github.com/josephguillaume/my-solidos-patches/blob/2860861f3ce4ddde9a8b0831ca520e4492878991/solid-ui.diff#L32

Edit: incidentally it's possible to get the desired behaviour by using ui:reverse with rdf:type as the ui:property

sosa:Observation ui:annotationForm :ObsForm.

:dummyClass ui:annotationForm :ObsListForm.
sosa:Observation a :dummyClass.

:ObsListForm
    a ui:Multiple;
    ui:part :ObsForm;
    ui:reverse 1;
    ui:property rdf:type.

Visiting sosa:Observation builds a form for :dummyClass which generates triples:
:newsubject a sosa:Observation

This might be more of a curiosity than a real solution.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/widgets/forms.js around line 273 and compare how ui:Multiple handles ui:part with the ui:category, ui:targetClass, and ui:from patterns described in the issue. Determine which approach should define default properties for a newly created object, using the sosa:Observation example as the acceptance case. Done means the new object receives its default rdf:type and solid-panes can render its form.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.