Search in sources :

Example 1 with ScoreItem

use of io.bssw.psip.ui.components.ScoreItem in project psip-automation by bssw-psip.

the class Assessment method createItemLayout.

private void createItemLayout(Item item) {
    mainLayout.removeAll();
    ScoreItem scoreItem = new ScoreItem(item);
    String path = item.getCategory().getActivity().getPath() + "/" + item.getCategory().getPath() + "/" + item.getPath();
    Item prevItem = activityService.getPrevItem(path);
    Button button1 = UIUtils.createLargeButton(VaadinIcon.CHEVRON_CIRCLE_LEFT);
    // FIXME: Don't hard code background
    button1.getElement().getStyle().set("background", "#F3F5F7").set("font-size", "30px");
    button1.getElement().addEventListener("click", e -> {
        MainLayout.navigate(Assessment.class, prevItem.getCategory().getPath() + "/" + prevItem.getPath());
    });
    if (prevItem == null) {
        button1.getElement().setEnabled(false);
    }
    Item nextItem = activityService.getNextItem(path);
    Button button2 = UIUtils.createLargeButton(VaadinIcon.CHEVRON_CIRCLE_RIGHT);
    // FIXME: Don't hard code background
    button2.getElement().getStyle().set("background", "#F3F5F7").set("font-size", "30px");
    button2.getElement().addEventListener("click", e -> {
        MainLayout.navigate(Assessment.class, nextItem.getCategory().getPath() + "/" + nextItem.getPath());
    });
    if (nextItem == null) {
        button2.getElement().setEnabled(false);
    }
    HorizontalLayout hz = new HorizontalLayout(button1, button2);
    hz.setJustifyContentMode(JustifyContentMode.CENTER);
    hz.setWidthFull();
    Anchor anchor = new Anchor();
    anchor.setText("Show me my assessment");
    anchor.getElement().addEventListener("click", e -> MainLayout.navigate(Assessment.class, null));
    HorizontalLayout hz2 = new HorizontalLayout(anchor);
    hz2.setJustifyContentMode(JustifyContentMode.CENTER);
    hz2.setWidthFull();
    VerticalLayout footer = new VerticalLayout(hz, hz2);
    footer.setMargin(false);
    mainLayout.addAndExpand(scoreItem, footer);
}
Also used : ScoreItem(io.bssw.psip.ui.components.ScoreItem) FormItem(com.vaadin.flow.component.formlayout.FormLayout.FormItem) Item(io.bssw.psip.backend.data.Item) Anchor(com.vaadin.flow.component.html.Anchor) Button(com.vaadin.flow.component.button.Button) ScoreItem(io.bssw.psip.ui.components.ScoreItem) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Aggregations

Button (com.vaadin.flow.component.button.Button)1 FormItem (com.vaadin.flow.component.formlayout.FormLayout.FormItem)1 Anchor (com.vaadin.flow.component.html.Anchor)1 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)1 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)1 Item (io.bssw.psip.backend.data.Item)1 ScoreItem (io.bssw.psip.ui.components.ScoreItem)1