package de.ivu.elect.presentation.menu;

import javax.inject.Inject;

import de.ivu.elect.business.wahl.boundary.WahlSessionSelector;
import de.ivu.elect.business.wahl.entity.NlWahlart;
import de.ivu.elect.business.wahl.entity.Wahl;
import de.ivu.elect.jee.faces.FacesContextUtil;

public class NlHtmlHandbuchMainMenuEntry extends AbstractExternerLinkMenuItemEntry {

  private static final long serialVersionUID = 1L;

  public static final String FALLBACK = NlWahlart.GEMEENTERAAD.getHelpPath();

  @Inject
  protected transient WahlSessionSelector wahlSessionSelector;

  @Override
  public boolean isRendered() {
    return true; // Handbuch immer anzeigen
  }

  @Override
  protected boolean hasUseCasePermission() {
    return true; // Handbuch immer anzeigen
  }

  @Override
  protected String getLabelForLink() {
    return getMessage("help.main.menu.item.label");
  }

  @Override
  protected String getUrlForLink() {
    return FacesContextUtil.getContextPath() + "/resources/help/" + getWahlpath() + "/index.html";
  }

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

  protected String getWahlpath() {
    Wahl wahl = wahlSessionSelector.getEntity();

    if (wahl != null) {
      return NlWahlart.valueOf(wahl).getHelpPath();
    }

    return FALLBACK;
  }

}
