
package de.ivu.elect.presentation.gebietsbaum;

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

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

@Specializes
public class WasGebietEditView extends GebietEditView {

  private static final long serialVersionUID = 1L;

  @Inject
  private transient ReplikationPresentationStatus replikationPresentationStatus;

  public WasGebietEditView() {
    super();
  }

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

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

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