mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-06 12:43:06 +08:00
Merge pull request #3039 from okriuchykhin/ok_SCI_5339
Disable comment adding for archived objects [SCI-5339]
This commit is contained in:
commit
15a8524a99
3 changed files with 19 additions and 0 deletions
|
@ -13,6 +13,11 @@ var CommentsSidebar = (function() {
|
||||||
$(SIDEBAR).removeClass('loading');
|
$(SIDEBAR).removeClass('loading');
|
||||||
$(SIDEBAR).find('.comments-subject-title').text(result.object_name);
|
$(SIDEBAR).find('.comments-subject-title').text(result.object_name);
|
||||||
$(SIDEBAR).find('.comments-list').html(result.comments);
|
$(SIDEBAR).find('.comments-list').html(result.comments);
|
||||||
|
if (result.comment_addable) {
|
||||||
|
$(SIDEBAR).find('.comment-input-container').removeClass('hidden');
|
||||||
|
} else {
|
||||||
|
$(SIDEBAR).find('.comment-input-container').addClass('hidden');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ class CommentsController < ApplicationController
|
||||||
|
|
||||||
render json: {
|
render json: {
|
||||||
object_name: @commentable.name,
|
object_name: @commentable.name,
|
||||||
|
comment_addable: comment_addable?(@commentable),
|
||||||
comments: render_to_string(partial: 'shared/comments/comments_list.html.erb',
|
comments: render_to_string(partial: 'shared/comments/comments_list.html.erb',
|
||||||
locals: { comments: comments })
|
locals: { comments: comments })
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,19 @@ module CommentHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def comment_addable?(object)
|
||||||
|
case object.class.name
|
||||||
|
when 'MyModule'
|
||||||
|
can_create_comments_in_module?(object)
|
||||||
|
when 'Step', 'Result'
|
||||||
|
can_create_comments_in_module?(object.my_module)
|
||||||
|
when 'Project'
|
||||||
|
can_create_comments_in_project?(object)
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def comment_editable?(comment)
|
def comment_editable?(comment)
|
||||||
case comment.type
|
case comment.type
|
||||||
when 'TaskComment', 'StepComment', 'ResultComment'
|
when 'TaskComment', 'StepComment', 'ResultComment'
|
||||||
|
|
Loading…
Reference in a new issue