Fix number block double submission [SCI-11864]

This commit is contained in:
Anton 2025-04-23 12:38:37 +02:00
parent 9fa6889d2b
commit e07cbb6492
3 changed files with 8 additions and 1 deletions

View file

@ -30,7 +30,6 @@
:disabled="disabled"
:value="modelValue"
@input="$emit('update:modelValue', $event.target.value)"
@change="$emit('change', $event.target.value)"
class="outline-none shadow-none placeholder:text-sn-grey rounded h-full border border-sn-sleepy-grey bg-white w-full px-4 focus:border-sn-science-blue"
:class="{
'!bg-sn-super-light-grey ': disabled,

View file

@ -7,6 +7,7 @@ class FormFieldValue < ApplicationRecord
belongs_to :submitted_by, class_name: 'User'
validate :not_applicable_values
validate :uniqueness_latest, if: :latest?
scope :latest, -> { where(latest: true) }
@ -37,4 +38,10 @@ class FormFieldValue < ApplicationRecord
errors.add(:value, :not_applicable) if value.present?
end
def uniqueness_latest
return unless form_response.form_field_values.exists?(form_field_id: form_field_id, latest: true)
errors.add(:value, :not_unique_latest)
end
end

View file

@ -264,6 +264,7 @@ en:
attributes:
value:
not_applicable: "Field is not applicable"
not_unique_latest: "Latest field value already exists"
storage_location:
missing_position: 'Missing position metadata'
not_uniq_position: 'Position already taken'