diff --git a/app/controllers/protocols_controller.rb b/app/controllers/protocols_controller.rb index baead7713..6a9a68774 100644 --- a/app/controllers/protocols_controller.rb +++ b/app/controllers/protocols_controller.rb @@ -59,7 +59,7 @@ class ProtocolsController < ApplicationController copy_to_repository ) - before_action :check_publish_permission, only: :publish + before_action :check_publish_permission, only: %i(publish version_comment update_version_comment) before_action :check_import_permissions, only: :import before_action :check_export_permissions, only: :export before_action :check_delete_draft_permissions, only: :destroy_draft @@ -882,6 +882,14 @@ class ProtocolsController < ApplicationController end end + def version_comment + respond_to do |format| + format.json do + render json: { version_comment: @protocol.version_comment } + end + end + end + def update_version_comment respond_to do |format| format.json do diff --git a/app/javascript/vue/protocol/container.vue b/app/javascript/vue/protocol/container.vue index 2c92d9cdf..d05646e2e 100644 --- a/app/javascript/vue/protocol/container.vue +++ b/app/javascript/vue/protocol/container.vue @@ -338,7 +338,16 @@ this.reordering = false; }, startPublish() { - this.publishing = true; + $.ajax({ + type: "GET", + url: this.urls.version_comment_url, + contentType: "application/json", + dataType: "json", + success: (result) => { + this.protocol.attributes.version_comment = result.version_comment; + this.publishing = true; + } + }); }, closePublishModal() { this.publishing = false; diff --git a/app/serializers/protocol_serializer.rb b/app/serializers/protocol_serializer.rb index 0a737a6ba..19cdc14ba 100644 --- a/app/serializers/protocol_serializer.rb +++ b/app/serializers/protocol_serializer.rb @@ -91,6 +91,7 @@ class ProtocolSerializer < ActiveModel::Serializer publish_url: publish_url, save_as_draft_url: save_as_draft_url, versions_modal_url: versions_modal_url, + version_comment_url: version_comment_url, print_protocol_url: print_protocol_url } end @@ -217,6 +218,12 @@ class ProtocolSerializer < ActiveModel::Serializer publish_protocol_path(object) end + def version_comment_url + return unless can_publish_protocol_in_repository?(object) + + version_comment_protocol_path(object) + end + def save_as_draft_url return unless can_save_protocol_version_as_draft?(object) diff --git a/app/views/protocols/index/_protocol_versions_modal.html.erb b/app/views/protocols/index/_protocol_versions_modal.html.erb index 8120e8755..521ccb007 100644 --- a/app/views/protocols/index/_protocol_versions_modal.html.erb +++ b/app/views/protocols/index/_protocol_versions_modal.html.erb @@ -46,7 +46,7 @@