package de.ivu.elect.presentation.email.menu;

import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.business.wahl.boundary.WahlSessionSelector;
import de.ivu.elect.business.wahl.boundary.WahlterminSessionSelect;
import de.ivu.elect.presentation.email.EmailVorgangSearchView;

import javax.inject.Inject;

public class EmailVorgangSearchMenuItemEntry extends AbstractEmailVorgangMenuItemEntry {

  private static final long serialVersionUID = 1L;

  @Inject
  private transient WahlSessionSelector wahlSelect;

  @Inject
  private transient WahlterminSessionSelect wahlterminSelect;

  public EmailVorgangSearchMenuItemEntry() {
    super();
  }

  @Override
  protected UseCasePermission getUseCasePermission() {
    return UseCasePermission.EMAIL_VORGANG_SEARCH;
  }

  @Override
  public String getTargetViewId() {
    return EmailVorgangSearchView.VIEW_ID;
  }

  @Override
  protected String getLabel() {
    return getMessage(getLabelKey(), getMeta().getMehrzahlMessage());
  }

  @Override
  public String getLabelKey() {
    return "entity.search.menu.item.label";
  }

  @Override
  public String getIcon() {
    return getIcons().getIconEmailVorgang();
  }

  @Override
  public boolean isDisabledInternal() {
    return super.isDisabledInternal() || !isWahlterminSelected() && !isWahlSelected();
  }

  protected boolean isWahlterminSelected() {
    return wahlterminSelect.isSelected();
  }

  protected boolean isWahlSelected() {
    return wahlSelect.isSelected();
  }
}
