feat: add company logo upload and white-label display

- Add has_one_attached :logo to Account model
- Add AccountLogoController for upload/delete in Settings
- Display custom logo in signing forms (start_form, submit_form)
- Display custom logo in submission preview
- Add logo upload form with drag-and-drop to personalization settings
pull/681/head
Sebastian Noe 1 month ago
parent 744d45d2c5
commit df3697a64f

@ -0,0 +1,29 @@
# frozen_string_literal: true
class AccountLogoController < ApplicationController
before_action :authorize_account_config
def create
file = params[:file]
if file.blank?
return redirect_to settings_personalization_path, alert: I18n.t('unable_to_save')
end
current_account.logo.attach(file)
redirect_to settings_personalization_path, notice: I18n.t('settings_have_been_saved')
end
def destroy
current_account.logo.purge
redirect_to settings_personalization_path, notice: I18n.t('settings_have_been_saved')
end
private
def authorize_account_config
authorize!(:create, AccountConfig)
end
end

@ -20,6 +20,8 @@
class Account < ApplicationRecord
attribute :uuid, :string, default: -> { SecureRandom.uuid }
has_one_attached :logo
has_many :users, dependent: :destroy
has_many :encrypted_configs, dependent: :destroy
has_many :account_configs, dependent: :destroy

@ -1 +1,34 @@
<%= render 'logo_placeholder' %>
<% if current_account.logo.attached? %>
<div class="mb-4">
<div class="flex items-center space-x-4">
<img src="<%= url_for(current_account.logo) %>" class="max-h-16 max-w-xs rounded" />
<%= button_to t('remove'), settings_account_logo_path, method: :delete, class: 'btn btn-sm btn-error btn-outline', data: { turbo_confirm: t('are_you_sure_') } %>
</div>
</div>
<% end %>
<%= form_with url: settings_account_logo_path, method: :post, html: { autocomplete: 'off', enctype: 'multipart/form-data' } do |f| %>
<file-dropzone data-submit-on-upload="true" class="w-full">
<label for="logo_file" class="w-full block h-32 relative bg-base-200 hover:bg-base-200/70 rounded-md border border-base-content border-dashed">
<div class="absolute top-0 right-0 left-0 bottom-0 flex items-center justify-center p-2">
<div class="flex flex-col items-center text-center">
<span data-target="file-dropzone.icon">
<%= svg_icon('cloud_upload', class: 'w-10 h-10') %>
</span>
<span data-target="file-dropzone.loading" class="hidden">
<%= svg_icon('loader', class: 'w-10 h-10 animate-spin') %>
</span>
<div class="font-medium mb-1">
<%= t('upload_logo') %>
</div>
<div class="text-xs">
<%= t('click_to_upload_or_drag_and_drop_html') %>
</div>
</div>
<input id="logo_file" name="file" class="hidden" data-action="change:file-dropzone#onSelectFiles" data-target="file-dropzone.input" type="file" accept="image/png,image/jpeg,image/jpg,image/gif,image/svg+xml">
</div>
</label>
</file-dropzone>
<div class="form-control mt-4">
<%= f.submit button_title(title: t('save'), disabled_with: t('saving')), class: 'base-button' %>
</div>
<% end %>

@ -1,15 +0,0 @@
<div class="alert my-4">
<%= svg_icon('info_circle', class: 'w-6 h-6') %>
<div>
<p class="font-bold">
<%= t('unlock_with_docuseal_pro') %>
</p>
<p>
<%= t('display_your_company_name_and_logo_when_signing_documents') %>
<br>
<a class="link font-medium" target="_blank" href="<%= Docuseal.multitenant? ? console_redirect_index_path(redir: "#{Docuseal::CONSOLE_URL}/plans") : "#{Docuseal::CLOUD_URL}/sign_up?#{{ redir: "#{Docuseal::CONSOLE_URL}/on_premises" }.to_query}" %>" data-turbo="false">
<%= t('learn_more') %>
</a>
</p>
</div>
</div>

@ -1,6 +1,10 @@
<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>
<% if @template&.account&.logo&.attached? %>
<img src="<%= url_for(@template.account.logo) %>" class="max-h-16 max-w-[250px]" />
<% else %>
<span class="mr-3">
<%= render 'shared/logo', width: '50px', height: '50px' %>
</span>
<h1 class="text-5xl font-bold text-center">DocuSeal</h1>
<% end %>
</a>

@ -1 +1,5 @@
<%= render 'shared/logo', width: 40, height: 40 %>
<% if @submission&.account&.logo&.attached? %>
<img src="<%= url_for(@submission.account.logo) %>" class="max-h-10 max-w-[160px]" />
<% else %>
<%= render 'shared/logo', width: 40, height: 40 %>
<% end %>

@ -1,4 +1,8 @@
<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>
<% if @submitter&.account&.logo&.attached? %>
<img src="<%= url_for(@submitter.account.logo) %>" class="max-h-12 max-w-[200px]" />
<% else %>
<%= render 'shared/logo', class: 'w-9 h-9 md:w-12 md:h-12' %>
<span><%= Docuseal.product_name %></span>
<% end %>
</a>

Loading…
Cancel
Save