
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.Wahltermin;
import de.ivu.elect.presentation.wahl.WahlterminEditView;

@Named(WahlterminEditAction.COMPONENT_NAME)
public class WahlterminEditAction extends AbstractWahlterminAction {

  private static final long serialVersionUID = 1L;

  public static final String COMPONENT_NAME = "wahlterminEditAction";

  @Override
  protected UseCasePermission getRequiredPermission() {
    return UseCasePermission.WAHLTERMIN_EDIT;
  }

  @Override
  protected String doIt(Wahltermin entity) {
    wahlterminConversationSelect.setEntity(entity);

    return WahlterminEditView.VIEW_ID;
  }

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

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

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