diff --git a/app/controllers/step_elements/checklist_items_controller.rb b/app/controllers/step_elements/checklist_items_controller.rb
index 1320efbbd..9889d6f51 100644
--- a/app/controllers/step_elements/checklist_items_controller.rb
+++ b/app/controllers/step_elements/checklist_items_controller.rb
@@ -10,22 +10,28 @@ module StepElements
before_action :check_toggle_permissions, only: %i(toggle)
before_action :check_manage_permissions, only: %i(create update destroy)
- def create
- checklist_item = @checklist.checklist_items.build(checklist_item_params.merge!(created_by: current_user))
+ def index
+ render json: @checklist.checklist_items, each_serializer: ChecklistItemSerializer, user: current_user
+ end
+ def create
+ checklist_item = @checklist.checklist_items.new(checklist_item_params.merge!(created_by: current_user))
+ new_items = []
ActiveRecord::Base.transaction do
- checklist_item.save!
- log_activity(
- "#{@step.protocol.in_module? ? :task : :protocol}_step_checklist_item_added",
- {
- checklist_item: checklist_item.text,
- checklist_name: @checklist.name
- }
- )
- checklist_item_annotation(@step, checklist_item)
+ new_items = checklist_item.save_multiline!
+ new_items.each do |item|
+ 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
- render json: checklist_item, serializer: ChecklistItemSerializer, user: current_user
+ render json: new_items, each_serializer: ChecklistItemSerializer, user: current_user
rescue ActiveRecord::RecordInvalid
render json: { errors: checklist_item.errors }, status: :unprocessable_entity
end
@@ -35,17 +41,20 @@ module StepElements
@checklist_item.assign_attributes(
checklist_item_params.except(:position, :id).merge(last_modified_by: current_user)
)
-
- if @checklist_item.save!
- log_activity(
- "#{@step.protocol.in_module? ? :task : :protocol}_step_checklist_item_edited",
- checklist_item: @checklist_item.text,
- checklist_name: @checklist.name
- )
- checklist_item_annotation(@step, @checklist_item, old_text)
+ new_items = []
+ ActiveRecord::Base.transaction do
+ new_items = @checklist_item.save_multiline!
+ new_items.each_with_index do |item, i|
+ 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
- render json: @checklist_item, serializer: ChecklistItemSerializer, user: current_user
+ render json: new_items, each_serializer: ChecklistItemSerializer, user: current_user
rescue ActiveRecord::RecordInvalid
render json: { errors: @checklist_item.errors }, status: :unprocessable_entity
end
@@ -96,7 +105,6 @@ module StepElements
checklist_item = @checklist.checklist_items.find(checklist_item_params[:id])
ActiveRecord::Base.transaction do
checklist_item.insert_at(checklist_item_params[:position])
- @checklist.touch
end
render json: params[:checklist_item_positions], status: :ok
rescue ActiveRecord::RecordInvalid
@@ -118,7 +126,7 @@ module StepElements
end
def checklist_item_params
- params.require(:attributes).permit(:text, :position, :id)
+ params.require(:attributes).permit(:text, :position, :id, :with_paragraphs)
end
def checklist_toggle_item_params
diff --git a/app/javascript/vue/protocol/container.vue b/app/javascript/vue/protocol/container.vue
index 6dd3bfe90..194eca331 100644
--- a/app/javascript/vue/protocol/container.vue
+++ b/app/javascript/vue/protocol/container.vue
@@ -431,7 +431,7 @@
secondaryNavigation.style.zIndex= 251;
} else {
secondaryNavigation.style.boxShadow = 'none';
- secondaryNavigation.style.zIndex= 0;
+ if (secondaryNavigationTop > 10) secondaryNavigation.style.zIndex= 0;
}
if (protocolHeaderTop - 5 < protocolHeaderHeight) { // When secondary navigation touch protocol header
@@ -457,7 +457,7 @@
secondaryNavigation.style.top = newSecondaryTop + 'px'; // Secondary navigation starts slowly disappear
protocolHeader.style.top = newSecondaryTop + secondaryNavigationHeight - 1 + 'px'; // Protocol header starts getting offset to compensate secondary navigation position
// -1 to compensate small gap between protocol header and secondary navigation
- if (newSecondaryTop <= 1) secondaryNavigation.style.zIndex= 0;
+ if (newSecondaryTop * -1 >= secondaryNavigationHeight) secondaryNavigation.style.zIndex= 0;
}
} else {
// Just reset secondary navigation and protocol header styles to initial state
diff --git a/app/javascript/vue/shared/content/checklist.vue b/app/javascript/vue/shared/content/checklist.vue
index 76d47c2f4..f82561faf 100644
--- a/app/javascript/vue/shared/content/checklist.vue
+++ b/app/javascript/vue/shared/content/checklist.vue
@@ -43,7 +43,7 @@
>