patch.txt

Osamu Murayama, 2018-02-07 12:28

Download (7.89 KB)

 
1
diff -ur redmine-3.4.4.orig/app/controllers/previews_controller.rb redmine-3.4.4/app/controllers/previews_controller.rb
2
--- redmine-3.4.4.orig/app/controllers/previews_controller.rb	2018-02-05 16:49:08.167636001 +0900
3
+++ redmine-3.4.4/app/controllers/previews_controller.rb	2018-02-06 17:25:39.826994006 +0900
4
@@ -16,10 +16,41 @@
5
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
6
 
7
 class PreviewsController < ApplicationController
8
-  before_action :find_project, :find_attachments
9
+  before_action :find_project, :find_attachments, :except => [:project]
10
+
11
+  def project
12
+    @project = nil
13
+    @project = Project.visible.find_by_id(params[:id]) unless params[:id].blank?
14
+    @fulltexts = {}
15
+    if @project
16
+      @description = (params[:project] ? params[:project][:description] : nil)
17
+      if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @proj.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
18
+        @description = nil
19
+      end
20
+
21
+      @project.custom_values.each do |value|
22
+        cf = value.custom_field
23
+        next unless cf.field_format == "text" && cf.text_formatting == "full"
24
+        text = params[:project] && params[:project][:custom_field_values] && params[:project][:custom_field_values][cf.id.to_s.to_sym]
25
+        next if text && text.gsub(/(\r?\n|\n\r?)/, "\n") == value.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
26
+        @fulltexts[cf.name] = text
27
+      end
28
+
29
+    else
30
+      @description = (params[:project] ? params[:project][:description] : nil)
31
+
32
+      CustomField.where(:type=>"ProjectCustomField", :field_format=>"text").each do |cf|
33
+        next unless cf.text_formatting == "full"
34
+        text = params[:project] && params[:project][:custom_field_values] && params[:project][:custom_field_values][cf.id.to_s.to_sym]
35
+        @fulltexts[cf.name] = text if text
36
+      end
37
+    end
38
+    render :layout => false
39
+  end
40
 
41
   def issue
42
     @issue = Issue.visible.find_by_id(params[:id]) unless params[:id].blank?
43
+    @fulltexts = {}
44
     if @issue
45
       @description = params[:issue] && params[:issue][:description]
46
       if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
47
@@ -27,8 +58,22 @@
48
       end
49
       @notes = params[:journal] ? params[:journal][:notes] : nil
50
       @notes ||= params[:issue] ? params[:issue][:notes] : nil
51
+
52
+      @issue.editable_custom_field_values.each do |value|
53
+        cf = value.custom_field
54
+        next unless cf.field_format == "text" && cf.text_formatting == "full"
55
+        text = params[:issue] && params[:issue][:custom_field_values] && params[:issue][:custom_field_values][cf.id.to_s.to_sym]
56
+        next if text && text.gsub(/(\r?\n|\n\r?)/, "\n") == value.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
57
+        @fulltexts[cf.name] = text
58
+      end
59
     else
60
       @description = (params[:issue] ? params[:issue][:description] : nil)
61
+
62
+      CustomField.where(:type=>"IssueCustomField", :field_format=>"text").each do |cf|
63
+        next unless cf.text_formatting == "full"
64
+        text = params[:issue] && params[:issue][:custom_field_values] && params[:issue][:custom_field_values][cf.id.to_s.to_sym]
65
+        @fulltexts[cf.name] = text if text
66
+      end
67
     end
68
     render :layout => false
69
   end
70
diff -ur redmine-3.4.4.orig/app/helpers/custom_fields_helper.rb redmine-3.4.4/app/helpers/custom_fields_helper.rb
71
--- redmine-3.4.4.orig/app/helpers/custom_fields_helper.rb	2018-01-09 04:38:16.000000000 +0900
72
+++ redmine-3.4.4/app/helpers/custom_fields_helper.rb	2018-02-07 10:55:48.002986236 +0900
73
@@ -79,11 +79,16 @@
74
 
75
   # Return custom field html tag corresponding to its format
76
   def custom_field_tag(prefix, custom_value)
77
-    custom_value.custom_field.format.edit_tag self,
78
-      custom_field_tag_id(prefix, custom_value.custom_field),
79
-      custom_field_tag_name(prefix, custom_value.custom_field),
80
+    cf = custom_value.custom_field
81
+    tag = cf.format.edit_tag self,
82
+      custom_field_tag_id(prefix, cf),
83
+      custom_field_tag_name(prefix, cf),
84
       custom_value,
85
-      :class => "#{custom_value.custom_field.field_format}_cf"
86
+      :class => "#{cf.field_format}_cf"
87
+    if cf.field_format == "text" && cf.text_formatting == "full"
88
+      tag += wikitoolbar_for custom_field_tag_id(prefix, cf)
89
+    end
90
+    tag
91
   end
92
 
93
   # Return custom field name tag
94
diff -ur redmine-3.4.4.orig/app/views/previews/issue.html.erb redmine-3.4.4/app/views/previews/issue.html.erb
95
--- redmine-3.4.4.orig/app/views/previews/issue.html.erb	2018-02-05 16:45:54.690948920 +0900
96
+++ redmine-3.4.4/app/views/previews/issue.html.erb	2018-02-05 16:48:29.432277998 +0900
97
@@ -9,3 +9,9 @@
98
     <%= textilizable @description, :attachments => @attachments, :object => @issue %>
99
   </fieldset>
100
 <% end %>
101
+
102
+<% @fulltexts.each do |name, text| %>
103
+  <fieldset class="preview"><legend><%= name %></legend>
104
+    <%= textilizable text, :attachments => @attachments, :object => @issue %>
105
+  </fieldset>
106
+<% end %>
107
diff -ur redmine-3.4.4.orig/app/views/previews/project.html.erb redmine-3.4.4/app/views/previews/project.html.erb
108
--- redmine-3.4.4.orig/app/views/previews/project.html.erb	2018-02-06 17:36:22.461695994 +0900
109
+++ redmine-3.4.4/app/views/previews/project.html.erb	2018-02-06 15:18:41.023496004 +0900
110
@@ -0,0 +1,11 @@
111
+<% if @description %>
112
+  <fieldset class="preview"><legend><%= l(:field_description) %></legend>
113
+    <%= textilizable @description, :object => @project %>
114
+  </fieldset>
115
+<% end %>
116
+
117
+<% @fulltexts.each do |name, text| %>
118
+  <fieldset class="preview"><legend><%= name %></legend>
119
+    <%= textilizable text, :object => @project %>
120
+  </fieldset>
121
+<% end %>
122
diff -ur redmine-3.4.4.orig/app/views/projects/_edit.html.erb redmine-3.4.4/app/views/projects/_edit.html.erb
123
--- redmine-3.4.4.orig/app/views/projects/_edit.html.erb	2018-01-09 04:38:17.000000000 +0900
124
+++ redmine-3.4.4/app/views/projects/_edit.html.erb	2018-02-06 17:13:00.155348000 +0900
125
@@ -1,4 +1,6 @@
126
 <%= labelled_form_for @project, :html => {:multipart => true} do |f| %>
127
 <%= render :partial => 'form', :locals => { :f => f } %>
128
 <%= submit_tag l(:button_save) %>
129
+<%= preview_link preview_edit_project_path(:id => @project), "edit_project_#{@project.id}" %>
130
 <% end %>
131
+<div id="preview" class="wiki"></div>
132
diff -ur redmine-3.4.4.orig/app/views/projects/new.html.erb redmine-3.4.4/app/views/projects/new.html.erb
133
--- redmine-3.4.4.orig/app/views/projects/new.html.erb	2018-01-09 04:38:17.000000000 +0900
134
+++ redmine-3.4.4/app/views/projects/new.html.erb	2018-02-07 11:04:02.330986236 +0900
135
@@ -4,4 +4,7 @@
136
 <%= render :partial => 'form', :locals => { :f => f } %>
137
 <%= submit_tag l(:button_create) %>
138
 <%= submit_tag l(:button_create_and_continue), :name => 'continue' %>
139
+<%= preview_link preview_new_project_path, 'new_project' %>
140
 <% end %>
141
+<div id="preview" class="wiki"></div>
142
+
143
diff -ur redmine-3.4.4.orig/config/routes.rb redmine-3.4.4/config/routes.rb
144
--- redmine-3.4.4.orig/config/routes.rb	2018-01-09 04:38:18.000000000 +0900
145
+++ redmine-3.4.4/config/routes.rb	2018-02-06 15:08:40.059163999 +0900
146
@@ -26,6 +26,9 @@
147
   get 'account/activation_email', :to => 'account#activation_email', :as => 'activation_email'
148
 
149
   match '/news/preview', :controller => 'previews', :action => 'news', :as => 'preview_news', :via => [:get, :post, :put, :patch]
150
+  match '/projects/preview/new', :to => 'previews#project', :as => 'preview_new_project', :via => [:get, :post, :put, :patch]
151
+  match '/projects/preview/edit/:id', :to => 'previews#project', :as => 'preview_edit_project', :via => [:get, :post, :put, :patch]
152
+  match '/projects/preview', :to => 'previews#project', :as => 'preview_project', :via => [:get, :post, :put, :patch]
153
   match '/issues/preview/new/:project_id', :to => 'previews#issue', :as => 'preview_new_issue', :via => [:get, :post, :put, :patch]
154
   match '/issues/preview/edit/:id', :to => 'previews#issue', :as => 'preview_edit_issue', :via => [:get, :post, :put, :patch]
155
   match '/issues/preview', :to => 'previews#issue', :as => 'preview_issue', :via => [:get, :post, :put, :patch]