Commit e9bb5eb1 by cahrens

Minor updates.

parent 98920e7e
...@@ -87,8 +87,9 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({ ...@@ -87,8 +87,9 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
} }
} }
else { else {
// This is the case of the page first rendering. // This is the case of the page first rendering, or when Cancel is pressed.
this.hideSaveCancelButtons(); this.hideSaveCancelButtons();
this.toggleNewButton(true);
} }
}, },
...@@ -171,7 +172,6 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({ ...@@ -171,7 +172,6 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
// That is, it doesn't change as the val changes until val is accepted. // That is, it doesn't change as the val changes until val is accepted.
var oldKey = $(event.currentTarget).closest('.key').attr('id'); var oldKey = $(event.currentTarget).closest('.key').attr('id');
var newKey = $(event.currentTarget).val(); var newKey = $(event.currentTarget).val();
console.log('update ', oldKey, newKey); // TODO: REMOVE ME
if (oldKey !== newKey) { if (oldKey !== newKey) {
// TODO: is it OK to erase other validation messages? // TODO: is it OK to erase other validation messages?
this.clearValidationErrors(); this.clearValidationErrors();
...@@ -179,10 +179,9 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({ ...@@ -179,10 +179,9 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
if (!this.validateKey(oldKey, newKey)) return; if (!this.validateKey(oldKey, newKey)) return;
if (this.model.has(newKey)) { if (this.model.has(newKey)) {
console.log('dupe key');
var error = {}; var error = {};
error[oldKey] = newKey + " has another entry"; error[oldKey] = 'You have already defined "' + newKey + '" in the manual policy definitions.';
error[newKey] = "Other entry for " + newKey; error[newKey] = "You tried to enter a duplicate of this key.";
this.model.trigger("error", this.model, error); this.model.trigger("error", this.model, error);
return false; return false;
} }
...@@ -195,7 +194,6 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({ ...@@ -195,7 +194,6 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
var validation = this.model.validate(newEntryModel); var validation = this.model.validate(newEntryModel);
if (validation) { if (validation) {
console.log('reserved key');
if (_.has(validation, newKey)) { if (_.has(validation, newKey)) {
// swap to the key which the map knows about // swap to the key which the map knows about
validation[oldKey] = validation[newKey]; validation[oldKey] = validation[newKey];
...@@ -242,7 +240,6 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({ ...@@ -242,7 +240,6 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
// model validation can't handle malformed keys nor notice if 2 fields have same key; so, need to add that chk here // model validation can't handle malformed keys nor notice if 2 fields have same key; so, need to add that chk here
// TODO ensure there's no spaces or illegal chars // TODO ensure there's no spaces or illegal chars
if (_.isEmpty(newKey)) { if (_.isEmpty(newKey)) {
console.log('no key');
var error = {}; var error = {};
error[oldKey] = "Key cannot be an empty string"; error[oldKey] = "Key cannot be an empty string";
this.model.trigger("error", this.model, error); this.model.trigger("error", this.model, error);
......
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