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

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

import de.ivu.elect.business.mandant.entity.Mandant;
import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.presentation.View;
import de.ivu.elect.presentation.mandant.MandantEditView;

@Named(MandantResetAction.COMPONENT_NAME)
public class MandantResetAction extends AbstractMandantAction {

  public static final String COMPONENT_NAME = "mandantResetAction";

  private static final long serialVersionUID = 1L;

  @View
  @Inject
  private MandantEditView editView;

  public MandantResetAction() {
    super();
  }

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

  @Override
  protected boolean isFireChangeEvent() {
    return true;
  }

  @Override
  protected String doIt(Mandant mandant) {
    editView.setEntity(mandant);

    // Return to current page and display the dialog!
    return null;
  }

  @Override
  public String getDialogName() {
    return "ResetConfirm";
  }

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

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

  @Override
  public boolean isDisabledInternal(@Nonnull Mandant mandant) {
    return super.isDisabledInternal(mandant) || !mandant.getArt().isSchulungMandant();
  }
}
