parent
ace56732ea
commit
8ffc598d12
@ -0,0 +1,47 @@ |
||||
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.commands; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashSet; |
||||
import java.util.function.Consumer; |
||||
|
||||
import com.vaadin.server.Resource; |
||||
|
||||
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.GroupDef; |
||||
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; |
||||
|
||||
public class AddPersonCommand implements ClubCommand { |
||||
|
||||
private final Consumer<Person> createdPersonConsumer; |
||||
|
||||
private final GroupDef defaultGroup; |
||||
|
||||
public AddPersonCommand(Consumer<Person> createdPersonConsumer, GroupDef defaultGroup) { |
||||
super(); |
||||
this.createdPersonConsumer = createdPersonConsumer; |
||||
this.defaultGroup = defaultGroup; |
||||
} |
||||
|
||||
@Override |
||||
public String getLabel() { |
||||
return "Person Hinzufügen"; |
||||
} |
||||
|
||||
@Override |
||||
public Resource getIcon() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void execute() { |
||||
Person person = new Person(); |
||||
|
||||
person.setGroups(new HashSet<>()); |
||||
person.setAdresses(new ArrayList<>()); |
||||
person.setEvents(new HashSet<>()); |
||||
person.setRelatives1(new ArrayList<>()); |
||||
person.add(defaultGroup); |
||||
|
||||
createdPersonConsumer.accept(person); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,50 @@ |
||||
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.menu; |
||||
|
||||
import java.time.ZonedDateTime; |
||||
import java.util.function.BiConsumer; |
||||
import java.util.function.Consumer; |
||||
import java.util.function.Supplier; |
||||
|
||||
import org.springframework.context.ApplicationContext; |
||||
|
||||
import com.vaadin.ui.MenuBar.MenuItem; |
||||
import com.vaadin.ui.UI; |
||||
|
||||
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao; |
||||
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.GroupDef; |
||||
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; |
||||
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.commands.AddPersonCommand; |
||||
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation.PersonEditView; |
||||
import net.sf.jasperreports.engine.JasperPrint; |
||||
|
||||
/** |
||||
* Status für authentifizierte User im {@link PersonEditView} |
||||
* @author markus |
||||
* |
||||
*/ |
||||
class LoggedinEditPersonViewMenuitemState extends LoggedinMenuitemState { |
||||
|
||||
private final Consumer<Person> newPersonConsumer; |
||||
|
||||
private GroupDao groupDao; |
||||
|
||||
public LoggedinEditPersonViewMenuitemState(ApplicationContext context, UI ui, Supplier<ZonedDateTime> startProvider, |
||||
Supplier<ZonedDateTime> endProvider, BiConsumer<String, JasperPrint> printConsumer, |
||||
Consumer<Person> newPersonConsumer) { |
||||
super(context, ui, startProvider, endProvider, printConsumer); |
||||
this.newPersonConsumer = newPersonConsumer; |
||||
groupDao = context.getBean(GroupDao.class); |
||||
} |
||||
|
||||
@Override |
||||
public void applyMenuStates(ClubhelperMenuBar menuBar) { |
||||
super.applyMenuStates(menuBar); |
||||
|
||||
MenuItem editMenu = menuBar.getEditMenuItem(); |
||||
|
||||
GroupDef defaultGroup = groupDao.get(1); |
||||
editMenu.addSeparator(); |
||||
AddPersonCommand addPersonCommand = new AddPersonCommand(newPersonConsumer, defaultGroup); |
||||
editMenu.addItem(addPersonCommand.getLabel(), new CommandWrapper(addPersonCommand)); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue