Skip to content

Commit dffe719

Browse files
committed
solved display issue for archived parent projects in Tree-Overview, replaced tabs with spaces
1 parent d5927ff commit dffe719

File tree

2 files changed

+60
-56
lines changed

2 files changed

+60
-56
lines changed

lib/project_tree/patches/projects_controller_patch.rb

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ module Patches
55
module ProjectsControllerPatch
66

77
def self.included(base) # :nodoc:
8-
base.send(:include, InstanceMethods)
8+
base.send(:include, InstanceMethods)
99
base.class_eval do
1010
unloadable
1111
#the before_filter is who gives the authorization to execute the function
12-
before_filter :authorize, :except => [ :index, :children, :autocomplete, :list, :new, :create, :copy ]
12+
before_filter :authorize, :except => [ :index, :children, :autocomplete, :list, :new, :create, :copy, :archive, :unarchive, :destroy ]
1313
end
1414
end
1515

@@ -24,13 +24,16 @@ def children
2424
# encapsulates all children of current project
2525
children = []
2626

27-
project.children.each do |child|
28-
entry = {}
29-
entry[:id] = child.id
30-
entry[:name] = child.name
31-
entry[:identifier] = child.identifier
32-
entry[:has_children] = (child.children.length > 0) ? true : false
33-
children << entry
27+
project.children.each do |child|
28+
# return only active projects to the result
29+
if child.status == 1
30+
entry = {}
31+
entry[:id] = child.id
32+
entry[:name] = child.name
33+
entry[:identifier] = child.identifier
34+
entry[:has_children] = (child.children.length > 0) ? true : false
35+
children << entry
36+
end
3437
end
3538
# add children to the result
3639
result[:children] = children
Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,57 @@
11
require_dependency 'projects_helper'
22

33
module ProjectTree
4-
module Patches
5-
module ProjectsHelperPatch
6-
7-
def top_projects
8-
@top_projects ||= find_toplevel_projects
9-
end
10-
11-
12-
def self.included(base) # :nodoc:
13-
base.send(:include, InstanceMethods)
4+
module Patches
5+
module ProjectsHelperPatch
6+
7+
def top_projects
8+
@top_projects ||= find_toplevel_projects
9+
end
10+
11+
12+
def self.included(base) # :nodoc:
13+
base.send(:include, InstanceMethods)
1414

15-
#base.class_eval do
16-
# 'unloadable' -> This is required only in the development mode
17-
# unloadable
18-
19-
# chain definition about new method which overrides to old method (see below: 'new_method_with_old_method')
20-
#alias_method_chain :new_method, :old_method
15+
#base.class_eval do
16+
# 'unloadable' -> This is required only in the development mode
17+
# unloadable
18+
19+
# chain definition about new method which overrides to old method (see below: 'new_method_with_old_method')
20+
#alias_method_chain :new_method, :old_method
2121

22-
# Anything you type in here is just like typing directly in the core
23-
# source files and will be run when the controller class is loaded.
24-
end
22+
# Anything you type in here is just like typing directly in the core
23+
# source files and will be run when the controller class is loaded.
24+
end
2525

26-
module InstanceMethods
27-
28-
# new method - fetches only the toplevel projects
29-
def find_toplevel_projects
30-
queryResult = ActiveRecord::Base.connection.exec_query("
31-
select p.id
32-
from
33-
#{Project.table_name} p
34-
where
35-
p.parent_id is null")
36-
37-
# load project as object and store it to the result
38-
result = []
39-
queryResult.each do |row|
40-
result << Project.find(row['id'])
41-
end
42-
43-
return result
44-
end
45-
46-
47-
#Insert overrides here
48-
#def new_method_with_old_method
49-
# your code
50-
#end
51-
end
52-
end
53-
end
26+
module InstanceMethods
27+
28+
# new method - fetches only the toplevel projects
29+
def find_toplevel_projects
30+
queryResult = ActiveRecord::Base.connection.exec_query("
31+
select p.id
32+
from
33+
#{Project.table_name} p
34+
where
35+
p.parent_id is null
36+
and p.status = 1")
37+
38+
# load project as object and store it to the result
39+
result = []
40+
queryResult.each do |row|
41+
result << Project.find(row['id'])
42+
end
43+
44+
return result
45+
end
46+
47+
48+
#Insert overrides here
49+
#def new_method_with_old_method
50+
# your code
51+
#end
52+
end
53+
end
54+
end
5455
end
5556

5657
ProjectsHelper.send(:include, ProjectTree::Patches::ProjectsHelperPatch)

0 commit comments

Comments
 (0)