package de.ivu.elect.presentation;

import javax.annotation.Nullable;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;

import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.jee.faces.PreConditionCheck;
import de.ivu.elect.jee.presentation.dynamicform.AdvancedDynaFormModel;
import de.ivu.elect.jee.presentation.dynamicform.DynamicFormEditOrCreateView;
import de.ivu.elect.jee.presentation.dynamicform.FormBuilder;

@RequestScoped
@Named(BlankView.COMPONENT_NAME)
@View(viewId = BlankView.VIEW_ID, useCase = UseCasePermission.ANWENDUNG_BENUTZEN)

public class BlankView extends AbstractElectView implements DynamicFormEditOrCreateView {
  private static final long serialVersionUID = 1L;

  public static final String COMPONENT_NAME = "blankView";

  public static final String VIEW_ID = "/blank.xhtml";

  @Nullable
  @PreConditionCheck
  public String checkPreCondition() {
    String startViewId = getStartViewId();
    if (!VIEW_ID.equals(startViewId)) {
      return startViewId;
    }
    return null;
  }

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

  public String getPageTitle() {
    return getMessage("blank.page.title");
  }

  public String getPageHeader() {
    return getMessage("blank.page.header");
  }

  @Override
  public AdvancedDynaFormModel getModel() {
    FormBuilder formBuilder = new FormBuilder();
    addProperties(formBuilder);
    return formBuilder.createModel();
  }

  protected void addProperties(FormBuilder formBuilder) {
    // nichts zu tun
  }

  @Override
  public String getBtnSaveLabel() {
    return "";
  }

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

  @Override
  public String save() {
    return VIEW_ID;
  }

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

  @Override
  public String reset() {
    return VIEW_ID;
  }

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

  @Override
  public String cancel() {
    return VIEW_ID;
  }
}
