diff --git a/README.md b/README.md index fc7b69c..c8729b1 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/app/views/issues/_subtask_list_accordion_partial.html.erb b/app/views/issues/_subtask_list_accordion_partial.html.erb index da5cb44..419a257 100644 --- a/app/views/issues/_subtask_list_accordion_partial.html.erb +++ b/app/views/issues/_subtask_list_accordion_partial.html.erb @@ -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 %>
diff --git a/assets/stylesheets/subtask_list_accordion_under32.css b/assets/stylesheets/subtask_list_accordion_under32.css new file mode 100644 index 0000000..f5759a7 --- /dev/null +++ b/assets/stylesheets/subtask_list_accordion_under32.css @@ -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); } diff --git a/config/locales/zh.yml b/config/locales/zh.yml index c4a22f4..e36043a 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -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' ) " diff --git a/init.rb b/init.rb index 7dd6d18..d061c17 100644 --- a/init.rb +++ b/init.rb @@ -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' diff --git a/lib/redmine_subtask_list_accordion/patches/issues_helper_patch.rb b/lib/redmine_subtask_list_accordion/patches/issues_helper_patch.rb index 858ace5..3c9ef52 100644 --- a/lib/redmine_subtask_list_accordion/patches/issues_helper_patch.rb +++ b/lib/redmine_subtask_list_accordion/patches/issues_helper_patch.rb @@ -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? ? '
' : '') - s << '' 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 = '
' + 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 << '
' + s.html_safe + else + s = '' + 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 << '
' + #Compatible 3.3 and 3.4 + subtask_list_accordion_tree_render_33? ? ('
' + s + '
').html_safe : s.html_safe end - s << '' - s << (subtask_list_accordion_tree_render_33? ? '' : '') - s.html_safe end def expand_tree_at_first?(issue) @@ -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