diff --git a/app/controllers/step_elements/checklist_items_controller.rb b/app/controllers/step_elements/checklist_items_controller.rb index 465d2a526..67feaabe9 100644 --- a/app/controllers/step_elements/checklist_items_controller.rb +++ b/app/controllers/step_elements/checklist_items_controller.rb @@ -30,7 +30,9 @@ module StepElements end def update - @checklist_item.assign_attributes(checklist_item_params) + @checklist_item.assign_attributes( + checklist_item_params.merge(last_modified_by: current_user) + ) if @checklist_item.save! if @checklist_item.saved_change_to_attribute?(:checked) diff --git a/app/javascript/vue/protocol/step.vue b/app/javascript/vue/protocol/step.vue index 2f4c346bf..766a3990b 100644 --- a/app/javascript/vue/protocol/step.vue +++ b/app/javascript/vue/protocol/step.vue @@ -15,7 +15,7 @@
- +
{ return { attributes: {...item, position: index } } }); + + if (this.isNew) { + this.addItem(); + } }, computed: { orderedChecklistItems() { @@ -177,7 +185,8 @@ attributes: { text: '', checked: false, - position: this.checklistItems.length + position: this.checklistItems.length, + isNew: true } } ); @@ -212,7 +221,7 @@ }, handleMultilinePaste(data) { this.linesToPaste = data.length; - let nextPosition = this.checklistItems.length; + let nextPosition = this.checklistItems.length - 1; // we need to post items to API in the right order, to avoid positions breaking let synchronousPost = (index) => { diff --git a/app/javascript/vue/protocol/step_elements/checklistItem.vue b/app/javascript/vue/protocol/step_elements/checklistItem.vue index 4bd5d94a0..f6d2cc8d1 100644 --- a/app/javascript/vue/protocol/step_elements/checklistItem.vue +++ b/app/javascript/vue/protocol/step_elements/checklistItem.vue @@ -9,6 +9,7 @@ @@ -24,7 +25,7 @@ :autofocus="editingText" :attributeName="`${i18n.t('ChecklistItem')} ${i18n.t('name')}`" :multilinePaste="true" - :editOnload="newItem()" + :editOnload="checklistItem.attributes.isNew" :smartAnnotation="true" @editingEnabled="enableTextEdit" @editingDisabled="disableTextEdit" @@ -41,23 +42,21 @@ -
-