mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-11 15:45:34 +08:00
Merge pull request #8353 from aignatov-bio/ai-sci-11646-add-sa-to-text-form-field
Add SA to text form field [SCI-11646]
This commit is contained in:
commit
cc79bad19e
4 changed files with 64 additions and 14 deletions
|
@ -128,9 +128,22 @@ module ReportsHelper
|
|||
form_response.form.form_fields&.map do |form_field|
|
||||
form_field_value = form_field_values.find_by(form_field_id: form_field.id, latest: true)
|
||||
|
||||
value = if form_field_value&.not_applicable
|
||||
I18n.t('forms.export.values.not_applicable')
|
||||
elsif form_field_value.is_a?(FormTextFieldValue)
|
||||
custom_auto_link(
|
||||
form_field_value&.formatted,
|
||||
simple_format: false,
|
||||
tags: %w(img),
|
||||
team: current_team
|
||||
)
|
||||
else
|
||||
form_field_value&.formatted
|
||||
end
|
||||
|
||||
{
|
||||
name: form_field.name,
|
||||
value: form_field_value&.not_applicable ? I18n.t('forms.export.values.not_applicable') : form_field_value&.formatted.to_s,
|
||||
value: value,
|
||||
submitted_at: form_field_value&.submitted_at&.utc.to_s,
|
||||
submitted_by: form_field_value&.submitted_by&.full_name.to_s
|
||||
}
|
||||
|
|
|
@ -1,17 +1,25 @@
|
|||
<template>
|
||||
<div class="sci-input-container-v2 h-24 mb-1" :class="{'error': !validValue}" :data-error="valueFieldError">
|
||||
<textarea
|
||||
class="sci-input"
|
||||
:value="value"
|
||||
ref="input"
|
||||
:disabled="fieldDisabled"
|
||||
@change="saveValue"
|
||||
:placeholder="fieldDisabled ? '' : i18n.t('forms.fields.add_text')"></textarea>
|
||||
<div>
|
||||
<div v-if="!fieldDisabled" class="sci-input-container-v2 h-24 mb-1" :class="{'error': !validValue}" :data-error="valueFieldError">
|
||||
<textarea
|
||||
class="sci-input"
|
||||
:value="value"
|
||||
ref="input"
|
||||
@blur="saveValue"
|
||||
:placeholder="fieldDisabled ? '' : i18n.t('forms.fields.add_text')"></textarea>
|
||||
</div>
|
||||
<div v-else
|
||||
ref="fieldValue"
|
||||
class="rounded min-h-[120px] border py-2 w-full px-4 bg-sn-super-light-grey border-sn-grey" >
|
||||
<span>
|
||||
{{ value }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/* global GLOBAL_CONSTANTS */
|
||||
/* global GLOBAL_CONSTANTS SmartAnnotation */
|
||||
|
||||
import fieldMixin from './field_mixin';
|
||||
|
||||
|
@ -30,10 +38,18 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.fieldDisabled) {
|
||||
window.renderElementSmartAnnotations(this.$refs.fieldValue, 'span');
|
||||
} else {
|
||||
SmartAnnotation.init($(this.$refs.input), false);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
saveValue(event) {
|
||||
this.value = event.target.value;
|
||||
if (this.validValue) {
|
||||
const noActiveSA = [...document.querySelectorAll('.atwho-view')].every((el) => !el.style.display || el.style.display !== 'block');
|
||||
if (this.validValue && noActiveSA) {
|
||||
this.$emit('save', this.value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ module Reports
|
|||
def draw_step_forms(element)
|
||||
return unless @settings.dig('task', 'protocol', 'step_forms')
|
||||
|
||||
team = @report_team
|
||||
user = @user
|
||||
form_response = element.orderable
|
||||
color = @color
|
||||
form_fields = form_response.form.form_fields
|
||||
|
@ -20,9 +22,16 @@ module Reports
|
|||
|
||||
form_fields&.each do |form_field|
|
||||
form_field_value = form_field_values.find_by(form_field_id: form_field.id, latest: true)
|
||||
value = if form_field_value&.not_applicable
|
||||
I18n.t('forms.export.values.not_applicable')
|
||||
elsif form_field_value.is_a?(FormTextFieldValue)
|
||||
SmartAnnotations::TagToText.new(user, team, form_field_value&.formatted).text
|
||||
else
|
||||
form_field_value&.formatted
|
||||
end
|
||||
table << [
|
||||
form_field.name,
|
||||
form_field_value&.not_applicable ? I18n.t('forms.export.values.not_applicable') : form_field_value&.formatted.to_s,
|
||||
value,
|
||||
form_field_value&.submitted_at&.utc.to_s,
|
||||
form_field_value&.submitted_by&.full_name.to_s
|
||||
]
|
||||
|
|
|
@ -28,7 +28,12 @@
|
|||
</div>
|
||||
<% if field.description %>
|
||||
<div>
|
||||
<%= field.description %>
|
||||
<%= custom_auto_link(
|
||||
field.description,
|
||||
simple_format: false,
|
||||
tags: %w(img),
|
||||
team: current_team
|
||||
) %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="mt-2">
|
||||
|
@ -44,7 +49,14 @@
|
|||
<% else %>
|
||||
<span class='iso-formatted-date <%= 'only-date' unless field.data['time'] %>'><%= field_value.datetime&.iso8601 %></span>
|
||||
<% end %>
|
||||
<% else%>
|
||||
<% elsif field_value.is_a?(FormTextFieldValue)%>
|
||||
<%= custom_auto_link(
|
||||
field_value.formatted,
|
||||
simple_format: false,
|
||||
tags: %w(img),
|
||||
team: current_team
|
||||
) %>
|
||||
<% else %>
|
||||
<%= field_value.formatted %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
|
|
Loading…
Add table
Reference in a new issue