Mobile personeditor

master
Markus Kreth 7 years ago
parent 04526b18b6
commit 97955fb3d5
  1. 33
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/ClubhelperNavigation.java
  2. 29
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/PersonEditView.java

@ -53,16 +53,13 @@ public class ClubhelperNavigation {
Page page = mainUI.getPage();
MainView mainView;
if (page.getBrowserWindowWidth() < 1000) {
mainView = new MainViewMobile(personDao, groupDao, eventBusiness, securityGroupVerifier);
} else {
mainView = new MainViewDesktop(personDao, groupDao, eventBusiness, securityGroupVerifier);
}
ViewFactory factory = new ViewFactory(page);
MainView mainView = factory.createMain();
navi.addView("", mainView);
navi.addView(ClubhelperViews.MainView.name(), mainView);
navi.addView(ClubhelperViews.LoginUI.name(), new LoginUI(personDao, securityGroupVerifier));
navi.addView(ClubhelperViews.PersonEditView.name(), new PersonEditView(groupDao, personDao));
navi.addView(ClubhelperViews.PersonEditView.name(), factory.createPersonEdit());
navi.addView(ClubhelperViews.EventDetails.name(),
new EventDetails(personDao, groupDao, eventBusiness, pflichtenDao, calendarAdapter));
@ -77,6 +74,28 @@ public class ClubhelperNavigation {
});
}
class ViewFactory {
private Page page;
public ViewFactory(Page page) {
this.page = page;
}
public MainView createMain() {
if (page.getBrowserWindowWidth() < 1000) {
return new MainViewMobile(personDao, groupDao, eventBusiness, securityGroupVerifier);
} else {
return new MainViewDesktop(personDao, groupDao, eventBusiness, securityGroupVerifier);
}
}
public PersonEditView createPersonEdit() {
return new PersonEditView(groupDao, personDao, (page.getBrowserWindowWidth() >= 1000));
}
}
public void navigateTo(String navigationState) {
navi.navigateTo(navigationState);
}

@ -27,7 +27,7 @@ public class PersonEditView extends VerticalLayout implements View {
private Navigator navigator;
public PersonEditView(GroupDao groupDao, PersonDao personDao) {
public PersonEditView(GroupDao groupDao, PersonDao personDao, boolean horizontalLayout) {
setMargin(true);
personGrid = new PersonGrid(groupDao, personDao);
@ -40,12 +40,11 @@ public class PersonEditView extends VerticalLayout implements View {
personDetails.setSizeFull();
personDetails.setPersonChangeHandler(personGrid::refreshItem);
HorizontalLayout layout = new HorizontalLayout();
layout.addComponents(personGrid, personDetails);
layout.setExpandRatio(personGrid, 1f);
layout.setExpandRatio(personDetails, 2f);
layout.setSizeFull();
addComponent(layout);
if (horizontalLayout) {
addComponent(createHorizontalLayout());
} else {
addComponent(createVerticalLayout());
}
Button addPerson = new Button("Hinzufügen");
addPerson.addClickListener(ev -> addPerson());
@ -55,6 +54,22 @@ public class PersonEditView extends VerticalLayout implements View {
addComponent(backButton);
}
public HorizontalLayout createHorizontalLayout() {
HorizontalLayout layout = new HorizontalLayout();
layout.addComponents(personGrid, personDetails);
layout.setExpandRatio(personGrid, 1f);
layout.setExpandRatio(personDetails, 2f);
layout.setSizeFull();
return layout;
}
public VerticalLayout createVerticalLayout() {
VerticalLayout layout = new VerticalLayout();
layout.addComponents(personGrid, personDetails);
layout.setSizeFull();
return layout;
}
private void addPerson() {
Person person = new Person();
person.setGroups(new HashSet<>());

Loading…
Cancel
Save