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

[doc] Add ADR for dynamic widgets support in Forms #2240

Merged
merged 2 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: vscode
path: vscode-extension/sirius-web-2023.8.1.vsix
path: vscode-extension/sirius-web-2023.8.2.vsix
retention-days: 20

- name: Compress the code coverage results
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

=== Architectural decision records

- [ADR-107] Add support for dynamic and conditional widgets in Forms


=== Breaking changes

Expand Down
50 changes: 50 additions & 0 deletions doc/adrs/107_dynamic_widgets.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
= [ADR-107] Add support for dynamic and conditional widgets in Forms

== Context

The set of widgets displayed by a _Form_ is currently hard-coded statically in the structure of the corresponding _FormDescription_.
Each _WidgetDescription_ will produce one, and only one, concrete widget when the form is rendered.

On the desktop side, EEF overcame this limitation by introducing https://eclipse.dev/sirius/doc/specifier/properties/Properties_View_Description.html#dynamic_mappings[dynamic mappings], based on two new configuration elements: `DynamicFor` and `DynamicIf`.

The core rendering algorithm of the Sirius Web Forms already implements these mechanisms to support the compatibility layer with Sirius Desktop VSMs, but they are not exposed when creating a _FormDescription_ using the View DSL.

== Decision

We will add support for `DynamicFor` and `DynamicIf` to the Forms DSL.

In this first version, we will only support the same case as in EEF desktop, namely widgets inside a _Group_.

A _GroupDescription_ currently has a _widgets: WidgetDescription_ reference.
As is the case in EEF desktop, we will introduce a new _ControlDescription_ type as a generalization of _WidgetDescription_, and _GroupDescription.widgets_ will now contain _ControlDescriptions_.
We will not change the name of the _widgets_ reference to avoid breaking existing models.

_FlexboxContainer_, which also acts as a container for widgets, will also be modified in a similar way so that it's _children_ are _ControlDescriptions_.

The new _DynamicFor_ element will also extends _ControlDescription_, so that a group can contain both actual widgets and _DynamicFor_.

_DynamicFor_ will have two attributes:

* `iterationExpression`: an AQL expression to be evaluated when rendering the form, which should return a collection of (arbitrary) elements;
* `iterator`: a (fixed) variable name.

It will also _contain_ an arbitrary number if _DynamicIf_, which has a `predicateExpression` attribute and a `control: ControlDescription[1]` containment reference.

The semantics will be the same as in EEF desktop.

When rendering a _FormDescription_ which uses _DynamicFor_ & _DynamicIfs_, in the context of a _FormDescription Editor_ these elements will not be visible.
The Form will display as if all the widgets inside all the _DynamicIfs_ of a _DynamicFor_ were defined directly inside the parent _GroupDescription_.

== Status

Accepted.

== Consequences

* Any custom widget's metamodel will need to be regenerated.
This is required for the custom widget's child creation extender to be able to be created inside the new _DynamicIf_ elements.
* With this, it will become possible to express more generic and dynamic form descriptions, including the equivalent of https://github.com/eclipse-sirius/sirius-desktop/blob/master/plugins/org.eclipse.sirius.properties.defaultrules/model/properties.odesign[Sirius Desktop defaults properties rules].
* With _DynamicIf_ containing _ControlDescriptions_ instead of actual widgets, it should be possible to create nested loops.
* The first version if the mechanism introduced here will be generalized to allow For/If in as many places as possible (and meaningful) in the Forms DSL, notable on Groups and Pages.
Note that pages already support `semanticCandidatesExpression` which cover part of the same uses cases but is less powerful.
* We will also investigate generalizing this mechanism to the diagrams DSL if/where it can make sense.
4 changes: 2 additions & 2 deletions integration-tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion integration-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sirius-web-integration-tests",
"version": "2023.8.1",
"version": "2023.8.2",
"license": "EPL-2.0",
"private": true,
"devDependencies": {
Expand Down
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eclipse-sirius/sirius-components-parent",
"version": "2023.8.1",
"version": "2023.8.2",
"author": "Eclipse Sirius",
"license": "EPL-2.0",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/charts/backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-charts-parent</artifactId>
<version>2023.8.1</version>
<version>2023.8.2</version>

<name>sirius-components-charts-parent</name>
<description>Sirius Components Charts Parent</description>
Expand Down
6 changes: 3 additions & 3 deletions packages/charts/backend/sirius-components-charts/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</parent>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-charts</artifactId>
<version>2023.8.1</version>
<version>2023.8.2</version>
<name>sirius-components-charts</name>
<description>Sirius Components Charts</description>

Expand All @@ -50,7 +50,7 @@
<dependency>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-representations</artifactId>
<version>2023.8.1</version>
<version>2023.8.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -60,7 +60,7 @@
<dependency>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-tests</artifactId>
<version>2023.8.1</version>
<version>2023.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</parent>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-collaborative-charts</artifactId>
<version>2023.8.1</version>
<version>2023.8.2</version>
<name>sirius-components-collaborative-charts</name>
<description>Sirius Components Collaborative Charts</description>

Expand Down Expand Up @@ -51,23 +51,23 @@
<dependency>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-charts</artifactId>
<version>2023.8.1</version>
<version>2023.8.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-collaborative</artifactId>
<version>2023.8.1</version>
<version>2023.8.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-tests</artifactId>
<version>2023.8.1</version>
<version>2023.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-spring-tests</artifactId>
<version>2023.8.1</version>
<version>2023.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eclipse-sirius/sirius-components-charts",
"version": "2023.8.1",
"version": "2023.8.2",
"author": "Eclipse Sirius",
"license": "EPL-2.0",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/compatibility/backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-compatibility-parent</artifactId>
<version>2023.8.1</version>
<version>2023.8.2</version>

<name>sirius-components-compatibility-parent</name>
<description>Sirius Components Compatibility Parent</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</parent>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-compatibility-emf</artifactId>
<version>2023.8.1</version>
<version>2023.8.2</version>
<name>sirius-components-compatibility-emf</name>
<description>Sirius Components Compatibility EMF</description>

Expand Down Expand Up @@ -58,22 +58,22 @@
<dependency>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-collaborative-diagrams</artifactId>
<version>2023.8.1</version>
<version>2023.8.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-collaborative-forms</artifactId>
<version>2023.8.1</version>
<version>2023.8.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-compatibility</artifactId>
<version>2023.8.1</version>
<version>2023.8.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-emf</artifactId>
<version>2023.8.1</version>
<version>2023.8.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -83,19 +83,19 @@
<dependency>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-tests</artifactId>
<version>2023.8.1</version>
<version>2023.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-diagrams-tests</artifactId>
<version>2023.8.1</version>
<version>2023.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-spring-tests</artifactId>
<version>2023.8.1</version>
<version>2023.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down