mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 13:13:22 +08:00
Merge pull request #6177 from artoscinote/ma_SCI_9267
Fix attachment sorting in results [SCI-9267]
This commit is contained in:
commit
8c3ff1813a
3 changed files with 16 additions and 13 deletions
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue