Delete Button for Event added.

master
Markus Kreth 7 years ago
parent 0bf7f3a039
commit ad53664e14
  1. 17
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/SingleEventView.java

@ -6,10 +6,12 @@ import java.time.temporal.ChronoUnit;
import com.vaadin.data.Binder; import com.vaadin.data.Binder;
import com.vaadin.data.HasValue.ValueChangeEvent; import com.vaadin.data.HasValue.ValueChangeEvent;
import com.vaadin.ui.Button;
import com.vaadin.ui.ComboBox; import com.vaadin.ui.ComboBox;
import com.vaadin.ui.CustomComponent; import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.DateField; import com.vaadin.ui.DateField;
import com.vaadin.ui.GridLayout; import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Notification;
import com.vaadin.ui.TextField; import com.vaadin.ui.TextField;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent; import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
@ -33,6 +35,8 @@ public class SingleEventView extends CustomComponent {
private Binder<ClubEvent> binder; private Binder<ClubEvent> binder;
private DefaultDataUpdateHandler updateHandler = new DefaultDataUpdateHandler(); private DefaultDataUpdateHandler updateHandler = new DefaultDataUpdateHandler();
private Button deleteEvent;
public SingleEventView(boolean showCompetitionType) { public SingleEventView(boolean showCompetitionType) {
setCaption("Gewählte Veranstaltung"); setCaption("Gewählte Veranstaltung");
addStyleName("bold-caption"); addStyleName("bold-caption");
@ -79,15 +83,25 @@ public class SingleEventView extends CustomComponent {
} else { } else {
layout = new GridLayout(2, 2); layout = new GridLayout(2, 2);
} }
deleteEvent = new Button("Löschen");
layout.setMargin(true); layout.setMargin(true);
layout.setSpacing(true); layout.setSpacing(true);
layout.addComponents(textTitle, startDate, textLocation, endDate); layout.addComponents(textTitle, startDate, textLocation, endDate);
if (showCompetitionType) { if (showCompetitionType) {
layout.addComponent(competitionType); layout.addComponent(competitionType);
deleteEvent = new Button("Löschen");
deleteEvent.addClickListener(ev -> deleteEvent());
layout.addComponent(deleteEvent);
} }
setCompositionRoot(layout); setCompositionRoot(layout);
} }
private void deleteEvent() {
Notification.show("Termin löschen?", "Soll " + binder.getBean() + " wirklich gelöscht werden?",
Notification.Type.HUMANIZED_MESSAGE);
}
void endDateVisibleCheck(ValueChangeEvent<LocalDate> event) { void endDateVisibleCheck(ValueChangeEvent<LocalDate> event) {
ZonedDateTime start = binder.getBean().getStart(); ZonedDateTime start = binder.getBean().getStart();
ZonedDateTime end = binder.getBean().getEnd(); ZonedDateTime end = binder.getBean().getEnd();
@ -127,11 +141,12 @@ public class SingleEventView extends CustomComponent {
binder.setBean(ev); binder.setBean(ev);
if (ev != null) { if (ev != null) {
deleteEvent.setEnabled(true);
} else { } else {
setTitle(""); setTitle("");
setLocation(""); setLocation("");
endDate.setVisible(false); endDate.setVisible(false);
deleteEvent.setEnabled(false);
} }
} }

Loading…
Cancel
Save