mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 17:51:13 +08:00
Fix protocol linked protocol changes tracking [SCI-6986]
This commit is contained in:
parent
1ee091aa53
commit
d1a46b3fc2
12 changed files with 20 additions and 12 deletions
|
@ -15,6 +15,7 @@ module Api
|
|||
@protocol.steps.find(order['id']).update_column(:position, order['position'])
|
||||
# rubocop:enable Rails/SkipsModelValidations
|
||||
end
|
||||
@protocol.touch
|
||||
rescue StandardError
|
||||
head :bad_request
|
||||
end
|
||||
|
|
|
@ -14,6 +14,7 @@ module Api
|
|||
@step.step_orderable_elements.find(order['id']).update_column(:position, order['position'])
|
||||
# rubocop:enable Rails/SkipsModelValidations
|
||||
end
|
||||
@step.touch
|
||||
rescue StandardError
|
||||
head :bad_request
|
||||
end
|
||||
|
|
|
@ -93,10 +93,11 @@ module StepElements
|
|||
end
|
||||
|
||||
def reorder
|
||||
ActiveRecord::Base.transaction do
|
||||
@checklist.with_lock do
|
||||
params[:checklist_item_positions].each do |id, position|
|
||||
@checklist.checklist_items.find(id).update_column(:position, position)
|
||||
end
|
||||
@checklist.touch
|
||||
end
|
||||
|
||||
render json: params[:checklist_item_positions], status: :ok
|
||||
|
|
|
@ -5,7 +5,7 @@ class StepOrderableElementsController < ApplicationController
|
|||
before_action :check_manage_permissions
|
||||
|
||||
def reorder
|
||||
ActiveRecord::Base.transaction do
|
||||
@step.with_lock do
|
||||
params[:step_orderable_element_positions].each do |id, position|
|
||||
@step.step_orderable_elements.find(id).update_column(:position, position)
|
||||
end
|
||||
|
@ -15,6 +15,7 @@ class StepOrderableElementsController < ApplicationController
|
|||
else
|
||||
log_activity(:protocol_step_content_rearranged, nil, protocol: @protocol.id)
|
||||
end
|
||||
@step.touch
|
||||
end
|
||||
|
||||
render json: params[:step_orderable_element_positions], status: :ok
|
||||
|
|
|
@ -458,7 +458,7 @@ class StepsController < ApplicationController
|
|||
end
|
||||
|
||||
def reorder
|
||||
ActiveRecord::Base.transaction do
|
||||
@protocol.with_lock do
|
||||
params[:step_positions].each do |id, position|
|
||||
@protocol.steps.find(id).update_column(:position, position)
|
||||
end
|
||||
|
@ -468,6 +468,7 @@ class StepsController < ApplicationController
|
|||
else
|
||||
log_activity(:protocol_steps_rearranged, nil, protocol: @protocol.id)
|
||||
end
|
||||
@protocol.touch
|
||||
end
|
||||
|
||||
render json: {
|
||||
|
|
|
@ -267,10 +267,9 @@
|
|||
data: JSON.stringify(stepPositions),
|
||||
contentType: "application/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() {
|
||||
this.reordering = true;
|
||||
|
|
|
@ -369,7 +369,8 @@
|
|||
data: JSON.stringify(elementPositions),
|
||||
contentType: "application/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);
|
||||
|
|
|
@ -231,7 +231,8 @@
|
|||
data: JSON.stringify(checklistItemPositions),
|
||||
contentType: "application/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) {
|
||||
|
|
|
@ -8,7 +8,8 @@ class ChecklistItem < ApplicationRecord
|
|||
validates :position, uniqueness: { scope: :checklist }, unless: -> { position.nil? }
|
||||
|
||||
belongs_to :checklist,
|
||||
inverse_of: :checklist_items
|
||||
inverse_of: :checklist_items,
|
||||
touch: true
|
||||
belongs_to :created_by,
|
||||
foreign_key: 'created_by_id',
|
||||
class_name: 'User',
|
||||
|
|
|
@ -49,9 +49,10 @@ class Comment < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def self.mark_as_seen_by(user)
|
||||
def self.mark_as_seen_by(user, commentable)
|
||||
# rubocop:disable Rails/SkipsModelValidations
|
||||
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
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<% end %>
|
||||
<div class="comments-list">
|
||||
<%= 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>
|
||||
<% if can_create_comments %>
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
locals: { comment: comment, skip_header: user == comment.user } %>
|
||||
<% user = comment.user %>
|
||||
<% end %>
|
||||
<% comments.mark_as_seen_by(current_user) && @commentable.touch %>
|
||||
<% comments.mark_as_seen_by(current_user, @commentable) %>
|
||||
|
|
Loading…
Reference in a new issue