|
diff -ur redmine-3.4.4.orig/app/controllers/previews_controller.rb redmine-3.4.4/app/controllers/previews_controller.rb
|
|
--- redmine-3.4.4.orig/app/controllers/previews_controller.rb 2018-02-05 16:49:08.167636001 +0900
|
|
+++ redmine-3.4.4/app/controllers/previews_controller.rb 2018-02-06 17:25:39.826994006 +0900
|
|
@@ -16,10 +16,41 @@
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
class PreviewsController < ApplicationController
|
|
- before_action :find_project, :find_attachments
|
|
+ before_action :find_project, :find_attachments, :except => [:project]
|
|
+
|
|
+ def project
|
|
+ @project = nil
|
|
+ @project = Project.visible.find_by_id(params[:id]) unless params[:id].blank?
|
|
+ @fulltexts = {}
|
|
+ if @project
|
|
+ @description = (params[:project] ? params[:project][:description] : nil)
|
|
+ if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @proj.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
|
|
+ @description = nil
|
|
+ end
|
|
+
|
|
+ @project.custom_values.each do |value|
|
|
+ cf = value.custom_field
|
|
+ next unless cf.field_format == "text" && cf.text_formatting == "full"
|
|
+ text = params[:project] && params[:project][:custom_field_values] && params[:project][:custom_field_values][cf.id.to_s.to_sym]
|
|
+ next if text && text.gsub(/(\r?\n|\n\r?)/, "\n") == value.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
|
|
+ @fulltexts[cf.name] = text
|
|
+ end
|
|
+
|
|
+ else
|
|
+ @description = (params[:project] ? params[:project][:description] : nil)
|
|
+
|
|
+ CustomField.where(:type=>"ProjectCustomField", :field_format=>"text").each do |cf|
|
|
+ next unless cf.text_formatting == "full"
|
|
+ text = params[:project] && params[:project][:custom_field_values] && params[:project][:custom_field_values][cf.id.to_s.to_sym]
|
|
+ @fulltexts[cf.name] = text if text
|
|
+ end
|
|
+ end
|
|
+ render :layout => false
|
|
+ end
|
|
|
|
def issue
|
|
@issue = Issue.visible.find_by_id(params[:id]) unless params[:id].blank?
|
|
+ @fulltexts = {}
|
|
if @issue
|
|
@description = params[:issue] && params[:issue][:description]
|
|
if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
|
|
@@ -27,8 +58,22 @@
|
|
end
|
|
@notes = params[:journal] ? params[:journal][:notes] : nil
|
|
@notes ||= params[:issue] ? params[:issue][:notes] : nil
|
|
+
|
|
+ @issue.editable_custom_field_values.each do |value|
|
|
+ cf = value.custom_field
|
|
+ next unless cf.field_format == "text" && cf.text_formatting == "full"
|
|
+ text = params[:issue] && params[:issue][:custom_field_values] && params[:issue][:custom_field_values][cf.id.to_s.to_sym]
|
|
+ next if text && text.gsub(/(\r?\n|\n\r?)/, "\n") == value.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
|
|
+ @fulltexts[cf.name] = text
|
|
+ end
|
|
else
|
|
@description = (params[:issue] ? params[:issue][:description] : nil)
|
|
+
|
|
+ CustomField.where(:type=>"IssueCustomField", :field_format=>"text").each do |cf|
|
|
+ next unless cf.text_formatting == "full"
|
|
+ text = params[:issue] && params[:issue][:custom_field_values] && params[:issue][:custom_field_values][cf.id.to_s.to_sym]
|
|
+ @fulltexts[cf.name] = text if text
|
|
+ end
|
|
end
|
|
render :layout => false
|
|
end
|
|
diff -ur redmine-3.4.4.orig/app/helpers/custom_fields_helper.rb redmine-3.4.4/app/helpers/custom_fields_helper.rb
|
|
--- redmine-3.4.4.orig/app/helpers/custom_fields_helper.rb 2018-01-09 04:38:16.000000000 +0900
|
|
+++ redmine-3.4.4/app/helpers/custom_fields_helper.rb 2018-02-07 10:55:48.002986236 +0900
|
|
@@ -79,11 +79,16 @@
|
|
|
|
# Return custom field html tag corresponding to its format
|
|
def custom_field_tag(prefix, custom_value)
|
|
- custom_value.custom_field.format.edit_tag self,
|
|
- custom_field_tag_id(prefix, custom_value.custom_field),
|
|
- custom_field_tag_name(prefix, custom_value.custom_field),
|
|
+ cf = custom_value.custom_field
|
|
+ tag = cf.format.edit_tag self,
|
|
+ custom_field_tag_id(prefix, cf),
|
|
+ custom_field_tag_name(prefix, cf),
|
|
custom_value,
|
|
- :class => "#{custom_value.custom_field.field_format}_cf"
|
|
+ :class => "#{cf.field_format}_cf"
|
|
+ if cf.field_format == "text" && cf.text_formatting == "full"
|
|
+ tag += wikitoolbar_for custom_field_tag_id(prefix, cf)
|
|
+ end
|
|
+ tag
|
|
end
|
|
|
|
# Return custom field name tag
|
|
diff -ur redmine-3.4.4.orig/app/views/previews/issue.html.erb redmine-3.4.4/app/views/previews/issue.html.erb
|
|
--- redmine-3.4.4.orig/app/views/previews/issue.html.erb 2018-02-05 16:45:54.690948920 +0900
|
|
+++ redmine-3.4.4/app/views/previews/issue.html.erb 2018-02-05 16:48:29.432277998 +0900
|
|
@@ -9,3 +9,9 @@
|
|
<%= textilizable @description, :attachments => @attachments, :object => @issue %>
|
|
</fieldset>
|
|
<% end %>
|
|
+
|
|
+<% @fulltexts.each do |name, text| %>
|
|
+ <fieldset class="preview"><legend><%= name %></legend>
|
|
+ <%= textilizable text, :attachments => @attachments, :object => @issue %>
|
|
+ </fieldset>
|
|
+<% end %>
|
|
diff -ur redmine-3.4.4.orig/app/views/previews/project.html.erb redmine-3.4.4/app/views/previews/project.html.erb
|
|
--- redmine-3.4.4.orig/app/views/previews/project.html.erb 2018-02-06 17:36:22.461695994 +0900
|
|
+++ redmine-3.4.4/app/views/previews/project.html.erb 2018-02-06 15:18:41.023496004 +0900
|
|
@@ -0,0 +1,11 @@
|
|
+<% if @description %>
|
|
+ <fieldset class="preview"><legend><%= l(:field_description) %></legend>
|
|
+ <%= textilizable @description, :object => @project %>
|
|
+ </fieldset>
|
|
+<% end %>
|
|
+
|
|
+<% @fulltexts.each do |name, text| %>
|
|
+ <fieldset class="preview"><legend><%= name %></legend>
|
|
+ <%= textilizable text, :object => @project %>
|
|
+ </fieldset>
|
|
+<% end %>
|
|
diff -ur redmine-3.4.4.orig/app/views/projects/_edit.html.erb redmine-3.4.4/app/views/projects/_edit.html.erb
|
|
--- redmine-3.4.4.orig/app/views/projects/_edit.html.erb 2018-01-09 04:38:17.000000000 +0900
|
|
+++ redmine-3.4.4/app/views/projects/_edit.html.erb 2018-02-06 17:13:00.155348000 +0900
|
|
@@ -1,4 +1,6 @@
|
|
<%= labelled_form_for @project, :html => {:multipart => true} do |f| %>
|
|
<%= render :partial => 'form', :locals => { :f => f } %>
|
|
<%= submit_tag l(:button_save) %>
|
|
+<%= preview_link preview_edit_project_path(:id => @project), "edit_project_#{@project.id}" %>
|
|
<% end %>
|
|
+<div id="preview" class="wiki"></div>
|
|
diff -ur redmine-3.4.4.orig/app/views/projects/new.html.erb redmine-3.4.4/app/views/projects/new.html.erb
|
|
--- redmine-3.4.4.orig/app/views/projects/new.html.erb 2018-01-09 04:38:17.000000000 +0900
|
|
+++ redmine-3.4.4/app/views/projects/new.html.erb 2018-02-07 11:04:02.330986236 +0900
|
|
@@ -4,4 +4,7 @@
|
|
<%= render :partial => 'form', :locals => { :f => f } %>
|
|
<%= submit_tag l(:button_create) %>
|
|
<%= submit_tag l(:button_create_and_continue), :name => 'continue' %>
|
|
+<%= preview_link preview_new_project_path, 'new_project' %>
|
|
<% end %>
|
|
+<div id="preview" class="wiki"></div>
|
|
+
|
|
diff -ur redmine-3.4.4.orig/config/routes.rb redmine-3.4.4/config/routes.rb
|
|
--- redmine-3.4.4.orig/config/routes.rb 2018-01-09 04:38:18.000000000 +0900
|
|
+++ redmine-3.4.4/config/routes.rb 2018-02-06 15:08:40.059163999 +0900
|
|
@@ -26,6 +26,9 @@
|
|
get 'account/activation_email', :to => 'account#activation_email', :as => 'activation_email'
|
|
|
|
match '/news/preview', :controller => 'previews', :action => 'news', :as => 'preview_news', :via => [:get, :post, :put, :patch]
|
|
+ match '/projects/preview/new', :to => 'previews#project', :as => 'preview_new_project', :via => [:get, :post, :put, :patch]
|
|
+ match '/projects/preview/edit/:id', :to => 'previews#project', :as => 'preview_edit_project', :via => [:get, :post, :put, :patch]
|
|
+ match '/projects/preview', :to => 'previews#project', :as => 'preview_project', :via => [:get, :post, :put, :patch]
|
|
match '/issues/preview/new/:project_id', :to => 'previews#issue', :as => 'preview_new_issue', :via => [:get, :post, :put, :patch]
|
|
match '/issues/preview/edit/:id', :to => 'previews#issue', :as => 'preview_edit_issue', :via => [:get, :post, :put, :patch]
|
|
match '/issues/preview', :to => 'previews#issue', :as => 'preview_issue', :via => [:get, :post, :put, :patch]
|