Commit for ErEmail
This commit is contained in:
parent
3847ed9a43
commit
a42cc52f02
2
Gemfile
2
Gemfile
|
@ -1,6 +1,6 @@
|
|||
source "https://rubygems.org"
|
||||
|
||||
# Declare your gem's dependencies in bulletin.gemspec.
|
||||
# Declare your gem's dependencies in email_er.gemspec.
|
||||
# Bundler will treat runtime dependencies like base dependencies, and
|
||||
# development dependencies will be added by default to the :development group.
|
||||
gemspec
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
er_email (0.0.1)
|
||||
mongoid (= 4.0.0.beta1)
|
||||
rails (~> 4.1.0.rc2)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actionmailer (4.1.0.rc2)
|
||||
actionpack (= 4.1.0.rc2)
|
||||
actionview (= 4.1.0.rc2)
|
||||
mail (~> 2.5.4)
|
||||
actionpack (4.1.0.rc2)
|
||||
actionview (= 4.1.0.rc2)
|
||||
activesupport (= 4.1.0.rc2)
|
||||
rack (~> 1.5.2)
|
||||
rack-test (~> 0.6.2)
|
||||
actionview (4.1.0.rc2)
|
||||
activesupport (= 4.1.0.rc2)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
activemodel (4.1.0.rc2)
|
||||
activesupport (= 4.1.0.rc2)
|
||||
builder (~> 3.1)
|
||||
activerecord (4.1.0.rc2)
|
||||
activemodel (= 4.1.0.rc2)
|
||||
activesupport (= 4.1.0.rc2)
|
||||
arel (~> 5.0.0)
|
||||
activesupport (4.1.0.rc2)
|
||||
i18n (~> 0.6, >= 0.6.9)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.1)
|
||||
tzinfo (~> 1.1)
|
||||
arel (5.0.0)
|
||||
atomic (1.1.16)
|
||||
bson (2.2.1)
|
||||
builder (3.2.2)
|
||||
connection_pool (2.0.0)
|
||||
erubis (2.7.0)
|
||||
hike (1.2.3)
|
||||
i18n (0.6.9)
|
||||
json (1.8.1)
|
||||
mail (2.5.4)
|
||||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
mime-types (1.25.1)
|
||||
minitest (5.3.1)
|
||||
mongoid (4.0.0.beta1)
|
||||
activemodel (>= 4.0.0)
|
||||
moped (~> 2.0.beta6)
|
||||
origin (~> 2.1)
|
||||
tzinfo (>= 0.3.37)
|
||||
moped (2.0.0.rc1)
|
||||
bson (~> 2.2)
|
||||
connection_pool (~> 2.0)
|
||||
optionable (~> 0.2.0)
|
||||
multi_json (1.9.2)
|
||||
optionable (0.2.0)
|
||||
origin (2.1.1)
|
||||
polyglot (0.3.4)
|
||||
rack (1.5.2)
|
||||
rack-test (0.6.2)
|
||||
rack (>= 1.0)
|
||||
rails (4.1.0.rc2)
|
||||
actionmailer (= 4.1.0.rc2)
|
||||
actionpack (= 4.1.0.rc2)
|
||||
actionview (= 4.1.0.rc2)
|
||||
activemodel (= 4.1.0.rc2)
|
||||
activerecord (= 4.1.0.rc2)
|
||||
activesupport (= 4.1.0.rc2)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.1.0.rc2)
|
||||
sprockets-rails (~> 2.0.0)
|
||||
railties (4.1.0.rc2)
|
||||
actionpack (= 4.1.0.rc2)
|
||||
activesupport (= 4.1.0.rc2)
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (10.2.2)
|
||||
sprockets (2.12.0)
|
||||
hike (~> 1.2)
|
||||
multi_json (~> 1.0)
|
||||
rack (~> 1.0)
|
||||
tilt (~> 1.1, != 1.3.0)
|
||||
sprockets-rails (2.0.1)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
sprockets (~> 2.8)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.1)
|
||||
atomic (>= 1.1.7, < 2)
|
||||
tilt (1.4.1)
|
||||
treetop (1.4.15)
|
||||
polyglot
|
||||
polyglot (>= 0.3.1)
|
||||
tzinfo (1.1.0)
|
||||
thread_safe (~> 0.1)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
er_email!
|
|
@ -1,3 +1,3 @@
|
|||
= Bulletin
|
||||
= EmailEr
|
||||
|
||||
This project rocks and uses MIT-LICENSE.
|
2
Rakefile
2
Rakefile
|
@ -8,7 +8,7 @@ require 'rdoc/task'
|
|||
|
||||
RDoc::Task.new(:rdoc) do |rdoc|
|
||||
rdoc.rdoc_dir = 'rdoc'
|
||||
rdoc.title = 'Announcement'
|
||||
rdoc.title = 'ErEmail'
|
||||
rdoc.options << '--line-numbers'
|
||||
rdoc.rdoc_files.include('README.rdoc')
|
||||
rdoc.rdoc_files.include('lib/**/*.rb')
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -0,0 +1,4 @@
|
|||
/*
|
||||
Place all the styles related to the matching controller here.
|
||||
They will automatically be included in application.css.
|
||||
*/
|
|
@ -0,0 +1,223 @@
|
|||
# encoding: utf-8
|
||||
class Admin::ErEmailsController < OrbitAdminController
|
||||
include Admin::ErEmailsHelper
|
||||
before_action ->(module_app = @app_title) { set_variables module_app }
|
||||
before_action :set_email_er, only: [:edit, :show, :send_email, :test_send_email, :destroy]
|
||||
|
||||
def initialize
|
||||
super
|
||||
@app_title = "er_email"
|
||||
end
|
||||
|
||||
def index
|
||||
@categories = @module_app.categories.enabled
|
||||
@table_fields = [:status, :category, 'er_email.mail_subject', 'er_email.created_user']
|
||||
|
||||
@email_ers = EmailEr.where(:is_preview.in=>[false,nil]).order_by(sort).with_categories(filters("category")).page(params[:page]).per(10)
|
||||
|
||||
if request.xhr?
|
||||
render :partial => "index"
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def new
|
||||
@categories = @module_app.categories.enabled
|
||||
@email_er = EmailEr.new
|
||||
@email_er.mail_sentdate = Time.now
|
||||
end
|
||||
|
||||
def create
|
||||
@email_er = EmailEr.new(email_er_params)
|
||||
@email_er.create_user_id = current_user.id
|
||||
@email_er.update_user_id = current_user.id
|
||||
# @email_er.save
|
||||
# build_email(@email_er)
|
||||
|
||||
respond_to do |format|
|
||||
if @email_er.save
|
||||
# build_email(@email_er)
|
||||
|
||||
format.html { redirect_to "/admin/er_emails" }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
@categories = @module_app.categories.enabled
|
||||
# @email_er.mail_sentdate = Time.now
|
||||
end
|
||||
|
||||
def update
|
||||
uid = params[:id].split('-').last
|
||||
@email_er = EmailEr.find_by(:uid=>uid)
|
||||
@email_er.email_confirm = false
|
||||
@email_er.update_user_id = current_user.id
|
||||
email_er_params[:email_member_ids] = email_er_params[:email_member_ids].blank? ? [] : email_er_params[:email_member_ids]
|
||||
# email_er.update_attributes(email_er_params)
|
||||
# email_er.save
|
||||
# build_email(email_er)
|
||||
|
||||
respond_to do |format|
|
||||
if @email_er.update_attributes(email_er_params)
|
||||
@email_er.save
|
||||
# build_email(@email_er)
|
||||
|
||||
format.html { redirect_to "/admin/er_emails" }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def destroy
|
||||
@email_er.destroy
|
||||
redirect_to "/admin/er_emails"
|
||||
end
|
||||
|
||||
def delete
|
||||
if params[:ids]
|
||||
EmailEr.any_in(:uid => params[:ids]).destroy_all
|
||||
end
|
||||
redirect_to "/admin/er_emails"
|
||||
end
|
||||
|
||||
def preview
|
||||
if params['preview_type'].eql?('edit')
|
||||
email_er_data = email_er_params
|
||||
org_email_er = EmailEr.find(params['email_er_id'])
|
||||
email_er = org_email_er.clone
|
||||
email_er.generate_uid
|
||||
email_er.email_er_files = []
|
||||
|
||||
if !email_er_data['email_er_files_attributes'].blank?
|
||||
email_er_data['email_er_files_attributes'].each do |key, email_er_file|
|
||||
next if !email_er_file['_destroy'].blank?
|
||||
file = nil
|
||||
if email_er_file['id'].blank?
|
||||
file = EmailErFile.new(email_er_file)
|
||||
file.email_er_id = email_er.id
|
||||
file.save
|
||||
else
|
||||
org_file = EmailErFile.find(email_er_file['id'])
|
||||
file = org_file.clone
|
||||
file.email_er_id = email_er.id
|
||||
file.file = org_file.file
|
||||
email_er_file.delete('id')
|
||||
email_er_file.delete('_destroy')
|
||||
file.update_attributes(email_er_file)
|
||||
end
|
||||
|
||||
file.save
|
||||
email_er.email_er_files << file
|
||||
end
|
||||
end
|
||||
|
||||
email_er_data.delete('email_er_files_attributes')
|
||||
email_er.update_attributes(email_er_data)
|
||||
else
|
||||
email_er = EmailEr.new(email_er_params)
|
||||
end
|
||||
|
||||
email_er.is_preview = true
|
||||
email_er.save
|
||||
render :text=>page_for_email_er(email_er)
|
||||
end
|
||||
|
||||
def destroy_preview
|
||||
email_er = EmailEr.find(params[:id])
|
||||
if email_er.is_preview
|
||||
email_er.destroy
|
||||
end
|
||||
render :json=>{'destroy'=>email_er.id.to_s}
|
||||
end
|
||||
|
||||
def build_email(email_er , test_send = false)
|
||||
|
||||
email = Email.new
|
||||
email.save
|
||||
email_er.email_id = email.id
|
||||
email_er.email_confirm = true if !test_send
|
||||
email_er.save
|
||||
|
||||
|
||||
if !test_send
|
||||
|
||||
@group_mail = email_er.email_addresses
|
||||
|
||||
@mail_sentdate = email_er.mail_sentdate
|
||||
|
||||
else
|
||||
|
||||
@user = MemberProfile.find(User.find(email_er.create_user_id).member_profile_id)
|
||||
|
||||
@group_mail = [@user.email]
|
||||
|
||||
@mail_sentdate = DateTime.now
|
||||
|
||||
end
|
||||
|
||||
email_er.email.update_attributes(
|
||||
:create_user=>current_user,
|
||||
:mail_sentdate=>@mail_sentdate,
|
||||
:module_app=>@module_app,
|
||||
:mail_to=>@group_mail,
|
||||
:mail_content => email_er.mail_content ,
|
||||
:mail_subject=>email_er.mail_subject
|
||||
)
|
||||
|
||||
if !email_er.email_er_files.blank?
|
||||
|
||||
email.email_files.destroy_all
|
||||
|
||||
email_er.email_er_files.each do | mrfile |
|
||||
|
||||
@mcfile = email.email_files.build
|
||||
|
||||
@mcfile.file = mrfile.file
|
||||
|
||||
@mcfile.title = mrfile.title
|
||||
|
||||
end
|
||||
|
||||
email.save
|
||||
|
||||
end
|
||||
|
||||
OrbitMailer.set_mail(email_er.email).deliver if test_send
|
||||
|
||||
end
|
||||
|
||||
def send_email
|
||||
if params[:id]
|
||||
build_email(@email_er)
|
||||
end
|
||||
|
||||
redirect_to "/admin/er_emails"
|
||||
end
|
||||
|
||||
def test_send_email
|
||||
if params[:id]
|
||||
build_email(@email_er, true)
|
||||
end
|
||||
|
||||
redirect_to "/admin/er_emails"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_email_er
|
||||
@email_er = EmailEr.find(params[:id])
|
||||
end
|
||||
|
||||
def email_er_params
|
||||
# params[:email_er][:email_sent] = params[:email_er][:email_sent].nil? ? 0 : params[:email_er][:email_sent]
|
||||
params.require(:email_er).permit!
|
||||
end
|
||||
end
|
|
@ -1,38 +0,0 @@
|
|||
class AnnouncementsController < ApplicationController
|
||||
|
||||
def index
|
||||
announcements = Bulletin.all
|
||||
announcements.collect do |a|
|
||||
{
|
||||
"title" => a.title,
|
||||
"body" => a.body,
|
||||
"link_to_show" => OrbitHelper.url_to_show(a.uid,a.title.parameterize),
|
||||
"more" => "More"
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def widget
|
||||
announcements = Bulletin.all
|
||||
announcements.collect do |a|
|
||||
{
|
||||
"title" => a.title,
|
||||
"subtitle" => a.body,
|
||||
"link_to_show" => OrbitHelper.url_to_show(a.uid,a.title.parameterize),
|
||||
"more" => "More",
|
||||
"link_to_index" => "index"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def show
|
||||
params = OrbitHelper.get_params
|
||||
announcement = Bulletin.find_by_param(params[:uid])
|
||||
{
|
||||
"title" => announcement.title,
|
||||
"body" => announcement.body
|
||||
}
|
||||
end
|
||||
end
|
|
@ -0,0 +1,27 @@
|
|||
module Admin::ErEmailsHelper
|
||||
def page_for_email_er(email_er)
|
||||
ann_page = nil
|
||||
pages = Page.where(:module=>'er_email')
|
||||
|
||||
pages.each do |page|
|
||||
if page.categories.count ==1
|
||||
if page.categories.include?(email_er.category.id.to_s)
|
||||
ann_page = page
|
||||
end
|
||||
end
|
||||
break if !ann_page.nil?
|
||||
end
|
||||
|
||||
if ann_page.nil?
|
||||
pages.each do |page|
|
||||
if page.categories.include?(email_er.category.id.to_s)
|
||||
ann_page = page
|
||||
end
|
||||
break if !ann_page.nil?
|
||||
end
|
||||
end
|
||||
|
||||
ann_page = pages.first if ann_page.nil?
|
||||
request.protocol+(request.host_with_port+'/admin/er_emails/'+email_er.id).gsub('//','/') rescue "/"
|
||||
end
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
class Bulletin
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
field :title, type: String, localize: true
|
||||
field :body, type: String, localize: true
|
||||
field :uid, type: String
|
||||
|
||||
# include Slug
|
||||
|
||||
def to_param
|
||||
I18n.locale
|
||||
title.parameterize
|
||||
end
|
||||
|
||||
def self.find_by_param(input)
|
||||
self.find_by(uid: input)
|
||||
end
|
||||
|
||||
def generate_uid
|
||||
self.uid = rand(36**8).to_s(36)
|
||||
self.save
|
||||
end
|
||||
end
|
|
@ -0,0 +1,65 @@
|
|||
class EmailEr
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
include OrbitModel::Status
|
||||
include OrbitModel::Impression
|
||||
# encoding: utf-8
|
||||
include OrbitTag::Taggable
|
||||
include OrbitCategory::Categorizable
|
||||
include Slug
|
||||
|
||||
field :mail_subject
|
||||
field :mail_sentdate , :type => DateTime
|
||||
field :mail_content
|
||||
|
||||
field :email_member_ids
|
||||
field :other_mailaddress
|
||||
|
||||
field :create_user_id
|
||||
field :update_user_id
|
||||
|
||||
field :email_id
|
||||
field :email_confirm, :type => Boolean, :default => false
|
||||
|
||||
field :is_preview, :type => Boolean, :default => false
|
||||
|
||||
has_many :email_er_files, :autosave => true, :dependent => :destroy
|
||||
accepts_nested_attributes_for :email_er_files, :allow_destroy => true
|
||||
|
||||
before_destroy :destroy_email
|
||||
|
||||
scope :can_display,->{where(is_hidden: false)}
|
||||
|
||||
validates :mail_subject,presence:{message:'blank is not allowed'}
|
||||
validates :other_mailaddress,
|
||||
:length => {:maximum => 1000, :message => I18n.t("er_email.other_mailaddress_note_limit")}
|
||||
|
||||
def update_user
|
||||
User.find(update_user_id) rescue nil
|
||||
end
|
||||
|
||||
def update_user=(user)
|
||||
self.update_user_id = user.id
|
||||
end
|
||||
|
||||
def email_members
|
||||
MemberProfile.find(self.email_member_ids) rescue []
|
||||
end
|
||||
|
||||
def email_addresses
|
||||
addresses = self.email_members.collect{|member| member.email} rescue []
|
||||
addresses = addresses +[self.other_mailaddress] if !self.other_mailaddress.blank?
|
||||
addresses.flatten
|
||||
end
|
||||
|
||||
def email
|
||||
mail = Email.find(self.email_id) rescue nil
|
||||
end
|
||||
|
||||
def destroy_email
|
||||
mail = Email.find(self.email_id) rescue nil
|
||||
mail.destroy if !mail.nil?
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,23 @@
|
|||
# encoding: utf-8
|
||||
class EmailErFile
|
||||
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
mount_uploader :file, AssetUploader
|
||||
|
||||
field :title, localize: true
|
||||
|
||||
belongs_to :email_er
|
||||
|
||||
validate :file_size
|
||||
|
||||
private
|
||||
|
||||
def file_size
|
||||
if file.file.size > 10.megabytes
|
||||
errors.add( :file, I18n.t("er_email.email_file_limit"))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,211 @@
|
|||
<% content_for :page_specific_css do %>
|
||||
<%= stylesheet_link_tag "lib/main-forms" %>
|
||||
<%= stylesheet_link_tag "lib/fileupload" %>
|
||||
<%= stylesheet_link_tag "lib/main-list" %>
|
||||
<% end %>
|
||||
<% content_for :page_specific_javascript do %>
|
||||
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
|
||||
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
|
||||
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
|
||||
<%= javascript_include_tag "lib/file-type" %>
|
||||
<%= javascript_include_tag "lib/module-area" %>
|
||||
<% end %>
|
||||
|
||||
<%= f.error_messages %>
|
||||
|
||||
<!-- Input Area -->
|
||||
<div class="input-area">
|
||||
|
||||
<!-- Module Tabs -->
|
||||
<div class="nav-name"><strong><%= t(:module) %></strong></div>
|
||||
<ul class="nav nav-pills module-nav">
|
||||
<li class="active"><a href="#basic" data-toggle="tab"><%= t(:basic) %></a></li>
|
||||
</ul>
|
||||
|
||||
<!-- Module -->
|
||||
<div class="tab-content module-area">
|
||||
|
||||
<!-- Basic Module -->
|
||||
<div class="tab-pane fade in active" id="basic">
|
||||
|
||||
<!-- Category -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:category) %></label>
|
||||
<div class="controls">
|
||||
<%= select_category(f, @module_app) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("er_email.mail_sentdate") %></label>
|
||||
<div class="controls">
|
||||
<%= f.datetime_picker :mail_sentdate, :no_label => true %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Mail Group -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("er_email.mail_to") %></label>
|
||||
<div class="controls">
|
||||
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'email_er[email_member_ids][]', email_members: @email_er.email_members} %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"></label>
|
||||
<div class="controls">
|
||||
<span class="help-block"><%= "#{t("er_email.other_mailaddress")}(#{t("er_email.other_mailaddress_note")})"%> </span>
|
||||
<%= f.text_area :other_mailaddress, :class=>"span12", :cols=>"25", :rows=>"10" %>
|
||||
<span class="help-block"><%= "#{t("er_email.mail_to_note")}"%> </span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Language -->
|
||||
<div class="tab-content language-area">
|
||||
|
||||
<!-- English -->
|
||||
<div class="tab-pane fade in active en">
|
||||
|
||||
<!-- Title-->
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t("er_email.mail_subject") %></label>
|
||||
<div class="controls">
|
||||
<%= f.text_field :mail_subject, class: "input-block-level", placeholder: t("er_email.mail_subject") %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Content -->
|
||||
<div class="control-group input-content">
|
||||
<label class="control-label muted"><%= t("er_email.mail_content") %></label>
|
||||
<div class="controls">
|
||||
<%#= f.text_area :mail_content, :style=>"width:100%", :class => 'ckeditor input-block-level' %>
|
||||
<%= f.cktext_area :mail_content, rows: 5, class: "input-block-level" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- File -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:file_) %></label>
|
||||
<div class="controls">
|
||||
|
||||
<!-- Exist -->
|
||||
<% if @email_er && !@email_er.email_er_files.blank? %>
|
||||
<div class="exist">
|
||||
<% @email_er.email_er_files.each_with_index do |email_er_file, i| %>
|
||||
<%= f.fields_for :email_er_files, email_er_file do |f| %>
|
||||
<%= render :partial => 'form_file', :object => email_er_file, :locals => {:f => f, :i => i} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<hr>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- Add -->
|
||||
<div class="add-target">
|
||||
</div>
|
||||
<p class="add-btn">
|
||||
<%= hidden_field_tag 'email_er_file_field_count', @email_er.email_er_files.count %>
|
||||
<a id="add_file" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Form Actions -->
|
||||
<div class="form-actions">
|
||||
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
||||
<%= button_tag t("preview"), id: "button_for_preview", name: "commit", class: 'btn', type: :button %>
|
||||
<%= link_to t('cancel'), admin_er_emails_path, :class=>"btn" %>
|
||||
</div>
|
||||
|
||||
<span id='show_preview'>
|
||||
<div class="modal hide fade in banner-preview" id="">
|
||||
<div class="modal-header">
|
||||
<a class="close" data-dismiss="modal">×</a>
|
||||
<h3><%= t(:preview) %></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<iframe id="preview-iframe" src=""></iframe>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a>
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
|
||||
<% content_for :page_specific_javascript do %>
|
||||
<script>
|
||||
$(function() {
|
||||
$("#main-wrap").after("");
|
||||
$(document).on('click', '#add_file', function(){
|
||||
var new_id = $(this).prev().attr('value');
|
||||
var old_id = new RegExp("new_email_er_files", "g");
|
||||
var on = $('.language-nav li.active').index();
|
||||
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
|
||||
$(this).prev().attr('value', parseInt(new_id) + 1);
|
||||
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_file', f, :email_er_files) %>").replace(old_id, new_id));
|
||||
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
|
||||
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
|
||||
});
|
||||
formTip();
|
||||
});
|
||||
$(document).on('click', '.delete_file', function(){
|
||||
$(this).parents('.input-prepend').remove();
|
||||
});
|
||||
$(document).on('click', '.remove_existing_record', function(){
|
||||
if(confirm("<%= I18n.t(:sure?)%>")){
|
||||
$(this).children('.should_destroy').attr('value', 1);
|
||||
$(this).parents('.start-line').hide();
|
||||
}
|
||||
});
|
||||
|
||||
$('#remind-check').prop('checked') ? '':$('.content-box').addClass('hide')
|
||||
$('#remind-check').on('change', function() {
|
||||
$(this).prop('checked') ? $('.content-box').removeClass('hide'):$('.content-box').addClass('hide')
|
||||
})
|
||||
|
||||
$('#button_for_preview').click(function(){
|
||||
var method = $('.main-forms input[name="_method"]').val();
|
||||
$('.main-forms input[name="_method"]').val("post");
|
||||
|
||||
for ( instance in CKEDITOR.instances )
|
||||
CKEDITOR.instances[instance].updateElement();
|
||||
|
||||
var formData = new FormData( $('.main-forms')[0] );
|
||||
formData.append("preview_type", ( (method==undefined) ? "new" : "edit" ));
|
||||
formData.append("email_er_id", '<%= @email_er.id.to_s %>');
|
||||
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: '<%= admin_er_email_preview_path %>',
|
||||
data : formData,
|
||||
processData: false,
|
||||
contentType: false
|
||||
}).done(function(data){
|
||||
$('.modal-body iframe').attr('src',data);
|
||||
$('#show_preview .modal').modal();
|
||||
$('#show_preview .modal').height(function() {
|
||||
return $(window).height() * 0.7;
|
||||
});
|
||||
|
||||
var slug = data.split('/')[(data.split('/').length-1)];
|
||||
$('#preview-iframe').on('load', function(){
|
||||
$.get('/admin/er_email/destroy_preview/'+slug,function(data){
|
||||
});
|
||||
});
|
||||
});
|
||||
$('.main-forms input[name="_method"]').val(method);
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
<% end %>
|
|
@ -0,0 +1,40 @@
|
|||
<%= f.error_messages %>
|
||||
<% if form_file.new_record? %>
|
||||
<div class="fileupload fileupload-new start-line" data-provides="fileupload">
|
||||
<% else %>
|
||||
<div class="fileupload fileupload-exist start-line" data-provides="fileupload">
|
||||
<% if form_file.file.blank? %>
|
||||
<%= t(:no_file) %>
|
||||
<% else %>
|
||||
<%= link_to content_tag(:i) + form_file.file_identifier, form_file.file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.file_identifier} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="input-prepend input-append">
|
||||
<label>
|
||||
<span class="add-on btn btn-file" title='<%= t(:file_) %>'>
|
||||
<i class="icons-paperclip"></i>
|
||||
<%= f.file_field :file %>
|
||||
</span>
|
||||
<div class="uneditable-input input-medium">
|
||||
<i class="icon-file fileupload-exists"></i>
|
||||
<span class="fileupload-preview"><%= (form_file.new_record? || form_file.file.blank?) ? t(:select_file) : t(:change_file) %></span>
|
||||
</div>
|
||||
</label>
|
||||
<span class="add-on icons-pencil" title='<%= t(:alternative) %>'></span>
|
||||
<span class="tab-content">
|
||||
<%= f.text_field :title %>
|
||||
</span>
|
||||
</span>
|
||||
<% if form_file.new_record? %>
|
||||
<span class="delete_file add-on btn" title="<%= t(:delete_) %>">
|
||||
<a class="icon-trash"></a>
|
||||
</span>
|
||||
<% else %>
|
||||
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
|
||||
<%= f.hidden_field :id %>
|
||||
<a class="icon-remove"></a>
|
||||
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,53 @@
|
|||
<table class="table main-list">
|
||||
<thead>
|
||||
<tr class="sort-header">
|
||||
<% @table_fields.each do |f| %>
|
||||
<%= thead(f) %>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @email_ers.each do |b| %>
|
||||
<tr>
|
||||
<td><%= (b.email_confirm.blank? ? t("er_email.email_no_confirm") : t("er_email.email_have_confirm") ) %></td>
|
||||
<td><%= b.category.title %></td>
|
||||
<td>
|
||||
<%= b.mail_subject %>
|
||||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills">
|
||||
<li><a href="/admin/er_emails/<%=b.id.to_s%>/edit"><%= t(:edit) %></a></li>
|
||||
<li><a href="/admin/er_email/test_send_email/<%=b.id.to_s%>"><%= t('er_email.test_send_email') %></a></li>
|
||||
<li><a href="#" class="detail-row" onclick="$('#<%= "#{b.id.to_s}-detail" %>').slideToggle(300)"><%= t(:detail) %></a></li>
|
||||
<li><a href="#" class="delete text-error" rel="/admin/er_emails/<%=b.id.to_s%>"><%= t(:delete_) %></a></li>
|
||||
<% if b.email_confirm.blank? and !b.email_addresses.blank? %><li><a href="/admin/er_email/send_email/<%=b.id.to_s%>"><%= t('er_email.email_confirm') %></a></li><% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
<td><%= b.update_user.user_name %></td>
|
||||
</tr>
|
||||
<tr class="footable-row-detail">
|
||||
<td class="footable-cell-detail" colspan="6">
|
||||
<div id="<%= "#{b.id.to_s}-detail" %>" class="footable-row-detail-inner" style="display: none;">
|
||||
<div>
|
||||
<strong><%= t("er_email.mail_to") %></strong> :
|
||||
<% b.email_members.each do |member| %>
|
||||
<span class="label"><%= member.name %></span>
|
||||
<% end %>
|
||||
<% unless b.other_mailaddress.nil? %>
|
||||
<% b.other_mailaddress.split(',').each do |mailaddress| %>
|
||||
<span class="label"><%= mailaddress %></span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%=
|
||||
content_tag :div, class: "bottomnav clearfix" do
|
||||
content_tag :div, paginate(@email_ers), class: "pagination pagination-centered"
|
||||
end
|
||||
%>
|
|
@ -0,0 +1,5 @@
|
|||
<%= form_for @email_er, url: admin_er_email_path(@email_er), html: {class: "form-horizontal main-forms previewable"} do |f| %>
|
||||
<fieldset>
|
||||
<%= render :partial => 'form', locals: {f: f} %>
|
||||
</fieldset>
|
||||
<% end %>
|
|
@ -0,0 +1,5 @@
|
|||
<span id="index_table">
|
||||
<%= render 'index'%>
|
||||
</span>
|
||||
|
||||
<%= render 'layouts/delete_modal', delete_options: @delete_options %>
|
|
@ -0,0 +1,5 @@
|
|||
<%= form_for @email_er, url: admin_er_emails_path, html: {class: "form-horizontal main-forms previewable"} do |f| %>
|
||||
<fieldset>
|
||||
<%= render :partial => 'form', locals: {f: f} %>
|
||||
</fieldset>
|
||||
<% end %>
|
|
@ -0,0 +1,17 @@
|
|||
<ul>
|
||||
<% if !@email_er.email_addresses.blank? %>
|
||||
<li>
|
||||
<%= label_tag t("er_email.mail_to") %>
|
||||
<% @email_er.email_members.each do |member| %>
|
||||
<span class="label"><%= member.name %></span>
|
||||
<% end %>
|
||||
<% unless @email_er.other_mailaddress.nil? %>
|
||||
<% @email_er.other_mailaddress.split(',').each do |mailaddress| %>
|
||||
<span class="label"><%= mailaddress %></span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
<li><%= label_tag t("er_email.mail_subject") %><%= @email_er.mail_subject %></li>
|
||||
<li><%= label_tag t("er_email.mail_content") %><%= @email_er.mail_content.html_safe %></li>
|
||||
</ul>
|
|
@ -1 +0,0 @@
|
|||
<%= render_view %>
|
|
@ -1 +0,0 @@
|
|||
<%= render_view %>
|
|
@ -2,7 +2,7 @@
|
|||
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
|
||||
|
||||
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
||||
ENGINE_PATH = File.expand_path('../../lib/announcement/engine', __FILE__)
|
||||
ENGINE_PATH = File.expand_path('../../lib/er_email/engine', __FILE__)
|
||||
|
||||
# Set up gems listed in the Gemfile.
|
||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
en:
|
||||
|
||||
er_email:
|
||||
er_email: Email_ER
|
||||
Group: Group
|
||||
Title: Title
|
||||
Content: Content
|
||||
Files: Files
|
||||
approval_setting: Approval Setting
|
||||
approve_email_er_fail: Approval Fail
|
||||
approve_email_er_success: Approve Successfully
|
||||
create_email_er_success: Create Successfully
|
||||
email_confirm: Sent mail to confirm
|
||||
email_have_confirm: Have confirmed
|
||||
email_no_confirm: Unconfirmed
|
||||
mail_resend: Resend
|
||||
test_send_email: Test Send Email
|
||||
mail_subject: Mail Subject
|
||||
mail_content: Mail Content
|
||||
mail_sentdate: Email Time
|
||||
mail_to: Email To
|
||||
mail_to_note: Remember to fill in or choose the people you want to send, or the system couldn't send off.
|
||||
other_mailaddress: Other Email
|
||||
other_mailaddress_note: Divide different email accounts with ","
|
||||
other_mailaddress_note_limit: maximum 1000 characters
|
||||
email_file_limit: File upload size is limited to 1MB
|
||||
created_user: Creator
|
|
@ -0,0 +1,27 @@
|
|||
zh_tw:
|
||||
|
||||
er_email:
|
||||
er_email: 寄信群組
|
||||
Group: 群組
|
||||
Title: 主旨
|
||||
Content: 內文
|
||||
Files: 檔案
|
||||
approval_setting: 審核設定
|
||||
approve_email_er_fail: 審核失敗
|
||||
approve_email_er_success: 審核成功
|
||||
create_email_er_success: 建立資料成功
|
||||
mail_resend: 重新寄送
|
||||
test_send_email: 測試寄信
|
||||
mail_subject: 主旨
|
||||
mail_content: 信件內容
|
||||
mail_sentdate: 寄送時間
|
||||
mail_to: 寄送對象
|
||||
mail_to_note: 請記得填寫或選擇寄送對象,若無填寫將導致系統無法確認寄信
|
||||
other_mailaddress: 其他Mail
|
||||
other_mailaddress_note: 輸入多組mail時,請用","逗號隔開
|
||||
other_mailaddress_note_limit: 限制1000字元以內
|
||||
email_file_limit: 檔案上傳容量限制為10MB
|
||||
email_confirm: 確認寄送
|
||||
email_have_confirm: 已確認
|
||||
email_no_confirm: 未確認
|
||||
created_user: 建立者
|
|
@ -1,10 +1,14 @@
|
|||
Rails.application.routes.draw do
|
||||
|
||||
scope "(:locale)", locale: /en|zh_tw/ do
|
||||
resources :announcements do
|
||||
collection do
|
||||
get ':uid/:title', to: 'announcements#show', as: :display
|
||||
end
|
||||
locales = Site.first.in_use_locales rescue I18n.available_locales
|
||||
|
||||
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
|
||||
namespace :admin do
|
||||
get 'er_email/send_email/:id', to: 'er_emails#send_email'
|
||||
get 'er_email/test_send_email/:id', to: 'er_emails#test_send_email'
|
||||
post 'er_email/preview', to: 'er_emails#preview'
|
||||
get 'er_email/destroy_preview/:id', to: 'er_emails#destroy_preview'
|
||||
resources :er_emails
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,22 +1,19 @@
|
|||
$:.push File.expand_path("../lib", __FILE__)
|
||||
|
||||
# Maintain your gem's version:
|
||||
require "announcement/version"
|
||||
require "er_email/version"
|
||||
|
||||
# Describe your gem and declare its dependencies:
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "announcement"
|
||||
s.version = Announcement::VERSION
|
||||
s.name = "er_email"
|
||||
s.version = ErEmail::VERSION
|
||||
s.authors = ["RulingDigital"]
|
||||
s.email = ["orbit@rulingcom.com"]
|
||||
s.homepage = "http://www.rulingcom.com"
|
||||
s.summary = "Announcements for Orbit"
|
||||
s.description = "Announcements for Orbit"
|
||||
s.summary = "ErEmails for Orbit"
|
||||
s.description = "ErEmails for Orbit"
|
||||
s.license = "MIT"
|
||||
|
||||
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
|
||||
s.test_files = Dir["test/**/*"]
|
||||
|
||||
s.add_dependency "rails", "~> 4.1.0.rc2"
|
||||
s.add_dependency "mongoid", "4.0.0.beta1"
|
||||
end
|
|
@ -1,4 +0,0 @@
|
|||
require "announcement/engine"
|
||||
|
||||
module Announcement
|
||||
end
|
|
@ -1,10 +0,0 @@
|
|||
module Announcement
|
||||
class Engine < ::Rails::Engine
|
||||
initializer "announcement" do
|
||||
OrbitApp.registration "Announcement", :type => "ModuleApp" do
|
||||
module_label "announcement.announcement"
|
||||
base_url File.expand_path File.dirname(__FILE__)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
require "er_email/engine"
|
||||
|
||||
module ErEmail
|
||||
end
|
|
@ -0,0 +1,39 @@
|
|||
module ErEmail
|
||||
class Engine < ::Rails::Engine
|
||||
initializer "er_email" do
|
||||
OrbitApp.registration "ErEmail", :type => "ModuleApp" do
|
||||
module_label "er_email.er_email"
|
||||
base_url File.expand_path File.dirname(__FILE__)
|
||||
taggable "EmailEr"
|
||||
categorizable
|
||||
authorizable
|
||||
|
||||
side_bar do
|
||||
head_label_i18n 'er_email.er_email', icon_class: "icons-paperplane"
|
||||
available_for [:admin,:manager,:sub_manager]
|
||||
active_for_controllers (['admin/er_emails'])
|
||||
head_link_path "admin_er_emails_path"
|
||||
|
||||
context_link 'all',
|
||||
:link_path=>"admin_er_emails_path" ,
|
||||
:priority=>1,
|
||||
:active_for_action=>{'admin/er_emails'=>'index'},
|
||||
:available_for => [:all]
|
||||
context_link 'new_',
|
||||
:link_path=>"new_admin_er_email_path" ,
|
||||
:priority=>2,
|
||||
:active_for_action=>{'admin/er_emails'=>'new'},
|
||||
:available_for => [:sub_manager]
|
||||
context_link 'categories',
|
||||
:link_path=>"admin_module_app_categories_path" ,
|
||||
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'er_email').id}",
|
||||
:priority=>3,
|
||||
:active_for_action=>{'admin/er_emails'=>'categories'},
|
||||
:active_for_category => 'ErEmail',
|
||||
:available_for => [:manager]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,3 +1,3 @@
|
|||
module Announcement
|
||||
module ErEmail
|
||||
VERSION = "0.0.1"
|
||||
end
|
|
@ -1,4 +1,4 @@
|
|||
# desc "Explaining what the task does"
|
||||
# task :bulletin do
|
||||
# task :email_er do
|
||||
# # Task goes here
|
||||
# end
|
|
@ -1,7 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class BulletinTest < ActiveSupport::TestCase
|
||||
test "truth" do
|
||||
assert_kind_of Module, Bulletin
|
||||
end
|
||||
end
|
|
@ -0,0 +1,14 @@
|
|||
require 'test_helper'
|
||||
|
||||
class Admin::ErEmailsControllerTest < ActionController::TestCase
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get create" do
|
||||
get :create
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
end
|
|
@ -9,7 +9,7 @@ require "sprockets/railtie"
|
|||
require "rails/test_unit/railtie"
|
||||
|
||||
Bundler.require(*Rails.groups)
|
||||
require "bulletin"
|
||||
require "email_er"
|
||||
|
||||
module Dummy
|
||||
class Application < Rails::Application
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EmailErTest < ActiveSupport::TestCase
|
||||
test "truth" do
|
||||
assert_kind_of Module, EmailEr
|
||||
end
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
require 'test_helper'
|
||||
|
||||
class Admin::ErEmailsHelperTest < ActionView::TestCase
|
||||
end
|
Loading…
Reference in New Issue