From 53039ba5eea45d6cc10c5eb8008c27be84de6031 Mon Sep 17 00:00:00 2001 From: wandji20 Date: Thu, 29 Feb 2024 13:18:58 +0100 Subject: [PATCH] Improve code [SCI-10292] --- app/javascript/vue/experiments/list.vue | 4 ++-- app/javascript/vue/experiments/modals/move.vue | 5 ++--- app/serializers/lists/experiment_serializer.rb | 1 - app/services/toolbars/experiments_service.rb | 3 ++- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/javascript/vue/experiments/list.vue b/app/javascript/vue/experiments/list.vue index 65e46f7ed..733079252 100644 --- a/app/javascript/vue/experiments/list.vue +++ b/app/javascript/vue/experiments/list.vue @@ -240,9 +240,9 @@ export default { duplicate(_e, experiment) { [this.duplicateModalObject] = experiment; }, - move(_e, rows) { + move(event, rows) { [this.moveModalObject] = rows; - this.moveModalObject.experimentIds = rows.map((exp) => exp.id); + this.moveModalObject.movePath = event.path; }, edit(_e, experiment) { [this.editModalObject] = experiment; diff --git a/app/javascript/vue/experiments/modals/move.vue b/app/javascript/vue/experiments/modals/move.vue index 25fa990c4..ccc73f231 100644 --- a/app/javascript/vue/experiments/modals/move.vue +++ b/app/javascript/vue/experiments/modals/move.vue @@ -54,9 +54,8 @@ export default { methods: { async submit() { this.disableSubmit = true; - await axios.post(this.experiment.urls.move, { - project_id: this.targetProject, - ids: this.experiment.experimentIds + await axios.post(this.experiment.movePath, { + project_id: this.targetProject }).then((response) => { this.$emit('move'); window.location.replace(response.data.path); diff --git a/app/serializers/lists/experiment_serializer.rb b/app/serializers/lists/experiment_serializer.rb index 37f0fd003..1cda27c8c 100644 --- a/app/serializers/lists/experiment_serializer.rb +++ b/app/serializers/lists/experiment_serializer.rb @@ -69,7 +69,6 @@ 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), diff --git a/app/services/toolbars/experiments_service.rb b/app/services/toolbars/experiments_service.rb index 58fd9b234..8c4df32b8 100644 --- a/app/services/toolbars/experiments_service.rb +++ b/app/services/toolbars/experiments_service.rb @@ -87,7 +87,8 @@ module Toolbars name: 'move', label: I18n.t('experiments.toolbar.move_button'), icon: 'sn-icon sn-icon-move', - type: :emit + type: :emit, + path: move_experiments_path(ids: @experiments.pluck(:id)) } end