プロジェクト

全般

プロフィール

Vote #79568

完了

Preview and wiki toolbar for full width custom fields

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Custom fields_14
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
14
version_id:
127
issue_org_id:
29712
author_id:
332
assigned_to_id:
332
comments:
21
status_id:
5
tracker_id:
2
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

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.

!{width: 707px; border: 1px solid #ccc;}.preview-and-toolbar@2x.png!


journals

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
Previous patch included unnecessary code, so I fixed it.
Please delete the previous patch.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
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@
<pre><code class="diff">
--- 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 %>
</code></pre>

2. Add 'wiki-edit' class to field from @custom_fields_helper.rb@
<pre><code class="diff">
--- 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

</code></pre>

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?
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
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:
<pre><code class="ruby">
css << ' wiki-edit' if custom_value.custom_field.full_width_layout?
</code></pre>
--------------------------------------------------------------------------------
#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.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Implemented for full width layout custom fields.

--------------------------------------------------------------------------------
Applying my previous patch, will allow us to refactor a small piece of code that adds the 'wiki' class to the issues custom fields with text formatting enabled (including my fix for #30027). I'm attaching the patch.
--------------------------------------------------------------------------------
Mizuki ISHIKAWA wrote:
> #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.

Agree, we should show to toolbar for all custom fields that support full text formatting, but I prefer to do it in another ticket because it require more changes.

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
LGTM. Setting the target version to 4.1.0.
--------------------------------------------------------------------------------
Committed the patch. Thank you all for working on improving Redmine.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

relates,Closed,27758,Adds preview option to the wiki toolbar
relates,Closed,21924,Formatting buttons on long text custom fields
duplicates,Closed,28085,Wiki Toolbar on Full Width Custom Fields
duplicates,Closed,30745,Rich text formatting is broken on Text and Long text custom fields

Admin Redmine さんが3年以上前に更新

  • カテゴリCustom fields_14 にセット
  • 対象バージョン4.1.0_127 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0