mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-10 08:21:37 +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() {
|
function initDuplicateProtocols() {
|
||||||
$('.protocols-index').on('click', '#duplicateProtocol', function() {
|
$('.protocols-index').on('click', '#duplicateProtocol', function() {
|
||||||
duplicateProtocols(rowsSelected[0]);
|
duplicateProtocols($(this));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function duplicateProtocols(id) {
|
function duplicateProtocols($el) {
|
||||||
var row = $("tr[data-row-id='" + id + "']");
|
$.ajax(
|
||||||
animateSpinner();
|
{
|
||||||
|
type: 'POST',
|
||||||
$.post(row.attr('data-clone-url'), (data) => {
|
url: $el.data('url'),
|
||||||
animateSpinner(null, false);
|
data: JSON.stringify({ ids: rowsSelected }),
|
||||||
HelperModule.flashAlertMsg(data.message, 'success');
|
contentType: 'application/json'
|
||||||
reloadTable();
|
},
|
||||||
}).error((data) => {
|
(data) => {
|
||||||
|
animateSpinner(null, false);
|
||||||
|
HelperModule.flashAlertMsg(data.message, 'success');
|
||||||
|
reloadTable();
|
||||||
|
}
|
||||||
|
).error((data) => {
|
||||||
animateSpinner(null, false);
|
animateSpinner(null, false);
|
||||||
HelperModule.flashAlertMsg(data.responseJSON.message, 'danger');
|
HelperModule.flashAlertMsg(data.responseJSON.message, 'danger');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function initLinkedChildrenModal() {
|
function initLinkedChildrenModal() {
|
||||||
// Only do this if the repository is public/private
|
// Only do this if the repository is public/private
|
||||||
if (repositoryType !== 'archive') {
|
if (repositoryType !== 'archive') {
|
||||||
|
|
|
||||||
|
|
@ -1159,7 +1159,7 @@ class ProtocolsController < ApplicationController
|
||||||
|
|
||||||
def check_clone_permissions
|
def check_clone_permissions
|
||||||
load_team_and_type
|
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
|
@original = protocol.latest_published_version || protocol
|
||||||
|
|
||||||
if @original.blank? ||
|
if @original.blank? ||
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
<i class="fas fa-door-open"></i>
|
<i class="fas fa-door-open"></i>
|
||||||
<span class="button-text"><%= t("protocols.index.action_toolbar.access") %></span>
|
<span class="button-text"><%= t("protocols.index.action_toolbar.access") %></span>
|
||||||
</button>
|
</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>
|
<i class="fas fa-copy"></i>
|
||||||
<span class="button-text"><%= t("protocols.index.action_toolbar.duplicate") %></span>
|
<span class="button-text"><%= t("protocols.index.action_toolbar.duplicate") %></span>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -585,7 +585,6 @@ Rails.application.routes.draw do
|
||||||
put 'name', to: 'protocols#update_name'
|
put 'name', to: 'protocols#update_name'
|
||||||
patch 'authors', to: 'protocols#update_authors'
|
patch 'authors', to: 'protocols#update_authors'
|
||||||
patch 'keywords', to: 'protocols#update_keywords'
|
patch 'keywords', to: 'protocols#update_keywords'
|
||||||
post 'clone', to: 'protocols#clone'
|
|
||||||
get 'unlink_modal', to: 'protocols#unlink_modal'
|
get 'unlink_modal', to: 'protocols#unlink_modal'
|
||||||
post 'unlink', to: 'protocols#unlink'
|
post 'unlink', to: 'protocols#unlink'
|
||||||
get 'revert_modal', to: 'protocols#revert_modal'
|
get 'revert_modal', to: 'protocols#revert_modal'
|
||||||
|
|
@ -618,6 +617,7 @@ Rails.application.routes.draw do
|
||||||
post 'make_private', to: 'protocols#make_private'
|
post 'make_private', to: 'protocols#make_private'
|
||||||
post 'archive', to: 'protocols#archive'
|
post 'archive', to: 'protocols#archive'
|
||||||
post 'restore', to: 'protocols#restore'
|
post 'restore', to: 'protocols#restore'
|
||||||
|
post 'clone', to: 'protocols#clone'
|
||||||
post 'import', to: 'protocols#import'
|
post 'import', to: 'protocols#import'
|
||||||
post 'protocolsio_import_create',
|
post 'protocolsio_import_create',
|
||||||
to: 'protocols#protocolsio_import_create'
|
to: 'protocols#protocolsio_import_create'
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue