fix: Update tag counts when changes are saved in the tag drawer
* fix: courseAuthoringUrl on message listener
This commit is contained in:
@@ -376,15 +376,14 @@ function($, _, gettext, BaseView, ViewUtils, XBlockViewUtils, MoveXBlockUtils, H
|
||||
"message", (event) => {
|
||||
// Listen any message from Manage tags drawer.
|
||||
var data = event.data;
|
||||
var courseAuthoringUrl = this.model.get("course_authoring_url")
|
||||
var courseAuthoringUrl = new URL(this.model.get("course_authoring_url")).origin;
|
||||
if (event.origin == courseAuthoringUrl
|
||||
&& data.includes('[Manage tags drawer] Tags updated:')) {
|
||||
&& data.type == 'authoring.events.tags.updated') {
|
||||
// This message arrives when there is a change in the tag list.
|
||||
// The message contains the new list of tags.
|
||||
let jsonData = data.replace(/\[Manage tags drawer\] Tags updated: /g, "");
|
||||
jsonData = JSON.parse(jsonData);
|
||||
if (jsonData.contentId == this.model.id) {
|
||||
this.model.set('tags', this.buildTaxonomyTree(jsonData));
|
||||
data = data.data
|
||||
if (data.contentId == this.model.id) {
|
||||
this.model.set('tags', this.buildTaxonomyTree(data));
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,15 +21,14 @@ function($, _, BaseView, HtmlUtils) {
|
||||
'message', (event) => {
|
||||
// Listen any message from Manage tags drawer.
|
||||
var data = event.data;
|
||||
var courseAuthoringUrl = this.model.get("course_authoring_url")
|
||||
var courseAuthoringUrl = new URL(this.model.get("course_authoring_url")).origin;
|
||||
if (event.origin == courseAuthoringUrl
|
||||
&& data.includes('[Manage tags drawer] Count updated:')) {
|
||||
&& data.type == 'authoring.events.tags.count.updated') {
|
||||
// This message arrives when there is a change in the tag list.
|
||||
// The message contains the new count of tags.
|
||||
let jsonData = data.replace(/\[Manage tags drawer\] Count updated: /g, "");
|
||||
jsonData = JSON.parse(jsonData);
|
||||
if (jsonData.contentId == this.model.get("content_id")) {
|
||||
this.model.set('tags_count', jsonData.count);
|
||||
data = data.data
|
||||
if (data.contentId == this.model.get("content_id")) {
|
||||
this.model.set('tags_count', data.count);
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user