mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-12 16:40:26 +00:00
Merge pull request #117 from jallakim/add-record-fix
Fix issues when adding a record, and sort and/or search is involved
This commit is contained in:
commit
8e58999f5a
@ -90,7 +90,7 @@ function editRow(oTable, nRow) {
|
|||||||
var record_type = records_allow_edit[i];
|
var record_type = records_allow_edit[i];
|
||||||
record_types += "<option value=\"" + record_type + "\">" + record_type + "</option>";
|
record_types += "<option value=\"" + record_type + "\">" + record_type + "</option>";
|
||||||
}
|
}
|
||||||
jqTds[0].innerHTML = '<input type="text" class="form-control input-small" value="' + aData[0] + '">';
|
jqTds[0].innerHTML = '<input type="text" id="edit-row-focus" class="form-control input-small" value="' + aData[0] + '">';
|
||||||
jqTds[1].innerHTML = '<select class="form-control" id="record_type" name="record_type" value="' + aData[1] + '"' + '>' + record_types + '</select>';
|
jqTds[1].innerHTML = '<select class="form-control" id="record_type" name="record_type" value="' + aData[1] + '"' + '>' + record_types + '</select>';
|
||||||
jqTds[2].innerHTML = '<select class="form-control" id="record_status" name="record_status" value="' + aData[2] + '"' + '><option value="false">Active</option><option value="true">Disabled</option></select>';
|
jqTds[2].innerHTML = '<select class="form-control" id="record_status" name="record_status" value="' + aData[2] + '"' + '><option value="false">Active</option><option value="true">Disabled</option></select>';
|
||||||
jqTds[3].innerHTML = '<select class="form-control" id="record_ttl" name="record_ttl" value="' + aData[3] + '"' + '><option value="60">1 minute</option><option value="300">5 minutes</option><option value="1800">30 minutes</option><option value="3600">60 minutes</option><option value="86400">24 hours</option></select>';
|
jqTds[3].innerHTML = '<select class="form-control" id="record_ttl" name="record_ttl" value="' + aData[3] + '"' + '><option value="60">1 minute</option><option value="300">5 minutes</option><option value="1800">30 minutes</option><option value="3600">60 minutes</option><option value="86400">24 hours</option></select>';
|
||||||
|
@ -71,38 +71,28 @@
|
|||||||
{% if domain.type != 'Slave' %}
|
{% if domain.type != 'Slave' %}
|
||||||
<td width="6%">
|
<td width="6%">
|
||||||
{% if record.is_allowed() %}
|
{% if record.is_allowed() %}
|
||||||
<button type="button" class="btn btn-flat btn-warning button_edit" id="{{ (record.name,domain.name)|display_record_name }}">
|
<button type="button" class="btn btn-flat btn-warning button_edit" id="{{ (record.name,domain.name)|display_record_name }}">Edit <i class="fa fa-edit"></i></button>
|
||||||
Edit <i class="fa fa-edit"></i>
|
|
||||||
</button>
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<button type="button" class="btn btn-flat btn-warning"">
|
<button type="button" class="btn btn-flat btn-warning""> <i class="fa fa-exclamation-circle"></i> </button>
|
||||||
<i class="fa fa-exclamation-circle"></i>
|
|
||||||
</button>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td width="6%">
|
<td width="6%">
|
||||||
{% if record.is_allowed() %}
|
{% if record.is_allowed() %}
|
||||||
<button type="button" class="btn btn-flat btn-danger button_delete" id="{{ (record.name,domain.name)|display_record_name }}">
|
<button type="button" class="btn btn-flat btn-danger button_delete" id="{{ (record.name,domain.name)|display_record_name }}">Delete <i class="fa fa-trash"></i></button>
|
||||||
Delete <i class="fa fa-trash"></i>
|
|
||||||
</button>
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<button type="button" class="btn btn-flat btn-warning"">
|
<button type="button" class="btn btn-flat btn-warning""> <i class="fa fa-exclamation-circle"></i> </button>
|
||||||
<i class="fa fa-exclamation-circle"></i>
|
|
||||||
</button>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<td width="6%">
|
<td width="6%">
|
||||||
<button type="button" class="btn btn-flat btn-warning"">
|
<button type="button" class="btn btn-flat btn-warning""> <i class="fa fa-exclamation-circle"></i> </button>
|
||||||
<i class="fa fa-exclamation-circle"></i>
|
|
||||||
</button>
|
|
||||||
</td>
|
</td>
|
||||||
<td width="6%">
|
<td width="6%">
|
||||||
<button type="button" class="btn btn-flat btn-warning"">
|
<button type="button" class="btn btn-flat btn-warning""> <i class="fa fa-exclamation-circle"></i> </button>
|
||||||
<i class="fa fa-exclamation-circle"></i>
|
|
||||||
</button>
|
|
||||||
</td>
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
|
<!-- hidden column that we can sort on -->
|
||||||
|
<td>1</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -145,8 +135,18 @@
|
|||||||
},
|
},
|
||||||
"retrieve" : true,
|
"retrieve" : true,
|
||||||
"columnDefs": [
|
"columnDefs": [
|
||||||
{ type: 'natural', targets: [0, 4] }
|
{
|
||||||
]
|
type: 'natural',
|
||||||
|
targets: [0, 4]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// hidden column so that we can add new records on top
|
||||||
|
// regardless of whatever sorting is done
|
||||||
|
visible: false,
|
||||||
|
targets: [ 7 ]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"orderFixed": [[7, 'asc']]
|
||||||
});
|
});
|
||||||
|
|
||||||
// handle delete button
|
// handle delete button
|
||||||
@ -214,15 +214,18 @@
|
|||||||
// handle add record button
|
// handle add record button
|
||||||
$(document.body).on("click", ".button_add_record", function (e) {
|
$(document.body).on("click", ".button_add_record", function (e) {
|
||||||
if (nNew || nEditing) {
|
if (nNew || nEditing) {
|
||||||
// TODO: replace this alert with modal
|
var modal = $("#modal_error");
|
||||||
alert("Previous record not saved. Please save it before adding more record.")
|
modal.find('.modal-body p').text("Previous record not saved. Please save it before adding more record.");
|
||||||
|
modal.modal('show');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var table = $("#tbl_records").DataTable();
|
// clear search first
|
||||||
|
$("#tbl_records").DataTable().search('').columns().search('').draw();
|
||||||
|
|
||||||
var aiNew = table.row.add(['', 'A', 'Active', 3600, '', '', '']).draw();
|
// add new row
|
||||||
var nRow = aiNew.index();
|
var nRow = jQuery('#tbl_records').dataTable().fnAddData(['', 'A', 'Active', 3600, '', '', '', '0']);
|
||||||
editRow(table, nRow);
|
editRow($("#tbl_records").DataTable(), nRow);
|
||||||
|
document.getElementById("edit-row-focus").focus();
|
||||||
nEditing = nRow;
|
nEditing = nRow;
|
||||||
nNew = true;
|
nNew = true;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user