Merge pull request #377 from Ducz0r/lm-sci-820-fix

Fix 2 bugs with comments editing [SCI-820]
This commit is contained in:
Luka Murn 2017-01-04 10:47:29 +01:00 committed by GitHub
commit 6402acc102
9 changed files with 48 additions and 13 deletions

View file

@ -310,8 +310,11 @@ var Comments = (function() {
.on('ajax:send', function() {
input.attr('readonly', true);
})
.on('ajax:success', function() {
.on('ajax:success', function(ev, data) {
var newMessage = input.val();
if (!_.isUndefined(data.comment)) {
newMessage = data.comment;
}
oldMessage.html(newMessage);
form.off('ajax:send ajax:success ajax:error ajax:complete');

View file

@ -1,4 +1,6 @@
class MyModuleCommentsController < ApplicationController
include ActionView::Helpers::TextHelper
before_action :load_vars
before_action :check_view_permissions, only: :index
before_action :check_add_permissions, only: [:create]
@ -112,7 +114,13 @@ class MyModuleCommentsController < ApplicationController
module: @my_module.name
)
)
render json: {}, status: :ok
render json: {
comment: auto_link(
simple_format(@comment.message),
link: :urls,
html: { target: '_blank' }
)
}, status: :ok
else
render json: { errors: @comment.errors.to_hash(true) },
status: :unprocessable_entity

View file

@ -1,4 +1,6 @@
class ProjectCommentsController < ApplicationController
include ActionView::Helpers::TextHelper
before_action :load_vars
before_action :check_view_permissions, only: :index
before_action :check_add_permissions, only: [:create]
@ -109,7 +111,13 @@ class ProjectCommentsController < ApplicationController
project: @project.name
)
)
render json: {}, status: :ok
render json: {
comment: auto_link(
simple_format(@comment.message),
link: :urls,
html: { target: '_blank' }
)
}, status: :ok
else
render json: { errors: @comment.errors.to_hash(true) },
status: :unprocessable_entity

View file

@ -1,4 +1,6 @@
class ResultCommentsController < ApplicationController
include ActionView::Helpers::TextHelper
before_action :load_vars
before_action :check_view_permissions, only: [:index]
@ -110,7 +112,13 @@ class ResultCommentsController < ApplicationController
result: @result.name
)
)
render json: {}, status: :ok
render json: {
comment: auto_link(
simple_format(@comment.message),
link: :urls,
html: { target: '_blank' }
)
}, status: :ok
else
render json: { errors: @comment.errors.to_hash(true) },
status: :unprocessable_entity

View file

@ -1,4 +1,6 @@
class StepCommentsController < ApplicationController
include ActionView::Helpers::TextHelper
before_action :load_vars
before_action :check_view_permissions, only: [:index]
@ -115,7 +117,13 @@ class StepCommentsController < ApplicationController
)
)
end
render json: {}, status: :ok
render json: {
comment: auto_link(
simple_format(@comment.message),
link: :urls,
html: { target: '_blank' }
)
}, status: :ok
else
render json: { errors: @comment.errors.to_hash(true) },
status: :unprocessable_entity

View file

@ -39,7 +39,7 @@
</div>
<strong><%= comment.user.full_name %>:</strong>
<div data-role="comment-message-container">
<p data-role="comment-message"><%= auto_link(simple_format(comment.message),
<div data-role="comment-message"><%= auto_link(simple_format(comment.message),
link: :urls,
html: { target: '_blank' }) %></p>
html: { target: '_blank' }) %></div>
</div>

View file

@ -39,7 +39,7 @@
</div>
<strong><%= comment.user.full_name %>:</strong>
<div data-role="comment-message-container">
<p data-role="comment-message"><%= auto_link(simple_format(comment.message),
<div data-role="comment-message"><%= auto_link(simple_format(comment.message),
link: :urls,
html: { target: '_blank' }) %></p>
html: { target: '_blank' }) %></div>
</div>

View file

@ -40,7 +40,7 @@
<% end %>
</div>
<div data-role="comment-message-container">
<p data-role="comment-message"><%= auto_link(simple_format(comment.message),
<div data-role="comment-message"><%= auto_link(simple_format(comment.message),
link: :urls,
html: { target: '_blank' }) %></p>
html: { target: '_blank' }) %></div>
</div>

View file

@ -40,7 +40,7 @@
<% end %>
</div>
<div data-role="comment-message-container">
<p data-role="comment-message"><%= auto_link(simple_format(comment.message),
<div data-role="comment-message"><%= auto_link(simple_format(comment.message),
link: :urls,
html: { target: '_blank' }) %></p>
html: { target: '_blank' }) %></div>
</div>