Commit 8fd15ce4 by cahrens

Review feedback.

parent 1c209789
# disable missing docstring
#pylint: disable=C0111 #pylint: disable=C0111
#pylint: disable=W0621
from lettuce import world from lettuce import world
from nose.tools import assert_equal from nose.tools import assert_equal
......
# disable missing docstring
#pylint: disable=C0111 #pylint: disable=C0111
#pylint: disable=W0621
from lettuce import world, step from lettuce import world, step
......
# disable missing docstring
#pylint: disable=C0111 #pylint: disable=C0111
#pylint: disable=W0621
from lettuce import world, step from lettuce import world, step
......
# disable missing docstring
#pylint: disable=C0111 #pylint: disable=C0111
#pylint: disable=W0621
from lettuce import world, step from lettuce import world, step
from nose.tools import assert_equal from nose.tools import assert_equal
......
# disable missing docstring
#pylint: disable=C0111 #pylint: disable=C0111
#pylint: disable=W0621
from lettuce import world, step from lettuce import world, step
......
...@@ -60,8 +60,10 @@ CMS.Models.Metadata = Backbone.Model.extend({ ...@@ -60,8 +60,10 @@ CMS.Models.Metadata = Backbone.Model.extend({
* Sets the displayed value. * Sets the displayed value.
*/ */
setValue: function (value) { setValue: function (value) {
this.set('explicitly_set', true); this.set({
this.set('value', value); explicitly_set: true,
value: value
});
}, },
/** /**
...@@ -93,8 +95,10 @@ CMS.Models.Metadata = Backbone.Model.extend({ ...@@ -93,8 +95,10 @@ CMS.Models.Metadata = Backbone.Model.extend({
* explicitly_set property. * explicitly_set property.
*/ */
clear: function() { clear: function() {
this.set('explicitly_set', false); this.set({
this.set('value', this.get('default_value')); explicitly_set: false,
value: this.get('default_value')
});
} }
}); });
......
...@@ -89,6 +89,7 @@ CMS.Views.Metadata.AbstractEditor = Backbone.View.extend({ ...@@ -89,6 +89,7 @@ CMS.Views.Metadata.AbstractEditor = Backbone.View.extend({
} }
this.template = _.template(tpl); this.template = _.template(tpl);
this.$el.append(this.template({model: this.model, uniqueId: this.uniqueId})); this.$el.append(this.template({model: this.model, uniqueId: this.uniqueId}));
this.listenTo(this.model, 'change', this.render);
this.render(); this.render();
}, },
...@@ -108,21 +109,17 @@ CMS.Views.Metadata.AbstractEditor = Backbone.View.extend({ ...@@ -108,21 +109,17 @@ CMS.Views.Metadata.AbstractEditor = Backbone.View.extend({
setValueInEditor : function (value) {}, setValueInEditor : function (value) {},
/** /**
* Sets the value in the model, using the value currently displayed in the view. Afterward, * Sets the value in the model, using the value currently displayed in the view.
* this method re-renders to update the clear button.
*/ */
updateModel: function () { updateModel: function () {
this.model.setValue(this.getValueFromEditor()); this.model.setValue(this.getValueFromEditor());
this.render();
}, },
/** /**
* Clears the value currently set in the model (reverting to the default). Afterward, this method * Clears the value currently set in the model (reverting to the default).
* re-renders the view.
*/ */
clear: function () { clear: function () {
this.model.clear(); this.model.clear();
this.render();
}, },
/** /**
...@@ -160,6 +157,8 @@ CMS.Views.Metadata.AbstractEditor = Backbone.View.extend({ ...@@ -160,6 +157,8 @@ CMS.Views.Metadata.AbstractEditor = Backbone.View.extend({
this.getClearButton().addClass('inactive'); this.getClearButton().addClass('inactive');
this.getClearButton().removeClass('active'); this.getClearButton().removeClass('active');
} }
return this;
} }
}); });
...@@ -229,6 +228,8 @@ CMS.Views.Metadata.Number = CMS.Views.Metadata.AbstractEditor.extend({ ...@@ -229,6 +228,8 @@ CMS.Views.Metadata.Number = CMS.Views.Metadata.AbstractEditor.extend({
this.initialized = true; this.initialized = true;
} }
return this;
}, },
templateName: "metadata-number-entry", templateName: "metadata-number-entry",
......
<div class="wrapper-comp-setting"> <div class="wrapper-comp-setting">
<label class="label setting-label" for="<%= uniqueId %>"><%= model.get('display_name') %></label> <label class="label setting-label" for="<%= uniqueId %>"><%= model.get('display_name') %></label>
<input class="input setting-input setting-input-number" type="number" id="<%= uniqueId %>" value='<%= model.get("value") %>'/> <input class="input setting-input setting-input-number" type="number" id="<%= uniqueId %>" value='<%= model.get("value") %>'/>
<button class="action setting-clear inactive" type="button" name="setting-clear" value="Clear" data-tooltip="Clear"> <button class="action setting-clear inactive" type="button" name="setting-clear" value="<%= gettext("Clear") %>" data-tooltip="<%= gettext("Clear") %>">
<i class="icon-undo"></i><span class="sr">Clear Value</span> <i class="icon-undo"></i><span class="sr">"<%= gettext("Clear Value") %>"</span>
</button> </button>
</div> </div>
<span class="tip setting-help"><%= model.get('help') %></span> <span class="tip setting-help"><%= model.get('help') %></span>
...@@ -2,15 +2,15 @@ ...@@ -2,15 +2,15 @@
<label class="label setting-label" for="<%= uniqueId %>"><%= model.get('display_name') %></label> <label class="label setting-label" for="<%= uniqueId %>"><%= model.get('display_name') %></label>
<select class="input setting-input" id="<%= uniqueId %>" name="<%= model.get('display_name') %>"> <select class="input setting-input" id="<%= uniqueId %>" name="<%= model.get('display_name') %>">
<% _.each(model.get('options'), function(option) { %> <% _.each(model.get('options'), function(option) { %>
<% if (option['display_name'] !== undefined) { %> <% if (option.display_name !== undefined) { %>
<option value="<%= option['display_name'] %>"><%= option['display_name'] %></option> <option value="<%= option['display_name'] %>"><%= option['display_name'] %></option>
<% } else { %> <% } else { %>
<option value="<%= option %>"><%= option %></option> <option value="<%= option %>"><%= option %></option>
<% } %> <% } %>
<% }) %> <% }) %>
</select> </select>
<button class="action setting-clear inactive" type="button" name="setting-clear" value="Clear" data-tooltip="Clear"> <button class="action setting-clear inactive" type="button" name="setting-clear" value="<%= gettext("Clear") %>" data-tooltip="<%= gettext("Clear") %>">
<i class="icon-undo"></i><span class="sr">Clear Value</span> <i class="icon-undo"></i><span class="sr">"<%= gettext("Clear Value") %>"</span>
</button> </button>
</div> </div>
<span class="tip setting-help"><%= model.get('help') %></span> <span class="tip setting-help"><%= model.get('help') %></span>
<div class="wrapper-comp-setting"> <div class="wrapper-comp-setting">
<label class="label setting-label" for="<%= uniqueId %>"><%= model.get('display_name') %></label> <label class="label setting-label" for="<%= uniqueId %>"><%= model.get('display_name') %></label>
<input class="input setting-input" type="text" id="<%= uniqueId %>" value='<%= model.get("value") %>'/> <input class="input setting-input" type="text" id="<%= uniqueId %>" value='<%= model.get("value") %>'/>
<button class="action setting-clear inactive" type="button" name="setting-clear" value="Clear" data-tooltip="Clear"> <button class="action setting-clear inactive" type="button" name="setting-clear" value="<%= gettext("Clear") %>" data-tooltip="<%= gettext("Clear") %>">
<i class="icon-undo"></i><span class="sr">Clear Value</span> <i class="icon-undo"></i><span class="sr">"<%= gettext("Clear Value") %>"</span>
</button> </button>
</div> </div>
<span class="tip setting-help"><%= model.get('help') %></span> <span class="tip setting-help"><%= model.get('help') %></span>
# disable missing docstring
#pylint: disable=C0111 #pylint: disable=C0111
#pylint: disable=W0621
from xmodule.x_module import XModuleFields from xmodule.x_module import XModuleFields
from xblock.core import Scope, String, Object, Boolean from xblock.core import Scope, String, Object, Boolean
......
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