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