//-/////////////////////////////////////////////////////////////////////////////
//-                                                                           //
//-               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#settings-macros-template(type="text/x-template")
  #settings-macros
    h1 Macro Configuration

    .toolbar
      bbutton(title="Add a new macro.", @click="add", text="Add")

    ol.macros(v-if="macros.length")
      li(v-for="macro in macros")
        label.index {{"#" + ($index + 1)}}
        .macro(draggable="true", @dragstart="dragstart", @mousedown="mousedown",
          @drag="drag($index)", @dragover.prevent="",
          @drop.prevent="drop($index)")
          .grip

          color-picker(:value.sync="macro.color", @change="change",
            title="Set the macro button color.")

          input.name(@change="change", v-model="macro.name",
            title="Set the macro button name.")

          input.path(@click="open($index)", :value="macro.path", readonly,
            title="Select the macro file")

          .actions
            .fa.fa-folder-open(@click="open($index)",
              title="Select the macro file.")
            .fa.fa-trash(@click="remove($index)",
              :title="'Delete macro ' + ($index + 1) + '.'")

    p.
      Macros are programs that you can run by clicking the corresponding
      button on the #[a(href="#control") control page].  To create a new
      macro, click the "Add" button.  Then set the button color, name and
      select a program to run from the file menu.  You can upload new
      programs or create them with the #[a(href="#editor") editor].
