<script src="/js/libs/codemirror/codemirror-min.js"></script>
<link rel="stylesheet" href="/css/codemirror/codemirror.min.css">
<script src="/js/libs/codemirror/mode/yaml-min.js"></script>

<script>
$( document ).ready(function() {
    var area = document.getElementById('yaml');
    if (area) {
        var editor = CodeMirror.fromTextArea(area, {
            lineNumbers: true,
            mode:  "yaml"
        });
    }
});
  function toHex(str) {
    var result = '';
    for (var i=0; i<str.length; i++) {
      result += str.charCodeAt(i).toString(16);
    }
    return result;
  }
</script>

[% site_config.title = c.loc('Batch Provisioning')  -%]

[%
    helper.name = modal_title;
    helper.identifier = 'provisioning_templates';
    helper.length_change = 1;
    helper.dt_columns = template_dt_columns;
    helper.data_static = 1;
    helper.messages = messages;
    helper.ajax_uri = c.uri_for_action('/batchprovisioning/ajax');

    helper.close_target = close_target;
    helper.create_flag = create_flag;
    helper.edit_flag = edit_flag;
    helper.form_object = form;

    UNLESS c.user.read_only;
        helper.dt_buttons = [
            { name = c.loc('Delete'), condition = "full.static == 0", uri = "/batchprovisioning/templates/'+toHex((full.reseller ? full.reseller + '/' : '') + full.name)+'/remove", no_back = 1, class = 'btn-small btn-secondary', icon = 'icon-remove' },
            { name = c.loc('Edit'), condition = "full.static == 0", uri = "/batchprovisioning/templates/'+toHex((full.reseller ? full.reseller + '/' : '') + full.name)+'/edit", no_back = 1, class = 'btn-small btn-primary', icon = 'icon-edit' },
            { name = c.loc('Open Form'), uri = "/batchprovisioning/templates/'+toHex((full.reseller ? full.reseller + '/' : '') + full.name)+'/form", no_back = 1, class = 'btn-small btn-tertiary', icon = 'icon-list' },
            { name = c.loc('Upload CSV'), uri = "/batchprovisioning/templates/'+toHex((full.reseller ? full.reseller + '/' : '') + full.name)+'/upload", no_back = 1, class = 'btn-small btn-tertiary', icon = 'icon-star' },
        ];
        helper.top_buttons = [
            { name = c.loc('Create Provisioning Template'), uri = c.uri_for_action('/batchprovisioning/create'), icon = 'icon-star' },
        ];
    END;

    PROCESS 'helpers/datatables.tt';
%]