-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use card collection to make variables look similar to groups (#356)
* use card collection to make variables look similar to groups * create card-collection that is independent of card type, rework css, remove unecessary classes * simplify listeners and events * rename variable level formatter and use it * rename methods to add listeners --------- Co-authored-by: Tobias Koch <[email protected]>
- Loading branch information
1 parent
e9d1ed2
commit 4a9ddda
Showing
13 changed files
with
245 additions
and
383 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...c/datamanager/views/projects/project/experiments/experiment/ExperimentalVariableCard.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package life.qbic.datamanager.views.projects.project.experiments.experiment; | ||
|
||
|
||
import com.vaadin.flow.component.html.Div; | ||
import com.vaadin.flow.component.html.Span; | ||
import java.io.Serial; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
import life.qbic.datamanager.views.general.Card; | ||
import life.qbic.projectmanagement.application.VariableValueFormatter; | ||
import life.qbic.projectmanagement.domain.project.experiment.ExperimentalVariable; | ||
|
||
/** | ||
* <b>Experimental Variable Card</b> | ||
* <p> | ||
* An experimental variable card can be used to display content of {@link ExperimentalVariable} and | ||
* provide interaction, such as edit and deletion. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public class ExperimentalVariableCard extends Card { | ||
|
||
@Serial | ||
private static final long serialVersionUID = -3801182379812377200L; | ||
private final transient ExperimentalVariable experimentalVariable; | ||
|
||
public ExperimentalVariableCard(ExperimentalVariable experimentalVariable) { | ||
super(); | ||
this.experimentalVariable = experimentalVariable; | ||
layoutComponent(); | ||
} | ||
|
||
private void layoutComponent() { | ||
addClassName("experimental-group"); | ||
|
||
Div cardHeader = new Div(); | ||
cardHeader.addClassName("header"); | ||
|
||
cardHeader.add(title(experimentalVariable.name().value())); | ||
this.add(cardHeader); | ||
|
||
Div cardContent = new Div(); | ||
cardContent.add(levels()); | ||
cardContent.addClassName("content"); | ||
this.add(cardContent); | ||
} | ||
|
||
|
||
private Span title(String value) { | ||
Span cardTitle = new Span(); | ||
cardTitle.setText(value); | ||
cardTitle.addClassName("card-title"); | ||
return cardTitle; | ||
} | ||
|
||
private Div levels() { | ||
var variableLevels = experimentalVariable.levels(); | ||
Div tagLayout = new Div(); | ||
tagLayout.addClassName("tag-collection"); | ||
List<Tag> tags = variableLevels.stream() | ||
.sorted(Comparator.comparing(variable -> variable.variableName().value())) | ||
.map(variableLevel -> new Tag(VariableValueFormatter.format(variableLevel.experimentalValue()))).toList(); | ||
tags.forEach(tagLayout::add); | ||
return tagLayout; | ||
} | ||
|
||
public String variableName() { | ||
return this.experimentalVariable.name().value(); | ||
} | ||
|
||
public ExperimentalVariable experimentalVariable() { | ||
return this.experimentalVariable; | ||
} | ||
|
||
} |
Oops, something went wrong.