Working on the first-round updates for the zone template editor.

This commit is contained in:
Matt Scott 2023-02-19 21:20:23 -05:00
parent fe49651e81
commit 4d64076dac

View File

@ -1,27 +1,18 @@
{% extends "base.html" %} {% extends "base.html" %}
{% set active_page = "admin_domain_template" %} {% set active_page = "admin_domain_template" %}
{% block title %}<title>Edit Zone Template - {{ SITE_NAME }}</title>{% endblock %}
{% block title %}
<title>
Edit Template - {{ SITE_NAME }}
</title>
{% endblock %}
{% block dashboard_stat %} {% block dashboard_stat %}
<div class="content-header"> <div class="content-header">
<div class="container-fluid"> <div class="container-fluid">
<div class="row mb-2"> <div class="row mb-2">
<div class="col-sm-6"> <div class="col-sm-6">
<h1 class="m-0 text-dark"> <h1 class="m-0 text-dark">Edit Zone Template</h1>
Template Edit
<small>{{ template }}</small>
</h1>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<ol class="breadcrumb float-sm-right"> <ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="{{ url_for('admin.templates') }}">Templates</a></li> <li class="breadcrumb-item"><a href="{{ url_for('admin.templates') }}">Templates</a></li>
<li class="breadcrumb-item active">Template Edit: {{ template }}</li> <li class="breadcrumb-item active">Edit Zone Template</li>
</ol> </ol>
</div> </div>
</div> </div>
@ -34,20 +25,23 @@
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="card"> <div class="card card-outline card-primary shadow">
<div class="card-header"> <div class="card-header">
<h3 class="card-title">Manage Template Records for {{ template }}</h3> <h3 class="card-title">Zone Template Editor</h3>
</div> <div class="card-tools">
<div class="card-body"> <button type="button" class="btn btn-primary float-left button_add_record"
<button type="button" class="btn btn-primary float-left button_add_record" id="{{ template }}"> title="Add Record" id="{{ template }}">
<i class="fa-solid fa-plus"></i>&nbsp;Add Record <i class="fa-solid fa-plus"></i>&nbsp;Add Record
</button> </button>
<button type="button" class="btn btn-primary float-right button_apply_changes" id="{{ template }}"> <button type="button" class="btn btn-primary float-right button_apply_changes ml-2"
<i class="fa-solid fa-save"></i>&nbsp;Save Changes title="Save Template" id="{{ template }}">
<i class="fa-solid fa-save"></i>&nbsp;Save Template
</button> </button>
</div> </div>
<div class="card-body"> </div>
<table id="tbl_records" class="table table-bordered table-striped"> <div class="card-body table-responsive">
<table id="tbl_records"
class="table table-bordered table-striped table-hover table-sm records">
<thead> <thead>
<tr> <tr>
<th>Name</th> <th>Name</th>
@ -56,8 +50,7 @@
<th>TTL</th> <th>TTL</th>
<th>Data</th> <th>Data</th>
<th>Comment</th> <th>Comment</th>
<th>Edit</th> <th>Actions</th>
<th>Delete</th>
<th>ID</th> <th>ID</th>
</tr> </tr>
</thead> </thead>
@ -82,20 +75,17 @@
<td> <td>
{{ record.comment }} {{ record.comment }}
</td> </td>
<td width="6%"> <td>
<button type="button" class="btn btn-warning button_edit"> <button type="button" class="btn btn-warning button_edit"
title="Edit Record">
<i class="fa-solid fa-edit"></i>&nbsp;Edit <i class="fa-solid fa-edit"></i>&nbsp;Edit
</button> </button>
</td> <button type="button" class="btn btn-danger button_delete"
<td width="6%"> title="Delete Record">
<button type="button" class="btn btn-danger button_delete">
<i class="fa-solid fa-trash"></i>&nbsp;Delete <i class="fa-solid fa-trash"></i>&nbsp;Delete
</button> </button>
</td> </td>
<td> <td>{{ id }}</td>
{{ record.id }}
</td>
</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
@ -107,6 +97,7 @@
</div> </div>
</section> </section>
{% endblock %} {% endblock %}
{% block extrascripts %} {% block extrascripts %}
<script> <script>
// superglobals // superglobals
@ -115,7 +106,7 @@
window.nEditing = null; window.nEditing = null;
window.nNew = false; window.nNew = false;
// set up user data table // Initialize DataTables
$("#tbl_records").DataTable({ $("#tbl_records").DataTable({
"paging": true, "paging": true,
"lengthChange": true, "lengthChange": true,
@ -144,14 +135,14 @@
// hidden column so that we can add new records on top // hidden column so that we can add new records on top
// regardless of whatever sorting is done. See orderFixed // regardless of whatever sorting is done. See orderFixed
visible: false, visible: false,
targets: [ 8 ] targets: [7]
}, },
{ {
className: "length-break", className: "length-break",
targets: [4, 5] targets: [4, 5]
} }
], ],
"orderFixed": [[8, 'asc']] "orderFixed": [[7, 'asc']]
}); });
// handle delete button // handle delete button
@ -174,6 +165,7 @@
modal.modal('hide'); modal.modal('hide');
}); });
}); });
// handle edit button and record click // handle edit button and record click
$(document.body).on("click", ".button_edit{% if quick_edit %}, .row_record{% endif %}", function (e) { $(document.body).on("click", ".button_edit{% if quick_edit %}, .row_record{% endif %}", function (e) {
e.stopPropagation(); e.stopPropagation();
@ -220,7 +212,10 @@
// following unbind("click") is to avoid multiple times execution // following unbind("click") is to avoid multiple times execution
modal.find('#button_apply_confirm').unbind("click").click(function () { modal.find('#button_apply_confirm').unbind("click").click(function () {
var data = getTableData(table); var data = getTableData(table);
applyChanges( {'_csrf_token': '{{ csrf_token() }}', 'records': data}, $SCRIPT_ROOT + '/admin/template/' + template + '/apply', true); applyChanges({
'_csrf_token': '{{ csrf_token() }}',
'records': data
}, $SCRIPT_ROOT + '/admin/template/' + template + '/apply', true);
modal.modal('hide'); modal.modal('hide');
}) })
modal.modal('show'); modal.modal('show');
@ -425,6 +420,7 @@
{% endif %} {% endif %}
</script> </script>
{% endblock %} {% endblock %}
{% block modals %} {% block modals %}
<div class="modal fade modal-warning" id="modal_delete"> <div class="modal fade modal-warning" id="modal_delete">
<div class="modal-dialog"> <div class="modal-dialog">
@ -440,7 +436,8 @@
<p></p> <p></p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary float-left" id="button_delete_cancel" data-dismiss="modal"> <button type="button" class="btn btn-secondary float-left" id="button_delete_cancel"
data-dismiss="modal">
Close Close
</button> </button>
<button type="button" class="btn btn-danger" id="button_delete_confirm"> <button type="button" class="btn btn-danger" id="button_delete_confirm">