mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-13 08:34:49 +08:00
Merge pull request #5038 from artoscinote/ma_SCI_7990
Fix protocol duplication in table [SCI-7990]
This commit is contained in:
commit
fab7d9c3d6
4 changed files with 18 additions and 14 deletions
|
@ -498,25 +498,29 @@ var ProtocolsIndex = (function() {
|
|||
|
||||
function initDuplicateProtocols() {
|
||||
$('.protocols-index').on('click', '#duplicateProtocol', function() {
|
||||
duplicateProtocols(rowsSelected[0]);
|
||||
duplicateProtocols($(this));
|
||||
});
|
||||
}
|
||||
|
||||
function duplicateProtocols(id) {
|
||||
var row = $("tr[data-row-id='" + id + "']");
|
||||
animateSpinner();
|
||||
|
||||
$.post(row.attr('data-clone-url'), (data) => {
|
||||
animateSpinner(null, false);
|
||||
HelperModule.flashAlertMsg(data.message, 'success');
|
||||
reloadTable();
|
||||
}).error((data) => {
|
||||
function duplicateProtocols($el) {
|
||||
$.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
url: $el.data('url'),
|
||||
data: JSON.stringify({ ids: rowsSelected }),
|
||||
contentType: 'application/json'
|
||||
},
|
||||
(data) => {
|
||||
animateSpinner(null, false);
|
||||
HelperModule.flashAlertMsg(data.message, 'success');
|
||||
reloadTable();
|
||||
}
|
||||
).error((data) => {
|
||||
animateSpinner(null, false);
|
||||
HelperModule.flashAlertMsg(data.responseJSON.message, 'danger');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function initLinkedChildrenModal() {
|
||||
// Only do this if the repository is public/private
|
||||
if (repositoryType !== 'archive') {
|
||||
|
|
|
@ -1159,7 +1159,7 @@ class ProtocolsController < ApplicationController
|
|||
|
||||
def check_clone_permissions
|
||||
load_team_and_type
|
||||
protocol = Protocol.find_by(id: params[:id])
|
||||
protocol = Protocol.find_by(id: params[:ids][0])
|
||||
@original = protocol.latest_published_version || protocol
|
||||
|
||||
if @original.blank? ||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<i class="fas fa-door-open"></i>
|
||||
<span class="button-text"><%= t("protocols.index.action_toolbar.access") %></span>
|
||||
</button>
|
||||
<button id="duplicateProtocol" class="btn btn-light single-object-action hidden only-active" data-for="copyable">
|
||||
<button id="duplicateProtocol" class="btn btn-light single-object-action hidden only-active" data-url="<%= clone_protocols_path %>" data-for="copyable">
|
||||
<i class="fas fa-copy"></i>
|
||||
<span class="button-text"><%= t("protocols.index.action_toolbar.duplicate") %></span>
|
||||
</button>
|
||||
|
|
|
@ -585,7 +585,6 @@ Rails.application.routes.draw do
|
|||
put 'name', to: 'protocols#update_name'
|
||||
patch 'authors', to: 'protocols#update_authors'
|
||||
patch 'keywords', to: 'protocols#update_keywords'
|
||||
post 'clone', to: 'protocols#clone'
|
||||
get 'unlink_modal', to: 'protocols#unlink_modal'
|
||||
post 'unlink', to: 'protocols#unlink'
|
||||
get 'revert_modal', to: 'protocols#revert_modal'
|
||||
|
@ -618,6 +617,7 @@ Rails.application.routes.draw do
|
|||
post 'make_private', to: 'protocols#make_private'
|
||||
post 'archive', to: 'protocols#archive'
|
||||
post 'restore', to: 'protocols#restore'
|
||||
post 'clone', to: 'protocols#clone'
|
||||
post 'import', to: 'protocols#import'
|
||||
post 'protocolsio_import_create',
|
||||
to: 'protocols#protocolsio_import_create'
|
||||
|
|
Loading…
Add table
Reference in a new issue