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

refactor: Improve validation of GUI elements and GUI attributes (DEV-1082) #2098

Merged
merged 33 commits into from Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
71b8e31
validate value type of gui attribute
Jul 18, 2022
b1621ff
improve formatting of salsah-gui.md
Jul 19, 2022
55aa3db
small improvements
Jul 19, 2022
8cb55bd
improve error handling
Jul 20, 2022
3ff6e70
return multiple validation errors
Jul 20, 2022
2c67113
add validation for all gui elements and gui attributes
Jul 21, 2022
629f52e
organize imports
Jul 21, 2022
8634e8f
test value types
Jul 21, 2022
35ae562
handle gui element of None
Jul 21, 2022
74c502e
Merge branch 'main' into wip/dev-1082-explore-newtypes
Jul 21, 2022
ee0fa52
simplify code
Jul 21, 2022
8286534
add more tests
Jul 21, 2022
58c9956
move tests
Jul 25, 2022
3147382
remove old value objects
Jul 25, 2022
ecee76d
update test data
Jul 25, 2022
eaf3190
update test data comments
Jul 25, 2022
b5629f0
add more validation for hlist gui attribute value
Jul 25, 2022
9ae9498
Merge branch 'main' into wip/dev-1082-explore-newtypes
Jul 26, 2022
69fe44c
clean up constants
Jul 26, 2022
643f8fe
clean up naming of imports
Jul 26, 2022
fb1f89c
move uriValidator
Jul 26, 2022
9699405
move expected gui attributes to global variable
Jul 26, 2022
2ade669
refactor gui attribute map
Jul 26, 2022
328be49
remove remnants of old salsah gui validation
Jul 26, 2022
97bbb7a
use subtype for password strength
Jul 26, 2022
5e36789
remove unused value
Jul 26, 2022
2938331
Merge branch 'main' into wip/dev-1082-explore-newtypes
Jul 27, 2022
42a2ebd
fix docstrings in UserRepo
Jul 28, 2022
9fb964e
implement feedback from PR review
Jul 28, 2022
4d4abef
Merge branch 'main' into wip/dev-1082-explore-newtypes
Jul 28, 2022
324e833
Fix wrong value
Jul 28, 2022
7193b57
Merge branch 'wip/dev-1082-explore-newtypes' of https://github.com/da…
Jul 28, 2022
3943f2e
return multiple errors in route
Jul 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
262 changes: 126 additions & 136 deletions docs/02-knora-ontologies/salsah-gui.md
Expand Up @@ -18,202 +18,192 @@ brevity, we omit the prefix in this document.

## Properties

`guiOrder`
### guiOrder

`guiOrder` can be attached to an `owl:Restriction` representing a cardinality
irinaschubert marked this conversation as resolved.
Show resolved Hide resolved
in a resource class, to indicate the order in which properties
should be displayed in the GUI. The object is a non-negative
integer. For example, a property with `guiOrder` 0 would be
displayed first, followed by a property with `guiOrder` 1, and so
on.

: Can be attached to an `owl:Restriction` representing a cardinality
in a resource class, to indicate the order in which properties
should be displayed in the GUI. The object is a non-negative
integer. For example, a property with `guiOrder` 0 would be
displayed first, followed by a property with `guiOrder` 1, and so
on.
### guiElement

`guiElement`
`guiElement` can be attached to a property definition to indicate which SALSAH
GUI element should be used to enter data for the property. This
irinaschubert marked this conversation as resolved.
Show resolved Hide resolved
should be one of the individuals of class `Guielement` described
below.

: Can be attached to a property definition to indicate which SALSAH
GUI element should be used to enter data for the property. This
should be one of the individuals of class `Guielement` described
below.
### guiAttribute

`guiAttribute`

: Can be attached to a property definition to provide attributes for
the GUI element specified in `guiElement`. The objects of this
predicate are written in a DSL with the following syntax:
`guiAttribute` can be attached to a property definition to provide attributes for
the GUI element specified in `guiElement`. The objects of this
predicate are written in a DSL with the following syntax:

```ebnf
object = attribute name, "=", attribute value ;

attribute name = identifier ;

identifier = letter , { letter } ;

attribute value = integer | decimal | percent | string | iri ;

percent = integer, "%" ;

iri = "<", string, ">" ;
object = attribute name, "=", attribute value ;
attribute name = identifier ;
identifier = letter , { letter } ;
attribute value = integer | decimal | percent | string | iri ;
percent = integer, "%" ;
iri = "<", string, ">" ;
irinaschubert marked this conversation as resolved.
Show resolved Hide resolved
```

