Commit 8fd15ce4 by cahrens

Review feedback.

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