Head Login as button with login logout popup

master
Markus Kreth 7 years ago
parent 51a30a69dc
commit afb71469d8
  1. 4
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/ClubhelperNavigation.java
  2. 33
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/HeadView.java
  3. 4
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/MainView.java
  4. 6
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/MainViewDesktop.java

@ -82,6 +82,10 @@ public class ClubhelperNavigation {
return this; return this;
} }
public void navigateTo(ClubhelperViews view) {
navigateTo(view.name());
}
@Override @Override
public void navigateTo(String navigationState) { public void navigateTo(String navigationState) {
ClubhelperViews byState = ClubhelperViews.byState(navigationState); ClubhelperViews byState = ClubhelperViews.byState(navigationState);

@ -58,7 +58,7 @@ public class HeadView extends HorizontalLayout {
private int monthItemId; private int monthItemId;
private Label personLabel; private Button personLabel;
private final ClubNavigator navigator; private final ClubNavigator navigator;
@ -76,13 +76,15 @@ public class HeadView extends HorizontalLayout {
monthName.setWidth(null); monthName.setWidth(null);
Button popupButton = new Button(VaadinIcons.MENU); Button popupButton = new Button(VaadinIcons.MENU);
popupButton.setId("calendar.menu"); popupButton.setId("head.menu");
popupButton.addClickListener(ev -> openPopupMenu(ev)); popupButton.addClickListener(ev -> openPopupMenu(ev));
popupButton.setWidth(null); popupButton.setWidth(null);
personLabel = new Label(); personLabel = new Button(VaadinIcons.USER);
personLabel.setStyleName("title_caption"); personLabel.setId("head.user");
personLabel.addStyleName("bold-caption"); // personLabel.setStyleName("title_caption");
// personLabel.addStyleName("bold-caption");
personLabel.addClickListener(this::openPopupMenu);
this.addComponent(popupButton); this.addComponent(popupButton);
this.addComponent(monthName); this.addComponent(monthName);
@ -118,13 +120,21 @@ public class HeadView extends HorizontalLayout {
Button button = ev.getButton(); Button button = ev.getButton();
ContextMenu contextMenu = new ContextMenu(button, true); ContextMenu contextMenu = new ContextMenu(button, true);
switch (button.getId()) {
case "head.menu":
monthItemId = contextMenu.addItem("Export Monat", ev1 -> calendarExport(ev1)).getId(); monthItemId = contextMenu.addItem("Export Monat", ev1 -> calendarExport(ev1)).getId();
contextMenu.addItem("Export Jahr", ev1 -> calendarExport(ev1)); contextMenu.addItem("Export Jahr", ev1 -> calendarExport(ev1));
if (securityVerifier.getLoggedinPerson() != null) { if (securityVerifier.isLoggedin()
if (securityVerifier.isPermitted(SecurityGroups.ADMIN, SecurityGroups.UEBUNGSLEITER)) { && securityVerifier.isPermitted(SecurityGroups.ADMIN, SecurityGroups.UEBUNGSLEITER)) {
contextMenu.addItem("Personen verwalten", contextMenu.addItem("Personen verwalten",
ev1 -> navigator.navigateTo(ClubhelperViews.PersonEditView.name())); ev1 -> navigator.navigateTo(ClubhelperViews.PersonEditView.name()));
} }
contextMenu.open(50, 50);
break;
case "head.user":
if (securityVerifier.getLoggedinPerson() != null) {
contextMenu.addItem("Abmelden", ev1 -> { contextMenu.addItem("Abmelden", ev1 -> {
securityVerifier.setLoggedinPerson(null); securityVerifier.setLoggedinPerson(null);
navigator.navigateTo(ClubhelperViews.MainView.name()); navigator.navigateTo(ClubhelperViews.MainView.name());
@ -132,7 +142,14 @@ public class HeadView extends HorizontalLayout {
} else { } else {
contextMenu.addItem("Anmelden", ev1 -> navigator.navigateTo(ClubhelperViews.LoginUI.name())); contextMenu.addItem("Anmelden", ev1 -> navigator.navigateTo(ClubhelperViews.LoginUI.name()));
} }
contextMenu.open(50, 50); int width = getUI().getPage().getBrowserWindowWidth();
contextMenu.open(width - 150, 50);
break;
default:
break;
}
} }
private void calendarExport(MenuItem ev1) { private void calendarExport(MenuItem ev1) {

@ -53,7 +53,7 @@ public abstract class MainView extends VerticalLayout implements View {
if (securityVerifier.isLoggedin()) { if (securityVerifier.isLoggedin()) {
LOGGER.info("{} already initialized - opening Person View.", getClass().getName()); LOGGER.info("{} already initialized - opening Person View.", getClass().getName());
ClubEvent current = eventBusiness.getCurrent(); ClubEvent current = eventBusiness.getCurrent();
openPersonViewForEvent(current); openDetailForEvent(current);
} else { } else {
LOGGER.info("{} already initialized - but not loggedin.", getClass().getName()); LOGGER.info("{} already initialized - but not loggedin.", getClass().getName());
detailClosed(); detailClosed();
@ -88,7 +88,7 @@ public abstract class MainView extends VerticalLayout implements View {
eventView.setVisible(false); eventView.setVisible(false);
} }
public void openPersonViewForEvent(ClubEvent ev) { public void openDetailForEvent(ClubEvent ev) {
LOGGER.debug("Opening detail view for {}", ev); LOGGER.debug("Opening detail view for {}", ev);
eventBusiness.setSelected(null); eventBusiness.setSelected(null);

@ -115,7 +115,7 @@ public class MainViewDesktop extends MainView {
ClubEvent ev = (ClubEvent) event.getCalendarItem(); ClubEvent ev = (ClubEvent) event.getCalendarItem();
if (securityVerifier.isLoggedin()) { if (securityVerifier.isLoggedin()) {
openPersonViewForEvent(ev); openDetailForEvent(ev);
} else { } else {
eventBusiness.setSelected(ev); eventBusiness.setSelected(ev);
navigator.navigateTo(ClubhelperViews.LoginUI.name() + '/' + ev.getId()); navigator.navigateTo(ClubhelperViews.LoginUI.name() + '/' + ev.getId());
@ -123,8 +123,8 @@ public class MainViewDesktop extends MainView {
} }
@Override @Override
public void openPersonViewForEvent(ClubEvent ev) { public void openDetailForEvent(ClubEvent ev) {
super.openPersonViewForEvent(ev); super.openDetailForEvent(ev);
mainLayout.addComponent(eastLayout); mainLayout.addComponent(eastLayout);
mainLayout.setExpandRatio(eastLayout, 1f); mainLayout.setExpandRatio(eastLayout, 1f);

Loading…
Cancel
Save