The attributes used with each GUI element are described below under
[Individuals](#individuals).

`guiAttributeDefinition`
### guiAttributeDefinition

: Used only in the `salsah-gui` ontology itself, as a predicate
attached to instances of `Guielement` (see [Individuals](#individuals)),
to specify the attributes that can be given as objects of `guiAttribute` when a given
`Guielement`. is used. The objects of this predicate are written in
a DSL with the following syntax:
`guiAttributeDefinition` is used only in the `salsah-gui` ontology itself, as a predicate
attached to instances of `Guielement` (see [Individuals](#individuals)),
to specify the attributes that can be given as objects of `guiAttribute` when a given
`Guielement` is used. The objects of this predicate are written in
a DSL with the following syntax:

```ebnf
object = attribute name, [ "(required)" ], ":", attribute type, [ enumerated values ] ;

enumerated values = "(", enumerated value, { "|", enumerated value } ")" ;

attribute name = identifier ;

attribute type = "integer" | "decimal" | "percent" | "string" | "iri" ;

enumerated value = identifier ;

identifier = letter , { letter } ;
object = attribute name, [ "(required)" ], ":", attribute type, [ enumerated values ] ;
enumerated values = "(", enumerated value, { "|", enumerated value } ")" ;
attribute name = identifier ;
attribute type = "integer" | "decimal" | "percent" | "string" | "iri" ;
enumerated value = identifier ;
identifier = letter , { letter } ;
```

Enumerated values are allowed only if `attribute type` is `string`.
If enumerated values are provided for an attribute, the attribute
value given via `guiAttribute` must be one of the enumerated values.
Enumerated values are allowed only if `attribute type` is `string`.
If enumerated values are provided for an attribute, the attribute
value given via `guiAttribute` must be one of the enumerated values.

## Classes

`Guielement`
### Guielement

: The instances of this class are individuals representing SALSAH GUI
elements for data entry.
The instances of class `Guielement` are individuals representing SALSAH GUI
irinaschubert marked this conversation as resolved.
Show resolved Hide resolved
irinaschubert marked this conversation as resolved.
Show resolved Hide resolved
elements for data entry.

## Individuals

`Colorpicker`
### Colorpicker

: A GUI element for selecting a color. A property definition that uses
this element may also contain a `guiAttribute` predicate whose
object is a string in the form `"ncolors=N"`, where `N` is an
integer specifying the number of colors to display.
`Colorpicker` is a GUI element for selecting a color. A property definition that uses
this element may also contain a `guiAttribute` predicate whose
object is a string in the form `"ncolors=N"`, where `N` is an
integer specifying the number of colors to display.

`Date`
### Date

: A GUI element for selecting a date.
`Date` is a GUI element for selecting a date.

`Geometry`
### Geometry

: A GUI element for selecting the geometry of a two-dimensional
region.
`Geometry` is a GUI element for selecting the geometry of a two-dimensional
region.

`Geonames`
### Geonames

: A GUI element for selecting a [Geonames](http://www.geonames.org/)
identifier.
`Geonames` is a GUI element for selecting a [Geonames](http://www.geonames.org/)
identifier.

`Interval`
### Interval

: A GUI element for selecting a time interval in an audio or video
recording.
`Interval` is a GUI element for selecting a time interval in an audio or video
recording.

`List`
### List

: A GUI element for selecting an item in a hierarchical list (see
[ListValue](knora-base.md#listvalue)). A property definition that
uses this element must also contain this `guiAttribute` predicate:
`List` is a GUI element for selecting an item in a hierarchical list (see
[ListValue](knora-base.md#listvalue)). A property definition that
uses this element must also contain this `guiAttribute` predicate:

- `"hlist=<LIST_IRI>"`, where `LIST_IRI` is the IRI of a
`knora-base:ListNode` that is the root node of a hierarchical list.
- `"hlist=<LIST_IRI>"`, where `LIST_IRI` is the IRI of a
`knora-base:ListNode` that is the root node of a hierarchical list.

`Pulldown`
### Pulldown

: A GUI element for selecting an item in a flat list (see
[ListValue](knora-base.md#listvalue)) using a pull-down menu. A
property definition that uses this element must also contain this
`guiAttribute` predicate:
`Pulldown` is a GUI element for selecting an item in a flat list (see
[ListValue](knora-base.md#listvalue)) using a pull-down menu. A
property definition that uses this element must also contain this
`guiAttribute` predicate:

- `"hlist=<LIST_IRI>"`, where `LIST_IRI` is the IRI of a
`knora-base:ListNode` that is the root node of a hierarchical list.
- `"hlist=<LIST_IRI>"`, where `LIST_IRI` is the IRI of a
irinaschubert marked this conversation as resolved.
Show resolved Hide resolved
`knora-base:ListNode` that is the root node of a hierarchical list.

`Radio`
### Radio

: A GUI element for selecting an item in a flat list (see
[ListValue](knora-base.md#listvalue)) using radio buttons. A property
definition that uses this element must also contain this
`guiAttribute` predicate:
`Radio` is a GUI element for selecting an item in a flat list (see
[ListValue](knora-base.md#listvalue)) using radio buttons. A property
definition that uses this element must also contain this
`guiAttribute` predicate:

- `"hlist=<LIST_IRI>"`, where `LIST_IRI` is the IRI of a
`knora-base:ListNode` that is the root node of a hierarchical list.
- `"hlist=<LIST_IRI>"`, where `LIST_IRI` is the IRI of a
irinaschubert marked this conversation as resolved.
Show resolved Hide resolved
`knora-base:ListNode` that is the root node of a hierarchical list.

`Richtext`
### Richtext

: A GUI element for editing multi-line formatted text.
`Richtext` is a GUI element for editing multi-line formatted text.

`Searchbox`
### Searchbox

: A GUI element for searching for a resource by matching text in its
`rdfs:label`. For DSP-API v1, a property definition that uses this
element may also contain this `guiAttribute` predicate:
`Searchbox` is a GUI element for searching for a resource by matching text in its
`rdfs:label`. For DSP-API v1, a property definition that uses this
element may also contain this `guiAttribute` predicate:

- `"numprops=N"`, where `N` is an integer specifying the number of
describing properties to be returned for each found resource.
- `"numprops=N"`, where `N` is an integer specifying the number of
irinaschubert marked this conversation as resolved.
Show resolved Hide resolved
irinaschubert marked this conversation as resolved.
Show resolved Hide resolved
describing properties to be returned for each found resource.

For DSP-API v2, the `guiAttribute` has no effect.
For DSP-API v2, the `guiAttribute` has no effect.

`SimpleText`
### SimpleText

: A GUI element for editing a single line of unformatted text. A
property definition that uses this element may also contain a
`guiAttribute` predicate with one or both of the following objects:
`SimpleText` is a GUI element for editing a single line of unformatted text. A
property definition that uses this element may also contain a
`guiAttribute` predicate with one or both of the following objects:

- `"size=N"`, where `N` is an integer specifying the size of the
text field.
- `"maxlength=N"`, where `N` is an integer specifying the maximum
length of the string to be input.
- `"size=N"`, where `N` is an integer specifying the size of the
text field.
- `"maxlength=N"`, where `N` is an integer specifying the maximum
length of the string to be input.

`Slider`
### Slider

: A GUI element for choosing numerical values using a slider. A
property definition that uses this element must also contain a
`guiAttribute` predicate with both of the following objects:
`Slider` is a GUI element for choosing numerical values using a slider. A
property definition that uses this element must also contain a
`guiAttribute` predicate with both of the following objects:

- `"min=N"`, where `N` is an integer specifying the minimum value
of the input.
- `"max=N"`, where `N` is an integer specifying the maximum value
of the input.
- `"min=N"`, where `N` is an integer specifying the minimum value
of the input.
- `"max=N"`, where `N` is an integer specifying the maximum value
of the input.

`Spinbox`
### Spinbox

: A GUI element for choosing numerical values using a spinbox. A
property definition that uses this element may also contain a
`guiAttribute` predicate with one or both of the following objects:
`Spinbox` is a GUI element for choosing numerical values using a spinbox. A
property definition that uses this element may also contain a
`guiAttribute` predicate with one or both of the following objects:

- `"min=N"`, where `N` is an integer specifying the minimum value
of the input.
- `"max=N"`, where `N` is an integer specifying the maximum value
of the input.
- `"min=N"`, where `N` is an integer specifying the minimum value
of the input.
- `"max=N"`, where `N` is an integer specifying the maximum value
of the input.

`Textarea`
### Textarea

: A GUI element for editing multi-line unformatted text. A property
definition that uses this element may also contain a `guiAttribute`
predicate with one or more of the following objects:
`Textarea` is a GUI element for editing multi-line unformatted text. A property
definition that uses this element may also contain a `guiAttribute`
predicate with one or more of the following objects:

- `"width=N"`, where `N` is a percentage of the window width (an
integer followed by `%`).
- `"cols=N"`, where `N` is an integer representing the number of
colums in the text entry box.
- `"rows=N"`, where `N` is an integer specifying the height of the
text entry box in rows.
- `"wrap=W"`, where `W` is `soft` or `hard` (see
[wrap](https://www.w3.org/TR/html5/sec-forms.html#element-attrdef-textarea-wrap)).
- `"width=N"`, where `N` is a percentage of the window width (an
integer followed by `%`).
- `"cols=N"`, where `N` is an integer representing the number of
colums in the text entry box.
- `"rows=N"`, where `N` is an integer specifying the height of the
text entry box in rows.
- `"wrap=W"`, where `W` is `soft` or `hard` (see
[wrap](https://www.w3.org/TR/html5/sec-forms.html#element-attrdef-textarea-wrap)).

`Checkbox`
### Checkbox

: A GUI element for choosing a boolean value using a checkbox.
`Checkbox` is a GUI element for choosing a boolean value using a checkbox.

`Fileupload`
### Fileupload

: A GUI element for uploading a file.
`Fileupload` is a GUI element for uploading a file.