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

import javax.inject.Inject;

import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.business.wahl.boundary.WahlSessionSelect;
import de.ivu.elect.presentation.replikation.ReplikationPresentationStatus;
import de.ivu.elect.presentation.wahl.WahlResetView;

/**
 *  on 21.07.2016.
 */
public class WahlResetMenuItemEntry extends AbstractWahlMenuItemEntry {

  private static final long serialVersionUID = 1L;

  public WahlResetMenuItemEntry() {
    super();
  }

  @Inject
  private transient WahlSessionSelect wahlSessionSelect;

  @Inject
  private transient ReplikationPresentationStatus replikationPresentationStatus;

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

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

  @Override
  public boolean isDisabledInternal() {
    return super.isDisabledInternal() || !wahlSessionSelect.isSelected() || isSlave();
  }

  // WASDE-1153
  private boolean isSlave() {
    return replikationPresentationStatus.isSlave();
  }

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

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

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