From 2976c8adcef6bc4c465640be0d89ead1e25369c9 Mon Sep 17 00:00:00 2001 From: Jordan Yoshihara Date: Fri, 11 Jan 2019 18:41:51 -0800 Subject: [PATCH] Don't allow user to set prerequisite from garbage tree on new content --- CHANGELOG.md | 5 +++++ .../static/js/edit_channel/related/views.js | 9 +++++++-- .../static/js/edit_channel/uploader/views.js | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82707eb8bb..8ce9be877c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ ## 2019-01-11 Update #### Changes * [[@jayoshih](https://github.com/jayoshih)] Fixed login screen layout +* [[@jayoshih](https://github.com/jayoshih)] Disabled prerequisite selection from garbage tree + +#### Issues +* [#1018](https://github.com/learningequality/studio/issues/1018) + ## 2019-01-10 Update diff --git a/contentcuration/contentcuration/static/js/edit_channel/related/views.js b/contentcuration/contentcuration/static/js/edit_channel/related/views.js index 8d65ebebf1..89c4b78b57 100644 --- a/contentcuration/contentcuration/static/js/edit_channel/related/views.js +++ b/contentcuration/contentcuration/static/js/edit_channel/related/views.js @@ -147,6 +147,7 @@ var PrerequisiteModalView = BaseViews.BaseModalView.extend({ this.onselect = options.onselect; this.parent_view = options.parent_view; this.collection = options.collection; + this.rootID = options.rootID; this.views_to_update = options.views_to_update; this.modal = true; this.render(this.close, {}); @@ -155,6 +156,7 @@ var PrerequisiteModalView = BaseViews.BaseModalView.extend({ onselect: this.close_prerequisites, modal : this, model:this.model, + rootID: this.rootID, views_to_update: this.views_to_update, collection: this.collection, allow_edit: options.allow_edit @@ -179,6 +181,7 @@ var PrerequisiteView = BaseViews.BaseListView.extend({ this.collection = State.nodeCollection; this.onselect = options.onselect; this.allow_edit = options.allow_edit; + this.rootID = options.rootID; this.views_to_update = options.views_to_update; this.render(); }, @@ -221,7 +224,8 @@ var PrerequisiteView = BaseViews.BaseListView.extend({ this.$("#selected_view_wrapper").css('display', 'none'); this.relatedView = new RelatedView({ model: this.model, - container: this + container: this, + rootID: this.rootID }); this.$("#related_view_wrapper").html(this.relatedView.el); }, @@ -244,6 +248,7 @@ var BasePrerequisiteView = BaseViews.BaseView.extend({ this.allow_edit = options.allow_edit; this.collection = new Models.ContentNodeCollection(); this.container = options.container; + this.rootID = options.rootID || this.model.get("parent"); this.render(); }, events:{ @@ -285,7 +290,7 @@ var RelatedView = BasePrerequisiteView.extend({ this.$el.html(this.template(null, { data: this.get_intl_data() })); - this.collection.get_all_fetch_simplified([this.model.get('parent')]).then(function(collection){ + this.collection.get_all_fetch_simplified([this.rootID]).then(function(collection){ self.navigate_to_node(collection.at(0) || State.current_channel.get_root("main_tree")); }); }, diff --git a/contentcuration/contentcuration/static/js/edit_channel/uploader/views.js b/contentcuration/contentcuration/static/js/edit_channel/uploader/views.js index a83b5f93a4..b927524da9 100644 --- a/contentcuration/contentcuration/static/js/edit_channel/uploader/views.js +++ b/contentcuration/contentcuration/static/js/edit_channel/uploader/views.js @@ -232,6 +232,7 @@ var EditMetadataView = BaseViews.BaseEditableListView.extend({ this.prerequisite_view = new Related.PrerequisiteView({ modal: false, model: selected_items[0].model, + rootID: this.model.id, onselect: this.set_prerequisites, views_to_update: selected_items, el: this.$("#metadata_prerequisites"),