//-/////////////////////////////////////////////////////////////////////////////
//-                                                                           //
//-               This file is part of the Buildbotics firmware.              //
//-                                                                           //
//-      Copyright (c) 2015 - 2023, Buildbotics LLC, All rights reserved.     //
//-                                                                           //
//-       This Source describes Open Hardware and is licensed under the       //
//-                               CERN-OHL-S v2.                              //
//-                                                                           //
//-       You may redistribute and modify this Source and make products       //
//-  using it under the terms of the CERN-OHL-S v2 (https:/cern.ch/cern-ohl). //
//-         This Source is distributed WITHOUT ANY EXPRESS OR IMPLIED         //
//-  WARRANTY, INCLUDING OF MERCHANTABILITY, SATISFACTORY QUALITY AND FITNESS //
//-   FOR A PARTICULAR PURPOSE. Please see the CERN-OHL-S v2 for applicable   //
//-                                conditions.                                //
//-                                                                           //
//-              Source location: https://github.com/buildbotics              //
//-                                                                           //
//-    As per CERN-OHL-S v2 section 4, should You produce hardware based on   //
//-  these sources, You must maintain the Source Location clearly visible on  //
//-  the external case of the CNC Controller or other product you make using  //
//-                                this Source.                               //
//-                                                                           //
//-              For more information, email info@buildbotics.com             //
//-                                                                           //
//-/////////////////////////////////////////////////////////////////////////////

script#axis-row-template(type="text/x-template")
  tr.axis(:class="axis.klass", :title="axis.title")
    th.name {{name}}
    td.position: unit-value(:value="axis.pos", precision=4)
    td.absolute: unit-value(:value="axis.abs", precision=3)
    td.offset: unit-value(:value="axis.off", precision=3)
    td.state #[.fa(class="fa-{{axis.icon}}")] {{axis.state}}
    th.actions
      bbutton(:disabled="!is_idle", icon="cog",
        title="Set {{name}} axis position.", @click="set_position")

      bbutton(:disabled="!is_idle", text="&empty;",
        title="Zero {{name}} axis offset.", @click="zero")

      bbutton(:disabled="!is_idle", @click="home", icon="home",
        title="Home {{name}} axis.")

      dialog(v-ref:set-position,
        :buttons="axis.homed ? 'Cancel Unhome Set' : 'Cancel Set'",
        :header="'Set ' + name + ' axis position'")
        div(slot="body")
          .pure-form
            .pure-control-group
              label Position
              input(v-model="position",
                @keyup.enter="$refs.setPosition.close('set')")

      dialog(v-ref:set-home, buttons="Cancel Set",
        :header="'Manually home ' + name + ' axis'")
        div(slot="body")
          p Set axis absolute position.
          .pure-form
            .pure-control-group
              label Absolute
              input(v-model="position",
                @keyup.enter="$refs.setHome.close('set')")
