mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-02 21:20:08 +08:00
Revision notes written in version modal are not seen/saved [SCI-8279] (#5272)
* Load latest protocol version comment in publish modal [SCI-8279] * Check publish permission before updating the draft comment [SCI-8279]
This commit is contained in:
parent
5e321b761d
commit
0f8918e9f6
5 changed files with 28 additions and 3 deletions
|
@ -59,7 +59,7 @@ class ProtocolsController < ApplicationController
|
||||||
copy_to_repository
|
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_import_permissions, only: :import
|
||||||
before_action :check_export_permissions, only: :export
|
before_action :check_export_permissions, only: :export
|
||||||
before_action :check_delete_draft_permissions, only: :destroy_draft
|
before_action :check_delete_draft_permissions, only: :destroy_draft
|
||||||
|
@ -882,6 +882,14 @@ class ProtocolsController < ApplicationController
|
||||||
end
|
end
|
||||||
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
|
def update_version_comment
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json do
|
format.json do
|
||||||
|
|
|
@ -338,7 +338,16 @@
|
||||||
this.reordering = false;
|
this.reordering = false;
|
||||||
},
|
},
|
||||||
startPublish() {
|
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() {
|
closePublishModal() {
|
||||||
this.publishing = false;
|
this.publishing = false;
|
||||||
|
|
|
@ -91,6 +91,7 @@ class ProtocolSerializer < ActiveModel::Serializer
|
||||||
publish_url: publish_url,
|
publish_url: publish_url,
|
||||||
save_as_draft_url: save_as_draft_url,
|
save_as_draft_url: save_as_draft_url,
|
||||||
versions_modal_url: versions_modal_url,
|
versions_modal_url: versions_modal_url,
|
||||||
|
version_comment_url: version_comment_url,
|
||||||
print_protocol_url: print_protocol_url
|
print_protocol_url: print_protocol_url
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -217,6 +218,12 @@ class ProtocolSerializer < ActiveModel::Serializer
|
||||||
publish_protocol_path(object)
|
publish_protocol_path(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def version_comment_url
|
||||||
|
return unless can_publish_protocol_in_repository?(object)
|
||||||
|
|
||||||
|
version_comment_protocol_path(object)
|
||||||
|
end
|
||||||
|
|
||||||
def save_as_draft_url
|
def save_as_draft_url
|
||||||
return unless can_save_protocol_version_as_draft?(object)
|
return unless can_save_protocol_version_as_draft?(object)
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="protocol-version-comment">
|
<div class="protocol-version-comment">
|
||||||
<% if can_manage_protocol_draft_in_repository?(draft) %>
|
<% if can_manage_protocol_draft_in_repository?(draft) && can_publish_protocol_in_repository?(draft) %>
|
||||||
<div
|
<div
|
||||||
class="protocol-comment-container inline-init-handler"
|
class="protocol-comment-container inline-init-handler"
|
||||||
data-field-to-update="version_comment"
|
data-field-to-update="version_comment"
|
||||||
|
|
|
@ -577,6 +577,7 @@ Rails.application.routes.draw do
|
||||||
post :publish
|
post :publish
|
||||||
post :destroy_draft
|
post :destroy_draft
|
||||||
post :save_as_draft
|
post :save_as_draft
|
||||||
|
get 'version_comment', to: 'protocols#version_comment'
|
||||||
get 'print', to: 'protocols#print'
|
get 'print', to: 'protocols#print'
|
||||||
get 'linked_children', to: 'protocols#linked_children'
|
get 'linked_children', to: 'protocols#linked_children'
|
||||||
post 'linked_children_datatable',
|
post 'linked_children_datatable',
|
||||||
|
|
Loading…
Reference in a new issue