diff --git a/app/static/custom/js/custom.js b/app/static/custom/js/custom.js
index 73c6c3a..d740766 100644
--- a/app/static/custom/js/custom.js
+++ b/app/static/custom/js/custom.js
@@ -90,7 +90,7 @@ function editRow(oTable, nRow) {
var record_type = records_allow_edit[i];
record_types += "";
}
- jqTds[0].innerHTML = '';
+ jqTds[0].innerHTML = '';
jqTds[1].innerHTML = '';
jqTds[2].innerHTML = '';
jqTds[3].innerHTML = '';
diff --git a/app/templates/domain.html b/app/templates/domain.html
index a634d46..4b19e7c 100644
--- a/app/templates/domain.html
+++ b/app/templates/domain.html
@@ -71,38 +71,28 @@
{% if domain.type != 'Slave' %}
{% if record.is_allowed() %}
-
+
{% else %}
-
+
{% endif %}
|
{% if record.is_allowed() %}
-
+
{% else %}
-
+
{% endif %}
{% else %}
|
-
+
|
-
+
|
{% endif %}
+
+ 1 |
{% endfor %}
@@ -145,8 +135,18 @@
},
"retrieve" : true,
"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
@@ -214,15 +214,18 @@
// handle add record button
$(document.body).on("click", ".button_add_record", function (e) {
if (nNew || nEditing) {
- // TODO: replace this alert with modal
- alert("Previous record not saved. Please save it before adding more record.")
+ var modal = $("#modal_error");
+ modal.find('.modal-body p').text("Previous record not saved. Please save it before adding more record.");
+ modal.modal('show');
return;
}
- var table = $("#tbl_records").DataTable();
-
- var aiNew = table.row.add(['', 'A', 'Active', 3600, '', '', '']).draw();
- var nRow = aiNew.index();
- editRow(table, nRow);
+ // clear search first
+ $("#tbl_records").DataTable().search('').columns().search('').draw();
+
+ // add new row
+ var nRow = jQuery('#tbl_records').dataTable().fnAddData(['', 'A', 'Active', 3600, '', '', '', '0']);
+ editRow($("#tbl_records").DataTable(), nRow);
+ document.getElementById("edit-row-focus").focus();
nEditing = nRow;
nNew = true;
});