Feature #29712

Preview and wiki toolbar for full width custom fields

Added by Go MAEDA about 1 month ago. Updated 12 days ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Custom fields
Target version:Candidate for next major release
Resolution:

Description

Currently, full-width custom fields don't have preview feature and wiki toolbar.

Since those look like a description field, I think it would be great and makes UI consistent to have preview and toolbar.

preview-and-toolbar@2x.png (37.5 KB) Go MAEDA, 2018-10-02 09:11

feature-29712-v2.patch Magnifier (2.34 KB) Mizuki ISHIKAWA, 2018-10-11 06:31

feature-29712-v3.patch Magnifier (4.59 KB) Mizuki ISHIKAWA, 2018-10-15 06:21


Related issues

Related to Redmine - Feature #27758: Adds preview option to the wiki toolbar Closed
Duplicated by Redmine - Feature #28085: Wiki Toolbar on Full Width Custom Fields Closed

History

#1 Updated by Go MAEDA about 1 month ago

  • Related to Feature #28085: Wiki Toolbar on Full Width Custom Fields added

#2 Updated by Go MAEDA about 1 month ago

  • Related to Feature #27758: Adds preview option to the wiki toolbar added

#3 Updated by Mizuki ISHIKAWA about 1 month ago

  • File feature-29712.patch added

By applying this patch preview and toolbar will be added to the full width IssueCustomField.

Full width custom fields often write long sentences, and previews and toolbars can help with that input.

#4 Updated by Mizuki ISHIKAWA about 1 month ago

Previous patch included unnecessary code, so I fixed it.
Please delete the previous patch.

#5 Updated by Go MAEDA about 1 month ago

  • File deleted (feature-29712.patch)

#6 Updated by Marius BALTEANU about 1 month ago

Thanks Mizuki for working on this. One question after I took a look at the patch without actually testing it, why we limit this feature only to Issue custom fields? I think we should have the toolbar wherever the text formatting is supported.

#7 Updated by Mizuki ISHIKAWA about 1 month ago

Marius BALTEANU wrote:

Thanks Mizuki for working on this. One question after I took a look at the patch without actually testing it, why we limit this feature only to Issue custom fields? I think we should have the toolbar wherever the text formatting is supported.

Thank you for your feedback. I had overlooked it.
I will fix the patch.

#8 Updated by Mizuki ISHIKAWA about 1 month ago

I wrote a patch to add a Wiki toolbar in other custom fields.

UserCustomField, TimeEntryActivityCustomField, and IssueCustomField(full_width_layout? == false) do not fit in the Wiki toolbar because the width of the input field is not the full width.
Therefore, this patch does not display the Wiki toolbar for these custom fields.

#9 Updated by Marius BALTEANU 19 days ago

Mizuki ISHIKAWA wrote:

I wrote a patch to add a Wiki toolbar in other custom fields.

UserCustomField, TimeEntryActivityCustomField, and IssueCustomField(full_width_layout? == false) do not fit in the Wiki toolbar because the width of the input field is not the full width.
Therefore, this patch does not display the Wiki toolbar for these custom fields.

Thanks again for working on this. Today I had some time to look over the proposed patch and I am almost sure that we should not touch the FieldFormat module to implement this feature.

I propose the following directions to implement this:

1. Call wikitoolbar_for from issues/_form_custom_fields.html.erb

--- a/app/helpers/custom_fields_helper.rb
+++ b/app/helpers/custom_fields_helper.rb
@@ -79,11 +79,18 @@ module CustomFieldsHelper

   # Return custom field html tag corresponding to its format
   def custom_field_tag(prefix, custom_value)
--- a/app/views/issues/_form_custom_fields.html.erb
+++ b/app/views/issues/_form_custom_fields.html.erb
@@ -20,4 +20,5 @@

 <% custom_field_values_full_width.each do |value| %>
   <p><%= custom_field_tag_with_label :issue, value, :required => @issue.required_attribute?(value.custom_field_id) %></p>
+  <%= wikitoolbar_for "issue_custom_field_values_#{value.custom_field_id}", preview_issue_path(:project_id => @issue.project, :issue_id => @issue.id) %>
 <% end %>

2. Add 'wiki-edit' class to field from custom_fields_helper.rb

--- a/app/helpers/custom_fields_helper.rb
+++ b/app/helpers/custom_fields_helper.rb
@@ -79,11 +79,18 @@ module CustomFieldsHelper

   # Return custom field html tag corresponding to its format
   def custom_field_tag(prefix, custom_value)
+    css = "#{custom_value.custom_field.field_format}_cf" 
+    cf_format_store = custom_value.custom_field.format_store
+    if cf_format_store.key?('text_formatting') && cf_format_store['text_formatting'] == 'full' &&
+      cf_format_store.key?('full_width_layout') && cf_format_store['full_width_layout'] == '1'
+      css << ' wiki-edit'
+    end
+
     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),
       custom_value,
-      :class => "#{custom_value.custom_field.field_format}_cf" 
+      :class => css
   end

Initially, I wanted to add the 'wiki-edit' class also from the view (together with the required attribute, but the custom_field_label_tag do not pass the options variable to custom_field_tag. Maybe it is better to modify these 2 functions instead of the solution from the above diff because will keep the code clearer (those 4 conditions do not look to well).

@Mizuki, what do you think?

#10 Updated by Marius BALTEANU 19 days ago

  • Related to deleted (Feature #28085: Wiki Toolbar on Full Width Custom Fields)

#11 Updated by Marius BALTEANU 19 days ago

  • Duplicated by Feature #28085: Wiki Toolbar on Full Width Custom Fields added

#12 Updated by Marius BALTEANU 19 days ago

Marius BALTEANU wrote:

2. Add 'wiki-edit' class to field from custom_fields_helper.rb
[...]

I'm blind, sorry. We should use the existing method full_width_layout? instead of the 4 conditions.
In the end, it could look something like this:

css << ' wiki-edit' if custom_value.custom_field.full_width_layout?

#13 Updated by Mizuki ISHIKAWA 17 days ago

#29712#note-9 code looks better than changing the FieldFormat module.

Custom fields other than IssueCustomFields do not have full_width_layout.
(http://www.redmine.org/projects/redmine/repository/entry/trunk/app/views/custom_fields/formats/_text.html.erb#L4)
If possible, I think that it is better to display the toolbar in other custom fields as well.

#14 Updated by Go MAEDA 12 days ago

  • Target version set to Candidate for next major release

Also available in: Atom PDF