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

import javax.annotation.Nonnull;
import javax.inject.Named;

import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.business.wahl.entity.Wahl;
import de.ivu.elect.presentation.wahl.WahlEditView;

@Named(WahlEditAction.COMPONENT_NAME)
public class WahlEditAction extends AbstractWahlAction {

  private static final long serialVersionUID = 1L;

  public static final String COMPONENT_NAME = "wahlEditAction";

  @Override
  public UseCasePermission getRequiredPermission() {
    return UseCasePermission.WAHL_EDIT;
  }

  @Override
  public boolean isDisabledInternal(@Nonnull Wahl entity) {
    return super.isDisabledInternal(entity) || !entity.getStatus().isAuswaehlbar();
  }

  @Override
  public String doIt(Wahl entity) {
    wahlConversationSelect.setEntity(entity);

    return WahlEditView.VIEW_ID;
  }

  @Override
  public String getLabelKey() {
    return "entity.edit.action.edit";
  }

  @Override
  public String getIcon() {
    return appIcons.getIconEdit();
  }
}
