diff --git a/cms/djangoapps/contentstore/views/item.py b/cms/djangoapps/contentstore/views/item.py index 4e43966fa02e..486019071bd4 100644 --- a/cms/djangoapps/contentstore/views/item.py +++ b/cms/djangoapps/contentstore/views/item.py @@ -1191,6 +1191,7 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F 'group_access': xblock.group_access, 'user_partitions': user_partitions, 'show_correctness': xblock.show_correctness, + 'icon': xblock.icon, }) if xblock.category == 'sequential': diff --git a/cms/static/js/models/xblock_info.js b/cms/static/js/models/xblock_info.js index 78eaaddea234..108dfcb283a1 100644 --- a/cms/static/js/models/xblock_info.js +++ b/cms/static/js/models/xblock_info.js @@ -53,6 +53,10 @@ function(Backbone, _, str, ModuleUtils) { * True if the xblock is a parentable xblock. */ has_children: null, + /** + * Meta icon of the unit. + */ + icons: null, /** * True if the xblock has changes. * Note: this is not always provided as a performance optimization. It is only provided for diff --git a/cms/static/js/spec/views/pages/course_outline_spec.js b/cms/static/js/spec/views/pages/course_outline_spec.js index dc5fec49dbb0..b79ebf31c15d 100644 --- a/cms/static/js/spec/views/pages/course_outline_spec.js +++ b/cms/static/js/spec/views/pages/course_outline_spec.js @@ -270,7 +270,7 @@ describe('CourseOutlinePage', function() { 'staff-lock-editor', 'unit-access-editor', 'content-visibility-editor', 'settings-modal-tabs', 'timed-examination-preference-editor', 'access-editor', 'show-correctness-editor', 'highlights-editor', 'highlights-enable-editor', - 'course-highlights-enable' + 'course-highlights-enable', 'icon-editor' ]); appendSetFixtures(mockOutlinePage); mockCourseJSON = createMockCourseJSON({}, [ diff --git a/cms/static/js/views/modals/course_outline_modals.js b/cms/static/js/views/modals/course_outline_modals.js index 6bff80e9772b..d4a0ba791326 100644 --- a/cms/static/js/views/modals/course_outline_modals.js +++ b/cms/static/js/views/modals/course_outline_modals.js @@ -17,7 +17,8 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview', AbstractEditor, BaseDateEditor, ReleaseDateEditor, DueDateEditor, GradingEditor, PublishEditor, AbstractVisibilityEditor, StaffLockEditor, UnitAccessEditor, ContentVisibilityEditor, TimedExaminationPreferenceEditor, - AccessEditor, ShowCorrectnessEditor, HighlightsEditor, HighlightsEnableXBlockModal, HighlightsEnableEditor; + AccessEditor, ShowCorrectnessEditor, HighlightsEditor, HighlightsEnableXBlockModal, HighlightsEnableEditor, + IconEditor; CourseOutlineXBlockModal = BaseModal.extend({ events: _.extend({}, BaseModal.prototype.events, { @@ -1026,6 +1027,28 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview', } }); + IconEditor = BaseDateEditor.extend({ + fieldName: 'icon', + templateName: 'icon-editor', + + hasChanges: function() { + return this.model.get("icon") !== parseInt(this.$('#icon').val()); + }, + + getValue: function () { + return (parseInt(this.$('#icon').val())); + }, + + getRequestData: function () { + return this.hasChanges() ? { + publish: 'republish', + metadata: { + 'icon': this.getValue() + } + } : {}; + } + }); + return { getModal: function(type, xblockInfo, options) { if (type === 'edit') { @@ -1050,7 +1073,7 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview', editors: [] }; if (xblockInfo.isVertical()) { - editors = [StaffLockEditor, UnitAccessEditor]; + editors = [StaffLockEditor, UnitAccessEditor, IconEditor]; } else { tabs = [ { diff --git a/cms/templates/course_outline.html b/cms/templates/course_outline.html index 5507ed75fab5..38d138a99be7 100644 --- a/cms/templates/course_outline.html +++ b/cms/templates/course_outline.html @@ -26,7 +26,7 @@ <%block name="header_extras"> -% for template_name in ['course-outline', 'xblock-string-field-editor', 'basic-modal', 'modal-button', 'course-outline-modal', 'due-date-editor', 'release-date-editor', 'grading-editor', 'publish-editor', 'staff-lock-editor', 'unit-access-editor', 'content-visibility-editor', 'verification-access-editor', 'timed-examination-preference-editor', 'access-editor', 'settings-modal-tabs', 'show-correctness-editor', 'highlights-editor', 'highlights-enable-editor', 'course-highlights-enable']: +% for template_name in ['course-outline', 'xblock-string-field-editor', 'basic-modal', 'modal-button', 'course-outline-modal', 'due-date-editor', 'release-date-editor', 'grading-editor', 'publish-editor', 'staff-lock-editor', 'unit-access-editor', 'content-visibility-editor', 'verification-access-editor', 'timed-examination-preference-editor', 'access-editor', 'settings-modal-tabs', 'show-correctness-editor', 'highlights-editor', 'highlights-enable-editor', 'course-highlights-enable', 'icon-editor']: @@ -164,7 +164,7 @@