diff --git a/content/modules/flow-ui/examples/onboarding/src/main/java/com/company/onboarding/view/component/popover/PopoverView.java b/content/modules/flow-ui/examples/onboarding/src/main/java/com/company/onboarding/view/component/popover/PopoverView.java new file mode 100644 index 00000000..08923bfa --- /dev/null +++ b/content/modules/flow-ui/examples/onboarding/src/main/java/com/company/onboarding/view/component/popover/PopoverView.java @@ -0,0 +1,94 @@ +package com.company.onboarding.view.component.popover; + +import com.company.onboarding.view.main.MainView; +import com.vaadin.flow.component.ClickEvent; +import com.vaadin.flow.component.button.ButtonVariant; +import com.vaadin.flow.component.html.H3; +import com.vaadin.flow.component.icon.VaadinIcon; +import com.vaadin.flow.component.popover.Popover; +import com.vaadin.flow.router.Route; +import io.jmix.flowui.UiComponents; +import io.jmix.flowui.component.textfield.TypedTextField; +import io.jmix.flowui.kit.component.button.JmixButton; +import io.jmix.flowui.view.*; +import org.springframework.beans.factory.annotation.Autowired; + +@Route(value = "popover-view", layout = MainView.class) +@ViewController("PopoverView") +@ViewDescriptor("popover-view.xml") +public class PopoverView extends StandardView { + + // tag::basics[] + @ViewComponent + private Popover infoPopover; + + // end::basics[] + // tag::runtimeTarget[] + @ViewComponent + private Popover emailHelpPopover; + @ViewComponent + private TypedTextField emailField; + @Autowired + private UiComponents uiComponents; + + // end::runtimeTarget[] + // tag::programmatic[] + @ViewComponent + private Popover promoCodePopover; + + // end::programmatic[] + // tag::modal[] + @ViewComponent + private Popover renamePopover; + @ViewComponent + private H3 reportTitle; + @ViewComponent + private TypedTextField titleField; + + // end::modal[] + // tag::basics[] + @Subscribe(id = "closeButton", subject = "clickListener") + public void onCloseButtonClick(final ClickEvent event) { + infoPopover.close(); + } + // end::basics[] + + // tag::runtimeTarget[] + @Subscribe + public void onInit(final InitEvent event) { + JmixButton helpButton = uiComponents.create(JmixButton.class); + helpButton.setIcon(VaadinIcon.QUESTION_CIRCLE.create()); + helpButton.addThemeVariants(ButtonVariant.TERTIARY); + emailField.setSuffixComponent(helpButton); + + emailHelpPopover.setTarget(helpButton); + } + // end::runtimeTarget[] + + // tag::programmatic[] + @Subscribe(id = "promoCodeHelpButton", subject = "clickListener") + public void onPromoCodeHelpButtonClick(final ClickEvent event) { + promoCodePopover.open(); + } + // end::programmatic[] + + // tag::modal[] + @Subscribe("renamePopover") + public void onRenamePopoverOpenedChange(final Popover.OpenedChangeEvent event) { + if (event.isOpened()) { + titleField.setValue(reportTitle.getText()); + } + } + + @Subscribe(id = "saveButton", subject = "clickListener") + public void onSaveButtonClick(final ClickEvent event) { + reportTitle.setText(titleField.getValue()); + renamePopover.close(); + } + + @Subscribe(id = "cancelButton", subject = "clickListener") + public void onCancelButtonClick(final ClickEvent event) { + renamePopover.close(); + } + // end::modal[] +} diff --git a/content/modules/flow-ui/examples/onboarding/src/main/resources/com/company/onboarding/menu.xml b/content/modules/flow-ui/examples/onboarding/src/main/resources/com/company/onboarding/menu.xml index 1fb38339..3da988de 100644 --- a/content/modules/flow-ui/examples/onboarding/src/main/resources/com/company/onboarding/menu.xml +++ b/content/modules/flow-ui/examples/onboarding/src/main/resources/com/company/onboarding/menu.xml @@ -68,6 +68,7 @@ title="msg://com.company.onboarding.view.component.multiselectcomboboxpicker/multiSelectComboBoxPickerView.title"/> + diff --git a/content/modules/flow-ui/examples/onboarding/src/main/resources/com/company/onboarding/messages_en.properties b/content/modules/flow-ui/examples/onboarding/src/main/resources/com/company/onboarding/messages_en.properties index 53e4cb09..cd038b82 100644 --- a/content/modules/flow-ui/examples/onboarding/src/main/resources/com/company/onboarding/messages_en.properties +++ b/content/modules/flow-ui/examples/onboarding/src/main/resources/com/company/onboarding/messages_en.properties @@ -198,6 +198,8 @@ com.company.onboarding.view.component.validator/validatorView.title=Validators com.company.onboarding.view.component.valuepicker/valuePickerView.title=valuePicker com.company.onboarding.view.component.progressbar/progressBarView.title=progressBar +com.company.onboarding.view.component.popover/popoverView.title=popover + com.company.onboarding.view.component.tooltip/tooltipView.title=tooltip com.company.onboarding.view.component.treedatagrid/treeDataGridView.title=treeDataGrid diff --git a/content/modules/flow-ui/examples/onboarding/src/main/resources/com/company/onboarding/view/component/popover/popover-view.xml b/content/modules/flow-ui/examples/onboarding/src/main/resources/com/company/onboarding/view/component/popover/popover-view.xml new file mode 100644 index 00000000..2edeb212 --- /dev/null +++ b/content/modules/flow-ui/examples/onboarding/src/main/resources/com/company/onboarding/view/component/popover/popover-view.xml @@ -0,0 +1,87 @@ + + + + +