Merge pull request #1816 from aignatov-bio/ai-sci-3525-fix-nil-error-in-module-tag-controller

Fix nil issue in tags_my_module controller [SCI-3525]
This commit is contained in:
Alex Kriuchykhin 2019-06-12 13:11:40 +02:00 committed by GitHub
commit 4f851b0995
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View file

@ -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);
});

View file

@ -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);
});

View file

@ -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