Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form: Add default properties for a new object? #460

Open
josephguillaume opened this issue Dec 19, 2021 · 0 comments
Open

Form: Add default properties for a new object? #460

josephguillaume opened this issue Dec 19, 2021 · 0 comments

Comments

@josephguillaume
Copy link

josephguillaume commented Dec 19, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant