mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2026-01-07 00:36:08 +08:00
Fix issue moving experiments [SCI-10292]
This commit is contained in:
parent
3f4189445b
commit
b59392b932
4 changed files with 17 additions and 15 deletions
|
|
@ -11,6 +11,7 @@ class ExperimentsController < ApplicationController
|
|||
before_action :load_project, only: %i(index create archive_group restore_group move)
|
||||
before_action :load_experiment, except: %i(create archive_group restore_group
|
||||
inventory_assigning_experiment_filter actions_toolbar index move)
|
||||
before_action :load_experiments, only: :move
|
||||
before_action :check_read_permissions, except: %i(index edit archive clone move new
|
||||
create archive_group restore_group
|
||||
inventory_assigning_experiment_filter actions_toolbar)
|
||||
|
|
@ -20,7 +21,6 @@ class ExperimentsController < ApplicationController
|
|||
before_action :check_update_permissions, only: :update
|
||||
before_action :check_archive_permissions, only: :archive
|
||||
before_action :check_clone_permissions, only: %i(clone_modal clone)
|
||||
before_action :check_move_permissions, only: %i(move_modal move)
|
||||
before_action :set_inline_name_editing, only: %i(index canvas module_archive)
|
||||
before_action :set_breadcrumbs_items, only: %i(index canvas module_archive)
|
||||
before_action :set_navigator, only: %i(index canvas module_archive)
|
||||
|
|
@ -231,8 +231,10 @@ class ExperimentsController < ApplicationController
|
|||
render json: tags
|
||||
end
|
||||
|
||||
# POST: move_experiment(id)
|
||||
# POST: move_experiments(ids)
|
||||
def move
|
||||
return render_403 unless @experiments.all? { |e| can_move_experiment?(e) }
|
||||
|
||||
@project.transaction do
|
||||
@experiments.each do |experiment|
|
||||
service = Experiments::MoveToProjectService
|
||||
|
|
@ -495,10 +497,6 @@ class ExperimentsController < ApplicationController
|
|||
render_403 unless can_clone_experiment?(@experiment)
|
||||
end
|
||||
|
||||
def check_move_permissions
|
||||
render_403 unless @experiments.all? { |e| can_move_experiment?(e) }
|
||||
end
|
||||
|
||||
def set_inline_name_editing
|
||||
if @experiment
|
||||
return unless can_manage_experiment?(@experiment)
|
||||
|
|
|
|||
|
|
@ -240,8 +240,9 @@ export default {
|
|||
duplicate(_e, experiment) {
|
||||
[this.duplicateModalObject] = experiment;
|
||||
},
|
||||
move(_e, experiment) {
|
||||
[this.moveModalObject] = experiment;
|
||||
move(_e, rows) {
|
||||
[this.moveModalObject] = rows;
|
||||
this.moveModalObject.experimentIds = rows.map((exp) => exp.id);
|
||||
},
|
||||
edit(_e, experiment) {
|
||||
[this.editModalObject] = experiment;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ i18n.t('general.cancel') }}</button>
|
||||
<button class="btn btn-primary" :disabled="!targetProject" type="submit">
|
||||
<button class="btn btn-primary" :disabled="!targetProject || disableSubmit" type="submit">
|
||||
{{ i18n.t('experiments.move.modal_submit') }}
|
||||
</button>
|
||||
</div>
|
||||
|
|
@ -48,20 +48,22 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
targetProject: null,
|
||||
disableSubmit: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
axios.post(this.experiment.urls.move, {
|
||||
experiment: {
|
||||
project_id: this.targetProject,
|
||||
},
|
||||
async submit() {
|
||||
this.disableSubmit = true;
|
||||
await axios.post(this.experiment.urls.move, {
|
||||
project_id: this.targetProject,
|
||||
ids: this.experiment.experimentIds
|
||||
}).then((response) => {
|
||||
this.$emit('move');
|
||||
HelperModule.flashAlertMsg(response.data.message, 'success');
|
||||
window.location.replace(response.data.path);
|
||||
}).catch((error) => {
|
||||
HelperModule.flashAlertMsg(error.response.data.message, 'danger');
|
||||
});
|
||||
this.disableSubmit = false;
|
||||
},
|
||||
changeProject(project) {
|
||||
this.targetProject = project;
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ module Lists
|
|||
actions: actions_toolbar_experiments_path(items: [{ id: object.id }].to_json),
|
||||
projects_to_clone: projects_to_clone_experiment_path(object),
|
||||
projects_to_move: projects_to_move_experiment_path(object),
|
||||
move: move_experiments_path,
|
||||
clone: clone_experiment_path(object),
|
||||
update: experiment_path(object),
|
||||
show_access: access_permissions_experiment_path(object),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue