From 0023d0610b2b09a947c472d32ae7077a3b98d048 Mon Sep 17 00:00:00 2001
From: huang
Date: Wed, 15 Apr 2015 15:15:51 +0800
Subject: [PATCH] =?UTF-8?q?=E7=BC=BA=E9=99=B7=E4=B8=BB=E9=A2=98=E3=80=81?=
=?UTF-8?q?=E6=8F=8F=E8=BF=B0=E5=BC=BA=E5=88=B6=E6=8D=A2=E8=A1=8C=20?=
=?UTF-8?q?=E8=B7=9F=E8=B8=AA=E6=8C=89=E9=92=AE=E6=A0=B7=E5=BC=8F=20?=
=?UTF-8?q?=E5=BC=95=E7=94=A8=E6=A0=B7=E5=BC=8F=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/helpers/journals_helper.rb | 29 ++++++++++
app/helpers/watchers_helper.rb | 23 +++++++-
app/views/issues/_action_menu.html.erb | 2 +-
app/views/issues/_history.html.erb | 15 ++---
app/views/issues/show.html.erb | 77 +++-----------------------
5 files changed, 65 insertions(+), 81 deletions(-)
diff --git a/app/helpers/journals_helper.rb b/app/helpers/journals_helper.rb
index cfebb4d30..6e3155f48 100644
--- a/app/helpers/journals_helper.rb
+++ b/app/helpers/journals_helper.rb
@@ -73,6 +73,35 @@ module JournalsHelper
content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes ,:style => "width:580px")
end
+ # 缺陷回复内容、引用内容
+ # Redo:后面需要统一扩展
+ def render_notes_issue (issue, journal, options={})
+ content = ''
+ editable = User.current.logged? && (User.current.allowed_to?(:edit_issue_notes, issue.project) || (journal.user == User.current && User.current.allowed_to?(:edit_own_issue_notes, issue.project)))
+ destroyable = User.current.logged? && ((journal.user == User.current) || (issue.author_id == User.current.id) || (User.current.admin == 1))
+ links = []
+ if !journal.notes.blank?
+ links << link_to(l(:button_quote),
+ {:controller => 'journals', :action => 'new', :id => issue.id, :journal_id => journal},
+ :remote => true,
+ :method => 'post',
+ :title => l(:button_quote)) if options[:reply_links]
+ links << link_to_in_place_notes_editor(l(:button_edit), "journal-#{journal.id}-notes",
+ { :controller => 'journals', :action => 'edit', :id => journal, :format => 'js' },
+ :title => l(:button_edit)) if editable
+ #Added by young
+ if destroyable
+ links << link_to(l(:button_delete), { :controller => 'journals', :action => 'destroy', :id => journal, :format => 'js' },
+ :title => l(:button_delete))
+ end
+ end
+ #content << content_tag('div', links.join(' ').html_safe, :class => 'contextual', :style => 'margin-top:-25px;') unless links.empty?
+ content << textilizable(journal, :notes)
+ css_classes = "wiki"
+ css_classes << " editable" if editable
+ content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes ,:style => "width:510px")
+ end
+
def link_to_in_place_notes_editor(text, field_id, url, options={})
onclick = "$.ajax({url: '#{url_for(url)}', type: 'get'}); return false;"
link_to text, '#', options.merge(:onclick => onclick)
diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb
index 6edb171c8..c615f59e2 100644
--- a/app/helpers/watchers_helper.rb
+++ b/app/helpers/watchers_helper.rb
@@ -42,7 +42,28 @@ module WatchersHelper
:object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort)
)
method = watched ? 'delete' : 'post'
-
+
+ link_to text, url, :remote => true, :method => method, :class => css
+ end
+
+ def watcher_link_issue(objects, user, options=[])
+ return '' unless user && user.logged?
+ objects = Array.wrap(objects)
+
+ watched = objects.any? {|object| object.watched_by?(user)}
+ @watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or objects.first.instance_of?(Contest) or (objects.first.instance_of?(Bid)))
+ css = @watch_flag ? ([watcher_css(objects), watched ? 'talk_edit ' : 'talk_edit '].join(' ') << options[0].to_s) :
+ ([watcher_css(objects), watched ? 'talk_edit fr ' : 'talk_edit fr '].join(' ') << options[0].to_s)
+
+ text = @watch_flag ?
+ (watched ? l(:button_unfollow) : l(:button_follow)) : (watched ? l(:button_unwatch) : l(:button_watch))
+
+ url = watch_path(
+ :object_type => objects.first.class.to_s.underscore,
+ :object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort)
+ )
+ method = watched ? 'delete' : 'post'
+
link_to text, url, :remote => true, :method => method, :class => css
end
diff --git a/app/views/issues/_action_menu.html.erb b/app/views/issues/_action_menu.html.erb
index 231116f2f..959ab52c1 100644
--- a/app/views/issues/_action_menu.html.erb
+++ b/app/views/issues/_action_menu.html.erb
@@ -1,6 +1,6 @@
-<%#= watcher_link(@issue, User.current) %>
+<%= watcher_link_issue(@issue, User.current) %>
<%#= link_to l(:button_copy), project_copy_issue_path(@project, @issue), :class => 'icon icon-copy' if User.current.allowed_to?(:add_issues, @project) %>
<%= link_to l(:button_delete), issue_path(@issue.id), :data => {:confirm => issues_destroy_confirmation_message(@issue)}, :method => :delete, :class => 'talk_edit fr' if User.current.allowed_to?(:delete_issues, @project) %>
diff --git a/app/views/issues/_history.html.erb b/app/views/issues/_history.html.erb
index e1e2de6a3..d9f9105ac 100644
--- a/app/views/issues/_history.html.erb
+++ b/app/views/issues/_history.html.erb
@@ -17,24 +17,17 @@
<% end %>
+
+
+ <%= render_notes_issue(issue, journal, :reply_links => reply_links) unless journal.notes.blank? %>
-
-
-
-
<%= render_notes(issue, journal, :reply_links => reply_links) unless journal.notes.blank? %>
-
<%= format_time journal.created_on %>
-
-
-
-
-
-<%= call_hook(:view_issues_history_journal_bottom, { :journal => journal }) %>
+ <%= call_hook(:view_issues_history_journal_bottom, { :journal => journal }) %>
<% end %>
<% heads_for_wiki_formatter if User.current.allowed_to?(:edit_issue_notes, issue.project) || User.current.allowed_to?(:edit_own_issue_notes, issue.project) %>
diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb
index 349f8ebc7..d905de48c 100644
--- a/app/views/issues/show.html.erb
+++ b/app/views/issues/show.html.erb
@@ -12,7 +12,7 @@
<%= link_to image_tag(url_to_avatar(@issue.author),:width => 46,:height => 46), user_path(@issue.author), :class => "ping_dispic" %>
-
+
<%= @issue.subject %><%= get_issue_typevalue(@issue.tracker_id) %>
由<%= @issue.author %>
@@ -24,7 +24,7 @@
'action_menu' %>
-
+
<% if @issue.description? || @issue.attachments.any? -%>
<% if @issue.description? %>
<%#= link_to l(:button_quote), quoted_issue_path(@issue.id), :remote => true, :method => 'post', :class => 'icon icon-comment' if authorize_for('issues', 'edit') %>
@@ -90,81 +90,22 @@
<%= link_to l(:button_quote), quoted_issue_path(@issue.id), :remote => true, :method => 'post', :class => 'talk_edit fr' if authorize_for('issues', 'edit') %>
+
<% if @journals.present? %>
-
<%=l(:label_history)%>
<%= render :partial => 'history', :locals => { :issue => @issue, :journals => @journals } %>
<% end %>
-
-<%# html_title "#{@issue.tracker.name} ##{@issue.id}: #{@issue.subject}" %>
-
-
-
-
- <%#·= link_to_if @prev_issue_id,
-# "\xc2\xab #{l(:label_previous)}",
-# (@prev_issue_id ? issue_path(Issue.find_by_id(@prev_issue_id)) : nil),
- :title => "##{@prev_issue_id}" %> |
-
-
-
- <%#= link_to_if @next_issue_id,
-# "#{l(:label_next)} \xc2\xbb",
-# (@next_issue_id ? issue_path(Issue.find_by_id(@next_issue_id)) : nil),
- :title => "##{@next_issue_id}" %>
-
-
-
-
-
-
-
-
-
-
- <%#= authoring @issue.created_on, @issue.author %>.
-
- <%#= l(:label_updated_time, time_tag(@issue.updated_on)).html_safe %>.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
<% if @changesets.present? %>
-
-
<%=l(:label_associated_revisions)%>
-<%= render :partial => 'changesets', :locals => { :changesets => @changesets} %>
-
+
+
<%=l(:label_associated_revisions)%>
+ <%= render :partial => 'changesets', :locals => { :changesets => @changesets} %>
+
<% end %>
-
-
-
+