mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-22 23:03:00 +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
|
ActiveRecord::Base.transaction do
|
||||||
new_items = @checklist_item.save_multiline!
|
new_items = @checklist_item.save_multiline!
|
||||||
new_items.each_with_index do |item, i|
|
new_items.each_with_index do |item, i|
|
||||||
if i.zero?
|
log_activity(
|
||||||
log_activity(
|
"#{@step.protocol.in_module? ? :task : :protocol}_step_checklist_item_#{i.zero? ? 'edited' : 'added'}",
|
||||||
"#{@step.protocol.in_module? ? :task : :protocol}_step_checklist_item_edited",
|
checklist_item: item.text,
|
||||||
checklist_item: item.text,
|
checklist_name: @checklist.name
|
||||||
checklist_name: @checklist.name
|
)
|
||||||
)
|
checklist_item_annotation(@step, item, old_text)
|
||||||
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
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ class ChecklistItem < ApplicationRecord
|
||||||
items = []
|
items = []
|
||||||
if new_record?
|
if new_record?
|
||||||
start_position = position
|
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 = checklist.checklist_items.create!(text: line)
|
||||||
new_item.insert_at(start_position + 1)
|
new_item.insert_at(start_position + 1)
|
||||||
start_position = new_item.position
|
start_position = new_item.position
|
||||||
|
@ -48,7 +48,7 @@ class ChecklistItem < ApplicationRecord
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
item = self
|
item = self
|
||||||
split_multiline.each_with_index do |line, index|
|
text.split("\n").compact.each_with_index do |line, index|
|
||||||
if index.zero?
|
if index.zero?
|
||||||
update!(text: line)
|
update!(text: line)
|
||||||
items.push(self)
|
items.push(self)
|
||||||
|
@ -73,8 +73,4 @@ class ChecklistItem < ApplicationRecord
|
||||||
checklist.touch
|
checklist.touch
|
||||||
# rubocop:enable Rails/SkipsModelValidations
|
# rubocop:enable Rails/SkipsModelValidations
|
||||||
end
|
end
|
||||||
|
|
||||||
def split_multiline
|
|
||||||
text.split("\n").compact
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue