Merge pull request #6177 from artoscinote/ma_SCI_9267

Fix attachment sorting in results [SCI-9267]
This commit is contained in:
Martin Artnik 2023-09-11 10:01:26 +02:00 committed by GitHub
commit 8c3ff1813a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 13 deletions

View file

@ -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

View file

@ -47,17 +47,16 @@
</div>
</div>
<div class="attachments" :data-parent-id="parent.id">
<template v-for="(attachment, index) in attachmentsOrdered">
<component
:is="attachment_view_mode(attachmentsOrdered[index])"
:key="attachment.id"
:attachment="attachment"
:parentId="parseInt(parent.id)"
@attachment:viewMode="updateAttachmentViewMode"
@attachment:delete="deleteAttachment(attachment.id)"
@attachment:moved="attachmentMoved"
/>
</template>
<component
v-for="(attachment, index) in attachmentsOrdered"
:key="attachment.id"
:is="attachment_view_mode(attachmentsOrdered[index])"
:attachment="attachment"
:parentId="parseInt(parent.id)"
@attachment:viewMode="updateAttachmentViewMode"
@attachment:delete="deleteAttachment(attachment.id)"
@attachment:moved="attachmentMoved"
/>
</div>
</div>
</template>

View file

@ -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