mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-08 22:50:26 +00:00
Fix issues when adding a record, and sort and/or search is involved.
Previously this caused the newly added record to either appear at the bottom, or not appear at all. Now it will always be added at the top, and whatever search present is cleared.
This commit is contained in:
parent
4ff755bc20
commit
480a00bb87
@ -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,17 @@
|
|||||||
// 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();
|
|
||||||
var nRow = aiNew.index();
|
// add new row
|
||||||
editRow(table, nRow);
|
var nRow = jQuery('#tbl_records').dataTable().fnAddData(['', 'A', 'Active', 3600, '', '', '', '0']);
|
||||||
|
editRow($("#tbl_records").DataTable(), nRow);
|
||||||
nEditing = nRow;
|
nEditing = nRow;
|
||||||
nNew = true;
|
nNew = true;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user