package cz.moneta.test.dsl.forte.pages.branches;

import cz.moneta.test.dsl.forte.FortePageFlow;
import cz.moneta.test.dsl.forte.components.BranchesMenu;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.forte.pages.branches.MmbBranchesListPage.PAGE_TITLE;

@Wait(PAGE_TITLE)
public interface MmbBranchesListPage extends FortePageFlow<MmbBranchesListPage>, BranchesMenu {

    String PAGE_TITLE = CONTENT_DIV + "//h3[starts-with(text(), 'Seznam poboček')]";
    String EXPORT_TO_EXCEL_BUTTON = CONTENT_DIV + "//table[@class='datagrid']//a[@title='Exportovat do Excelu']//span[@class='icon-container']";
    String FILTER_FORM = CONTENT_DIV + "//form[@id='frm-grid-form']";
    String ADDRESS_FILTER_INPUT = FILTER_FORM + "//input[@id='frm-datagrid-grid-form-filters-address']";
    String SUBMIT_FILTER_BUTTON = FILTER_FORM + "//label[./*[@id='filter-grid']]";
    String FIRST_BRANCH_DETAIL_LINK = CONTENT_DIV + "//table[@class='datagrid']//tbody//child::tr[1]//a";

    @TypeInto(value = ADDRESS_FILTER_INPUT, clear = true)
    MmbBranchesListPage fillAddressFilter(String address);

    @Click(value = SUBMIT_FILTER_BUTTON, andWait = @Wait(value = SPINNER, until = Until.GONE,by = Lookup.ID))
    MmbBranchesListPage clickSubmitFilter();

    @Click(FIRST_BRANCH_DETAIL_LINK)
    MmbBranchDetailPage clickFirstBranchDetail();

    @Click(EXPORT_TO_EXCEL_BUTTON)
    MmbBranchesListPage clickExportToExcel();

}