mirror of https://github.com/docusealco/docuseal
parent
545b18086a
commit
187b354605
@ -0,0 +1,20 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class PersonalizationSettingsController < ApplicationController
|
||||||
|
def show; end
|
||||||
|
|
||||||
|
def create
|
||||||
|
account_config =
|
||||||
|
current_account.account_configs.find_or_initialize_by(key: encrypted_config_params[:key])
|
||||||
|
|
||||||
|
account_config.update!(encrypted_config_params)
|
||||||
|
|
||||||
|
redirect_back(fallback_location: settings_personalization_path, notice: 'Settings have been saved.')
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def encrypted_config_params
|
||||||
|
params.require(:account_config).permit!
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: account_configs
|
||||||
|
#
|
||||||
|
# id :bigint not null, primary key
|
||||||
|
# key :string not null
|
||||||
|
# value :text not null
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
# account_id :bigint not null
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_account_configs_on_account_id (account_id)
|
||||||
|
# index_account_configs_on_account_id_and_key (account_id,key) UNIQUE
|
||||||
|
#
|
||||||
|
# Foreign Keys
|
||||||
|
#
|
||||||
|
# fk_rails_... (account_id => accounts.id)
|
||||||
|
#
|
||||||
|
class AccountConfig < ApplicationRecord
|
||||||
|
SUBMITTER_INVITATION_EMAIL_KEY = 'submitter_invitation_email'
|
||||||
|
|
||||||
|
DEFAULT_VALUES = {
|
||||||
|
SUBMITTER_INVITATION_EMAIL_KEY => {
|
||||||
|
'subject' => 'You have been invited to submit a form',
|
||||||
|
'body' => "Hi there,\n\n" \
|
||||||
|
"You have been invited to submit the \"{{template.name}}\" form:\n\n" \
|
||||||
|
"{{submitter.link}}\n\n" \
|
||||||
|
"Please contact us by replying to this email if you didn't request this.\n\n" \
|
||||||
|
"Thanks,\n" \
|
||||||
|
'{{account.name}}'
|
||||||
|
}
|
||||||
|
}.freeze
|
||||||
|
|
||||||
|
belongs_to :account
|
||||||
|
|
||||||
|
serialize :value, JSON
|
||||||
|
end
|
||||||
@ -0,0 +1 @@
|
|||||||
|
<%= render 'logo_placeholder' %>
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
<div class="alert my-4">
|
||||||
|
<%= svg_icon('info_circle', class: 'w-6 h-6') %>
|
||||||
|
<div>
|
||||||
|
<p class="font-bold">Unlock with DocuSeal Enterprise</p>
|
||||||
|
<p>
|
||||||
|
Display your company name and logo when signing documents.
|
||||||
|
<br>
|
||||||
|
<a class="link font-medium" target="_blank" href="<%= Docuseal::PRODUCT_URL + '/pricing' %>">Learn More</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
<div class="flex flex-wrap space-y-4 md:flex-nowrap md:space-y-0">
|
||||||
|
<%= render 'shared/settings_nav' %>
|
||||||
|
<div class="flex-grow max-w-xl mx-auto">
|
||||||
|
<p class="text-4xl font-bold mb-4">Signature Request Email</p>
|
||||||
|
<%= form_for AccountConfigs.find_or_initialize_for_key(current_account, AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY), url: settings_personalization_path, method: :post, html: { autocomplete: 'off', class: 'space-y-4' } do |f| %>
|
||||||
|
<%= f.hidden_field :key %>
|
||||||
|
<%= f.fields_for :value, OpenStruct.new(f.object.value) do |ff| %>
|
||||||
|
<div class="form-control">
|
||||||
|
<%= ff.label :subject, class: 'label' %>
|
||||||
|
<%= ff.text_field :subject, required: true, class: 'base-input' %>
|
||||||
|
</div>
|
||||||
|
<div class="form-control">
|
||||||
|
<%= ff.label :body, class: 'label' %>
|
||||||
|
<autoresize-textarea>
|
||||||
|
<%= ff.text_area :body, required: true, class: 'base-input w-full py-2' %>
|
||||||
|
</autoresize-textarea>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<div class="form-control pt-2">
|
||||||
|
<%= f.button button_title(title: 'Save', disabled_with: 'Saving'), class: 'base-button' %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<p class="text-4xl font-bold mb-4 mt-8">Company Logo</p>
|
||||||
|
<%= render 'logo_form' %>
|
||||||
|
</div>
|
||||||
|
<div class="w-0 md:w-52"></div>
|
||||||
|
</div>
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
<p>
|
||||||
|
---
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Sent using <a href="<%= Docuseal::PRODUCT_URL %>"><%= Docuseal::PRODUCT_NAME %></a> free document signing.
|
||||||
|
</p>
|
||||||
@ -0,0 +1 @@
|
|||||||
|
<%= render 'shared/email_attribution' %>
|
||||||
@ -0,0 +1 @@
|
|||||||
|
<%= render 'docuseal_logo' %>
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
<a href="/" class="flex justify-center items-center">
|
||||||
|
<span class="mr-3">
|
||||||
|
<%= render 'shared/logo', width: '50px', height: '50px' %>
|
||||||
|
</span>
|
||||||
|
<h1 class="text-5xl font-bold text-center">DocuSeal</h1>
|
||||||
|
</a>
|
||||||
@ -0,0 +1 @@
|
|||||||
|
<%= render 'docuseal_logo' %>
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
<a href="<%= root_path %>" class="mx-auto text-2xl md:text-3xl font-bold items-center flex space-x-3">
|
||||||
|
<%= render 'shared/logo', class: 'w-9 h-9 md:w-12 md:h-12' %>
|
||||||
|
<span><%= Docuseal::PRODUCT_NAME %></span>
|
||||||
|
</a>
|
||||||
@ -1,7 +1,11 @@
|
|||||||
<p>Hi there,</p>
|
<% if @email_config %>
|
||||||
<%= simple_format(@message) %>
|
<%= auto_link(simple_format(h(ReplaceEmailVariables.call(@email_config.value['body'], submitter: @submitter)))) %>
|
||||||
<p><%= link_to 'Submit Form', submit_form_url(slug: @submitter.slug) %></p>
|
<% else %>
|
||||||
<p>Please contact us by replying to this email if you didn't request this.</p>
|
<p>Hi there,</p>
|
||||||
<p>
|
<%= simple_format(@message) %>
|
||||||
Thanks,<br><%= @submitter.submission.template.account.name %>
|
<p><%= link_to 'Submit Form', submit_form_url(slug: @submitter.slug) %></p>
|
||||||
</p>
|
<p>Please contact us by replying to this email if you didn't request this.</p>
|
||||||
|
<p>
|
||||||
|
Thanks,<br><%= @current_account.name %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
|||||||
@ -0,0 +1,15 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class CreateAccountConfigs < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
create_table :account_configs do |t|
|
||||||
|
t.references :account, null: false, foreign_key: true, index: true
|
||||||
|
t.string :key, null: false
|
||||||
|
t.text :value, null: false
|
||||||
|
|
||||||
|
t.index %i[account_id key], unique: true
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module AccountConfigs
|
||||||
|
module_function
|
||||||
|
|
||||||
|
def find_or_initialize_for_key(account, key)
|
||||||
|
account.account_configs.find_by(key:) ||
|
||||||
|
account.account_configs.new(key:, value: AccountConfig::DEFAULT_VALUES[key])
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module ReplaceEmailVariables
|
||||||
|
TEMAPLTE_NAME = '{{template.name}}'
|
||||||
|
SUBMITTER_LINK = '{{submitter.link}}'
|
||||||
|
ACCOUNT_NAME = '{{account.name}}'
|
||||||
|
|
||||||
|
module_function
|
||||||
|
|
||||||
|
def call(text, submitter:)
|
||||||
|
link =
|
||||||
|
Rails.application.routes.url_helpers.submit_form_url(
|
||||||
|
slug: submitter.slug, **Docuseal.default_url_options
|
||||||
|
)
|
||||||
|
|
||||||
|
text = text.gsub(TEMAPLTE_NAME, submitter.template.name)
|
||||||
|
text = text.gsub(SUBMITTER_LINK, link)
|
||||||
|
|
||||||
|
text.gsub(ACCOUNT_NAME, submitter.template.account.name)
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in new issue