use of com.vaadin.flow.component.formlayout.FormLayout.FormItem in project psip-automation by bssw-psip.
the class Assessment method createActivitySummaryAsProgress.
@SuppressWarnings("unused")
private Component createActivitySummaryAsProgress(Activity activity) {
FormLayout form = new FormLayout();
for (Category category : activity.getCategories()) {
int score = 0;
for (Item item : category.getItems()) {
if (item.getScore().isPresent()) {
score += item.getScore().get();
}
}
ProgressBar bar = new ProgressBar(0, category.getItems().size() > 0 ? 100 * category.getItems().size() : 1);
bar.getElement().getStyle().set("height", "10px");
bar.setValue(score);
if (category.getItems().isEmpty()) {
bar.getElement().setEnabled(false);
}
FormItem formItem = form.addFormItem(bar, category.getName());
// Set width of label otherwise it will wrap
formItem.getElement().getStyle().set("--vaadin-form-item-label-width", "15em");
// FormLayout defaults to 2 columns so span both
form.setColspan(formItem, 2);
}
return form;
}
use of com.vaadin.flow.component.formlayout.FormLayout.FormItem in project psip-automation by bssw-psip.
the class Assessment method createCategoryLayout.
private void createCategoryLayout(Category category) {
mainLayout.removeAll();
FormLayout form = new FormLayout();
form.getElement().getStyle().set("padding", "30px");
for (Item item : category.getItems()) {
ScoreSlider slider = new ScoreSlider(item);
FormItem formItem = form.addFormItem(slider, item.getName());
// Set width of label otherwise it will wrap
formItem.getElement().getStyle().set("--vaadin-form-item-label-width", "15em");
formItem.getElement().getStyle().set("align-self", "flex-start");
formItem.getElement().getStyle().set("padding", "5px");
// FormLayout defaults to 2 columns so span both
form.setColspan(formItem, 2);
}
Div div = new Div();
div.add(new Paragraph(new Emphasis("The rows below show how well your team is doing for each practice. " + "As your practices improve, you can always return to this page to update them directly.")));
Anchor anchor = new Anchor();
anchor.setText("Click here to assess your individual practices.");
anchor.getElement().addEventListener("click", e -> MainLayout.navigate(Assessment.class, category.getPath() + "/" + category.getItems().get(0).getPath()));
mainLayout.add(div, anchor, form);
}
Aggregations