mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-04 19:53:19 +08:00
Merge pull request #8147 from aignatov-bio/ai-sci-11463-fix-archived-forms
Fix archived forms [SCI-11463]
This commit is contained in:
commit
fd36e6645b
5 changed files with 22 additions and 10 deletions
|
@ -21,7 +21,7 @@
|
|||
</h1>
|
||||
</div>
|
||||
<div class="flex items-center gap-4 ml-auto">
|
||||
<button v-if="preview && !this.form.attributes.published_on" class="btn btn-secondary"@click="preview = false">
|
||||
<button v-if="preview && !this.form.attributes.published_on && this.form.attributes.can_manage_form_draft" class="btn btn-secondary"@click="preview = false">
|
||||
<i class="sn-icon sn-icon-edit"></i>
|
||||
{{ i18n.t('forms.show.edit_form') }}
|
||||
</button>
|
||||
|
|
|
@ -16,13 +16,15 @@
|
|||
<div class="max-w-[800px] w-full rounded bg-sn-super-light-grey p-6 flex flex-col gap-4">
|
||||
<div class="flex items-center">
|
||||
<h3 class="my-1">{{ form.name }}</h3>
|
||||
<div v-if="this.formResponse.status == 'submitted'" class="ml-auto text-right text-xs text-sn-grey-700">
|
||||
{{ i18n.t('forms.response.submitted_on') }} {{ this.formResponse.submitted_at }}<br>
|
||||
{{ i18n.t('forms.response.by') }} {{ this.formResponse.submitted_by_full_name }}
|
||||
</div>
|
||||
<div v-else class="ml-auto text-right text-xs text-sn-grey-700">
|
||||
{{ i18n.t('forms.response.not_submitted') }}
|
||||
</div>
|
||||
<template v-if="!this.formResponse.in_repository">
|
||||
<div v-if="this.formResponse.status == 'submitted'" class="ml-auto text-right text-xs text-sn-grey-700">
|
||||
{{ i18n.t('forms.response.submitted_on') }} {{ this.formResponse.submitted_at }}<br>
|
||||
{{ i18n.t('forms.response.by') }} {{ this.formResponse.submitted_by_full_name }}
|
||||
</div>
|
||||
<div v-else class="ml-auto text-right text-xs text-sn-grey-700">
|
||||
{{ i18n.t('forms.response.not_submitted') }}
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<Field v-for="field in formFields" :disabled="formDisabled" ref="formFields" :key="field.id" :field="field" :formResponse="formResponse" @save="saveValue" />
|
||||
<div>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
Canaid::Permissions.register_for(Form) do
|
||||
%i(manage_form
|
||||
clone_form
|
||||
manage_form_draft
|
||||
publish_form)
|
||||
.each do |perm|
|
||||
can perm do |_, form|
|
||||
|
|
|
@ -4,7 +4,7 @@ class FormSerializer < ActiveModel::Serializer
|
|||
include Canaid::Helpers::PermissionsHelper
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
attributes :id, :name, :archived, :published_on, :published_by, :updated_at, :description, :urls
|
||||
attributes :id, :name, :archived, :published_on, :published_by, :updated_at, :description, :urls, :can_manage_form_draft
|
||||
|
||||
has_many :form_fields,
|
||||
key: :form_fields,
|
||||
|
@ -26,6 +26,11 @@ class FormSerializer < ActiveModel::Serializer
|
|||
I18n.l(object.updated_at, format: :full) if object.updated_at
|
||||
end
|
||||
|
||||
def can_manage_form_draft
|
||||
user = scope[:user] || @instance_options[:user]
|
||||
can_manage_form_draft?(user, object)
|
||||
end
|
||||
|
||||
def urls
|
||||
user = scope[:user] || @instance_options[:user]
|
||||
list = { show: form_path(object) }
|
||||
|
|
|
@ -4,7 +4,7 @@ class StepFormResponseSerializer < ActiveModel::Serializer
|
|||
include Canaid::Helpers::PermissionsHelper
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
attributes :id, :created_at, :form_id, :urls, :submitted_by_full_name, :status, :submitted_at, :parent_type
|
||||
attributes :id, :created_at, :form_id, :urls, :submitted_by_full_name, :status, :submitted_at, :parent_type, :in_repository
|
||||
|
||||
has_one :form, serializer: FormSerializer
|
||||
|
||||
|
@ -20,6 +20,10 @@ class StepFormResponseSerializer < ActiveModel::Serializer
|
|||
:step
|
||||
end
|
||||
|
||||
def in_repository
|
||||
!object.step.protocol.my_module
|
||||
end
|
||||
|
||||
def submitted_by_full_name
|
||||
object.submitted_by&.full_name
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue