Skip to content

Commit 3f6cc40

Browse files
committed
Merge branch 'development'
2 parents 0b51d07 + b488710 commit 3f6cc40

File tree

15 files changed

+906
-1
lines changed

15 files changed

+906
-1
lines changed

LICENSE.md

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,24 @@
1-
# redmine_diff_popup
1+
# Redmine Diff Popup
2+
3+
This plugin provide on pop-up show feature of diff.
4+
5+
* http://www.redmine.org/plugins/redmine_diff_popup
6+
7+
## Features
8+
9+
* Add pop-up show feature on issue's history diff.
10+
* Add switch of pop-up/default in user preferences.
11+
12+
## Compatibility
13+
14+
Redmine 3.3 or 3.4 stable
15+
16+
Tested on:
17+
* 3.3.3
18+
* 3.4.2
19+
20+
## Installation
21+
22+
1. Follow the Redmine plugin installation steps at: http://www.redmine.org/wiki/redmine/Plugins
23+
2. Run the plugin migrations `rake redmine:plugins:migrate RAILS_ENV=production`
24+
3. Restart your Redmine web server
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
class DiffPopupController < ApplicationController
2+
unloadable
3+
before_action :find_journal, :only => [:journal_diff]
4+
5+
layout false
6+
helper :issues
7+
helper :custom_fields
8+
9+
def journal_diff
10+
@issue = @journal.issue
11+
if params[:detail_id].present?
12+
@detail = @journal.details.find_by_id(params[:detail_id])
13+
else
14+
@detail = @journal.details.detect {|d| d.property == 'attr' && d.prop_key == 'description'}
15+
end
16+
unless @issue && @detail
17+
render_404
18+
return false
19+
end
20+
if @detail.property == 'cf'
21+
unless @detail.custom_field && @detail.custom_field.visible_by?(@issue.project, User.current)
22+
raise ::Unauthorized
23+
end
24+
end
25+
@diff = Redmine::Helpers::Diff.new(@detail.value, @detail.old_value)
26+
end
27+
28+
private
29+
30+
def find_journal
31+
@journal = Journal.visible.find(params[:id])
32+
@project = @journal.journalized.project
33+
rescue ActiveRecord::RecordNotFound
34+
render_404
35+
end
36+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<p><%= authoring @journal.created_on, @journal.user, :label => :label_updated_time_by %></p>
2+
<div style="text-align:right;">
3+
<span class="diff_in"><%= l(:diff_popup_legend_add) %></span>&nbsp;<span class="diff_out"><%= l(:diff_popup_legend_remove) %></span>
4+
</div>
5+
<div class="text-diff">
6+
<%= simple_format_without_paragraph @diff.to_html %>
7+
</div>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<% if journal.details.any? && User.current.pref.enable_popup_journal_diff == '1' %>
2+
<% journal.visible_details.each do |detail| %>
3+
<% if is_show_diff_detail?(detail) %>
4+
<li><%= show_detail_diff_popup(detail, journal.indice) %></li>
5+
<% end %>
6+
<% end %>
7+
<% end %>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<% if User.current.pref.enable_popup_journal_diff == '1' %>
2+
<%= content_for :header_tags do
3+
javascript_include_tag("diff_popup", :plugin => "redmine_diff_popup")
4+
end %>
5+
<script>
6+
$(function () {
7+
replaceJournalDiff();
8+
});
9+
</script>
10+
<% end %>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<%= labelled_fields_for :pref, @user.pref do |pref_fields| %>
2+
<p><%= pref_fields.check_box :enable_popup_journal_diff %></p>
3+
<% end %>

assets/javascripts/diff_popup.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
function replaceJournalDiff()
2+
{
3+
$("#history div.journal ul > li > a").each(function(){
4+
//find li
5+
var orgDiff = $(this).parent();
6+
var popDiff = $(this).parents("div.journal:first").next("li");
7+
8+
//replace and set func
9+
popDiff.replaceAll(orgDiff).find("a").on("click", function(){
10+
var diffUrl = $(this).attr("href");
11+
var journalIndice = diffUrl.split("&indice=")[1];
12+
var dlgName = "#diffpopup" + journalIndice;
13+
14+
//on top dialog
15+
if ($(dlgName).size() == 1)
16+
{
17+
$(dlgName).dialog("moveToTop");
18+
return;
19+
}
20+
21+
//show dialog
22+
$.get(diffUrl, function (data) {
23+
var journalIndice = decodeURIComponent(this.url.split("?")[1].split("&indice=")[1]);
24+
var popupId = "diffpopup" + journalIndice;
25+
$("#content").append("<div id='" + popupId + "'></div>");
26+
$("#" + popupId).html(data).dialog({
27+
title: "#" + journalIndice,
28+
width: window.innerWidth / 2 - 40,
29+
maxHeight: window.innerHeight - 160,
30+
position: { my: "center center", at: "right center", of: window },
31+
create: function(event) {
32+
$(event.target).dialog("widget").css({ "position": "fixed" });
33+
},
34+
open: function() {
35+
$(this).find("a").blur();
36+
},
37+
close: function (event) {
38+
$(this).dialog("destroy");
39+
$(event.target).remove();
40+
}
41+
}).show();
42+
});
43+
});
44+
});
45+
}

config/locales/en.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# English strings go here for Rails i18n
2+
en:
3+
diff_popup_legend_add: "Added"
4+
diff_popup_legend_remove: "Removed"
5+
field_enable_popup_journal_diff: "Enable popup show of issue's history diff"

config/locales/ja.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Japanese strings go here for Rails i18n
2+
ja:
3+
diff_popup_legend_add: "追加"
4+
diff_popup_legend_remove: "削除"
5+
field_enable_popup_journal_diff: "チケット履歴の差分をポップアップ表示する"

0 commit comments

Comments
 (0)