Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
GEROMAX committed Feb 8, 2018
2 parents 1bd757e + 73d8993 commit b4c0d3d
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 26 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ Server mode is faster than client mode, but server mode is tradeoff other subtas

## Compatibility

Redmine 3.3 or 3.4 stable
Redmine 3.2 or 3.3 or 3.4 stable

Tested on:
* 3.2.9
* 3.3.6
* 3.4.4

Expand Down
2 changes: 1 addition & 1 deletion app/views/issues/_subtask_list_accordion_partial.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% if has_grandson_issues?(@issue) %>
<%= content_for :header_tags do
stylesheet_link_tag("subtask_list_accordion", :plugin => "redmine_subtask_list_accordion") +
stylesheet_link_tag("subtask_list_accordion" + (subtask_list_accordion_tree_render_32? ? "_under32" : ""), :plugin => "redmine_subtask_list_accordion") +
javascript_include_tag("subtask_list_accordion" + (subtask_tree_client_processing? ? "_client" : ""), :plugin => "redmine_subtask_list_accordion")
end %>
<div class="accordion_control contextual">
Expand Down
63 changes: 63 additions & 0 deletions assets/stylesheets/subtask_list_accordion_under32.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#issue_tree > p {
margin-bottom: 5px;
}

.contextual.accordion_control {
float: left;
margin-bottom: 5px;
padding: 2px 7px 2px 2px;
}

.accordion_control a {
background-position: 0 50%;
background-repeat: no-repeat;
padding-bottom: 3px;
padding-left: 20px;
padding-top: 2px;
}

.accordion_control a.subtask_all_expand {
background-image: url(../../../images/arrow_expanded.png);
}

.accordion_control a.subtask_all_collapse {
background-image: url(../../../images/arrow_collapsed.png);
}

tr.issue.idnt td.subject a {
background: none;
padding-left: 0px;
}

tr.issue:not(.idnt):not(.haschild) td.subject a {
margin-left: 16px;
}

tr.issue.idnt:not(.haschild) td.subject a {
margin-left: 32px;
}

tr.issue.haschild > td.subject > span.treearrow {
cursor: pointer;
}

tr.issue.haschild:not(.idnt) > td.subject > span.treearrow {
padding-left: 16px;
}

tr.issue.haschild.idnt > td.subject > span.treearrow {
margin-left: 16px;
padding-left: 16px;
}

tr.issue.haschild.collapse > td.subject > span.treearrow {
background: url(../../../images/arrow_collapsed.png) no-repeat right bottom;
}

tr.issue.haschild.expand > td.subject > span.treearrow {
background: url(../../../images/arrow_expanded.png) no-repeat right bottom;
}

.icon-arrow-expanded { background-image: url(../../../images/arrow_expanded.png); }

.icon-arrow-collapsed { background-image: url(../../../images/arrow_collapsed.png); }
6 changes: 3 additions & 3 deletions config/locales/zh.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# English strings go here for Rails i18n
# Simplified Chinese strings go here for Rails i18n
zh:
list_all_expand: "全部展开"
list_all_collapse: "全部收拢"
context_menu_expand: "展开当前树形结构"
context_menu_collapse: "收拢当前树形结构"
context_menu_all_expand_next: "下一级全部展开"
field_subtasks_default_expand_limit_upper: "Upper limit of child issues to tree expanding from the first time"
label_enable_server_scripting_mode: "Enable server processing mode (Has many subtasks tree display more than faster, but tradeoff other subtask's plugin. for exsample 'subtask_list_columns' plugin)"
field_subtasks_default_expand_limit_upper: "子任务树中的问题数量上限(初次加载)"
label_enable_server_scripting_mode: "启用服务器处理模式(若存在多级树结构,启用该选项会较快,但可能会与其他子任务相关插件有冲突,如插件 'subtask_list_columns' "
2 changes: 1 addition & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
name 'Redmine Subtask List Accordion plugin'
author 'Ryuta Tobita'
description 'This plugin provide accordion to subtask list of issue.'
version '2.0.0'
version '2.1.0'
url 'https://github.com/GEROMAX/redmine_subtask_list_accordion'
author_url 'https://github.com/GEROMAX'
settings default: { 'enable_server_scripting_mode' => true }, :partial => 'settings/subtask_list_accordion_settings'
Expand Down
65 changes: 45 additions & 20 deletions lib/redmine_subtask_list_accordion/patches/issues_helper_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,48 @@ def switch_render_descendants_tree(issue)

