Merge pull request #4658 from aignatov-bio/ai-sci-7453-add-restore-task-to-experiment-table-view

Add restore action to experiment table [SCI-7453]
This commit is contained in:
aignatov-bio 2022-12-02 13:37:45 +01:00 committed by GitHub
commit fdf13f822e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 1 deletions

View file

@ -115,6 +115,12 @@ var ExperimnetTable = {
this.archiveMyModules(e.target.href, e.target.dataset.id);
});
$(this.table).on('click', '.restore-my-module', (e) => {
e.preventDefault();
this.restoreMyModules(e.target.href, e.target.dataset.id);
});
$(this.table).on('click', '.duplicate-my-module', (e) => {
e.preventDefault();
this.duplicateMyModules($('#duplicateTasks').data('url'), e.target.dataset.id);
@ -157,6 +163,14 @@ var ExperimnetTable = {
HelperModule.flashAlertMsg(data.responseJSON.message, 'danger');
});
},
initRestoreMyModules: function() {
$('#restoreTask').on('click', (e) => {
this.restoreMyModules(e.target.dataset.url, this.selectedMyModules);
});
},
restoreMyModules: function(url, ids) {
$.post(url, { my_modules_ids: ids, view: 'table' });
},
initAccessModal: function() {
$('#manageTaskAccess').on('click', () => {
$(`.table-row[data-id="${this.selectedMyModules[0]}"] .open-access-modal`).click();
@ -525,6 +539,7 @@ var ExperimnetTable = {
this.initNewTaskModal(this);
this.initMyModuleActions();
this.updateExperimentToolbar();
this.initRestoreMyModules();
this.initManageUsersDropdown();
}
};

View file

@ -376,7 +376,12 @@ class MyModulesController < ApplicationController
else
flash[:error] = t('my_modules.restore_group.error_flash')
end
redirect_to module_archive_experiment_path(experiment)
if params[:view] == 'table'
redirect_to table_experiment_path(experiment, view_mode: :archived)
else
redirect_to module_archive_experiment_path(experiment)
end
end
def update_state

View file

@ -74,9 +74,11 @@ module Experiments
permissions: permissions_my_module_path(my_module),
actions_dropdown: actions_dropdown_my_module_path(my_module),
name_update: my_module_path(my_module),
restore: restore_my_modules_experiment_path(experiment),
provisioning_status:
my_module.provisioning_status == 'in_progress' && provisioning_status_my_module_url(my_module),
access: edit_access_permissions_project_experiment_my_module_path(project, experiment, my_module)
}
}
end

View file

@ -37,3 +37,11 @@
</a>
</li>
<% end %>
<% if can_restore_my_module?(my_module) %>
<li>
<a href="<%= restore_my_modules_experiment_path(my_module.experiment) %>" class="restore-my-module" data-id="<%= my_module.id %>">
<i class="fas fa-undo"></i>
<%= t("experiments.table.my_module_actions.restore") %>
</a>
</li>
<% end %>

View file

@ -32,6 +32,10 @@
<i class="fas fa-archive"></i>
<%= t("experiments.table.toolbar.archive") %>
</button>
<button id="restoreTask" class="btn btn-light multiple-object-action hidden only-archive" data-url="<%= restore_my_modules_experiment_path(@experiment) %>" data-for="restorable">
<i class="fas fa-undo"></i>
<%= t("experiments.table.toolbar.restore") %>
</button>
</div>
<div class="toolbar-right-block">
<button id="taskDataDisplay" class="btn btn-light" data-toggle="modal" data-target="#tableDisplayModal">

View file

@ -1333,6 +1333,7 @@ en:
new: 'New task'
edit: 'Edit'
archive: 'Archive'
restore: 'Restore'
move: 'Move'
duplicate: 'Duplicate'
manage_access: 'Manage access'
@ -1344,6 +1345,7 @@ en:
move: 'Move to another experiment'
access: 'Task access'
archive: 'Archive'
restore: 'Restore'
filters:
name: 'Task name'
due_date: 'Due date'