Module: EmailTemplatesHelper
- Defined in:
- app/helpers/email_templates_helper.rb
Overview
== Schema Information
Table name: email_templates
id :integer not null, primary key
from :string(255)
to :string(255)
cc :string(255)
bcc :string(255)
resource_type :string(255)
resource_id :integer
body :text
subject :string(255)
creator_id :integer
updater_id :integer
description :string(255)
state :string(255)
css :text
stylesheet :string(255)
created_at :datetime not null
updated_at :datetime not null
system_code :string(20)
category :string
template :string
preview_text :string
Instance Method Summary collapse
- #email_template_command_options(email_template) ⇒ Object
- #email_template_redactor_status_badge(email_template) ⇒ Object
- #email_template_state_label(email_template) ⇒ Object
Instance Method Details
#email_template_command_options(email_template) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/helpers/email_templates_helper.rb', line 47 def (email_template) [].tap do |opts| opts << link_to(fa_icon('pen-to-square', text: 'Edit'), edit_email_template_path(email_template)) if can?(:update, EmailTemplate) opts << link_to(fa_icon('trash', text: 'Delete'), email_template_path(email_template), data: { turbo_method: :delete, turbo_confirm: 'Delete for sure?' }) if can?(:destroy, EmailTemplate) # Only allow copying Redactor 4 templates to prevent legacy R3 templates from spreading if can?(:create, EmailTemplate) && email_template.redactor_4_ready? opts << link_to(fa_icon('copy', text: 'Copy'), copy_email_template_path(email_template)) end opts << link_to(fa_icon('envelope', text: 'Send Preview Email'), send_preview_email_template_path(email_template)) # Preview in browser - opens email HTML directly in new tab version = email_template.redactor_4_ready? ? 'v4' : 'v3' opts << link_to(fa_icon('browser', text: 'Preview in Browser'), browser_preview_email_template_path(email_template, version: version), target: '_blank', rel: "noopener noreferrer") end end |
#email_template_redactor_status_badge(email_template) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/helpers/email_templates_helper.rb', line 34 def email_template_redactor_status_badge(email_template) if email_template.redactor_4_ready? content_tag(:span, 'Redactor 4', class: 'badge bg-success', style: 'font-size: 0.75rem;') elsif email_template.body_v4.present? safe_join([ content_tag(:span, 'Redactor 4 Content', class: 'badge bg-white text-success me-1', style: 'border: 2px solid #198754; font-size: 0.75rem;'), content_tag(:span, 'Legacy', class: 'badge bg-warning text-white', style: 'font-size: 0.75rem;') ]) else content_tag(:span, 'Legacy', class: 'badge bg-warning text-white', style: 'font-size: 0.75rem;') end end |
#email_template_state_label(email_template) ⇒ Object
29 30 31 32 |
# File 'app/helpers/email_templates_helper.rb', line 29 def email_template_state_label(email_template) state_class = { active: 'success', archive: 'danger' }[email_template.state&.to_sym] || 'secondary' content_tag(:span, email_template.state, class: "badge bg-#{state_class}") end |