mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-28 16:08: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
|
def update_view_state
|
||||||
view_state = @result.current_view_state(current_user)
|
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?
|
view_state.save! if view_state.changed?
|
||||||
|
|
||||||
render json: {}, status: :ok
|
render json: {}, status: :ok
|
||||||
|
|
|
@ -47,17 +47,16 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="attachments" :data-parent-id="parent.id">
|
<div class="attachments" :data-parent-id="parent.id">
|
||||||
<template v-for="(attachment, index) in attachmentsOrdered">
|
<component
|
||||||
<component
|
v-for="(attachment, index) in attachmentsOrdered"
|
||||||
:is="attachment_view_mode(attachmentsOrdered[index])"
|
:key="attachment.id"
|
||||||
:key="attachment.id"
|
:is="attachment_view_mode(attachmentsOrdered[index])"
|
||||||
:attachment="attachment"
|
:attachment="attachment"
|
||||||
:parentId="parseInt(parent.id)"
|
:parentId="parseInt(parent.id)"
|
||||||
@attachment:viewMode="updateAttachmentViewMode"
|
@attachment:viewMode="updateAttachmentViewMode"
|
||||||
@attachment:delete="deleteAttachment(attachment.id)"
|
@attachment:delete="deleteAttachment(attachment.id)"
|
||||||
@attachment:moved="attachmentMoved"
|
@attachment:moved="attachmentMoved"
|
||||||
/>
|
/>
|
||||||
</template>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -9,7 +9,7 @@ class ResultSerializer < ActiveModel::Serializer
|
||||||
|
|
||||||
attributes :name, :id, :urls, :updated_at, :created_at_formatted, :updated_at_formatted, :user,
|
attributes :name, :id, :urls, :updated_at, :created_at_formatted, :updated_at_formatted, :user,
|
||||||
:my_module_id, :attachments_manageble, :marvinjs_enabled, :marvinjs_context, :type,
|
: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
|
def marvinjs_enabled
|
||||||
MarvinJsService.enabled?
|
MarvinJsService.enabled?
|
||||||
|
@ -55,6 +55,10 @@ class ResultSerializer < ActiveModel::Serializer
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def assets_order
|
||||||
|
object.current_view_state(current_user).state.dig('assets', 'sort') unless object.destroyed?
|
||||||
|
end
|
||||||
|
|
||||||
def attachments_manageble
|
def attachments_manageble
|
||||||
can_manage_result?(object)
|
can_manage_result?(object)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue