Merge pull request #6132 from G-Chubinidze/gc_SCI_9179

Archiving results doesn't work [SCI-9179]
This commit is contained in:
artoscinote 2023-09-05 10:53:43 +02:00 committed by GitHub
commit c59ee1c358
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 2 deletions

View file

@ -14,7 +14,7 @@ class ResultsController < ApplicationController
respond_to do |format|
format.json do
# API endpoint
@results = @my_module.results
@results = @my_module.results.active
apply_sort!
apply_filters!
@ -46,6 +46,27 @@ class ResultsController < ApplicationController
render json: @result
end
def archive
result = @my_module.results.find(params[:result_id])
result.archive(current_user)
if result.save
Activities::CreateActivityService
.call(activity_type: :destroy_result,
owner: current_user,
subject: result,
team: @my_module.team,
project: @my_module.project,
message_items: { result: result.id })
flash[:success] = t('my_modules.module_archive.archive_flash',
result: result.name,
module: @my_module.name)
redirect_to my_module_results_path(@my_module)
end
end
def elements
render json: @result.result_orderable_elements.order(:position),
each_serializer: ResultOrderableElementSerializer,

View file

@ -332,7 +332,12 @@
});
},
archiveResult() {
if (this.urls.archive_url) {
axios.post(this.urls.archive_url).then((response) => {
this.$emit('resultArchived', response.data);
location.reload();
});
}
},
duplicateResult() {
axios.post(this.urls.duplicate_url).then((_) => {

View file

@ -73,6 +73,7 @@ class ResultSerializer < ActiveModel::Serializer
if can_manage_result?(object)
urls_list.merge!({
delete_url: result_path(object),
archive_url: my_module_result_archive_path(object.my_module, object),
update_url: my_module_result_path(object.my_module, object),
create_table_url: my_module_result_tables_path(object.my_module, object),
create_text_url: my_module_result_texts_path(object.my_module, object),

View file

@ -1141,6 +1141,7 @@ en:
option_delete: "Delete"
confirm_delete: "Are you sure you want to permanently delete result?"
delete_flash: "Successfully removed result <strong>%{result}</strong> from task <strong>%{module}</strong>."
archive_flash: "Successfully archived result <strong>%{result}</strong> in task <strong>%{module}</strong>"
archived_on: "Archived on"
archived_on_title: "Result archived on %{date} at %{time}."
option_download: "Download"

View file

@ -555,6 +555,7 @@ Rails.application.routes.draw do
post :duplicate
end
end
post 'archive', to: 'results#archive'
end
end