Allow for edits to start by clicking on the record row. Fixes #29

This commit is contained in:
Ivan Filippov 2016-04-29 11:44:39 -06:00
parent ecebfb0951
commit 8c7110b820

View File

@ -52,7 +52,7 @@
</thead> </thead>
<tbody> <tbody>
{% for record in records %} {% for record in records %}
<tr class="odd"> <tr class="odd row_record" id="{{ domain.name }}">
<td> <td>
{{ (record.name,domain.name)|display_record_name }} {{ (record.name,domain.name)|display_record_name }}
</td> </td>
@ -137,7 +137,8 @@
}); });
// handle delete button // handle delete button
$(document).on("click", ".button_delete", function() { $(document).on("click", ".button_delete", function(e) {
e.stopPropagation();
var modal = $("#modal_delete"); var modal = $("#modal_delete");
var table = $("#tbl_records").DataTable(); var table = $("#tbl_records").DataTable();
var record = $(this).prop('id'); var record = $(this).prop('id');
@ -151,11 +152,18 @@
}); });
// handle edit button // handle edit button
$(document).on("click", ".button_edit", function() { $(document).on("click", ".button_edit, .row_record", function(e) {
var nRow = $(this).parents('tr')[0]; e.stopPropagation();
if ($(this).is('tr')) {
var nRow = $(this)[0];
} else {
var nRow = $(this).parents('tr')[0];
}
var table = $("#tbl_records").DataTable(); var table = $("#tbl_records").DataTable();
if (nEditing !== null && nEditing != nRow && nNew == false) { if (nEditing == nRow) {
/* click on row already being edited, do nothing */
} else if (nEditing !== null && nEditing != nRow && nNew == false) {
/* Currently editing - but not this row - restore the old before continuing to edit mode */ /* Currently editing - but not this row - restore the old before continuing to edit mode */
restoreRow(table, nEditing); restoreRow(table, nEditing);
editRow(table, nRow); editRow(table, nRow);
@ -207,6 +215,7 @@
//handle cancel button //handle cancel button
$(document).on("click", ".button_cancel", function (e) { $(document).on("click", ".button_cancel", function (e) {
e.stopPropagation();
var oTable = $("#tbl_records").DataTable(); var oTable = $("#tbl_records").DataTable();
if (nNew) { if (nNew) {
oTable.row(nEditing).remove().draw(); oTable.row(nEditing).remove().draw();
@ -220,6 +229,7 @@
//handle save button //handle save button
$(document).on("click", ".button_save", function (e) { $(document).on("click", ".button_save", function (e) {
e.stopPropagation();
var table = $("#tbl_records").DataTable(); var table = $("#tbl_records").DataTable();
saveRow(table, nEditing); saveRow(table, nEditing);
nEditing = null; nEditing = null;