Add restore action to experiment table [SCI-7453]

This commit is contained in:
Anton 2022-11-28 12:44:15 +01:00
parent 9c88a34d99
commit 2901c7b627
6 changed files with 36 additions and 2 deletions

View file

@ -70,6 +70,11 @@ var ExperimnetTable = {
e.preventDefault();
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);
});
},
initArchiveMyModules: function() {
$('#archiveTask').on('click', (e) => {
@ -84,6 +89,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();
@ -299,6 +312,7 @@ var ExperimnetTable = {
this.initNewTaskModal(this);
this.initMyModuleActions();
this.updateExperimentToolbar();
this.initRestoreMyModules();
}
};

View file

@ -362,8 +362,13 @@ class MyModulesController < ApplicationController
else
flash[:error] = t('my_modules.restore_group.error_flash')
end
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
old_status_id = @my_module.my_module_status_id

View file

@ -70,7 +70,8 @@ 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),
access: edit_access_permissions_project_experiment_my_module_path(project, experiment, my_module)
access: edit_access_permissions_project_experiment_my_module_path(project, experiment, my_module),
restore: restore_my_modules_experiment_path(experiment)
}
}
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

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