mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-20 14:54:15 +01:00
(bug) child cannot be updated
This commit is contained in:
parent
8a3110cd0f
commit
ea83265b87
@ -30,7 +30,7 @@ class API::ChildrenController < API::APIController
|
|||||||
def update
|
def update
|
||||||
authorize @child
|
authorize @child
|
||||||
|
|
||||||
if @child.update(child_params)
|
if ChildService.update(@child, child_params)
|
||||||
render status: :ok
|
render status: :ok
|
||||||
else
|
else
|
||||||
render json: @child.errors.full_messages, status: :unprocessable_entity
|
render json: @child.errors.full_messages, status: :unprocessable_entity
|
||||||
|
@ -116,7 +116,7 @@ export const ChildForm: React.FC<ChildFormProps> = ({ child, onSubmit, supportin
|
|||||||
defaultFile={sf as FileType}
|
defaultFile={sf as FileType}
|
||||||
id={`supporting_document_files_attributes.${index}`}
|
id={`supporting_document_files_attributes.${index}`}
|
||||||
accept="application/pdf"
|
accept="application/pdf"
|
||||||
rules={{ required: true }}
|
rules={{ required: !sf.attachment }}
|
||||||
setValue={setValue}
|
setValue={setValue}
|
||||||
label={getSupportingDocumentsTypeName(sf.supporting_document_type_id)}
|
label={getSupportingDocumentsTypeName(sf.supporting_document_type_id)}
|
||||||
showRemoveButton={false}
|
showRemoveButton={false}
|
||||||
|
@ -28,7 +28,9 @@ class ChildService
|
|||||||
all_files_are_upload = true
|
all_files_are_upload = true
|
||||||
SupportingDocumentType.where(document_type: 'Child').each do |sdt|
|
SupportingDocumentType.where(document_type: 'Child').each do |sdt|
|
||||||
file = sdt.supporting_document_files.find_by(supportable: child)
|
file = sdt.supporting_document_files.find_by(supportable: child)
|
||||||
all_files_are_upload = false if file.nil? || file.attachment_identifier.nil?
|
if file.nil? || file.attachment_identifier.nil? || child_params['supporting_document_files_attributes']['0']['attachment'].blank?
|
||||||
|
all_files_are_upload = false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if all_files_are_upload
|
if all_files_are_upload
|
||||||
NotificationCenter.call type: 'notify_admin_user_child_supporting_document_files_updated',
|
NotificationCenter.call type: 'notify_admin_user_child_supporting_document_files_updated',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user