<?xml version="1.0" encoding="UTF-8"?>

<?import com.andrewlalis.perfin.view.component.AccountHistoryView?>
<?import com.andrewlalis.perfin.view.component.PropertiesPane?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<BorderPane
        xmlns="http://javafx.com/javafx"
        xmlns:fx="http://javafx.com/fxml"
        fx:controller="com.andrewlalis.perfin.control.AccountViewController"
>
    <top>
        <Label fx:id="titleLabel" styleClass="std-padding,large-font,bold-text"/>
    </top>
    <center>
        <VBox>
            <!-- Main account properties and actions -->
            <FlowPane styleClass="std-padding,std-spacing">
                <!-- Main account properties. -->
                <PropertiesPane vgap="5" hgap="5">
                    <Label text="Name" styleClass="bold-text"/>
                    <Label fx:id="accountNameLabel"/>

                    <Label text="Number" styleClass="bold-text"/>
                    <Label fx:id="accountNumberLabel" styleClass="mono-font"/>

                    <Label text="Currency" styleClass="bold-text"/>
                    <Label fx:id="accountCurrencyLabel"/>

                    <Label text="Created At" styleClass="bold-text"/>
                    <Label fx:id="accountCreatedAtLabel" styleClass="mono-font"/>

                    <VBox>
                        <Label text="Current Balance" styleClass="bold-text" fx:id="balanceLabel"/>
                        <Text
                                styleClass="small-font,secondary-color-fill"
                                wrappingWidth="${balanceLabel.width}"
                        >Computed using the last recorded balance and all transactions since.</Text>
                    </VBox>
                    <Label fx:id="accountBalanceLabel" styleClass="mono-font"/>
                </PropertiesPane>
            </FlowPane>

            <PropertiesPane vgap="5" hgap="5" fx:id="descriptionPane">
                <Label text="Description" styleClass="bold-text" labelFor="${accountDescriptionText}"/>
                <TextFlow maxWidth="500"><Text fx:id="accountDescriptionText"/></TextFlow>
            </PropertiesPane>

            <!-- Action buttons -->
            <HBox fx:id="actionsBox" styleClass="std-padding,std-spacing,small-font">
                <Button text="Edit" onAction="#goToEditPage"/>
                <Button text="Record Balance" onAction="#goToCreateBalanceRecord"/>
                <Button text="Archive" onAction="#archiveAccount"/>
                <Button text="Delete" onAction="#deleteAccount"/>
                <Button text="Unarchive" onAction="#unarchiveAccount"/>
            </HBox>

            <!-- Historical Balance Checker -->
            <VBox styleClass="std-padding,std-spacing">
                <HBox styleClass="std-spacing">
                    <AnchorPane>
                        <Label text="Check Historical Balance" styleClass="bold-text" AnchorPane.topAnchor="0" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0"/>
                    </AnchorPane>
                    <DatePicker fx:id="balanceCheckerDatePicker"/>
                    <Button text="Check" fx:id="balanceCheckerButton"/>
                </HBox>
                <TextFlow maxWidth="500">
                    <Text styleClass="small-font,secondary-color-fill">
                        Use this tool to check the balance of this account on any
                        given day in the past. Perfin will compute the balance
                        according to any balance records and transactions it finds
                        around that time.
                    </Text>
                </TextFlow>
            </VBox>


            <!-- Account history -->
            <VBox VBox.vgrow="ALWAYS">
                <Label text="History" styleClass="bold-text,std-padding"/>
                <AccountHistoryView fx:id="accountHistory" initialItemsToLoad="10"/>
            </VBox>
        </VBox>
    </center>
</BorderPane>
