forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from nelc/and/backport_tag_course
And/backport tag course
- Loading branch information
Showing
21 changed files
with
337 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import * as TagCountView from 'js/views/tag_count'; | ||
import * as TagCountModel from 'js/models/tag_count'; | ||
|
||
// eslint-disable-next-line no-unused-expressions | ||
'use strict'; | ||
export default function TagCountFactory(TagCountJson, el) { | ||
var model = new TagCountModel(TagCountJson, {parse: true}); | ||
var tagCountView = new TagCountView({el, model}); | ||
tagCountView.setupMessageListener(); | ||
tagCountView.render(); | ||
} | ||
|
||
export {TagCountFactory}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
define(['backbone', 'underscore'], function(Backbone, _) { | ||
/** | ||
* Model for Tag count view | ||
*/ | ||
var TagCountModel = Backbone.Model.extend({ | ||
defaults: { | ||
content_id: null, | ||
tags_count: 0, | ||
course_authoring_url: null, | ||
}, | ||
}); | ||
return TagCountModel; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
define([ | ||
'jquery', 'underscore', 'backbone', 'js/utils/templates', | ||
'edx-ui-toolkit/js/utils/html-utils', 'js/views/utils/tagging_drawer_utils', | ||
'js/views/tag_count', 'js/models/tag_count'], | ||
function( | ||
$, _, Backbone, TemplateUtils, HtmlUtils, TaggingDrawerUtils, TagCountView, TagCountModel | ||
) { | ||
'use strict'; | ||
|
||
var CourseManageTagsView = Backbone.View.extend({ | ||
events: { | ||
'click .manage-tags-button': 'openManageTagsDrawer', | ||
}, | ||
|
||
initialize: function() { | ||
this.template = TemplateUtils.loadTemplate('course-manage-tags'); | ||
this.courseId = course.id; | ||
}, | ||
|
||
openManageTagsDrawer: function(event) { | ||
const taxonomyTagsWidgetUrl = this.model.get('taxonomy_tags_widget_url'); | ||
const contentId = this.courseId; | ||
TaggingDrawerUtils.openDrawer(taxonomyTagsWidgetUrl, contentId); | ||
}, | ||
|
||
renderTagCount: function() { | ||
const contentId = this.courseId; | ||
const tagCountsForCourse = this.model.get('course_tags_count'); | ||
const tagsCount = tagCountsForCourse !== undefined ? tagCountsForCourse[contentId] : 0; | ||
var countModel = new TagCountModel({ | ||
content_id: contentId, | ||
tags_count: tagsCount, | ||
course_authoring_url: this.model.get('course_authoring_url'), | ||
}, {parse: true}); | ||
var tagCountView = new TagCountView({el: this.$('.tag-count'), model: countModel}); | ||
tagCountView.setupMessageListener(); | ||
tagCountView.render(); | ||
this.$('.tag-count').click((event) => { | ||
event.preventDefault(); | ||
this.openManageTagsDrawer(); | ||
}); | ||
}, | ||
|
||
render: function() { | ||
var html = this.template(this.model.attributes); | ||
HtmlUtils.setHtml(this.$el, HtmlUtils.HTML(html)); | ||
this.renderTagCount(); | ||
return this; | ||
} | ||
}); | ||
|
||
return CourseManageTagsView; | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.