package de.ivu.elect.presentation.gebietsbaum;

import javax.enterprise.inject.Specializes;
import javax.inject.Inject;

import de.ivu.elect.business.gebietsbaum.entity.Gebietsart;
import de.ivu.elect.jee.presentation.dynamicform.FormBuilder;
import de.ivu.elect.presentation.replikation.ReplikationPresentationStatus;

/**
 *  on 25.07.2017.
 */
@Specializes
public class WasGebietsartEditView extends GebietsartEditView {

  private static final long serialVersionUID = 1L;

  @Inject
  private transient ReplikationPresentationStatus replikationPresentationStatus;

  @Override
  public void addProperties(FormBuilder formBuilder, Gebietsart gebietsart) {
    super.addProperties(formBuilder, gebietsart);
    if (isSlave()) {
      formBuilder.globalReadonly();
    }
  }

  // WASDE-1153
  private boolean isSlave() {
    return replikationPresentationStatus.isSlave();
  }

  @Override
  public boolean isBtnSaveRendered() {
    return super.isBtnSaveRendered() && !isSlave();
  }
}
