Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better email notifications and more #27

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions app/models/mention_mailer.rb

This file was deleted.

9 changes: 6 additions & 3 deletions app/views/hooks/redmine_mentions/_edit_mentionable.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<%users_regex=users.collect{|u| "#{Setting.plugin_redmine_mentions['trigger']}#{u.login}"}.join('|')%>
<% regex_highlight = '/\B('+users_regex+')/g' %>
<script>
$(document).ready(function() {
$('#issue_notes,#issue_description').textcomplete([
{
mentions: <%= users.collect{|u| "#{u.firstname} #{u.lastname} - <small>#{u.login}</small>".downcase}.to_json.html_safe %>,
Expand All @@ -28,8 +29,10 @@
{
match: new RegExp(<%=regex_highlight%>),
css: {
'background-color': '#C6D5F3',
'background-color': '#C6D5F3'
}
}
]);
</script>
])
});

</script>
6 changes: 6 additions & 0 deletions app/views/mailer/notify_mentioning.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
You've been mentioned by <strong><%= @journal.user %></strong> on <strong><%= format_time @journal.created_on %></strong>
<hr />

<h1><%= link_to "#{@issue.tracker.name} ##{@issue.id}: #{@issue.subject}", issue_url(@issue) %></h1>

<p><%= textilizable(@journal, :notes, :only_path => false) %></p>
6 changes: 6 additions & 0 deletions app/views/mailer/notify_mentioning.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
You've been mentioned by <%= @journal.user %> on <%= format_time @journal.created_on %>

<%= @issue.tracker.name %> #<%= @issue.id %>: <%= @issue.subject %>
Access at: <%= issue_url(@issue) %>

<%= @journal.notes %>
9 changes: 0 additions & 9 deletions app/views/mention_mailer/notify_mentioning.html.erb

This file was deleted.

6 changes: 0 additions & 6 deletions app/views/mention_mailer/notify_mentioning.text.erb

This file was deleted.

2 changes: 1 addition & 1 deletion assets/javascripts/jquery.overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@
color: 'transparent',
'white-space': 'pre-wrap',
'word-wrap': 'break-word',
display: 'none',
overflow: 'hidden'
},
textarea: {
background: 'transparent',
position: 'relative',
outline: 0
}
Expand Down
31 changes: 29 additions & 2 deletions assets/javascripts/jquery.textcomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@
// position above the element
if(this.strategy.placement === 'top') {
// Move it to be in line with the match character
fontSize = parseInt(this.$el.css('font-size'));
fontSize = parseInt(this.$el.css('font-size'));
// Overwrite the position object to set the 'bottom' property instead of the top.
position = {
top: 'auto',
Expand All @@ -488,9 +488,13 @@
} else {
// Overwrite 'bottom' property because once `placement: 'top'`
// strategy is shown, $el keeps the property.
position.bottom = 'auto';

position.top = this.$el.parent().height() - position.top ;
position.marginTop= this.$el.parent().height() - position.top ;
}

this.$el.css(position);

return this;
},

Expand Down Expand Up @@ -584,3 +588,26 @@
};

})(window.jQuery || window.Zepto);

$(".jstb_zenedit").on('click', function(){

if($(this).parents('.jstEditor').attr('class').indexOf("zen")===-1) // not fullscreen
{
$("textarea").css("margin-left", "0%");
$("textarea").prev().css("margin-left", "0%");
}
else
{
$("textarea").css("margin-left", "25%");
$("textarea").prev().css("margin-left", "25%");
}
});

document.onkeydown = function(evt) {
evt = evt || window.event;
if (evt.keyCode == 27) {
$('.jstEditor.zen').removeClass('zen');
$('html.zen').removeClass('zen');
$("textarea").css("margin-left", "0px");
}
};
9 changes: 9 additions & 0 deletions assets/stylesheets/auto_complete.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,16 @@
border-radius: 3px 3px 3px 3px;
color: #fff;
}
.textcomplete-wrapper{
width: 100%;
height: 100%;
}
.wiki-edit{
display:block;
width: 100%;
height: 100%;
}
.textoverlay-wrapper{
width: 100%;
height: 100%;
}
4 changes: 3 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# English strings go here for Rails i18n
en:
# my_label: "My label"
field_color: Color
label_agile_color_: No colors

1 change: 1 addition & 0 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require_dependency 'redmine_mentions/hooks'
require_dependency 'journal'
Journal.send(:include, RedmineMentions::JournalPatch)
Mailer.send(:include, RedmineMentions::MailerPatch)
end
Redmine::Plugin.register :redmine_mentions do
name 'Redmine Mentions'
Expand Down
9 changes: 7 additions & 2 deletions lib/redmine_mentions/journal_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module JournalPatch
def self.included(base)
base.class_eval do
after_create :send_mail

before_create :check_colors

def send_mail
if self.journalized.is_a?(Issue) && self.notes.present?
issue = self.journalized
Expand All @@ -16,11 +17,15 @@ def send_mail
mentioned_users.each do |mentioned_user|
username = mentioned_user.first[1..-1]
if user = User.find_by_login(username)
MentionMailer.notify_mentioning(issue, self, user).deliver
Mailer.notify_mentioning(issue, self, user).deliver
end
end
end
end

def check_colors
details.reject!{|d| d.property == 'attr' and d.prop_key == 'color' and d.old_value.to_s.empty? and d.value.to_s.empty? }
end
end
end
end
Expand Down
16 changes: 16 additions & 0 deletions lib/redmine_mentions/mailer_patch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module RedmineMentions
module MailerPatch
def self.included(base)
base.class_eval do

def notify_mentioning(issue, journal, user)
@issue = issue
@journal = journal
subject = "[#{issue.project.to_s} - #{issue.tracker.name} ##{issue.id}] (#{issue.status.name}) #{issue.subject}"
mail(to: user.mail, subject: subject)
end

end
end
end
end