Commit 909f35bb by Gregory Martin

add blankTitle option

parent 8c009881
...@@ -421,7 +421,7 @@ class AccountSettingsPageTest(AccountSettingsTestMixin, AcceptanceTest): ...@@ -421,7 +421,7 @@ class AccountSettingsPageTest(AccountSettingsTestMixin, AcceptanceTest):
self._test_dropdown_field( self._test_dropdown_field(
u'time_zone', u'time_zone',
u'Time Zone', u'Time Zone',
u'', u'Default (Local Time Zone)',
[ [
u'Europe/Kiev ({abbr}, UTC{offset})'.format(abbr=kiev_abbr, offset=kiev_offset), u'Europe/Kiev ({abbr}, UTC{offset})'.format(abbr=kiev_abbr, offset=kiev_offset),
u'US/Pacific ({abbr}, UTC{offset})'.format(abbr=pacific_abbr, offset=pacific_offset), u'US/Pacific ({abbr}, UTC{offset})'.format(abbr=pacific_abbr, offset=pacific_offset),
......
...@@ -54,7 +54,8 @@ define(['backbone', ...@@ -54,7 +54,8 @@ define(['backbone',
valueAttribute: 'time_zone', valueAttribute: 'time_zone',
groupOptions: [{ groupOptions: [{
groupTitle: gettext('All Time Zones'), groupTitle: gettext('All Time Zones'),
selectOptions: FieldViewsSpecHelpers.SELECT_OPTIONS selectOptions: FieldViewsSpecHelpers.SELECT_OPTIONS,
blankTitle: 'Default (Local Time Zone)'
}], }],
persistChanges: true, persistChanges: true,
required: true required: true
...@@ -97,7 +98,7 @@ define(['backbone', ...@@ -97,7 +98,7 @@ define(['backbone',
// expect time zone dropdown to have two subheaders (country/all time zone sub-headers) with new values // expect time zone dropdown to have two subheaders (country/all time zone sub-headers) with new values
expect(timeZoneView.$(groupsSelector).length).toBe(2); expect(timeZoneView.$(groupsSelector).length).toBe(2);
expect(timeZoneView.$(groupOptionsSelector).length).toBe(5); expect(timeZoneView.$(groupOptionsSelector).length).toBe(6);
expect(timeZoneView.$(groupOptionsSelector)[0].value).toBe('America/Guyana'); expect(timeZoneView.$(groupOptionsSelector)[0].value).toBe('America/Guyana');
// select time zone option from option // select time zone option from option
......
...@@ -118,7 +118,8 @@ ...@@ -118,7 +118,8 @@
helpMessage: gettext('Select the time zone for displaying course dates. If you do not specify a time zone, course dates, including assignment deadlines, will be displayed in your browser\'s local time zone.'), // eslint-disable-line max-len helpMessage: gettext('Select the time zone for displaying course dates. If you do not specify a time zone, course dates, including assignment deadlines, will be displayed in your browser\'s local time zone.'), // eslint-disable-line max-len
groupOptions: [{ groupOptions: [{
groupTitle: gettext('All Time Zones'), groupTitle: gettext('All Time Zones'),
selectOptions: fieldsData.time_zone.options selectOptions: fieldsData.time_zone.options,
blankTitle: gettext('Default (Local Time Zone)')
}], }],
persistChanges: true persistChanges: true
}) })
......
...@@ -20,16 +20,20 @@ ...@@ -20,16 +20,20 @@
<span class="u-field-value-readonly"></span> <span class="u-field-value-readonly"></span>
<% } else { %> <% } else { %>
<select name="select" id="u-field-select-<%- id %>" aria-describedby="u-field-help-message-<%- id %>"> <select name="select" id="u-field-select-<%- id %>" aria-describedby="u-field-help-message-<%- id %>">
<% if (showBlankOption) { %>
<option value=""></option>
<% } %>
<% _.each(groupOptions, function(groupOption) { %> <% _.each(groupOptions, function(groupOption) { %>
<% if (groupOption.groupTitle != null) { %> <% if (showBlankOption) { %>
<optgroup label="<%- groupOption.groupTitle %>"> <% if (groupOption.blankTitle) { %>
<option value=""><%- groupOption.blankTitle %></option>
<% } else { %>
<option value=""></option>
<% } %>
<% } %> <% } %>
<% _.each(groupOption.selectOptions, function(selectOption) { %> <% if (groupOption.groupTitle != null) { %>
<option value="<%- selectOption[0] %>"><%- selectOption[1] %></option> <optgroup label="<%- groupOption.groupTitle %>">
<% }); %> <% } %>
<% _.each(groupOption.selectOptions, function(selectOption) { %>
<option value="<%- selectOption[0] %>"><%- selectOption[1] %></option>
<% }); %>
<% }); %> <% }); %>
</select> </select>
<span class="icon-caret-down" aria-hidden="true"></span> <span class="icon-caret-down" aria-hidden="true"></span>
......
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