# add method to IssuesHelper
def render_descendants_tree_accordion(issue)
#Compatible 3.3 and 3.4
s = (subtask_list_accordion_tree_render_33? ? '<form>' : '')
s << '<table class="list issues odd-even">'
trIdx = 0
issue_list(issue.descendants.visible.preload(:status, :priority, :tracker, :assigned_to).sort_by(&:lft)) do |child, level|
arrow = (child.descendants.visible.count > 0 ? content_tag('span', '', :class => 'treearrow') : ''.html_safe)
css = "issue issue-#{child.id} hascontextmenu #{child.css_classes}"
css << " haschild" if child.children?
css << (expand_tree_at_first?(issue) ? " expand" : " collapse")
css << " idnt idnt-#{level}" if level > 0
hide_or_show = 'display: none;' unless level <= 0 || expand_tree_at_first?(issue)
s << content_tag('tr',
content_tag('td', check_box_tag("ids[]", child.id, false, :id => nil), :class => 'checkbox') +
content_tag('td', arrow + link_to_issue(child, :project => (issue.project_id != child.project_id)), :class => 'subject', :style => 'width: 50%') +
content_tag('td', h(child.status), :class => 'status') +
content_tag('td', link_to_user(child.assigned_to), :class => 'assigned_to') +
content_tag('td', child.disabled_core_fields.include?('done_ratio') ? '' : progress_bar(child.done_ratio), :class=> 'done_ratio'),
:class => css, :cs => (trIdx+=1).to_s, :ce => (trIdx + child.descendants.visible.count - 1).to_s, :rank => level.to_s, :style => hide_or_show)
#switch under 3.2 or higher
if subtask_list_accordion_tree_render_32?
s = '<form><table class="list issues">'
issue_list(issue.descendants.visible.preload(:status, :priority, :tracker).sort_by(&:lft)) do |child, level|
arrow = (child.descendants.visible.count > 0 ? content_tag('span', '', :class => 'treearrow') : ''.html_safe)
css = "issue issue-#{child.id} hascontextmenu"
css << " haschild" if child.children?
css << (expand_tree_at_first?(issue) ? " expand" : " collapse")
css << " idnt idnt-#{level}" if level > 0
hide_or_show = 'display: none;' unless level <= 0 || expand_tree_at_first?(issue)
s << content_tag('tr',
content_tag('td', check_box_tag("ids[]", child.id, false, :id => nil), :class => 'checkbox') +
content_tag('td', arrow + link_to_issue(child, :project => (issue.project_id != child.project_id)), :class => 'subject', :style => 'width: 50%') +
content_tag('td', h(child.status)) +
content_tag('td', link_to_user(child.assigned_to)) +
content_tag('td', child.disabled_core_fields.include?('done_ratio') ? '' : progress_bar(child.done_ratio)),
:class => css, :cs => (trIdx+=1).to_s, :ce => (trIdx + child.descendants.visible.count - 1).to_s, :rank => level.to_s, :style => hide_or_show)
end
s << '</table></form>'
s.html_safe
else
s = '<table class="list issues odd-even">'
issue_list(issue.descendants.visible.preload(:status, :priority, :tracker, :assigned_to).sort_by(&:lft)) do |child, level|
arrow = (child.descendants.visible.count > 0 ? content_tag('span', '', :class => 'treearrow') : ''.html_safe)
css = "issue issue-#{child.id} hascontextmenu #{child.css_classes}"
css << " haschild" if child.children?
css << (expand_tree_at_first?(issue) ? " expand" : " collapse")
css << " idnt idnt-#{level}" if level > 0
hide_or_show = 'display: none;' unless level <= 0 || expand_tree_at_first?(issue)
s << content_tag('tr',
content_tag('td', check_box_tag("ids[]", child.id, false, :id => nil), :class => 'checkbox') +
content_tag('td', arrow + link_to_issue(child, :project => (issue.project_id != child.project_id)), :class => 'subject', :style => 'width: 50%') +
content_tag('td', h(child.status), :class => 'status') +
content_tag('td', link_to_user(child.assigned_to), :class => 'assigned_to') +
content_tag('td', child.disabled_core_fields.include?('done_ratio') ? '' : progress_bar(child.done_ratio), :class=> 'done_ratio'),
:class => css, :cs => (trIdx+=1).to_s, :ce => (trIdx + child.descendants.visible.count - 1).to_s, :rank => level.to_s, :style => hide_or_show)
end
s << '</table>'
#Compatible 3.3 and 3.4
subtask_list_accordion_tree_render_33? ? ('<form>' + s + '</form>').html_safe : s.html_safe
end
s << '</table>'
s << (subtask_list_accordion_tree_render_33? ? '</form>' : '')
s.html_safe
end

def expand_tree_at_first?(issue)
Expand All @@ -58,6 +78,11 @@ def subtask_tree_client_processing?
return !Setting.plugin_redmine_subtask_list_accordion['enable_server_scripting_mode']
end

def subtask_list_accordion_tree_render_32?
threshold = [3,3,0]
return (Redmine::VERSION.to_a[0, 3] <=> threshold) < 0
end

def subtask_list_accordion_tree_render_33?
threshold = [3,4,0]
return (Redmine::VERSION.to_a[0, 3] <=> threshold) < 0
Expand Down

0 comments on commit b4c0d3d

Please sign in to comment.