//-/////////////////////////////////////////////////////////////////////////////
//-                                                                           //
//-               This file is part of the Buildbotics firmware.              //
//-                                                                           //
//-      Copyright (c) 2015 - 2021, 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#templated-input-template(type="text/x-template")
  .pure-control-group(class="tmpl-input-{{name}}", :title="title")
    label(:for="name") {{name}}

    select(v-if="template.type == 'enum' || template.values", v-model="view",
      :name="name", @change="change")
      option(v-for="opt in template.values", :value="opt") {{opt}}

    input(v-if="template.type == 'bool'", type="checkbox", v-model="view",
      :name="name", @change="change")

    input(v-if="template.type == 'float'", v-model.number="view", number,
      :min="template.min", :max="template.max", :step="template.step || 'any'",
      type="number", :name="name", @change="change")

    input(v-if="template.type == 'int' && !template.values", number,
      v-model.number="view", :min="template.min", :max="template.max",
      type="number", :name="name", @change="change")

    input(v-if="template.type == 'string'", v-model="view", type="text",
      :name="name", @change="change")

    textarea(v-if="template.type == 'text'", v-model="view", :name="name",
      @change="change")

    span.range(v-if="template.type == 'percent'")
      input(type="range", v-model="view", :name="name", number, min="0",
        max="100", step="1", @change="change")
      | {{view}}

    label.units {{units}}

    slot(name="extra")
