From ede9e40be8d605792e39fa185ccc4b156c920f3c Mon Sep 17 00:00:00 2001 From: Martin Artnik Date: Fri, 8 Sep 2023 16:07:43 +0200 Subject: [PATCH] Fix attachment sorting in results [SCI-9267] --- app/controllers/results_controller.rb | 2 +- .../vue/shared/content/attachments.vue | 21 +++++++++---------- app/serializers/result_serializer.rb | 6 +++++- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/controllers/results_controller.rb b/app/controllers/results_controller.rb index f32b977c4..1ca4df48f 100644 --- a/app/controllers/results_controller.rb +++ b/app/controllers/results_controller.rb @@ -106,7 +106,7 @@ class ResultsController < ApplicationController def update_view_state view_state = @result.current_view_state(current_user) - view_state.state['result_assets']['sort'] = params.require(:assets).require(:order) + view_state.state['assets']['sort'] = params.require(:assets).require(:order) view_state.save! if view_state.changed? render json: {}, status: :ok diff --git a/app/javascript/vue/shared/content/attachments.vue b/app/javascript/vue/shared/content/attachments.vue index 66d45cb5d..5f1a6a4f1 100644 --- a/app/javascript/vue/shared/content/attachments.vue +++ b/app/javascript/vue/shared/content/attachments.vue @@ -47,17 +47,16 @@
- +
diff --git a/app/serializers/result_serializer.rb b/app/serializers/result_serializer.rb index f77f490ad..694782d5d 100644 --- a/app/serializers/result_serializer.rb +++ b/app/serializers/result_serializer.rb @@ -9,7 +9,7 @@ class ResultSerializer < ActiveModel::Serializer attributes :name, :id, :urls, :updated_at, :created_at_formatted, :updated_at_formatted, :user, :my_module_id, :attachments_manageble, :marvinjs_enabled, :marvinjs_context, :type, - :wopi_enabled, :wopi_context, :created_at, :created_by, :archived + :wopi_enabled, :wopi_context, :created_at, :created_by, :archived, :assets_order def marvinjs_enabled MarvinJsService.enabled? @@ -55,6 +55,10 @@ class ResultSerializer < ActiveModel::Serializer } end + def assets_order + object.current_view_state(current_user).state.dig('assets', 'sort') unless object.destroyed? + end + def attachments_manageble can_manage_result?(object) end