Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [FC-0070] Manage Tags interoperation #35751

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cms/static/js/views/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ function($, _, XBlockView, ModuleUtils, gettext, StringUtils, NotificationView)
newParent = undefined;
},
update: function(event, ui) {
try {
window.parent.postMessage(
{
type: 'refreshPositions',
payload: {}
}, document.referrer
);
} catch (e) {
console.error(e);
}
// When dragging from one ol to another, this method
// will be called twice (once for each list). ui.sender will
// be null if the change is related to the list the element
Expand Down
62 changes: 48 additions & 14 deletions cms/static/js/views/pages/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ function($, _, Backbone, gettext, BasePage,

}

window.addEventListener('message', (event) => {
if (event.data && event.data.type === 'refreshXBlock') {
this.render();
}
});

this.listenTo(Backbone, 'move:onXBlockMoved', this.onXBlockMoved);
},

Expand Down Expand Up @@ -224,6 +230,7 @@ function($, _, Backbone, gettext, BasePage,
},

initializePasteButton() {
var self = this;
if (this.options.canEdit && !self.options.isIframeEmbed) {
// We should have the user's clipboard status.
const data = this.options.clipboardData;
Expand All @@ -241,7 +248,7 @@ function($, _, Backbone, gettext, BasePage,
refreshPasteButton(data) {
// Do not perform any changes on paste button since they are not
// rendered on Library or LibraryContent pages
if (!this.isLibraryPage && !this.isLibraryContentPage && !self.options.isIframeEmbed) {
if (!this.isLibraryPage && !this.isLibraryContentPage && !(self.options && self.options.isIframeEmbed)) {
// 'data' is the same data returned by the "get clipboard status" API endpoint
// i.e. /api/content-staging/v1/clipboard/
if (this.options.canEdit && data.content) {
Expand Down Expand Up @@ -380,11 +387,14 @@ function($, _, Backbone, gettext, BasePage,
editXBlock: function(event, options) {
event.preventDefault();
try {
if (this.options.isIframeEmbed) {
window.parent.postMessage(
if (this.options.isIframeEmbed && event.currentTarget.className === 'access-button') {
return window.parent.postMessage(
{
type: 'editXBlock',
payload: {}
type: 'manageXBlockAccess',
payload: {
id: this.findXBlockElement(event.target).data('locator'),
targetElementClassName: event.currentTarget.className,
}
}, document.referrer
);
}
Expand All @@ -404,7 +414,23 @@ function($, _, Backbone, gettext, BasePage,
|| (useNewVideoEditor === 'True' && blockType === 'video')
|| (useNewProblemEditor === 'True' && blockType === 'problem')
) {
var destinationUrl = primaryHeader.attr('authoring_MFE_base_url') + '/' + blockType + '/' + encodeURI(primaryHeader.attr('data-usage-id'));
var pathToNewXBlockEditor = `/${blockType}/${encodeURI(primaryHeader.attr('data-usage-id'))}`;
var destinationUrl = `${primaryHeader.attr('authoring_MFE_base_url')}${pathToNewXBlockEditor}`;

try {
if (this.options.isIframeEmbed) {
return window.parent.postMessage(
{
type: 'newXBlockEditor',
payload: {
url: pathToNewXBlockEditor,
}
}, document.referrer
);
}
} catch (e) {
console.error(e);
}
window.location.href = destinationUrl;
return;
}
Expand Down Expand Up @@ -471,20 +497,22 @@ function($, _, Backbone, gettext, BasePage,
},

openManageTags: function(event) {
const contentId = this.findXBlockElement(event.target).data('locator');
try {
if (this.options.isIframeEmbed) {
window.parent.postMessage(
{
type: 'openManageTags',
payload: {}
payload: {
id: contentId,
}
}, document.referrer
);
}
} catch (e) {
console.error(e);
}
const taxonomyTagsWidgetUrl = this.model.get('taxonomy_tags_widget_url');
const contentId = this.findXBlockElement(event.target).data('locator');

TaggingDrawerUtils.openDrawer(taxonomyTagsWidgetUrl, contentId);
},
Expand All @@ -497,10 +525,12 @@ function($, _, Backbone, gettext, BasePage,
event.preventDefault();
try {
if (this.options.isIframeEmbed) {
window.parent.postMessage(
return window.parent.postMessage(
{
type: 'copyXBlock',
payload: {}
payload: {
id: this.findXBlockElement(event.target).data('locator')
}
}, document.referrer
);
}
Expand Down Expand Up @@ -554,10 +584,12 @@ function($, _, Backbone, gettext, BasePage,
event.preventDefault();
try {
if (this.options.isIframeEmbed) {
window.parent.postMessage(
return window.parent.postMessage(
{
type: 'duplicateXBlock',
payload: {}
payload: {
id: this.findXBlockElement(event.target).data('locator')
}
}, document.referrer
);
}
Expand Down Expand Up @@ -597,10 +629,12 @@ function($, _, Backbone, gettext, BasePage,
event.preventDefault();
try {
if (this.options.isIframeEmbed) {
window.parent.postMessage(
return window.parent.postMessage(
{
type: 'deleteXBlock',
payload: {}
payload: {
id: this.findXBlockElement(event.target).data('locator')
}
}, document.referrer
);
}
Expand Down
2 changes: 1 addition & 1 deletion cms/static/js/views/pages/container_subviews.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ function($, _, gettext, BaseView, ViewUtils, XBlockViewUtils, MoveXBlockUtils, H
tagValueElement.className = 'tagging-label-value';

tagContentElement.appendChild(tagValueElement);
parentElement.appendChild(tagContentElement);
parentElement?.appendChild(tagContentElement);

if (tag.children.length > 0) {
var tagIconElement = document.createElement('span'),
Expand Down
12 changes: 12 additions & 0 deletions cms/static/sass/course-unit-mfe-iframe-bundle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
&:hover {
background-color: $primary;
border-color: $transparent;
color: $white;
}

&:focus {
Expand Down Expand Up @@ -649,3 +650,14 @@ select {
.wrapper-comp-setting.metadata-list-enum .action.setting-clear.active {
margin-top: 0;
}

.wrapper-xblock .xblock-header-primary .header-actions {
.wrapper-nav-sub {
z-index: 15;
}

.actions-list .action-item.tag-count button.btn-default.action-button.manage-tags-button {
width: auto;
border-radius: 0;
}
}