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

import javax.inject.Inject;

import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.presentation.konfiguration.KonfigurationMandantEditView;
import de.ivu.elect.presentation.mandant.MandantSessionSelect;
import de.ivu.elect.presentation.menu.AbstractMenuItemEntry;
import de.ivu.elect.presentation.security.AbstractGebietSecurity;

public class KonfigurationMandantEditMenuItemEntry extends AbstractMenuItemEntry {

  private static final long serialVersionUID = 1L;

  @Inject
  private transient MandantSessionSelect mandantSessionSelect;

  @Override
  public boolean isRendered() {
    return hasUseCasePermission(UseCasePermission.KONFIGURATION_MANDANT_EDIT) && isNurSystemMandant();
  }

  private boolean isNurSystemMandant() {
    var mandant = mandantSessionSelect.getMandant();
    return mandant != null && !mandant.getArt().isCustomerMandant();
  }

  @Override
  public String getLabelKey() {
    return "konfiguration.mandant.edit.menu.item.label";
  }

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

  @Override
  public boolean isDisabledInternal() {
    return false;
  }

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

  @Override
  protected AbstractGebietSecurity getGebietSecurity() {
    return KEINE_GEBIET_SECURITY;
  }

}
