From f07a003bfcf0c4dc975adf51ec68e933ff9268f9 Mon Sep 17 00:00:00 2001
From: Marius BALTEANU <marius.balteanu@zitec.com>
Date: Thu, 14 Jun 2018 19:51:52 +0000
Subject: [PATCH] option to collapse/expand issue description, files, full
 width custom fields, subtasks and relations

---
 app/helpers/issues_helper.rb          |  6 +++---
 app/views/attachments/_links.html.erb |  2 +-
 app/views/issues/_relations.html.erb  |  4 ++--
 app/views/issues/show.html.erb        | 10 +++++-----
 public/javascripts/application.js     |  6 ++++++
 public/stylesheets/application.css    |  5 +++++
 6 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb
index d1fb289..8f4f628 100644
--- a/app/helpers/issues_helper.rb
+++ b/app/helpers/issues_helper.rb
@@ -82,7 +82,7 @@ module IssuesHelper
     s << '<div>'
     subject = h(issue.subject)
     if issue.is_private?
-      subject = subject + ' ' + content_tag('span', l(:field_is_private), :class => 'private') 
+      subject = subject + ' ' + content_tag('span', l(:field_is_private), :class => 'private')
     end
     s << content_tag('h3', subject)
     s << '</div>' * (ancestors.size + 1)
@@ -269,8 +269,8 @@ module IssuesHelper
 
       content =
           content_tag('hr') +
-          content_tag('p', content_tag('strong', custom_field_name_tag(value.custom_field) )) +
-          content_tag('div', attr_value, class: 'value')
+          content_tag('p', content_tag('strong', custom_field_name_tag(value.custom_field), :class => 'toggle-section icon icon-expanded' )) +
+          content_tag('div', attr_value, class: 'value collapsible')
       s << content_tag('div', content, class: "cf_#{value.custom_field.id} attribute")
     end
     s
diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb
index 0a9f5e3..4d6f018 100644
--- a/app/views/attachments/_links.html.erb
+++ b/app/views/attachments/_links.html.erb
@@ -1,4 +1,4 @@
-<div class="attachments">
+<div class="attachments collapsible">
 <div class="contextual">
   <%= link_to(l(:label_edit_attachments),
               container_attachments_edit_path(container),
diff --git a/app/views/issues/_relations.html.erb b/app/views/issues/_relations.html.erb
index 3825fe6..6c59ee7 100644
--- a/app/views/issues/_relations.html.erb
+++ b/app/views/issues/_relations.html.erb
@@ -4,10 +4,10 @@
 <% end %>
 </div>
 
-<p><strong><%=l(:label_related_issues)%></strong></p>
+<p><strong class="toggle-section icon icon-expanded"><%=l(:label_related_issues)%></strong></p>
 
 <% if @relations.present? %>
-<%= form_tag({}, :data => {:cm_url => issues_context_menu_path}) do %>
+<%= form_tag({}, :class => 'collapsible', :data => {:cm_url => issues_context_menu_path}) do %>
   <%= render_issue_relations(@issue, @relations) %>
 <% end %>
 <% end %>
diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb
index 5a1cc85..0d48852 100644
--- a/app/views/issues/show.html.erb
+++ b/app/views/issues/show.html.erb
@@ -82,15 +82,15 @@ end %>
   <%= link_to l(:button_quote), quoted_issue_path(@issue), :remote => true, :method => 'post', :class => 'icon icon-comment' if @issue.notes_addable? %>
   </div>
 
-  <p><strong><%=l(:field_description)%></strong></p>
-  <div class="wiki">
+  <p><strong class="toggle-section icon icon-expanded"><%=l(:field_description)%></strong></p>
+  <div class="wiki collapsible">
   <%= textilizable @issue, :description, :attachments => @issue.attachments %>
   </div>
 </div>
 <% end %>
 <% if @issue.attachments.any? %>
   <hr />
-  <p><strong><%=l(:label_attachment_plural)%></strong></p>
+  <p><strong class="toggle-section icon icon-expanded"><%=l(:label_attachment_plural)%></strong></p>
   <%= link_to_attachments @issue, :thumbnails => true %>
 <% end %>
 
@@ -104,8 +104,8 @@ end %>
 <div class="contextual">
   <%= link_to_new_subtask(@issue) if User.current.allowed_to?(:manage_subtasks, @project) %>
 </div>
-<p><strong><%=l(:label_subtask_plural)%></strong></p>
-<%= form_tag({}, :data => {:cm_url => issues_context_menu_path}) do %>
+<p><strong class="toggle-section icon icon-expanded"><%=l(:label_subtask_plural)%></strong></p>
+<%= form_tag({}, :class => 'collapsible', :data => {:cm_url => issues_context_menu_path}) do %>
 <%= render_descendants_tree(@issue) unless @issue.leaf? %>
 <% end %>
 </div>
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index c8a7df1..ac3441e 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -844,6 +844,12 @@ function toggleNewObjectDropdown() {
 $(document).ready(function(){
   $('#content').on('change', 'input[data-disables], input[data-enables], input[data-shows]', toggleDisabledOnChange);
   toggleDisabledInit();
+
+  $(".toggle-section").on('click', function() {
+    element = $(this)
+    element.toggleClass('icon-collapsed icon-expanded');
+    element.parent().next('.collapsible').toggle();
+  });
 });
 
 function keepAnchorOnSignIn(form){
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 725befb..a90066a 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -482,6 +482,9 @@ fieldset.collapsible {border-width: 1px 0 0 0;}
 fieldset.collapsible>legend { padding-left: 18px; background: url(../images/arrow_down.png) no-repeat 4px 40%; cursor:pointer; }
 fieldset.collapsible.collapsed>legend { background-image: url(../images/arrow_right.png); }
 
+.toggle-section {cursor: pointer;}
+.toggle-section.icon {padding-left: 15px;}
+
 fieldset#date-range p { margin: 2px 0 2px 0; }
 fieldset#filters table { border-collapse: collapse; }
 fieldset#filters table td { padding: 0; vertical-align: middle; }
@@ -1315,6 +1318,8 @@ div.wiki img {vertical-align:middle; max-width:100%;}
 .icon-add-bullet { background-image: url(../images/bullet_add.png); }
 .icon-shared { background-image: url(../images/link.png); }
 .icon-actions { background-image: url(../images/3_bullets.png); }
+.icon-collapsed {background-image: url(../images/arrow_right.png); }
+.icon-expanded {background-image: url(../images/arrow_down.png); }
 
 .icon-file { background-image: url(../images/files/default.png); }
 .icon-file.text-plain { background-image: url(../images/files/text.png); }
-- 
2.1.4

