misc id changes

pull/501/head
Mikhael Rakauskas 4 months ago
parent 1fc9d212ca
commit d881b9242c

@ -193,7 +193,7 @@ module Api
submitters: [[:send_email, :send_sms, :completed_redirect_url, :uuid, :name, :email, :role,
:completed, :phone, :application_key, :external_id, :reply_to, :go_to_last,
{ metadata: {}, values: {}, roles: [], readonly_fields: [], message: %i[subject body],
fields: [:name, :uuid, :default_value, :value, :title, :description,
fields: [:name, :uuid, :question_id, :default_value, :value, :title, :description,
:readonly, :required, :validation_pattern, :invalid_message,
{ default_value: [], value: [], preferences: {} }] }]]
}

@ -109,15 +109,16 @@ module Api
:external_id,
:shared_link,
{
external_data_fields: {},
submitters: [%i[name uuid is_requester invite_by_uuid optional_invite_by_uuid linked_to_uuid email]],
fields: [[:uuid, :submitter_uuid, :name, :type,
fields: [[:uuid, :question_id, :submitter_uuid, :name, :type,
:required, :readonly, :default_value,
:title, :description,
{ preferences: {},
conditions: [%i[field_uuid value action operation]],
options: [%i[value uuid]],
options: [%i[value uuid answer_id]],
validation: %i[message pattern],
areas: [%i[x y w h cell_w attachment_uuid option_uuid page]] }]]
areas: [%i[x y w h cell_w attachment_uuid option_uuid answer_id page]] }]]
}
]

@ -121,14 +121,15 @@ class TemplatesController < ApplicationController
:name,
{ schema: [[:attachment_uuid, :name, { conditions: [%i[field_uuid value action operation]] }]],
submitters: [%i[name uuid is_requester linked_to_uuid invite_by_uuid optional_invite_by_uuid email]],
fields: [[:uuid, :submitter_uuid, :name, :type,
external_data_fields: {},
fields: [[:uuid, :question_id, :submitter_uuid, :name, :type,
:required, :readonly, :default_value,
:title, :description,
{ preferences: {},
conditions: [%i[field_uuid value action operation]],
options: [%i[value uuid]],
options: [%i[value uuid answer_id]],
validation: %i[message pattern],
areas: [%i[x y w h cell_w attachment_uuid option_uuid page]] }]] }
areas: [%i[x y w h cell_w attachment_uuid option_uuid answer_id page]] }]] }
)
end

@ -6,7 +6,7 @@
#
# id :bigint not null, primary key
# archived_at :datetime
# external_data_fields :string
# external_data_fields :text
# fields :text not null
# name :string not null
# preferences :text not null
@ -52,6 +52,7 @@ class Template < ApplicationRecord
attribute :preferences, :string, default: -> { {} }
attribute :fields, :string, default: -> { [] }
attribute :schema, :string, default: -> { [] }
attribute :external_data_fields, :string, default: -> { {} }
attribute :submitters, :string, default: -> { [{ name: I18n.t(:first_party), uuid: SecureRandom.uuid }] }
attribute :slug, :string, default: -> { SecureRandom.base58(14) }
attribute :source, :string, default: 'native'
@ -60,6 +61,7 @@ class Template < ApplicationRecord
serialize :fields, coder: JSON
serialize :schema, coder: JSON
serialize :submitters, coder: JSON
serialize :external_data_fields, coder: JSON
has_many_attached :documents
@ -79,12 +81,6 @@ class Template < ApplicationRecord
external_id
end
def external_data_fields
return {} if self[:external_data_fields].blank?
JSON.parse(self[:external_data_fields])
end
private
def maybe_set_default_folder

@ -1,5 +1,5 @@
class AddExternalDataFieldsToTemplates < ActiveRecord::Migration[8.0]
def change
add_column :templates, :external_data_fields, :string
add_column :templates, :external_data_fields, :text
end
end

@ -393,7 +393,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_07_03_143236) do
t.string "external_id"
t.text "preferences", null: false
t.boolean "shared_link", default: false, null: false
t.string "external_data_fields"
t.text "external_data_fields"
t.index ["account_id", "folder_id", "id"], name: "index_templates_on_account_id_and_folder_id_and_id", where: "(archived_at IS NULL)"
t.index ["account_id", "id"], name: "index_templates_on_account_id_and_id_archived", where: "(archived_at IS NOT NULL)"
t.index ["account_id"], name: "index_templates_on_account_id"

Loading…
Cancel
Save