detect fields autosave false

pull/721/head
Pete Matsyburka 3 weeks ago
parent 033ce3a169
commit 436d947f6a

@ -10,8 +10,14 @@ class TemplatesDetectFieldsController < ApplicationController
sse = SSE.new(response.stream)
documents = @template.schema_documents.preload(:blob)
documents = documents.where(uuid: params[:attachment_uuid]) if params[:attachment_uuid].present?
documents =
if params[:attachment_uuid].present?
@template.documents.where(uuid: params[:attachment_uuid])
else
@template.schema_documents
end
documents = documents.preload(:blob)
page_number = params[:page].presence&.to_i

@ -555,8 +555,10 @@ export default {
return this.template.schema.some((item) => item.dynamic)
},
numberOfPages () {
return this.template.documents.reduce((acc, doc) => {
return acc + doc.metadata?.pdf?.number_of_pages || doc.preview_images.length
return this.template.schema.reduce((acc, item) => {
const doc = this.template.documents.find((d) => d.uuid === item.attachment_uuid)
return acc + (doc?.metadata?.pdf?.number_of_pages || doc?.preview_images?.length || 0)
}, 0)
},
isShowFieldSearch () {
@ -774,9 +776,10 @@ export default {
headers: {
'Content-Type': 'application/json'
},
...(this.withDetectExistingFields
? { body: JSON.stringify({ fields: this.buildExistingFields() }) }
: {})
body: JSON.stringify({
attachment_uuid: this.template.schema.map((item) => item.attachment_uuid),
...(this.withDetectExistingFields ? { fields: this.buildExistingFields() } : {})
})
}).then(async (response) => {
const reader = response.body.getReader()
const decoder = new TextDecoder('utf-8')

Loading…
Cancel
Save