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.EmailVorlageCreateView;

import javax.inject.Inject;
import java.util.Arrays;
import java.util.List;


public class EmailVorlageVerwaltenMenuItemEntry extends AbstractEmailVorlageMenuItemEntry {

  private static final long serialVersionUID = 1L;

  @Inject
  private WahlSessionSelector wahlSelect;

  @Inject
  private WahlterminSessionSelect wahlterminSelect;

  @Inject
  private EmailVorlageSearchMenuItemEntry emailVorlageSearchMenuItemEntry;

  public EmailVorlageVerwaltenMenuItemEntry() {
    super();
  }


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

  @Override
  public boolean isDisabledInternal() {
    return !wahlSelect.isSelected() && !wahlterminSelect.isSelected();
  }

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

  @Override
  protected List<String> getAdditionalTopicViewIds() {
    return Arrays.asList(EmailVorlageCreateView.VIEW_ID);
  }

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

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

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