<mvc:View controllerName=“fivea.controller.Cultivar_Detail” xmlns=“sap.m” xmlns:f=“sap.f” xmlns:t=“sap.ui.table” xmlns:l=“sap.ui.layout” xmlns:fl=“sap.ui.layout.form” xmlns:core=“sap.ui.core” xmlns:mvc=“sap.ui.core.mvc” xmlns:u=“sap.ui.unified”>

<Page title="Cultivar detail">
  <customHeader>
    <Bar>
      <contentRight>
        <Button icon="sap-icon://delete" text="Delete" press="onDeletePress" />
      </contentRight>
      <contentLeft>
        <Button icon="sap-icon://nav-back" press="onNavBack" />
        <Button icon="sap-icon://save" type="Accept" press="onSave" text="Save changes" />
        <Button icon="sap-icon://create" type="Accept" text="Create" press="onCreatePress" />
      </contentLeft>
    </Bar>
  </customHeader>
  <ObjectHeader title="{id} : {name}" />
  <Panel expandable="true" expanded="true" headerText="Details" 
    width="auto" class="sapUiResponsiveMargin">
    <content>
      <fl:SimpleForm editable="true">
        <Label text="Name" />
        <Input id="name" type="Text" name="name" enabled="true" 
               value="{name}" />
        <Label text="Year" />
        <Input id="year" type="Number" name="year" enabled="true" 
               value="{year}" />
        <Label text="Breeder" />
        <Input id="breeder_id" type="Text" width="40%" 
               showValueHelp="true" 
               valueHelpRequest="onBreederIdValueHelp" 
               name="breeder_id" value="{breeder_id}" enabled="true" />
          <f:Avatar   id="avatar" class="sapUiSmallMarginEnd"/>
          <Link id="breeder_id_descr" 
                text="{breeder/first_name} {breeder/last_name}" 
                press="handleBreederPress" />
          <Button icon="sap-icon://create" 
                  type="Accept" 
                  text="Create" 
                  press="onBreederCreatePress" />
      </fl:SimpleForm>
    </content>
  </Panel>
  <Panel expandable="true" expanded="true" headerText="Images" width="auto" class="sapUiResponsiveMargin">
    <content>
      <Toolbar class="sapUiMediumMarginTop" id="im_toolbar">
        <Button icon="sap-icon://attachment" type="Accept" 
                text="Upload" press="handleUploadPress" />
        <u:FileUploader id="fileUploader" useMultipart="false" name="myFileUpload" uploadUrl="/odata/cultivar({id})/photo" width="400px" tooltip="Upload your file to the local server" uploadComplete="handleUploadComplete" />
      </Toolbar>
      <l:HorizontalLayout id="images" />
    </content>
  </Panel>
  <Panel expandable="true" expanded="true" headerText="Parents" width="auto" class="sapUiResponsiveMargin">
    <content>
      <t:Table id="parent_table" rows="{path: 'parent', parameters:{expand : 'cultivar/breeder,parent/breeder'} }" rowSelectionChange="onParentSelectionChange" selectionMode="Single" visibleRowCount="4" visibleRowCountMode="Auto" selectionBehavior="Row">
        <t:columns>
          <t:Column width="10%" autoResizable="true">
            <Label text="Par. Type" />
            <t:template>
              <Text text="{path:'ptype_id'}" />
            </t:template>
          </t:Column>
          <t:Column autoResizable="true" sortProperty="parent/name" filterProperty="parent/name">
            <Label text="Parent" />
            <t:template>
              <Text text="{parent/name}" />
            </t:template>
          </t:Column>
          <t:Column autoResizable="true">
            <Label text="Breeder" />
            <t:template>
              <Text text="{parent/breeder/last_name}" />
            </t:template>
          </t:Column>
        </t:columns>
      </t:Table>
    </content>
  </Panel>
  <Panel expandable="true" expanded="true" headerText="Direct decendency" width="auto" class="sapUiResponsiveMargin">
    <content>
      <t:Table id="child_table" rows="{path: 'child', parameters:{expand : 'cultivar/breeder'} }" rowSelectionChange="onChildSelectionChange" selectionMode="Single" visibleRowCount="10" visibleRowCountMode="Auto" selectionBehavior="Row">
        <t:columns>
          <t:Column width="10%" autoResizable="true">
            <Label text="Par. Type" />
            <t:template>
              <Text text="{path:'ptype_id'}" />
            </t:template>
          </t:Column>
          <t:Column autoResizable="true" sortProperty="cultivar/name" filterProperty="cultivar/name">
            <Label text="Cultivar" />
            <t:template>
              <Text text="{cultivar/name}" />
            </t:template>
          </t:Column>
          <t:Column autoResizable="true" sortProperty="cultivar/breeder/last_name" filterProperty="cultivar/breeder/last_name">
            <Label text="Breeder" />
            <t:template>
              <Text text="{cultivar/breeder/last_name}" />
            </t:template>
          </t:Column>
        </t:columns>
      </t:Table>
    </content>
  </Panel>
</Page>

</mvc:View>