{
+ return acc + doc.metadata?.pdf?.number_of_pages || doc.preview_images.length
+ }, 0)
+ },
isShowFieldSearch () {
if (this.withFieldsSearch === false) {
return false
@@ -389,6 +430,68 @@ export default {
this.$emit('set-drag', field)
},
+ detectFields () {
+ const fields = []
+
+ this.fieldPagesLoaded = 0
+
+ this.baseFetch(`/templates/${this.template.id}/detect_fields`, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ }
+ }).then(async (response) => {
+ const reader = response.body.getReader()
+ const decoder = new TextDecoder('utf-8')
+ let buffer = ''
+
+ while (true) {
+ const { value, done } = await reader.read()
+
+ if (done) break
+
+ buffer += decoder.decode(value, { stream: true })
+
+ const lines = buffer.split('\n\n')
+
+ buffer = lines.pop()
+
+ for (const line of lines) {
+ if (line.startsWith('data: ')) {
+ const jsonStr = line.replace(/^data: /, '')
+ const data = JSON.parse(jsonStr)
+
+ if (data.error) {
+ alert(data.error)
+
+ break
+ } else if (data.completed) {
+ this.fieldPagesLoaded = null
+ this.template.fields = fields
+ this.save()
+
+ break
+ } else if (data.fields) {
+ data.fields.forEach((f) => {
+ if (!f.submitter_uuid) {
+ f.submitter_uuid = this.template.submitters[0].uuid
+ }
+ })
+
+ this.fieldPagesLoaded += 1
+
+ fields.push(...data.fields)
+ }
+ }
+ }
+ }
+ }).catch(error => {
+ console.error('Error in streaming message: ', error)
+ }).finally(() => {
+ this.fieldPagesLoaded = null
+ this.isFieldsLoading = false
+ })
+ },
setDragPlaceholder (event) {
this.$emit('set-drag-placeholder', {
offsetX: event.offsetX,
diff --git a/app/javascript/template_builder/i18n.js b/app/javascript/template_builder/i18n.js
index 75b450fe..a23e5c8b 100644
--- a/app/javascript/template_builder/i18n.js
+++ b/app/javascript/template_builder/i18n.js
@@ -1,5 +1,6 @@
const en = {
view: 'View',
+ autodetect_fields: 'Autodetect fields',
payment_link: 'Payment link',
strikeout: 'Strikeout',
draw_strikethrough_the_document: 'Draw strikethrough the document',
diff --git a/app/views/submissions/_value.html.erb b/app/views/submissions/_value.html.erb
index 025053ef..f0487425 100644
--- a/app/views/submissions/_value.html.erb
+++ b/app/views/submissions/_value.html.erb
@@ -1,10 +1,11 @@
<% align = field.dig('preferences', 'align') %>
<% valign = field.dig('preferences', 'valign') %>
<% color = field.dig('preferences', 'color') %>
+<% bg_color = field.dig('preferences', 'background') %>
<% font = field.dig('preferences', 'font') %>
<% font_type = field.dig('preferences', 'font_type') %>
<% font_size_px = (field.dig('preferences', 'font_size').presence || Submissions::GenerateResultAttachments::FONT_SIZE).to_i * local_assigns.fetch(:font_scale) { 1000.0 / PdfUtils::US_LETTER_W } %>
-
width: <%= area['w'] * 100 %>%; height: <%= area['h'] * 100 %>%; left: <%= area['x'] * 100 %>%; top: <%= area['y'] * 100 %>%; font-size: <%= fs = "clamp(1pt, #{font_size_px / 10}vw, #{font_size_px}px)" %>; line-height: calc(<%= fs %> * 1.3); font-size: <%= fs = "#{font_size_px / 10}cqmin" %>; line-height: calc(<%= fs %> * 1.3)">
+<%= "background: #{bg_color}; " if bg_color.present? %>width: <%= area['w'] * 100 %>%; height: <%= area['h'] * 100 %>%; left: <%= area['x'] * 100 %>%; top: <%= area['y'] * 100 %>%; font-size: <%= fs = "clamp(1pt, #{font_size_px / 10}vw, #{font_size_px}px)" %>; line-height: calc(<%= fs %> * 1.3); font-size: <%= fs = "#{font_size_px / 10}cqmin" %>; line-height: calc(<%= fs %> * 1.3)">
<% if field['type'] == 'signature' %>
<% is_narrow = area['h']&.positive? && (area['w'].to_f / area['h']) > 6 %>
diff --git a/app/views/submissions_preview/completed.html.erb b/app/views/submissions_preview/completed.html.erb
index f8346117..60370a46 100644
--- a/app/views/submissions_preview/completed.html.erb
+++ b/app/views/submissions_preview/completed.html.erb
@@ -38,14 +38,6 @@
<%= f.button button_title(title: t('send_copy_to_email'), disabled_with: t('starting')), class: 'base-button' %>
<% end %>
- <% if Docuseal.multitenant? %>
-
<%= t('or') %>
- <% end %>
- <% end %>
- <% if Docuseal.multitenant? %>
-
- <%= link_to t('create_free_account'), registration_path, class: 'white-button w-full' %>
-
<% end %>
diff --git a/app/views/templates/edit.html.erb b/app/views/templates/edit.html.erb
index 79a10118..9fbc8d39 100644
--- a/app/views/templates/edit.html.erb
+++ b/app/views/templates/edit.html.erb
@@ -6,4 +6,4 @@
<%= button_to nil, user_configs_path, method: :post, params: { user_config: { key: UserConfig::SHOW_APP_TOUR, value: true } }, class: 'hidden', id: 'start_tour_button' %>
<% end %>
<% end %>
-