
package de.ivu.elect.presentation.hilfe;

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

import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.business.security.control.ElectCommonPrincipal;
import de.ivu.elect.jee.faces.FacesContextUtil;
import de.ivu.elect.jee.faces.PreConditionCheck;
import de.ivu.elect.jee.presentation.security.StartViewResolver;
import de.ivu.elect.presentation.View;

@OnlineHilfeId(KeineOnlineHilfe.KEINE_ONLINE_HILFE)
@Named
@View(viewId = HelpElectUiComponentsView.VIEW_ID, useCase = UseCasePermission.ANWENDUNG_BENUTZEN/*ELECTVAPP-476*/)
public class HelpElectUiComponentsView {

  public static final String VIEW_ID = "/hilfe/help-elect-ui-components.xhtml";

  @Inject
  private transient ElectCommonPrincipal principal;

  @Inject
  protected transient StartViewResolver startViewResolver;

  @Nullable
  @PreConditionCheck
  public String checkCondition() {
    if (FacesContextUtil.isDevelopmentStage() && principal.isLoggedIn()) {
      return null;
    }

    // ELECTVAPP-476
    return startViewResolver.getStartViewId();
  }

}
