Skip to content

Commit

Permalink
Checkin current progress
Browse files Browse the repository at this point in the history
  • Loading branch information
sven1103 committed Oct 24, 2024
1 parent 742d50f commit 682e0a0
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 8 deletions.
23 changes: 21 additions & 2 deletions user-interface/frontend/themes/datamanager/components/section.css
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,33 @@
padding: var(--lumo-space-m) var(--lumo-space-m) var(--lumo-space-m);
}



.detail-box-child:first-child {
border-width: 0 0 1px 0;
border-style: solid;
border-color: lightgray;
}

.icon-label {
font-size: var(--lumo-font-size-m);
line-height: 1;
display: flex;
flex-direction: row;
gap: var(--lumo-space-l);
}

.icon-label-container {
display: flex;
flex-direction: row;
font-size: var(--lumo-font-size-m);
color: #878787;
font-weight: bold;
gap: var(--lumo-space-xs);
}

.icon-label-container vaadin-icon {
height: auto;
}

.vertical-list {
display: flex;
flex-direction: column;
Expand Down
3 changes: 2 additions & 1 deletion user-interface/frontend/themes/datamanager/styles.css
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
@import "theme-editor.css";
@import "components/custom.css";
@import "components/vaadin-custom.css";
@import "components/vaadin-custom.css";
Binary file modified user-interface/src/main/bundles/dev.bundle
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package life.qbic.datamanager.views.general.section;

import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.Span;
import com.vaadin.flow.component.icon.Icon;
import com.vaadin.flow.component.icon.VaadinIcon;

/**
* <b><class short description - 1 Line!></b>
*
* <p><More detailed description - When to use, what it solves, etc.></p>
*
* @since <version tag>
*/
public class IconLabel extends Div {

private Icon icon;

private String label;

private final Icon toolTipIcon = VaadinIcon.INFO_CIRCLE.create();

private String toolTipText;

private boolean showTooltip;

private String information;

private IconLabel() {
addClassName("icon-label");
addClassName("horizontal-list");
this.showTooltip = false;
}

public IconLabel(Icon icon, String label) {
this();
this.icon = icon;
this.label = label;
rebuild();
}

public void setTooltipText(String toolTipText) {
this.showTooltip = true;
this.toolTipText = toolTipText;
rebuild();
}

public void setInformation(String information) {
this.information = information;
rebuild();
}

private void rebuild() {
removeAll();
var iconLabelContainer = new Div();
iconLabelContainer.setClassName("icon-label-container");

if (icon != null) {
iconLabelContainer.add(icon);
}
iconLabelContainer.add(new Span(label));

if (showTooltip) {
toolTipIcon.setTooltipText(toolTipText);
iconLabelContainer.add(toolTipIcon);
}
add(iconLabelContainer);

if (information != null) {
add(new Span(information));
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public void setContent(SectionContent content) {
rebuild();
}

public SectionContent content() {
return content;
}

private void rebuild() {
removeAll();
add(sectionHeader, content);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package life.qbic.datamanager.views.general.section;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.html.Div;

/**
Expand All @@ -15,4 +16,9 @@ public SectionContent() {
addClassName("section-content");
}

public SectionContent(Component... components) {
this();
add(components);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

import com.vaadin.flow.component.avatar.AvatarGroup;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.html.Anchor;
import com.vaadin.flow.component.html.AnchorTarget;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.Span;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.spring.annotation.SpringComponent;
import com.vaadin.flow.spring.annotation.UIScope;
Expand Down Expand Up @@ -35,6 +38,7 @@
import life.qbic.datamanager.views.general.section.ActionBar;
import life.qbic.datamanager.views.general.section.DetailBox;
import life.qbic.datamanager.views.general.section.HeadingWithIcon;
import life.qbic.datamanager.views.general.section.IconLabel;
import life.qbic.datamanager.views.general.section.OntologyTermDisplay;
import life.qbic.datamanager.views.general.section.Section;
import life.qbic.datamanager.views.general.section.Section.SectionBuilder;
Expand All @@ -51,6 +55,7 @@
import life.qbic.projectmanagement.application.experiment.ExperimentInformationService;
import life.qbic.projectmanagement.domain.model.OntologyTerm;
import life.qbic.projectmanagement.domain.model.experiment.Experiment;
import life.qbic.projectmanagement.domain.model.project.Contact;
import life.qbic.projectmanagement.domain.model.project.Project;
import life.qbic.projectmanagement.domain.model.project.ProjectId;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -129,18 +134,60 @@ private void setContent(ProjectOverview projectInformation, Project fullProject,
buildHeaderSection(projectInformation);
buildDesignSection(projectInformation, fullProject);
buildExperimentInformationSection(projectInformation, experiments);
buildFundingInformationSection(projectInformation);
buildProjectContactsInfoSection(projectInformation);
buildFundingInformationSection(fullProject);
buildProjectContactsInfoSection(fullProject);
}

private void buildProjectContactsInfoSection(ProjectOverview projectInformation) {
fundingInformationSection.setHeader(
private void buildProjectContactsInfoSection(Project project) {
projectContactsSection.setHeader(
new SectionHeader(new SectionTitle("Project Contacts"), new ActionBar(new Button("Edit"))));
var piBox = new DetailBox();
var piBoxHeader = new DetailBox.Header(VaadinIcon.USER.create(), "Principal Investigator");
piBox.setHeader(piBoxHeader);
var principalInvestigator = project.getPrincipalInvestigator();
piBox.setContent(renderContactInfo(principalInvestigator));

var pmBox = new DetailBox();
var pmBoxHeader = new DetailBox.Header(VaadinIcon.USER.create(), "Project Manager");
pmBox.setHeader(pmBoxHeader);
var projectManager = project.getProjectManager();
pmBox.setContent(renderContactInfo(projectManager));

projectContactsSection.setContent(new SectionContent(piBox, pmBox));

if (project.getResponsiblePerson().isPresent()) {
var prBox = new DetailBox();
var prBoxHeader = new DetailBox.Header(VaadinIcon.USER.create(), "Project Responsible");
prBox.setHeader(prBoxHeader);
var responsible = project.getResponsiblePerson().get();
prBox.setContent(renderContactInfo(responsible));
projectContactsSection.content().add(prBox);
}
}

private Div renderContactInfo(Contact contact) {
var contactInfo = new Div();
contactInfo.addClassName("vertical-list");
var name = new Span(contact.fullName());
var email = new Anchor("mailto:" + contact.emailAddress(), contact.emailAddress());
contactInfo.add(name, email);
return contactInfo;
}

private void buildFundingInformationSection(ProjectOverview projectInformation) {
private void buildFundingInformationSection(Project fullProject) {
fundingInformationSection.setHeader(
new SectionHeader(new SectionTitle("Funding Information"), new ActionBar(new Button("Edit"))));

if (fullProject.funding().isEmpty()) {
fundingInformationSection.setContent(new SectionContent(new Span("No funding information provided.")));
} else {
var grantIconLabel = new IconLabel(VaadinIcon.MONEY.create(), "Grant");
var funding = fullProject.funding().get();
grantIconLabel.setInformation("%s (%s)".formatted(funding.grant(), funding.grantId()));
grantIconLabel.setTooltipText("Information about what grant served as funding for the project.");
fundingInformationSection.setContent(new SectionContent(grantIconLabel));
}

}

private void buildExperimentInformationSection(ProjectOverview projectInformation, List<Experiment> experiments) {
Expand Down

0 comments on commit 682e0a0

Please sign in to comment.