Commit 437c806f by cahrens

Enable/disable new entry button.

parent 67a557d5
...@@ -105,6 +105,16 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({ ...@@ -105,6 +105,16 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
this.buttonsEnabled = false; this.buttonsEnabled = false;
}, },
toggleNewButton: function (enable) {
var newButton = this.$el.find(".new-button");
if (enable) {
newButton.removeClass('disabled');
}
else {
newButton.addClass('disabled');
}
},
deleteEntry : function(event) { deleteEntry : function(event) {
event.preventDefault(); event.preventDefault();
// find out which entry // find out which entry
...@@ -154,6 +164,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({ ...@@ -154,6 +164,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
var policyValueDivs = this.$el.find('#' + this.new_key).closest('li').find('.json'); var policyValueDivs = this.$el.find('#' + this.new_key).closest('li').find('.json');
// only 1 but hey, let's take advantage of the context mechanism // only 1 but hey, let's take advantage of the context mechanism
_.each(policyValueDivs, this.attachJSONEditor, this); _.each(policyValueDivs, this.attachJSONEditor, this);
this.toggleNewButton(false);
this.showMessage(this.unsaved_changes); this.showMessage(this.unsaved_changes);
}, },
updateKey : function(event) { updateKey : function(event) {
...@@ -205,6 +216,10 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({ ...@@ -205,6 +216,10 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
this.model.deleteKeys.push(oldKey); this.model.deleteKeys.push(oldKey);
this.model.unset(oldKey) ; this.model.unset(oldKey) ;
} }
else {
// id for the new entry will now be the key value. Enable new entry button.
this.toggleNewButton(true);
}
// check for newkey being the name of one which was previously deleted in this session // check for newkey being the name of one which was previously deleted in this session
var wasDeleting = this.model.deleteKeys.indexOf(newKey); var wasDeleting = this.model.deleteKeys.indexOf(newKey);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment