Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/helpers/knowledgebase_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ def sort_categories?
def show_category_totals?
redmine_knowledgebase_settings_value(:show_category_totals)
end

def show_article_tree_lists?
redmine_knowledgebase_settings_value(:show_article_tree_lists)
end

def updated_by(updated, updater)
l(:label_updated_who, :updater => link_to_user(updater), :age => time_tag(updated)).html_safe
Expand Down
54 changes: 54 additions & 0 deletions app/views/articles/_article_tree.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<div id="article-tree-options">
<a id="articleTreeExpandBtn" href="#" class="btn" onclick="articleTree.expandAllNodes(); articleTree.reload(); expandArticleTree();"><%= l(:label_expand_all) %></a>
<a id="articleTreeCollapseBtn" href="#" class="btn" onclick="articleTree.collapseAllNodes(); articleTree.reload(); collapseArticleTree();"><%= l(:label_collapse_all) %></a>
</div>

<div id="article-tree"></div>

<script type="text/javascript">
function expandArticleTree() {
$('#articleTreeExpandBtn').hide();
$('#articleTreeCollapseBtn').show();
}

function collapseArticleTree() {
$('#articleTreeCollapseBtn').hide();
$('#articleTreeExpandBtn').show();
}

var expandIcon = '<i class="icon-folder-expand"></i>';
var collapseIcon = '<i class="icon-folder-collapse"></i>';

var rootNode = new TreeNode("Categories",
{
icon: expandIcon
}
);

rootNode.on('expand', function(node){
node.setOptions({
icon: expandIcon
});
});

rootNode.on('collapse', function(node){
node.setOptions({
icon: collapseIcon
});
});

<% cats = @categories %>
<% cats = cats.sort_by(&:title) if sort_categories? %>
<% cats.each do |category| %>
<%= render :partial => "articles/article_tree_row", :locals => { :category => category, :parent_node_id => 'rootNode' } %>
<% end %>

var articleTree = new TreeView(rootNode, "#article-tree");

$(document).ready(function() {
articleTree.collapseAllNodes();
articleTree.reload();
collapseArticleTree();
});

</script>
38 changes: 38 additions & 0 deletions app/views/articles/_article_tree_row.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
node<%= category.id %> = new TreeNode('<%= link_to(category.title, {:controller => 'categories', :action => 'show', :id => category.id, :project_id => @project} ) %>',
{
icon: expandIcon
}
);

node<%= category.id %>.on('expand', function(node){
node.setOptions({
icon: expandIcon
});
});

node<%= category.id %>.on('collapse', function(node){
node.setOptions({
icon: collapseIcon
});
});

<%= parent_node_id %>.addChild(node<%= category.id %>);

<% subs = category.children %>
<% subs = subs.sort_by(&:title) if sort_categories? %>
<% subs.each do |subcat| %>
<%= render :partial => 'articles/article_tree_row', :locals => { :category => subcat, :parent_node_id => "node#{category.id}" } %>
<% end %>

<% arts = category.articles %>
<% arts = arts.sort_by(&:title) if sort_categories? %>
<% arts.each do |article| %>
<% truncate_length = 100 if local_assigns[:truncate_length].nil? %>

node<%= category.id %>.addChild(new TreeNode('<%= link_to truncate(article.title, :length => truncate_length), { :controller => 'articles', :action => 'show', :id => article.id, :project_id => @project}, :title => article.title %>',
{
icon: '<i class="icon-article"></i>'
}
));
<% end %>

8 changes: 8 additions & 0 deletions app/views/articles/_index_original.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
<% end %>
</ul>
</div>

<% if show_article_tree_lists? %>
<div class="articles box">
<h3><%= l(:title_article_tree_lists) %></h3>
<%= render :partial => 'articles/article_tree' %>
</div>
<% end %>

<% if User.current.allowed_to?(:view_recent_articles, @project) %>
<h3><%= l(:title_recently_updated_articles) %></h3>
<div class="articles index-summary">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
<%= check_box_tag 'settings[show_tiled_article_lists]', 1, @settings[:show_tiled_article_lists] %>
</p>

<p>
<%= label_tag :settings_show_category_tree_lists, l(:show_article_tree_lists) %>
<%= check_box_tag 'settings[show_article_tree_lists]', 1, @settings[:show_article_tree_lists] %>
</p>

<p>
<%= label_tag :settings_critical_tags, l(:critical_tags) %>
<%= text_field_tag "settings[critical_tags]", @settings[:critical_tags] %>
Expand Down
Binary file added assets/images/article_tree_document.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/article_tree_folder_expanded.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/article_tree_folder_folded.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading