package com.ecep.contract.controller.vendor.approved_list;

import java.time.format.DateTimeFormatter;

import com.ecep.contract.controller.tab.AbstEntityBasedTabSkin;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.model.CompanyVendorApprovedList;
import com.ecep.contract.vm.CompanyVendorApprovedListViewModel;

import javafx.scene.control.Tab;
import javafx.util.converter.LocalDateStringConverter;

public class CompanyVendorApprovedListTabSkinBase
        extends
        AbstEntityBasedTabSkin<CompanyVendorApprovedListWindowController, CompanyVendorApprovedList, CompanyVendorApprovedListViewModel>
        implements TabSkin {
    public CompanyVendorApprovedListTabSkinBase(CompanyVendorApprovedListWindowController controller) {
        super(controller);
    }

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

    @Override
    public void initializeTab() {
        controller.titleField.textProperty().bindBidirectional(viewModel.getTitle());
        controller.pathField.textProperty().bindBidirectional(viewModel.getPath());
        LocalDateStringConverter converter = new LocalDateStringConverter(DateTimeFormatter.ISO_LOCAL_DATE, null);
        controller.publishDateField.setConverter(converter);
        controller.publishDateField.valueProperty().bindBidirectional(viewModel.getPublishDate());
        controller.descriptionField.textProperty().bindBidirectional(viewModel.getDescription());
    }
}
