mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-12-09 13:46:21 +08:00
Fix toolbar buttons on archived task canvas page [SCI-10945]
This commit is contained in:
parent
52f9a8411c
commit
b3da5cf8c3
4 changed files with 45 additions and 9 deletions
|
|
@ -7,14 +7,15 @@
|
||||||
let taskId = $(this).closest('.task-selector-container').data('task-id');
|
let taskId = $(this).closest('.task-selector-container').data('task-id');
|
||||||
let index = $.inArray(taskId, selectedTasks);
|
let index = $.inArray(taskId, selectedTasks);
|
||||||
|
|
||||||
window.actionToolbarComponent.fetchActions({ my_module_ids: selectedTasks });
|
|
||||||
|
|
||||||
// If checkbox is checked and row ID is not in list of selected folder IDs
|
// If checkbox is checked and row ID is not in list of selected folder IDs
|
||||||
if (this.checked && index === -1) {
|
if (this.checked && index === -1) {
|
||||||
selectedTasks.push(taskId);
|
selectedTasks.push(taskId);
|
||||||
} else if (!this.checked && index !== -1) {
|
} else if (!this.checked && index !== -1) {
|
||||||
selectedTasks.splice(index, 1);
|
selectedTasks.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const items = selectedTasks.length ? JSON.stringify(selectedTasks.map((item) => ({ id: item }))) : [];
|
||||||
|
window.actionToolbarComponent.fetchActions({ items });
|
||||||
});
|
});
|
||||||
|
|
||||||
function restoreMyModules(url, ids) {
|
function restoreMyModules(url, ids) {
|
||||||
|
|
@ -63,7 +64,32 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initAccessModal() {
|
||||||
|
$('#module-archive').on('click', '#openAccessModal', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const container = document.getElementById('accessModalContainer');
|
||||||
|
const target = e.currentTarget;
|
||||||
|
|
||||||
|
$.get(target.dataset.url, (data) => {
|
||||||
|
const object = {
|
||||||
|
...data.data.attributes,
|
||||||
|
id: data.data.id,
|
||||||
|
type: data.data.type
|
||||||
|
};
|
||||||
|
const { rolesUrl } = container.dataset;
|
||||||
|
const params = {
|
||||||
|
object,
|
||||||
|
roles_path: rolesUrl
|
||||||
|
};
|
||||||
|
const modal = $('#accessModalComponent').data('accessModal');
|
||||||
|
modal.params = params;
|
||||||
|
modal.open();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
window.initActionToolbar();
|
window.initActionToolbar();
|
||||||
initRestoreMyModules();
|
initRestoreMyModules();
|
||||||
initMoveButton();
|
initMoveButton();
|
||||||
|
initAccessModal();
|
||||||
}());
|
}());
|
||||||
|
|
|
||||||
|
|
@ -410,7 +410,7 @@ class MyModulesController < ApplicationController
|
||||||
actions:
|
actions:
|
||||||
Toolbars::MyModulesService.new(
|
Toolbars::MyModulesService.new(
|
||||||
current_user,
|
current_user,
|
||||||
my_module_ids: JSON.parse(params[:items]).map { |i| i['id'] }
|
my_module_ids: params[:items].present? ? JSON.parse(params[:items]).map { |i| i['id'] } : params[:items]
|
||||||
).actions
|
).actions
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ module Toolbars
|
||||||
name: 'restore',
|
name: 'restore',
|
||||||
label: I18n.t('experiments.table.toolbar.restore'),
|
label: I18n.t('experiments.table.toolbar.restore'),
|
||||||
icon: 'sn-icon sn-icon-restore',
|
icon: 'sn-icon sn-icon-restore',
|
||||||
|
button_id: 'restoreTask',
|
||||||
path: restore_my_modules_experiment_path(experiment),
|
path: restore_my_modules_experiment_path(experiment),
|
||||||
type: :emit
|
type: :emit
|
||||||
}
|
}
|
||||||
|
|
@ -68,16 +69,12 @@ module Toolbars
|
||||||
|
|
||||||
return unless can_read_my_module?(my_module)
|
return unless can_read_my_module?(my_module)
|
||||||
|
|
||||||
path = if can_manage_my_module_users?(my_module)
|
|
||||||
edit_access_permissions_my_module_path(my_module)
|
|
||||||
else
|
|
||||||
access_permissions_my_module_path(my_module)
|
|
||||||
end
|
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'access',
|
name: 'access',
|
||||||
label: I18n.t('experiments.table.my_module_actions.access'),
|
label: I18n.t('experiments.table.my_module_actions.access'),
|
||||||
icon: 'sn-icon sn-icon-project-member-access',
|
icon: 'sn-icon sn-icon-project-member-access',
|
||||||
|
path: my_module_path(my_module, format: :json),
|
||||||
|
button_id: 'openAccessModal',
|
||||||
type: :emit
|
type: :emit
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
@ -89,6 +86,7 @@ module Toolbars
|
||||||
name: 'move',
|
name: 'move',
|
||||||
label: I18n.t('experiments.table.toolbar.move'),
|
label: I18n.t('experiments.table.toolbar.move'),
|
||||||
icon: 'sn-icon sn-icon-move',
|
icon: 'sn-icon sn-icon-move',
|
||||||
|
button_id: 'moveTask',
|
||||||
type: :emit,
|
type: :emit,
|
||||||
path: move_modules_experiment_path(@my_modules.first.experiment, my_module_ids: @my_modules.pluck(:id))
|
path: move_modules_experiment_path(@my_modules.first.experiment, my_module_ids: @my_modules.pluck(:id))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,17 @@
|
||||||
<div id="actionToolbar" data-behaviour="vue">
|
<div id="actionToolbar" data-behaviour="vue">
|
||||||
<action-toolbar actions-url="<%= actions_toolbar_my_modules_url %>" />
|
<action-toolbar actions-url="<%= actions_toolbar_my_modules_url %>" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="accessModalContainer" class="vue-access-modal"
|
||||||
|
data-roles-url="<%= user_roles_projects_path %>">
|
||||||
|
<div ref="accessModal" id="accessModalComponent"></div>
|
||||||
|
<teleport to="body">
|
||||||
|
<access-modal
|
||||||
|
v-if="accessModalOpen"
|
||||||
|
:params="params"
|
||||||
|
@close="accessModalOpen = false" />
|
||||||
|
</teleport>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% unless @my_modules.present? %>
|
<% unless @my_modules.present? %>
|
||||||
<div class="pt-10">
|
<div class="pt-10">
|
||||||
|
|
@ -38,5 +49,6 @@
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= javascript_include_tag('vue_components_action_toolbar') %>
|
<%= javascript_include_tag('vue_components_action_toolbar') %>
|
||||||
|
<%= javascript_include_tag 'vue_legacy_access_modal' %>
|
||||||
<%= javascript_include_tag('projects/canvas') %>
|
<%= javascript_include_tag('projects/canvas') %>
|
||||||
<%= javascript_include_tag('my_modules/archived') %>
|
<%= javascript_include_tag('my_modules/archived') %>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue