mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-22 14:54:38 +08:00
Small fixes [SCI-9340]
This commit is contained in:
parent
77948572f1
commit
566705cb67
2 changed files with 8 additions and 23 deletions
|
@ -45,23 +45,12 @@ module StepElements
|
|||
ActiveRecord::Base.transaction do
|
||||
new_items = @checklist_item.save_multiline!
|
||||
new_items.each_with_index do |item, i|
|
||||
if i.zero?
|
||||
log_activity(
|
||||
"#{@step.protocol.in_module? ? :task : :protocol}_step_checklist_item_edited",
|
||||
checklist_item: item.text,
|
||||
checklist_name: @checklist.name
|
||||
)
|
||||
checklist_item_annotation(@step, item, old_text)
|
||||
else
|
||||
log_activity(
|
||||
"#{@step.protocol.in_module? ? :task : :protocol}_step_checklist_item_added",
|
||||
{
|
||||
checklist_item: item.text,
|
||||
checklist_name: @checklist.name
|
||||
}
|
||||
)
|
||||
checklist_item_annotation(@step, item)
|
||||
end
|
||||
log_activity(
|
||||
"#{@step.protocol.in_module? ? :task : :protocol}_step_checklist_item_#{i.zero? ? 'edited' : 'added'}",
|
||||
checklist_item: item.text,
|
||||
checklist_name: @checklist.name
|
||||
)
|
||||
checklist_item_annotation(@step, item, old_text)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ class ChecklistItem < ApplicationRecord
|
|||
items = []
|
||||
if new_record?
|
||||
start_position = position
|
||||
split_multiline.each do |line|
|
||||
text.split("\n").compact.each do |line|
|
||||
new_item = checklist.checklist_items.create!(text: line)
|
||||
new_item.insert_at(start_position + 1)
|
||||
start_position = new_item.position
|
||||
|
@ -48,7 +48,7 @@ class ChecklistItem < ApplicationRecord
|
|||
end
|
||||
else
|
||||
item = self
|
||||
split_multiline.each_with_index do |line, index|
|
||||
text.split("\n").compact.each_with_index do |line, index|
|
||||
if index.zero?
|
||||
update!(text: line)
|
||||
items.push(self)
|
||||
|
@ -73,8 +73,4 @@ class ChecklistItem < ApplicationRecord
|
|||
checklist.touch
|
||||
# rubocop:enable Rails/SkipsModelValidations
|
||||
end
|
||||
|
||||
def split_multiline
|
||||
text.split("\n").compact
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue