package com.ecep.contract.controller.permission;

import com.ecep.contract.Desktop;
import com.ecep.contract.controller.tab.TabSkin;

import javafx.scene.control.Tab;

public class EmployeeRoleTabSkinBase extends AbstEmployeeRoleBasedTabSkin implements TabSkin {

    public EmployeeRoleTabSkinBase(EmployeeRoleWindowController controller) {
        super(controller);
    }

    @Override
    public Tab getTab() {
        return controller.baseInfoTab;
    }

    @Override
    public void initializeTab() {
        controller.nameField.textProperty().bindBidirectional(viewModel.getName());
        controller.codeField.textProperty().bindBidirectional(viewModel.getCode());
        if (Desktop.instance.getActiveEmployee().isSystemAdministrator()) {
            controller.systemAdministratorField.selectedProperty().bindBidirectional(viewModel.getSystemAdministrator());
        } else {
            controller.systemAdministratorField.selectedProperty().bind(viewModel.getSystemAdministrator());
        }
        controller.managerField.selectedProperty().bindBidirectional(viewModel.getManager());
        controller.activeField.selectedProperty().bindBidirectional(viewModel.getActive());
    }
}
