Search in sources :

Example 46 with FormLayout

use of com.vaadin.flow.component.formlayout.FormLayout 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;
}
Also used : FormLayout(com.vaadin.flow.component.formlayout.FormLayout) ScoreItem(io.bssw.psip.ui.components.ScoreItem) FormItem(com.vaadin.flow.component.formlayout.FormLayout.FormItem) Item(io.bssw.psip.backend.data.Item) Category(io.bssw.psip.backend.data.Category) FormItem(com.vaadin.flow.component.formlayout.FormLayout.FormItem) ProgressBar(com.vaadin.flow.component.progressbar.ProgressBar)

Example 47 with FormLayout

use of com.vaadin.flow.component.formlayout.FormLayout 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);
}
Also used : FormLayout(com.vaadin.flow.component.formlayout.FormLayout) Div(com.vaadin.flow.component.html.Div) ScoreItem(io.bssw.psip.ui.components.ScoreItem) FormItem(com.vaadin.flow.component.formlayout.FormLayout.FormItem) Item(io.bssw.psip.backend.data.Item) Emphasis(com.vaadin.flow.component.html.Emphasis) Anchor(com.vaadin.flow.component.html.Anchor) FormItem(com.vaadin.flow.component.formlayout.FormLayout.FormItem) ScoreSlider(io.bssw.psip.ui.components.ScoreSlider) Paragraph(com.vaadin.flow.component.html.Paragraph)

Aggregations

FormLayout (com.vaadin.flow.component.formlayout.FormLayout)47 TextField (com.vaadin.flow.component.textfield.TextField)28 Binder (com.vaadin.flow.data.binder.Binder)21 BinderCrudEditor (com.vaadin.flow.component.crud.BinderCrudEditor)15 Person (com.vaadin.demo.domain.Person)12 EmailField (com.vaadin.flow.component.textfield.EmailField)10 Div (com.vaadin.flow.component.html.Div)8 ResponsiveStep (com.vaadin.flow.component.formlayout.FormLayout.ResponsiveStep)6 FormItem (com.vaadin.flow.component.formlayout.FormLayout.FormItem)4 Label (com.vaadin.flow.component.html.Label)4 NumberField (com.vaadin.flow.component.textfield.NumberField)4 TextArea (com.vaadin.flow.component.textfield.TextArea)4 StringLengthValidator (com.vaadin.flow.data.validator.StringLengthValidator)4 FurmsFormLayout (io.imunity.furms.ui.components.FurmsFormLayout)4 Test (org.junit.Test)4 ValueChangeEvent (com.vaadin.flow.component.HasValue.ValueChangeEvent)3 Checkbox (com.vaadin.flow.component.checkbox.Checkbox)3 ComboBox (com.vaadin.flow.component.combobox.ComboBox)3 RichTextEditor (com.vaadin.flow.component.richtexteditor.RichTextEditor)3 EAGER (com.vaadin.flow.data.value.ValueChangeMode.EAGER)3