knowledgepixels / nanodash

A web client to browse and publish nanopublications.
GNU Affero General Public License v3.0
27 stars 2 forks source link

Bug (?): optional statements are not optional in grouped statements #153

Closed Ostrzyciel closed 2 months ago

Ostrzyciel commented 2 months ago

When I create a Nanopub template with a grouped statement, I sometimes want to have an optional statement within that group. This is useful for any case where we create local resources that have some optional properties (e.g., a list of people with an optional email address of each person).

The Nanopub template editor does allow me to specify the nested statement as "optional", but this doesn't seem to have any effect on Nanodash. It still treats the nested statement as mandatory.

Minimal example template to reproduce this: https://nanodash.petapico.org/explore?id=https://w3id.org/np/RAyM0zW2Aj9Z08D4_AjhKRQrgwMhkA0xJoDUL6dmclRYg

This template has an optional "comment" field. When you try to create a nanopub using this template and skip this field, you get an error:

image

Expectation: Nanodash should allow me to save this Nanopublication.

tkuhn commented 2 months ago

Yes, that's correct, but it's not a bug. This is by design and expected behavior (though insufficiently documented).

Well, it's a minor bug that you can still mark the statement as optional, even though it doesn't have an effect, which is because it can be tricky to define such complex restrictions with the current templating features. (It might be possible, I am not sure and would have to look into it again...)

Optional and repeatable are only applicable to top-level elements. And groups cannot be nested, so there are only at most two levels. This is because deeper nesting leads to all kinds of practical complexities and problems, also with respect to providing a good user interface.

You can, however, move these optional parts to the top level with a separate repeatable statement. See e.g. here, where we have a list of authors that can optionally have email addresses, but the latter are in a separate top-level statement: https://nanodash.knowledgepixels.com/publish?template=https://w3id.org/np/RAeQJfX3lMDqtzyddnRmlBvxSoWohzEKzsaMKWrR8K6J0

In the particular case of a literal, fixing the bug that literal values can currently not be empty (https://github.com/knowledgepixels/nanodash/issues/49) would also allow for the option to have a mandatory comment field but allow for it to be left empty.

Ostrzyciel commented 2 months ago

Again, thank you for the quick reply and the link to a template that tackles this.

If it's not a bug, then should we close this?

tkuhn commented 2 months ago

Yes, I think we can close it. Unless you want to keep it open so we can track any progress about the minor bugs of being able to express it in the first place, the missing documentation, etc., then I am fine with keeping it open too.

Ostrzyciel commented 2 months ago

Let's close it then. :) Better to have more specific tasks for these minor issues, I think.