"
@@ -46,14 +46,14 @@ var viewHelpers = {
form_group += ""
- form_group += ""
+ form_group += ""
} else {
if (input_type == 'integer') {
input_type = "text"
}
- form_group += ""
}
@@ -117,7 +117,7 @@ $(document).ready(function(){
}
})
- $('#settings-form').on('change', 'input', function(){
+ $('#settings-form').on('change', 'input.trigger-change', function(){
// this input was changed, add the changed data attribute to it
$(this).attr('data-changed', true)
@@ -335,12 +335,20 @@ function badgeSidebarForDifferences(changedInput) {
var badgeValue = 0
- for (var setting in Settings.initialValues[panelParentID]) {
+ // badge for any settings we have that are not the same or are not present in initialValues
+ for (var setting in panelJSON) {
if (panelJSON[setting] != Settings.initialValues[panelParentID][setting]) {
badgeValue += 1
}
}
+ // badge for any settings we remove that are in the initialValues
+ for (var setting in Settings.initialValues[panelParentID]) {
+ if (!_.has(panelJSON, setting)) {
+ badgeValue += 1
+ }
+ }
+
// update the list-group-item badge to have the new value
if (badgeValue == 0) {
badgeValue = ""
@@ -394,7 +402,8 @@ function addTableRow(add_glyphicon) {
var input_clone = row.clone()
// Change input row to data row
- var setting_name = row.parents("table").attr("name")
+ var table = row.parents("table")
+ var setting_name = table.attr("name")
var full_name = setting_name + "." + name
row.attr("class", "row-data")
@@ -419,7 +428,8 @@ function addTableRow(add_glyphicon) {
var input = $(element).children("input")
$(element).html(input.val())
input.remove()
- } else if ($(element).hasClass("row-data")) { // Hide inputs
+ } else if ($(element).hasClass("row-data")) {
+ // Hide inputs
var input = $(element).children("input")
input.attr("type", "hidden")
@@ -429,10 +439,9 @@ function addTableRow(add_glyphicon) {
input.attr("name", full_name + "." + $(element).attr("name"))
}
- input.attr("value", input.val())
input.attr("data-changed", "true")
- $(element).html($(element).html() + input.val())
+ $(element).append(input.val())
} else {
console.log("Unknown table element")
}
@@ -442,6 +451,8 @@ function addTableRow(add_glyphicon) {
$(this).val('')
});
+ badgeSidebarForDifferences($(table))
+
row.parent().append(input_clone)
}