feat: studio redirect to new editors (#30523)

This commit is contained in:
connorhaugh
2022-06-07 16:30:40 -04:00
committed by GitHub
parent 290236390b
commit c9dce91b9a
3 changed files with 29 additions and 13 deletions

View File

@@ -187,15 +187,15 @@ define(['jquery', 'underscore', 'backbone', 'gettext', 'js/views/pages/base_page
event.preventDefault();
if(!options || options.view !== 'visibility_view' ){
var useNewTextEditor = this.$('.edit-button').attr("use-new-editor-text"),
useNewVideoEditor = this.$('.edit-button').attr("use-new-editor-video"),
useNewProblemEditor = this.$('.edit-button').attr("use-new-editor-problem"),
blockType = xblockElement.find('.xblock').attr("data-block-type");
var useNewTextEditor = this.$('.xblock-header-primary').attr("use-new-editor-text"),
useNewVideoEditor = this.$('.xblock-header-primary').attr("use-new-editor-video"),
useNewProblemEditor = this.$('.xblock-header-primary').attr("use-new-editor-problem"),
blockType = xblockElement.find('.xblock').attr("data-block-type");
if( (useNewTextEditor === "True" && blockType === "html") ||
(useNewVideoEditor === "True" && blockType === "video") ||
(useNewProblemEditor === "True" && blockType === "problem")
) {
var destinationUrl = this.$('.edit-button').attr("authoring_MFE_base_url") + '/' + blockType + '/' + encodeURI(xblockElement.find('.xblock').attr("data-usage-id"));
var destinationUrl = this.$('.xblock-header-primary').attr("authoring_MFE_base_url") + '/' + blockType + '/' + encodeURI(xblockElement.find('.xblock').attr("data-usage-id"));
window.location.href = destinationUrl;
return;
}
@@ -322,6 +322,23 @@ define(['jquery', 'underscore', 'backbone', 'gettext', 'js/views/pages/base_page
},
onNewXBlock: function(xblockElement, scrollOffset, is_duplicate, data) {
var useNewTextEditor = this.$('.xblock-header-primary').attr("use-new-editor-text"),
useNewVideoEditor = this.$('.xblock-header-primary').attr("use-new-editor-video"),
useNewProblemEditor = this.$('.xblock-header-primary').attr("use-new-editor-problem");
//find the block type in the locator if availible
if(data.hasOwnProperty('locator')){
var matchBlockTypeFromLocator = /\@(.*?)\+/;
var blockType = data.locator.match(matchBlockTypeFromLocator);
}
if((useNewTextEditor === "True" && blockType.includes("html")) ||
(useNewVideoEditor === "True" && blockType.includes("video"))||
(useNewProblemEditor === "True" && blockType.includes("problem"))
){
var destinationUrl = this.$('.xblock-header-primary').attr("authoring_MFE_base_url") + '/' + blockType[1] + '/' + encodeURI(data.locator);
window.location.href = destinationUrl;
return;
}
ViewUtils.setScrollOffset(xblockElement, scrollOffset);
xblockElement.data('locator', data.locator);
return this.refreshXBlock(xblockElement, true, is_duplicate);

View File

@@ -59,7 +59,12 @@ block_is_unit = is_unit(xblock)
% if not show_preview:
is-collapsed
% endif
">
"
use-new-editor-text = ${use_new_editor_text}
use-new-editor-video = ${use_new_editor_video}
use-new-editor-problem = ${use_new_editor_problem}
authoring_MFE_base_url = ${get_editor_page_base_url(xblock.location.course_key)}
>
<div class="header-details">
% if show_inline:
<a href="#" data-tooltip="${_('Expand or Collapse')}" class="action expand-collapse collapse">
@@ -80,12 +85,7 @@ block_is_unit = is_unit(xblock)
% if can_edit:
% if not show_inline:
<li class="action-item action-edit">
<button class="btn-default edit-button action-button"
use-new-editor-text = ${use_new_editor_text}
use-new-editor-video = ${use_new_editor_video}
use-new-editor-problem = ${use_new_editor_problem}
authoring_MFE_base_url = ${get_editor_page_base_url(xblock.location.course_key)}
>
<button class="btn-default edit-button action-button">
<span class="icon fa fa-pencil" aria-hidden="true"></span>
<span class="action-button-text">${_("Edit")}</span>
</button>