Skip to content

Commit

Permalink
[3834] Add more variables for DeckDescription
Browse files Browse the repository at this point in the history
Bug: #3834
Signed-off-by: Laurent Fasani <[email protected]>
  • Loading branch information
lfasani committed Aug 27, 2024
1 parent b083ee1 commit 925c6ce
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
9 changes: 9 additions & 0 deletions doc/specifier/representation-deck.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ image::images/deck-description-overview.png[Deck description overview]
* `Precondition Expression`: An expression that determine if it is possible to create the representation
* `Title Expression`: The initial name of the representation once created
### Variables

The variable `deckTarget` is the semantic element associated with the deck representation.
It is available for

* lane descriptions
* card descriptions
* all style descriptions
### Deck style

It is possible to define the *background color* of the `Deck` representation by adding a `StyleDescription` in the `DeckDescription`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ public IPayload createCard(CreateDeckCardInput createDeckCardInput, IEditingCont
String currentLaneId = createDeckCardInput.currentLaneId();
Optional<Lane> optionalParentLane = this.findLane(lane -> Objects.equals(lane.id(), currentLaneId), deck);
Optional<LaneDescription> optionalLaneDescription = optionalParentLane.flatMap(lane -> this.findLaneDescription(lane.descriptionId(), deck, editingContext));
Optional<Object> deckTargetOpt = this.objectService.getObject(editingContext, deck.getTargetObjectId());

if (optionalLaneDescription.isPresent()) {
if (optionalLaneDescription.isPresent() && deckTargetOpt.isPresent()) {
VariableManager variableManager = new VariableManager();
Optional<Object> optionalTargetObject;
if (currentLaneId != null) {
Expand All @@ -84,6 +85,7 @@ public IPayload createCard(CreateDeckCardInput createDeckCardInput, IEditingCont
}
if (optionalTargetObject.isPresent()) {
variableManager.put(VariableManager.SELF, optionalTargetObject.get());
variableManager.put(DeckDescription.DECK_TARGET, deckTargetOpt.get());
variableManager.put(DeckDescription.TITLE, createDeckCardInput.title());
variableManager.put(DeckDescription.DESCRIPTION, createDeckCardInput.description());
variableManager.put(DeckDescription.LABEL, createDeckCardInput.label());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ private Deck doRender(String label, Object targetObject, IEditingContext editing
VariableManager variableManager = new VariableManager();
variableManager.put(DeckDescription.LABEL, label);
variableManager.put(VariableManager.SELF, targetObject);
variableManager.put(DeckDescription.DECK_TARGET, targetObject);
variableManager.put(IEditingContext.EDITING_CONTEXT, editingContext);
Optional<Deck> optionalPreviousDeck = optionalDeckContext.map(IDeckContext::getDeck);
Optional<IDeckEvent> optionalDeckEvent = optionalDeckContext.map(IDeckContext::getDeckEvent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public record DeckDescription(String id, String label, Function<VariableManager,

public static final String LABEL = "label";

public static final String DECK_TARGET = "deckTarget";

public static final String NEW_TITLE = "newTitle";

public static final String NEW_DESCRIPTION = "newDescription";
Expand Down

0 comments on commit 925c6ce

Please sign in to comment.