mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-20 22:56:46 +08:00
Fix protocol linked protocol changes tracking [SCI-6986]
This commit is contained in:
parent
1ee091aa53
commit
d1a46b3fc2
|
@ -15,6 +15,7 @@ module Api
|
||||||
@protocol.steps.find(order['id']).update_column(:position, order['position'])
|
@protocol.steps.find(order['id']).update_column(:position, order['position'])
|
||||||
# rubocop:enable Rails/SkipsModelValidations
|
# rubocop:enable Rails/SkipsModelValidations
|
||||||
end
|
end
|
||||||
|
@protocol.touch
|
||||||
rescue StandardError
|
rescue StandardError
|
||||||
head :bad_request
|
head :bad_request
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,6 +14,7 @@ module Api
|
||||||
@step.step_orderable_elements.find(order['id']).update_column(:position, order['position'])
|
@step.step_orderable_elements.find(order['id']).update_column(:position, order['position'])
|
||||||
# rubocop:enable Rails/SkipsModelValidations
|
# rubocop:enable Rails/SkipsModelValidations
|
||||||
end
|
end
|
||||||
|
@step.touch
|
||||||
rescue StandardError
|
rescue StandardError
|
||||||
head :bad_request
|
head :bad_request
|
||||||
end
|
end
|
||||||
|
|
|
@ -93,10 +93,11 @@ module StepElements
|
||||||
end
|
end
|
||||||
|
|
||||||
def reorder
|
def reorder
|
||||||
ActiveRecord::Base.transaction do
|
@checklist.with_lock do
|
||||||
params[:checklist_item_positions].each do |id, position|
|
params[:checklist_item_positions].each do |id, position|
|
||||||
@checklist.checklist_items.find(id).update_column(:position, position)
|
@checklist.checklist_items.find(id).update_column(:position, position)
|
||||||
end
|
end
|
||||||
|
@checklist.touch
|
||||||
end
|
end
|
||||||
|
|
||||||
render json: params[:checklist_item_positions], status: :ok
|
render json: params[:checklist_item_positions], status: :ok
|
||||||
|
|
|
@ -5,7 +5,7 @@ class StepOrderableElementsController < ApplicationController
|
||||||
before_action :check_manage_permissions
|
before_action :check_manage_permissions
|
||||||
|
|
||||||
def reorder
|
def reorder
|
||||||
ActiveRecord::Base.transaction do
|
@step.with_lock do
|
||||||
params[:step_orderable_element_positions].each do |id, position|
|
params[:step_orderable_element_positions].each do |id, position|
|
||||||
@step.step_orderable_elements.find(id).update_column(:position, position)
|
@step.step_orderable_elements.find(id).update_column(:position, position)
|
||||||
end
|
end
|
||||||
|
@ -15,6 +15,7 @@ class StepOrderableElementsController < ApplicationController
|
||||||
else
|
else
|
||||||
log_activity(:protocol_step_content_rearranged, nil, protocol: @protocol.id)
|
log_activity(:protocol_step_content_rearranged, nil, protocol: @protocol.id)
|
||||||
end
|
end
|
||||||
|
@step.touch
|
||||||
end
|
end
|
||||||
|
|
||||||
render json: params[:step_orderable_element_positions], status: :ok
|
render json: params[:step_orderable_element_positions], status: :ok
|
||||||
|
|
|
@ -458,7 +458,7 @@ class StepsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def reorder
|
def reorder
|
||||||
ActiveRecord::Base.transaction do
|
@protocol.with_lock do
|
||||||
params[:step_positions].each do |id, position|
|
params[:step_positions].each do |id, position|
|
||||||
@protocol.steps.find(id).update_column(:position, position)
|
@protocol.steps.find(id).update_column(:position, position)
|
||||||
end
|
end
|
||||||
|
@ -468,6 +468,7 @@ class StepsController < ApplicationController
|
||||||
else
|
else
|
||||||
log_activity(:protocol_steps_rearranged, nil, protocol: @protocol.id)
|
log_activity(:protocol_steps_rearranged, nil, protocol: @protocol.id)
|
||||||
end
|
end
|
||||||
|
@protocol.touch
|
||||||
end
|
end
|
||||||
|
|
||||||
render json: {
|
render json: {
|
||||||
|
|
|
@ -267,10 +267,9 @@
|
||||||
data: JSON.stringify(stepPositions),
|
data: JSON.stringify(stepPositions),
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
error: (() => HelperModule.flashAlertMsg(this.i18n.t('errors.general'), 'danger'))
|
error: (() => HelperModule.flashAlertMsg(this.i18n.t('errors.general'), 'danger')),
|
||||||
|
success: (() => this.reorderSteps(this.steps))
|
||||||
});
|
});
|
||||||
|
|
||||||
this.reorderSteps(this.steps);
|
|
||||||
},
|
},
|
||||||
startStepReorder() {
|
startStepReorder() {
|
||||||
this.reordering = true;
|
this.reordering = true;
|
||||||
|
|
|
@ -369,7 +369,8 @@
|
||||||
data: JSON.stringify(elementPositions),
|
data: JSON.stringify(elementPositions),
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
error: (() => HelperModule.flashAlertMsg(this.i18n.t('errors.general'), 'danger'))
|
error: (() => HelperModule.flashAlertMsg(this.i18n.t('errors.general'), 'danger')),
|
||||||
|
success: (() => this.$emit('stepUpdated'))
|
||||||
});
|
});
|
||||||
|
|
||||||
this.reorderElements(this.elements);
|
this.reorderElements(this.elements);
|
||||||
|
|
|
@ -231,7 +231,8 @@
|
||||||
data: JSON.stringify(checklistItemPositions),
|
data: JSON.stringify(checklistItemPositions),
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
error: (() => HelperModule.flashAlertMsg(this.i18n.t('errors.general'), 'danger'))
|
error: (() => HelperModule.flashAlertMsg(this.i18n.t('errors.general'), 'danger')),
|
||||||
|
success: (() => this.update())
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleMultilinePaste(data) {
|
handleMultilinePaste(data) {
|
||||||
|
|
|
@ -8,7 +8,8 @@ class ChecklistItem < ApplicationRecord
|
||||||
validates :position, uniqueness: { scope: :checklist }, unless: -> { position.nil? }
|
validates :position, uniqueness: { scope: :checklist }, unless: -> { position.nil? }
|
||||||
|
|
||||||
belongs_to :checklist,
|
belongs_to :checklist,
|
||||||
inverse_of: :checklist_items
|
inverse_of: :checklist_items,
|
||||||
|
touch: true
|
||||||
belongs_to :created_by,
|
belongs_to :created_by,
|
||||||
foreign_key: 'created_by_id',
|
foreign_key: 'created_by_id',
|
||||||
class_name: 'User',
|
class_name: 'User',
|
||||||
|
|
|
@ -49,9 +49,10 @@ class Comment < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.mark_as_seen_by(user)
|
def self.mark_as_seen_by(user, commentable)
|
||||||
# rubocop:disable Rails/SkipsModelValidations
|
# rubocop:disable Rails/SkipsModelValidations
|
||||||
all.where('? = ANY (unseen_by)', user.id).update_all("unseen_by = array_remove(unseen_by, #{user.id.to_i}::bigint)")
|
all.where('? = ANY (unseen_by)', user.id).update_all("unseen_by = array_remove(unseen_by, #{user.id.to_i}::bigint)")
|
||||||
|
commentable.touch
|
||||||
# rubocop:enable Rails/SkipsModelValidations
|
# rubocop:enable Rails/SkipsModelValidations
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="comments-list">
|
<div class="comments-list">
|
||||||
<%= render partial: 'shared/comments/list.html.erb', locals: { comments: comments} %>
|
<%= render partial: 'shared/comments/list.html.erb', locals: { comments: comments} %>
|
||||||
<% comments.mark_as_seen_by(current_user) %>
|
<% comments.mark_as_seen_by(current_user, object) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% if can_create_comments %>
|
<% if can_create_comments %>
|
||||||
|
|
|
@ -4,4 +4,4 @@
|
||||||
locals: { comment: comment, skip_header: user == comment.user } %>
|
locals: { comment: comment, skip_header: user == comment.user } %>
|
||||||
<% user = comment.user %>
|
<% user = comment.user %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% comments.mark_as_seen_by(current_user) && @commentable.touch %>
|
<% comments.mark_as_seen_by(current_user, @commentable) %>
|
||||||
|
|
Loading…
Reference in a new issue