Skip to content

Commit

Permalink
[doc] Update the ADR to display selection dialog as tree
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Barbin <[email protected]>
  • Loading branch information
florianbarbin committed Jul 10, 2024
1 parent 350670a commit ea2acd9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions doc/adrs/153_selection_dialog_tree_view.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,28 @@ type SelectionObject {

=== Preferred option

==== View model

The specifier will choose whether the objects returned by the candidates expression will be displayed as a tree or as a flat list.

The `SelectionDialogDescription` from the Diagram View model will have two additional boolean attributes:

* `displayedAsTree`: to indicate whether the dialog layout should be a tree.
* `expendedAtOpening`: to indicate if the tree should be expended by default (that means all tree items are expended at opening)
* `expandedAtOpening`: to indicate if the tree should be expanded by default (that means all tree items are expanded at opening)

==== Backend and GraphQL API

In addition, the Selection computed by the `SelectionRender` by the server will now return the containment information.

Since the tree depth is not known by the frontend beforehand, the backend needs to return the whole tree items in a flat way.

In addition, the Selection computed by the `SelectionRender` by the server will now return the containment information:
The GraphQL subscription query will thus have a fixed depth. The containment information will be owned by a field called `parentId`.

* A `SelectionObject` can contain `SelectionObject` as children.
To do so, we will keep the same GraphQL structure but with the following changes:

* A `SelectionObject` will have a `parentId` field (optional), that will be a reference to another `SelectionObject#id` field.
* A `SelectionObject` will contain the information whether it can be selected or not in order to differentiate elements from the candidatesExpression to the hierarchical nodes.
* The `Selection` will also contains the information whether the dialog should be displayed as a tree or not and if we should expand all nodes at opening.

Thus, the GraphQL API will evolved as following:

Expand All @@ -66,14 +77,14 @@ type Selection implements Representation {
message: String
objects: [SelectionObject!]!
displayedAsTree: Boolean!
expendedAtOpening: Boolean!
expandedAtOpening: Boolean!
}

type SelectionObject {
id: ID!
label: String!
iconURL: [String!]!
objects: [SelectionObject!]!
parentId: String
isSelectable: Boolean!
}
```
Expand Down Expand Up @@ -107,6 +118,8 @@ Root
|_ (F)
```

==== Frontend

Elements that are not selectable (out of the computed candidates set) will by faded in the same way than the reference widget semantic browser do:

image:images/153/referenceWidgetSemanticBrowser.png[Reference Widget Semantic Browser, 50%]
Expand Down Expand Up @@ -139,6 +152,20 @@ We will rely on the MaterialUI `TreeItem` and `TreeView` in the same way than th
);
```

If the Selection is refreshed by the backend, following a semantic change from another client for instance, a new Selection from the subscription will be received by the SelectionDialog and trigger the component rerendering.

If the end-user has changed the expanded state, we want to keep them expanded in that situation.

To do so, We will modify the SelectionDialog state machine as follow:

* A new `expandedSelectionObjectIds : string[]` will be added in the `SelectionDialogContext`.
* A new event `HandleExpandUpdatedEvent` = { type: 'HANDLE_EXPAND_UPDATED'; expandedObjectId: string }; This event will add or remove the expandedObjectId from the expandedSelectionObjectIds array.

A TreeItem will be expanded if:

* The expandedAtOpening is activated: in that case, the `expandedSelectionObjectIds` will be initialized with all selectedObject ids.
* The user expanded the item manually.

=== Second option

The second option but not the preferred one, consists in relying on the TreeRepresentation.
Expand Down
Binary file added doc/adrs/images/153/currentSelectionDialog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ea2acd9

Please sign in to comment.