https://www.redmine.org/https://www.redmine.org/favicon.ico?16793021292021-01-27T01:56:15ZRedmineRedmine - Defect #34641: When editing an issue, the Log time and/or Add notes does not show or hide dynamicallyhttps://www.redmine.org/issues/34641?journal_id=1007042021-01-27T01:56:15ZYuichi HARADA
<ul><li><strong>File</strong> <a href="/attachments/26578">34641.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/26578/34641.patch">34641.patch</a> added</li></ul><p>When you change the project, <a class="source" href="https://www.redmine.org/projects/redmine/repository/svn/entry/trunk/app/views/issues/edit.js.erb">source:trunk/app/views/issues/edit.js.erb</a> will be executed, so you should be able to show/hide the Log time. However, the function does not work because <code>$('#log_time')</code> does not exist on the issue edit form.<br />I created a patch like this:</p>
<pre><code class="diff syntaxhl"><span class="gh">diff --git a/app/views/issues/_edit.html.erb b/app/views/issues/_edit.html.erb
index 33f8352f57..766e9c78aa 100644
</span><span class="gd">--- a/app/views/issues/_edit.html.erb
</span><span class="gi">+++ b/app/views/issues/_edit.html.erb
</span><span class="p">@@ -9,8 +9,7 @@</span>
</div>
</fieldset>
<% end %>
<span class="gd">- <% if User.current.allowed_to?(:log_time, @project) %>
- <fieldset class="tabular"><legend><%= l(:button_log_time) %></legend>
</span><span class="gi">+ <fieldset id="log_time" class="tabular"><legend><%= l(:button_log_time) %></legend>
</span> <%= labelled_fields_for :time_entry, @time_entry do |time_entry| %>
<div class="splitcontent">
<div class="splitcontentleft">
<span class="p">@@ -25,8 +24,8 @@</span>
<p><%= custom_field_tag_with_label :time_entry, value %></p>
<% end %>
<% end %>
<span class="gd">- </fieldset>
- <% end %>
</span><span class="gi">+ </fieldset>
+ <%= javascript_tag("$('#log_time').hide();") unless User.current.allowed_to?(:log_time, @project) %>
</span> <% if @issue.notes_addable? %>
<fieldset><legend><%= l(:field_notes) %></legend>
<%= f.text_area :notes, :cols => 60, :rows => 10, :class => 'wiki-edit',
</code></pre> Redmine - Defect #34641: When editing an issue, the Log time and/or Add notes does not show or hide dynamicallyhttps://www.redmine.org/issues/34641?journal_id=1007782021-02-02T09:48:50ZMischa The Evil
<ul><li><strong>Target version</strong> set to <i>Candidate for next minor release</i></li></ul><p>Nice catch! It probably needs some test coverage to ensure it won't break in the future.</p> Redmine - Defect #34641: When editing an issue, the Log time and/or Add notes does not show or hide dynamicallyhttps://www.redmine.org/issues/34641?journal_id=1007802021-02-02T10:12:35ZMarius BĂLTEANU
<ul><li><strong>Assignee</strong> set to <i>Marius BĂLTEANU</i></li></ul><p>Let me look a little bit on this, I don't think that we need Javascript for this.</p> Redmine - Defect #34641: When editing an issue, the Log time and/or Add notes does not show or hide dynamicallyhttps://www.redmine.org/issues/34641?journal_id=1007972021-02-02T12:39:50ZMischa The Evil
<ul></ul><p>Marius BALTEANU wrote:</p>
<blockquote>
<p>[...] I don't think that we need Javascript for this.</p>
</blockquote>
<p>That would be even nicer then...</p> Redmine - Defect #34641: When editing an issue, the Log time and/or Add notes does not show or hide dynamicallyhttps://www.redmine.org/issues/34641?journal_id=1008122021-02-04T00:05:19ZMarius BĂLTEANU
<ul><li><strong>Subject</strong> changed from <i>When editing an issue, the Log time does not show or hide dynamically</i> to <i>When editing an issue, the Log time and/or Add notes does not show or hide dynamically</i></li><li><strong>Target version</strong> changed from <i>Candidate for next minor release</i> to <i>Candidate for next major release</i></li></ul><p>I've updated the subject because the same problem reproduces also for add notes block.</p>
<p>Looking in the code, the log time block was supposed to hide automatically (see <a class="source" href="https://www.redmine.org/projects/redmine/repository/svn/entry/trunk/app/views/issues/edit.js.erb#L3">source:trunk/app/views/issues/edit.js.erb#L3</a>), but it doesn't work because the fieldset is missing the "log_time" id (most probably, because of <a class="changeset" title="Removed TabularFormBuilder references in views." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/8142">r8142</a>).</p>
<p>The fix to hide both blocks is quite small, just adding some ids and extra few lines of code for add notes, but it doesn't work in all cases, for example, if you edit an issue with the log time not available for the user and you change the project to one with log time available, it won't appear because the element was not rendered initially in the page.</p>
<p><a class="user active" href="https://www.redmine.org/users/129121">優一 内田</a> HARADA, indeed, rendering the block all the time and hiding using javascript it is an option, but I still prefer to find a non javascript solution for this.</p> Redmine - Defect #34641: When editing an issue, the Log time and/or Add notes does not show or hide dynamicallyhttps://www.redmine.org/issues/34641?journal_id=1008132021-02-04T00:08:28ZMarius BĂLTEANU
<ul></ul><p>For next minor release, we can deliver only the fix to hide the blocks if you find it useful.</p> Redmine - Defect #34641: When editing an issue, the Log time and/or Add notes does not show or hide dynamicallyhttps://www.redmine.org/issues/34641?journal_id=1008222021-02-04T07:31:25ZYuichi HARADA
<ul><li><strong>File</strong> <a href="/attachments/26612">34641-v2.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/26612/34641-v2.patch">34641-v2.patch</a> added</li></ul><p>Marius BALTEANU wrote:</p>
<blockquote>
<p><a class="user active" href="https://www.redmine.org/users/129121">優一 内田</a> HARADA, indeed, rendering the block all the time and hiding using javascript it is an option, but I still prefer to find a non javascript solution for this.</p>
</blockquote>
<p>I tried using <code>hidden</code> class (<a class="source" href="https://www.redmine.org/projects/redmine/repository/svn/entry/trunk/public/stylesheets/application.css#L136">source:trunk/public/stylesheets/application.css#L136</a>) like a <a class="source" href="https://www.redmine.org/projects/redmine/repository/svn/entry/trunk/app/views/issues/_attributes.html.erb#L27">source:trunk/app/views/issues/_attributes.html.erb#L27</a> . I fixed only the Log time block.</p>
<pre><code class="diff syntaxhl"><span class="gh">diff --git a/app/views/issues/_edit.html.erb b/app/views/issues/_edit.html.erb
index 33f8352f57..fe7dad04a8 100644
</span><span class="gd">--- a/app/views/issues/_edit.html.erb
</span><span class="gi">+++ b/app/views/issues/_edit.html.erb
</span><span class="p">@@ -9,8 +9,7 @@</span>
</div>
</fieldset>
<% end %>
<span class="gd">- <% if User.current.allowed_to?(:log_time, @project) %>
- <fieldset class="tabular"><legend><%= l(:button_log_time) %></legend>
</span><span class="gi">+ <fieldset id="log_time" class="tabular<%= ' hidden' unless User.current.allowed_to?(:log_time, @project) %>"><legend><%= l(:button_log_time) %></legend>
</span> <%= labelled_fields_for :time_entry, @time_entry do |time_entry| %>
<div class="splitcontent">
<div class="splitcontentleft">
<span class="p">@@ -25,8 +24,7 @@</span>
<p><%= custom_field_tag_with_label :time_entry, value %></p>
<% end %>
<% end %>
<span class="gd">- </fieldset>
- <% end %>
</span><span class="gi">+ </fieldset>
</span> <% if @issue.notes_addable? %>
<fieldset><legend><%= l(:field_notes) %></legend>
<%= f.text_area :notes, :cols => 60, :rows => 10, :class => 'wiki-edit',
<span class="gh">diff --git a/app/views/issues/edit.js.erb b/app/views/issues/edit.js.erb
index 8c94aecebd..ef04553e0c 100644
</span><span class="gd">--- a/app/views/issues/edit.js.erb
</span><span class="gi">+++ b/app/views/issues/edit.js.erb
</span><span class="p">@@ -1,7 +1,7 @@</span>
replaceIssueFormWith('<%= escape_javascript(render :partial => 'form') %>');
<% if User.current.allowed_to?(:log_time, @issue.project) %>
<span class="gd">- $('#log_time').show();
</span><span class="gi">+ $('#log_time').removeClass('hidden');
</span> <% else %>
<span class="gd">- $('#log_time').hide();
</span><span class="gi">+ $('#log_time').addClass('hidden');
</span> <% end %>
</code></pre> Redmine - Defect #34641: When editing an issue, the Log time and/or Add notes does not show or hide dynamicallyhttps://www.redmine.org/issues/34641?journal_id=1008732021-02-09T01:23:22ZYuichi HARADA
<ul><li><strong>File</strong> <a href="/attachments/26627">34641-v3.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/26627/34641-v3.patch">34641-v3.patch</a> added</li></ul><p>Added system test to <a class="attachment" href="https://www.redmine.org/attachments/26612">34641-v2.patch</a>.</p> Redmine - Defect #34641: When editing an issue, the Log time and/or Add notes does not show or hide dynamicallyhttps://www.redmine.org/issues/34641?journal_id=1008922021-02-10T22:38:13ZMarius BĂLTEANU
<ul><li><strong>File</strong> <i>0001-Update-log-time-and-add-notes-blocks-when-updating-t.patch</i> added</li></ul><p>Yuichi, thanks for updating your patch.</p>
<p>What do you think if we update the entire "edit" form instead of only "form"? In this way, we fix this issue for all three affected blocks: log time, add notes and add attachments and we simplify the code, as well.</p>
<p>Beside this, the attached patch fixes another issue:<br /><code>if User.current.allowed_to?(:log_time, @project)</code> checks if the user has the log time permission on the project and not on the issue's project and because of this, you can have the case when you open an issue on a project where you have rights to log time and when you select another project where you don't have rights, the block is still displayed because <code>@project</code> is the same.</p> Redmine - Defect #34641: When editing an issue, the Log time and/or Add notes does not show or hide dynamicallyhttps://www.redmine.org/issues/34641?journal_id=1008932021-02-10T22:38:41ZMarius BĂLTEANU
<ul><li><strong>File</strong> deleted (<del><i>0001-Update-log-time-and-add-notes-blocks-when-updating-t.patch</i></del>)</li></ul> Redmine - Defect #34641: When editing an issue, the Log time and/or Add notes does not show or hide dynamicallyhttps://www.redmine.org/issues/34641?journal_id=1008942021-02-10T22:41:01ZMarius BĂLTEANU
<ul><li><strong>File</strong> <a href="/attachments/26640">0001-Update-log-time-and-add-notes-blocks-when-updating-t.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/26640/0001-Update-log-time-and-add-notes-blocks-when-updating-t.patch">0001-Update-log-time-and-add-notes-blocks-when-updating-t.patch</a> added</li></ul> Redmine - Defect #34641: When editing an issue, the Log time and/or Add notes does not show or hide dynamicallyhttps://www.redmine.org/issues/34641?journal_id=1009152021-02-12T08:39:35ZGo MAEDA
<ul><li><strong>Category</strong> set to <i>Issues</i></li></ul> Redmine - Defect #34641: When editing an issue, the Log time and/or Add notes does not show or hide dynamicallyhttps://www.redmine.org/issues/34641?journal_id=1009832021-02-15T06:51:25ZYuichi HARADA
<ul></ul><p>Marius BALTEANU wrote:</p>
<blockquote>
<p>What do you think if we update the entire "edit" form instead of only "form"? In this way, we fix this issue for all three affected blocks: log time, add notes and add attachments and we simplify the code, as well.</p>
</blockquote>
<p>Marius, I thought it was good. However, <code>replaceIssueFormWith</code> was also used in the issue creation form, and this patch broke this issue creation form.</p>
<pre><code class="ruby syntaxhl"><span class="n">app</span><span class="o">/</span><span class="n">views</span><span class="o">/</span><span class="n">issues</span><span class="o">/</span><span class="n">new</span><span class="p">.</span><span class="nf">js</span><span class="p">.</span><span class="nf">erb</span><span class="p">:</span><span class="mi">1</span><span class="ss">:replaceIssueFormWith</span><span class="p">(</span><span class="s1">'<%= escape_javascript(render :partial => '</span><span class="n">form</span><span class="s1">') %>'</span><span class="p">);</span>
</code></pre> Redmine - Defect #34641: When editing an issue, the Log time and/or Add notes does not show or hide dynamicallyhttps://www.redmine.org/issues/34641?journal_id=1010482021-02-22T22:19:12ZMarius BĂLTEANU
<ul></ul><p>Yuichi HARADA wrote:</p>
<blockquote>
<p>Marius BALTEANU wrote:</p>
<blockquote>
<p>What do you think if we update the entire "edit" form instead of only "form"? In this way, we fix this issue for all three affected blocks: log time, add notes and add attachments and we simplify the code, as well.</p>
</blockquote>
<p>Marius, I thought it was good. However, <code>replaceIssueFormWith</code> was also used in the issue creation form, and this patch broke this issue creation form.</p>
<p>[...]</p>
</blockquote>
<p>Oh, such a bad patch, sorry for it. I'll post soon an updated one.</p> Redmine - Defect #34641: When editing an issue, the Log time and/or Add notes does not show or hide dynamicallyhttps://www.redmine.org/issues/34641?journal_id=1010762021-02-24T18:53:52ZMarius BĂLTEANU
<ul><li><strong>File</strong> <a href="/attachments/26732">0002-Update-log-time-and-add-notes-blocks-when-updating-t.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/26732/0002-Update-log-time-and-add-notes-blocks-when-updating-t.patch">0002-Update-log-time-and-add-notes-blocks-when-updating-t.patch</a> added</li></ul><p>Yuichi, can you test the attached patch?</p> Redmine - Defect #34641: When editing an issue, the Log time and/or Add notes does not show or hide dynamicallyhttps://www.redmine.org/issues/34641?journal_id=1010842021-02-25T03:07:19ZYuichi HARADA
<ul></ul><p>Marius BALTEANU wrote:</p>
<blockquote>
<p>Yuichi, can you test the attached patch?</p>
</blockquote>
<p>Marius, I tested your patch. I confirmed that the show or hide is dynamically switched. I think it's good.<br />However, I found a typo. I think it's better to fix it.</p>
<pre><code class="diff syntaxhl"><span class="gh">diff --git a/app/views/issues/_edit.html.erb b/app/views/issues/_edit.html.erb
index aca1ae8f4..bc881db4b 100644
</span><span class="gd">--- a/app/views/issues/_edit.html.erb
</span><span class="gi">+++ b/app/views/issues/_edit.html.erb
</span><span class="p">@@ -43,7 +43,7 @@</span>
<%= call_hook(:view_issues_edit_notes_bottom, { :issue => @issue, :notes => @notes, :form => f }) %>
</fieldset>
- <fieldset id="add_attachments"'><legend><%= l(:label_attachment_plural) %></legend>
<span class="gi">+ <fieldset id="add_attachments"><legend><%= l(:label_attachment_plural) %></legend>
</span> <% if @issue.attachments.any? && @issue.safe_attribute?('deleted_attachment_ids') %>
<div class="contextual"><%= link_to l(:label_edit_attachments), '#', :onclick => "$('#existing-attachments').toggle(); return false;" %></div>
<div id="existing-attachments" style="<%= @issue.deleted_attachment_ids.blank? ? 'display:none;' : '' %>">
</code></pre> Redmine - Defect #34641: When editing an issue, the Log time and/or Add notes does not show or hide dynamicallyhttps://www.redmine.org/issues/34641?journal_id=1050322022-01-03T03:19:46ZGo MAEDA
<ul><li><strong>Target version</strong> changed from <i>Candidate for next major release</i> to <i>5.0.0</i></li></ul><p>Setting the target version to 5.0.0.</p>
<p>The patch that should be committed is <a class="attachment" href="https://www.redmine.org/attachments/26732">0002-Update-log-time-and-add-notes-blocks-when-updating-t.patch</a> with the update in <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Defect: When editing an issue, the Log time and/or Add notes does not show or hide dynamically (Closed)" href="https://www.redmine.org/issues/34641#note-16">#34641#note-16</a>.</p> Redmine - Defect #34641: When editing an issue, the Log time and/or Add notes does not show or hide dynamicallyhttps://www.redmine.org/issues/34641?journal_id=1060952022-03-22T07:03:31ZMarius BĂLTEANU
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Resolved</i></li><li><strong>Resolution</strong> set to <i>Fixed</i></li></ul><p>Patch committed, thanks!</p> Redmine - Defect #34641: When editing an issue, the Log time and/or Add notes does not show or hide dynamicallyhttps://www.redmine.org/issues/34641?journal_id=1061412022-03-24T16:50:15ZMarius BĂLTEANU
<ul><li><strong>Status</strong> changed from <i>Resolved</i> to <i>Closed</i></li></ul> Redmine - Defect #34641: When editing an issue, the Log time and/or Add notes does not show or hide dynamicallyhttps://www.redmine.org/issues/34641?journal_id=1066992022-05-15T12:45:30ZMarius BĂLTEANU
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-5 priority-4 priority-default closed" href="/issues/37053">Defect #37053</a>: Attachments are lost when the status of the ticket is changed</i> added</li></ul>