Give Admin email an interface

parent 7776d4d0
class Admin::EmailsController < Admin::ApplicationController class Admin::EmailsController < Admin::ApplicationController
def show def show
render text: 'hello world'
end end
end end
module AdminEmailHelper
def admin_email_grouped_recipient_options
options_for_select([['Everyone', 'all']]) +
grouped_options_for_select(
'Groups' => Group.pluck(:name, :id).map{ |name, id| [name, "group_#{id}"] },
'Projects' => grouped_project_list
)
end
protected
def grouped_project_list
Group.includes(:projects).flat_map do |group|
group.human_name
group.projects.map do |project|
["#{group.human_name} / #{project.name}", "project_#{project.id}"]
end
end
end
end
\ No newline at end of file
%h3.page-title
Send email notication
%p.light
You can notify the app / group or a project by sending them an email notification
= form_tag admin_email_path, class: 'form-horizontal' do
.form-group
%label.control-label{for: :subject} Subject
.col-sm-10
= text_field_tag :subject, '', class: 'form-control'
.form-group
%label.control-label{for: :body} Body
.col-sm-10
= text_area_tag :body, '', class: 'form-control', rows: 15
.form-group
%label.control-label{for: :recipients} Recipients
.col-sm-10
= select_tag :recipients, admin_email_grouped_recipient_options, class: :select2
.form-actions
= submit_tag 'Send message', class: 'btn btn-create'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment