Commit 0a8b2649 by Andy Armstrong

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

Fix the title of edit modals from the unit page.
parents 0c9d682d 5792e7e0
...@@ -87,14 +87,13 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers ...@@ -87,14 +87,13 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers
}); });
it('can edit itself', function() { it('can edit itself', function() {
var editButtons, modalElement, var editButtons,
updatedTitle = 'Updated Test Container'; updatedTitle = 'Updated Test Container';
renderContainerPage(mockContainerXBlockHtml, this); renderContainerPage(mockContainerXBlockHtml, this);
// Click the root edit button // Click the root edit button
editButtons = containerPage.$('.nav-actions .edit-button'); editButtons = containerPage.$('.nav-actions .edit-button');
editButtons.first().click(); editButtons.first().click();
modalElement = edit_helpers.getModalElement();
// Expect a request to be made to show the studio view for the container // Expect a request to be made to show the studio view for the container
expect(lastRequest().url).toBe( expect(lastRequest().url).toBe(
...@@ -107,7 +106,7 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers ...@@ -107,7 +106,7 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers
expect(edit_helpers.isShowingModal()).toBeTruthy(); expect(edit_helpers.isShowingModal()).toBeTruthy();
// Expect the correct title to be shown // 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 // Press the save button and respond with a success message to the save
edit_helpers.pressModalButton('.action-save'); edit_helpers.pressModalButton('.action-save');
......
...@@ -211,7 +211,11 @@ define(["jquery", "underscore", "jasmine", "coffee/src/views/unit", "js/models/m ...@@ -211,7 +211,11 @@ define(["jquery", "underscore", "jasmine", "coffee/src/views/unit", "js/models/m
html: mockXBlockEditorHtml, html: mockXBlockEditorHtml,
resources: [] resources: []
}); });
// Expect that a modal is shown with the correct title
expect(edit_helpers.isShowingModal()).toBeTruthy(); expect(edit_helpers.isShowingModal()).toBeTruthy();
expect(edit_helpers.getModalTitle()).toBe('Editing: Test Child Container');
}); });
}); });
......
...@@ -27,6 +27,11 @@ define(["jquery", "js/spec_helpers/view_helpers"], ...@@ -27,6 +27,11 @@ define(["jquery", "js/spec_helpers/view_helpers"],
return modalElement; return modalElement;
}; };
getModalTitle = function(modal) {
var modalElement = getModalElement(modal);
return modalElement.find('.modal-window-title').text();
};
isShowingModal = function(modal) { isShowingModal = function(modal) {
var modalElement = getModalElement(modal); var modalElement = getModalElement(modal);
return modalElement.length > 0; return modalElement.length > 0;
...@@ -58,6 +63,7 @@ define(["jquery", "js/spec_helpers/view_helpers"], ...@@ -58,6 +63,7 @@ define(["jquery", "js/spec_helpers/view_helpers"],
return $.extend(view_helpers, { return $.extend(view_helpers, {
'getModalElement': getModalElement, 'getModalElement': getModalElement,
'getModalTitle': getModalTitle,
'installModalTemplates': installModalTemplates, 'installModalTemplates': installModalTemplates,
'isShowingModal': isShowingModal, 'isShowingModal': isShowingModal,
'hideModalIfShowing': hideModalIfShowing, 'hideModalIfShowing': hideModalIfShowing,
......
...@@ -181,6 +181,10 @@ define(["jquery", "underscore", "gettext", "js/views/modals/base_modal", ...@@ -181,6 +181,10 @@ define(["jquery", "underscore", "gettext", "js/views/modals/base_modal",
if (xblockWrapperElement.length > 0) { if (xblockWrapperElement.length > 0) {
xblockElement = xblockWrapperElement.find('.xblock'); xblockElement = xblockWrapperElement.find('.xblock');
displayName = xblockWrapperElement.find('.xblock-header .header-details').text().trim(); 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({ xblockInfo = new XBlockInfo({
id: xblockWrapperElement.data('locator'), id: xblockWrapperElement.data('locator'),
courseKey: xblockWrapperElement.data('course-key'), courseKey: xblockWrapperElement.data('course-key'),
......
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