diff --git a/app/assets/javascripts/my_modules.js b/app/assets/javascripts/my_modules.js index de71ca6df..13cd2b826 100644 --- a/app/assets/javascripts/my_modules.js +++ b/app/assets/javascripts/my_modules.js @@ -108,6 +108,11 @@ function bindEditTagsAjax() { // tag. function initAddTagForm() { manageTagsModalBody.find('.add-tag-form') + .submit(function() { + var selectOptions = manageTagsModalBody.find('.add-tag-form .dropdown-menu li').length; + if (selectOptions === 0) return false; + return true; + }) .on('ajax:success', function(e, data) { initTagsModalBody(data); }); diff --git a/app/assets/javascripts/projects/canvas.js.erb b/app/assets/javascripts/projects/canvas.js.erb index eda3acb67..49d21437c 100644 --- a/app/assets/javascripts/projects/canvas.js.erb +++ b/app/assets/javascripts/projects/canvas.js.erb @@ -796,6 +796,11 @@ function bindEditTagsAjax(elements) { // tag. function initAddTagForm() { manageTagsModalBody.find(".add-tag-form") + .submit(function() { + var selectOptions = manageTagsModalBody.find('.add-tag-form .dropdown-menu li').length; + if (selectOptions === 0) return false; + return true; + }) .on("ajax:success", function (e, data) { initTagsModalBody(data); }); diff --git a/app/controllers/my_module_tags_controller.rb b/app/controllers/my_module_tags_controller.rb index 7dc692a82..2523bc1a9 100644 --- a/app/controllers/my_module_tags_controller.rb +++ b/app/controllers/my_module_tags_controller.rb @@ -55,7 +55,7 @@ class MyModuleTagsController < ApplicationController end def create - return render_403 unless mt_params[:tag_id] + return render_403 unless params[:my_module_tag] && mt_params[:tag_id] @mt = MyModuleTag.new(mt_params.merge(my_module: @my_module)) @mt.created_by = current_user @@ -125,6 +125,9 @@ class MyModuleTagsController < ApplicationController def destroy_by_tag_id tag = @my_module.my_module_tags.find_by_tag_id(params[:id]) + + return render_404 unless tag + tag.destroy render json: { result: tag } end