Merge pull request #3933 from edx/andya/edit-container-fixes

Fix the title of edit modals from the unit page.
This commit is contained in:
Andy Armstrong
2014-05-30 09:38:36 -04:00
4 changed files with 16 additions and 3 deletions

View File

@@ -87,14 +87,13 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers
});
it('can edit itself', function() {
var editButtons, modalElement,
var editButtons,
updatedTitle = 'Updated Test Container';
renderContainerPage(mockContainerXBlockHtml, this);
// Click the root edit button
editButtons = containerPage.$('.nav-actions .edit-button');
editButtons.first().click();
modalElement = edit_helpers.getModalElement();
// Expect a request to be made to show the studio view for the container
expect(lastRequest().url).toBe(
@@ -107,7 +106,7 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers
expect(edit_helpers.isShowingModal()).toBeTruthy();
// Expect the correct title to be shown
expect(modalElement.find('.modal-window-title').text()).toBe('Editing: Test Container');
expect(edit_helpers.getModalTitle()).toBe('Editing: Test Container');
// Press the save button and respond with a success message to the save
edit_helpers.pressModalButton('.action-save');

View File

@@ -211,7 +211,11 @@ define(["jquery", "underscore", "jasmine", "coffee/src/views/unit", "js/models/m
html: mockXBlockEditorHtml,
resources: []
});
// Expect that a modal is shown with the correct title
expect(edit_helpers.isShowingModal()).toBeTruthy();
expect(edit_helpers.getModalTitle()).toBe('Editing: Test Child Container');
});
});

View File

@@ -27,6 +27,11 @@ define(["jquery", "js/spec_helpers/view_helpers"],
return modalElement;
};
getModalTitle = function(modal) {
var modalElement = getModalElement(modal);
return modalElement.find('.modal-window-title').text();
};
isShowingModal = function(modal) {
var modalElement = getModalElement(modal);
return modalElement.length > 0;
@@ -58,6 +63,7 @@ define(["jquery", "js/spec_helpers/view_helpers"],
return $.extend(view_helpers, {
'getModalElement': getModalElement,
'getModalTitle': getModalTitle,
'installModalTemplates': installModalTemplates,
'isShowingModal': isShowingModal,
'hideModalIfShowing': hideModalIfShowing,

View File

@@ -181,6 +181,10 @@ define(["jquery", "underscore", "gettext", "js/views/modals/base_modal",
if (xblockWrapperElement.length > 0) {
xblockElement = xblockWrapperElement.find('.xblock');
displayName = xblockWrapperElement.find('.xblock-header .header-details').text().trim();
// If not found, try looking for the old unit page style rendering
if (!displayName) {
displayName = this.xblockElement.find('.component-header').text().trim();
}
xblockInfo = new XBlockInfo({
id: xblockWrapperElement.data('locator'),
courseKey: xblockWrapperElement.data('course-key'),