Search in sources :

Example 6 with FormItem

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;
}
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 7 with FormItem

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);
}
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

FormItem (com.vaadin.flow.component.formlayout.FormLayout.FormItem)7 Component (com.vaadin.flow.component.Component)4 FormLayout (com.vaadin.flow.component.formlayout.FormLayout)4 Div (com.vaadin.flow.component.html.Div)3 Label (com.vaadin.flow.component.html.Label)3 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)2 TextField (com.vaadin.flow.component.textfield.TextField)2 Item (io.bssw.psip.backend.data.Item)2 ScoreItem (io.bssw.psip.ui.components.ScoreItem)2 Composite (com.vaadin.flow.component.Composite)1 Checkbox (com.vaadin.flow.component.checkbox.Checkbox)1 DatePicker (com.vaadin.flow.component.datepicker.DatePicker)1 ResponsiveStep (com.vaadin.flow.component.formlayout.FormLayout.ResponsiveStep)1 Anchor (com.vaadin.flow.component.html.Anchor)1 Emphasis (com.vaadin.flow.component.html.Emphasis)1 H2 (com.vaadin.flow.component.html.H2)1 NativeButton (com.vaadin.flow.component.html.NativeButton)1 Paragraph (com.vaadin.flow.component.html.Paragraph)1 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)1 ProgressBar (com.vaadin.flow.component.progressbar.ProgressBar)1