Skip to content
Browse files

minor updates

  • Loading branch information...
1 parent a1c51ae commit e816ba2e992376c9eb849b281117c4036ffaae40 @peng-appannie committed
View
4 app/helpers/ez_issue_summaries_helper.rb
@@ -1,6 +1,6 @@
module EzIssueSummariesHelper
- def find_issue
- @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
+ def find_issue(id = params[:id])
+ @issue = Issue.find(id, :include => [:project, :tracker, :status, :author, :priority, :category])
@project = @issue.project
rescue ActiveRecord::RecordNotFound
render_404
View
37 app/models/ez_issue_mailer.rb
@@ -1,10 +1,37 @@
-class IssueMailer < ActionMailer::Base
- def issue_summary(recv, thesubject, content)
+class EzIssueMailer < ActionMailer::Base
+ helper :custom_fields
+ helper :application
+ include Redmine::I18n
+
+ include CustomFieldsHelper
+ include ApplicationHelper
+
+ self.view_paths.unshift File.join(Rails.configuration.plugin_paths[0], "redmine_ez_summary", "app", "views")
+
+ def self.default_url_options
+ Mailer.default_url_options
+ end
+
+
+ def issue_summary(recv, thesubject, content, issue)
+
recipients recv
from "peng.zuo@qq.com"
subject thesubject
- sent_on Time.now
- body content
+ sent_on Time.now
+
+ body :issue => issue,
+ :content => content,
+ :issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue)
end
-end
+ def render_message(method_name, body)
+ layout = method_name.to_s.match(%r{text\.(html|xml)}) ? 'layout.text.html.rhtml' : 'layout.text.plain.rhtml'
+ mailer_view_root = File.join(template_root, "mailer")
+ body[:content_for_layout] = render(:file => method_name, :body => body )
+ # plugin_path = File.join(Rails.configuration.plugin_paths[0], "redmine_ez_summary", "app", "views")
+ root_view_path = self.class.view_paths.last
+ ActionView::Base.new( root_view_path, body, self).render(:file => "mailer/#{layout}" , :use_full_path => true)
+ end
+
+end
View
15 app/views/ez_issue_mailer/_issue.text.html.erb
@@ -0,0 +1,15 @@
+<h1><%= link_to "#{issue.tracker.name} ##{issue.id}: #{issue.subject}", issue_url %></h1>
+
+<ul>
+<li><%=t(:field_author)%>: <%= issue.author %></li>
+<li><%=t(:field_status)%>: <%= issue.status %></li>
+<li><%=t(:field_priority)%>: <%= issue.priority %></li>
+<li><%=t(:field_assigned_to)%>: <%= issue.assigned_to %></li>
+<li><%=t(:field_category)%>: <%= issue.category %></li>
+<li><%=t(:field_fixed_version)%>: <%= issue.fixed_version %></li>
+<% issue.custom_values.each do |c| %>
+ <li><%= c.custom_field.name %>: <%= show_value(c) %></li>
+<% end %>
+</ul>
+
+<%= textilizable(issue, :description, :only_path => false) %>
View
13 app/views/ez_issue_mailer/_issue.text.plain.erb
@@ -0,0 +1,13 @@
+<%= "#{issue.tracker.name} ##{issue.id}: #{issue.subject}" %>
+<%= issue_url %>
+
+<%=t(:field_author)%>: <%= issue.author %>
+<%=t(:field_status)%>: <%= issue.status %>
+<%=t(:field_priority)%>: <%= issue.priority %>
+<%=t(:field_assigned_to)%>: <%= issue.assigned_to %>
+<%=t(:field_category)%>: <%= issue.category %>
+<%=t(:field_fixed_version)%>: <%= issue.fixed_version %>
+<% issue.custom_values.each do |c| %><%= c.custom_field.name %>: <%= show_value(c) %>
+<% end %>
+
+<%= issue.description %>
View
3 app/views/ez_issue_mailer/issue_summary.text.html.erb
@@ -0,0 +1,3 @@
+<p><%= @content %></p>
+<hr />
+<%= render :partial => "issue", :locals => { :issue => @issue, :issue_url => @issue_url } %>
View
4 app/views/ez_issue_mailer/issue_summary.text.plain.erb
@@ -0,0 +1,4 @@
+<%= @content %>
+
+----------------------------------------
+<%= render :partial => "issue", :locals => { :issue => @issue, :issue_url => @issue_url } %>
View
17 app/views/ez_issue_summaries/_email.html.erb
@@ -0,0 +1,17 @@
+<fieldset id="email">
+ <legend><%= t("ez.email") %></legend>
+<% form_tag ez_email_path, :method => :post do -%>
+ <div class="label_wrapper">
+ <%= label_tag 'recipients', "#{t('ez.recipients')}:" %>
+ <%= text_area_tag 'recipients' %>
+ </div>
+ <div class="label_wrapper">
+ <%= label_tag "#{t('ez.subject')}:"%>
+ <%= text_field_tag 'subject', issue.subject %>
+ </div>
+ <%= hidden_field_tag 'issue_id', issue.id %>
+ <%= hidden_field_tag 'save_flag', 0 %>
+ <textarea name="content" id="issue_content" cols="40" rows="10" ></textarea><br />
+ <%= submit_tag t("ez.send_mail") %> <%= submit_tag t("ez.send_and_save_mail"), :id => "send_and_save" %>
+<% end -%>
+</fieldset>
View
6 app/views/ez_issue_summaries/_templates.html.erb
@@ -0,0 +1,6 @@
+<fieldset id="mail_templates">
+ <legend><%= t("ez.email_template") %></legend>
+<%= select_tag "templates", options_from_collection_for_select(templates, :content, :content), :size => 6 %>
+<br />
+<input type="button" name="fill_in" value="<%= t('ez.fill_in')%>" id="fill_in" />
+</fieldset>
View
34 app/views/ez_issue_summaries/show.html.erb
@@ -1,7 +1,7 @@
<% content_for :header_tags do -%>
- <%= javascript_include_tag "jquery", :plugin => "redmine_issue_summary" %>
+ <%= javascript_include_tag "jquery", :plugin => "redmine_ez_summary" %>
- <%= stylesheet_link_tag 'issue_summary', :plugin => 'redmine_issue_summary' %>
+ <%= stylesheet_link_tag 'issue_summary', :plugin => 'redmine_ez_summary' %>
<link rel="stylesheet" href="http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomplete.css" type="text/css" />
<script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.bgiframe.min.js"></script>
<script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.dimensions.js"></script>
@@ -11,25 +11,19 @@
$("#recipients").autocomplete("/ez_contacts", {
multiple: true
});
+ $("#send_and_save").click(
+ function(){
+ $("#save_flag").attr("value", 1);
+ });
+ $("#fill_in").click(
+ function(){
+ $("#issue_content").append( $("#templates option:selected").val() );
+ }
+ );
});
</script>
<% end -%>
+
+<%= render :partial => "email", :locals => { :issue => @issue } %>
-<% form_tag ez_email_path, :method => :post do -%>
- <div class="label_wrapper">
- <%= label_tag 'recipients', 'recipients:' %>
- <%= text_area_tag 'recipients' %>
- </div>
- <div class="label_wrapper">
- <%= label_tag 'CC', 'CC:' %>
- <%= text_area_tag 'CC' %>
- </div>
- <div class="label_wrapper">
- <%= label_tag 'subject:'%>
- <%= text_field_tag 'subject', @issue.subject %>
- </div>
- <textarea name="content" id="issue_content" cols="40" rows="10" ><%= h(render :partial => "content", :object => @issue) %></textarea> <br />
- <%= submit_tag 'Send Mail' %>
-<% end -%>
-
-<div id="result"></div>
+<%= render :partial => "templates", :object => @templates %>
View
3 assets/javascripts/issue_summary.js
@@ -1,4 +1,5 @@
$(function() {
var menu = $("div#content div.contextual > a:first");
- $("#email_issue_menu").insertBefore(menu).css("display", "inline");
+ $("#email_issue_menu").insertBefore(menu).css("display", "inline");
+
});
View
7 assets/stylesheets/issue_summary.css
@@ -7,7 +7,6 @@ label {
}
.label_wrapper input, textarea {
width: 80% ;
- border: 1px solid black;
padding-left: 0px;
padding-right: 0px;
margin-left: 0px;
@@ -50,4 +49,10 @@ div.autocomplete ul li {
display:block;
list-style-type:none;
cursor:pointer;
+}
+#mail_templates{
+ margin-top: 10px;
+}
+#templates{
+ width: 20em;
}
View
2 lib/issue_summary_listener.rb
@@ -1,7 +1,7 @@
class RedmineIssueSummaryListener < Redmine::Hook::ViewListener
render_on :view_layouts_base_html_head, :inline => <<-END
<% if controller.controller_name == "issues" && controller.action_name == "show" %>
- <%= javascript_include_tag 'jquery', 'issue_summary', :plugin => 'redmine_issue_summary' %>
+ <%= javascript_include_tag 'jquery', 'issue_summary', :plugin => 'redmine_ez_summary' %>
<% end %>
END
View
5 test/fixtures/ez_mail_templates.yml
@@ -0,0 +1,5 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+one:
+ id: 1
+two:
+ id: 2
View
10 test/unit/ez_mail_template_test.rb
@@ -0,0 +1,10 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class EzMailTemplateTest < Test::Unit::TestCase
+ fixtures :ez_mail_templates
+
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end

0 comments on commit e816ba2

Please sign in to comment.
Something went wrong with that request. Please try again.