org_chart 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +28 -1
- data/lib/get_org_data.rb +34 -0
- data/lib/org_chart/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTYxM2EzNjZiYjg4NTkzOWJkZGNiNjM2NWNkOGQ2MmNhYjRjNzczMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTYwNTcyYzg4OWIxNGJlNWI1Y2Y2Y2UwM2ZmNDVlNzY2OTJlNDBmZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzA3MDMyNjI4NzRmMTI5ODViMjBlOTQ5ZjUwMDkwZTEyZDA4NjQ3N2YxNmY1
|
10
|
+
NjVkZTUxN2JhZDBjNzUwOGZiZjcwNTZjNzI5MmJlM2Y3YzY3ZmY1MzU5OGIy
|
11
|
+
OGM5NjBkOTY2OGE4M2MyOThjYmViZDM4N2Y0ZmU3NzVhNmQzMjA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzI3NTVjZDFmYzg3NmZhMWFlM2ZiZGRmMjFhZjdkNTNlMDEwMWI0YmIyNzAw
|
14
|
+
M2FhYzNlMjk1OTU1ZGFkNjkwY2Y0ZmUzOWM0YjAzNWYwMGU4YjlkYTlhYWRi
|
15
|
+
NGFmNTRhZmYwMmQ5N2E1ODgwNjUxMTRmMDBmY2ZiNWUyNjNjYTA=
|
data/README.md
CHANGED
@@ -21,11 +21,38 @@ Add the following to your `app/assets/javascripts/application.js`:
|
|
21
21
|
//= require getorgchart
|
22
22
|
|
23
23
|
|
24
|
-
|
24
|
+
If you want to use the default CSS, add the following to your
|
25
25
|
`app/assets/stylesheets/application.css`:
|
26
26
|
|
27
27
|
*= require getorgchart
|
28
28
|
|
29
|
+
Add an Initializer to `app/config/initializer/{nameofthefile}.rb` and add a line `require 'get_org_data'`.
|
30
|
+
In your controller create nodes i.e.
|
31
|
+
|
32
|
+
class HomeController < ApplicationController
|
33
|
+
def index
|
34
|
+
|
35
|
+
@node = GetOrgData.new
|
36
|
+
@node.id = 1
|
37
|
+
@node.parent_id = nil
|
38
|
+
@node.name = "Irfan"
|
39
|
+
@node.title = "CEO"
|
40
|
+
|
41
|
+
@node2 = GetOrgData.new
|
42
|
+
@node2.id = 2
|
43
|
+
@node2.parent_id = 1
|
44
|
+
@node2.name = "Imran"
|
45
|
+
@node2.title = "DSE"
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
Finally add nodes to view simply:
|
51
|
+
<%= GetOrgData.to_start %>
|
52
|
+
<%= @node.to_node %>
|
53
|
+
<%= @node2.to_node %>
|
54
|
+
<%= GetOrgData.to_end %>
|
55
|
+
|
29
56
|
## Contributing
|
30
57
|
|
31
58
|
1. Fork it
|
data/lib/get_org_data.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
class GetOrgData
|
2
|
+
attr_accessor :id, :name, :parent_id, :title, :image
|
3
|
+
|
4
|
+
def self.to_start
|
5
|
+
table_start = ""
|
6
|
+
table_start << "<table id='orgChartData' style='display: none;'>"
|
7
|
+
table_start<< "<tr>"
|
8
|
+
table_start<< "<th>id</th>"
|
9
|
+
table_start<<"<th>parent id</th>"
|
10
|
+
table_start<<"<th>name</th>"
|
11
|
+
table_start<<"<th>title</th>"
|
12
|
+
table_start<<"<th>image</th>"
|
13
|
+
table_start<<"</tr>"
|
14
|
+
table_start.html_safe
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.to_end
|
18
|
+
table_end = ""
|
19
|
+
table_end << "</table>"
|
20
|
+
table_end.html_safe
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_node
|
24
|
+
node = ""
|
25
|
+
node << "<tr>"
|
26
|
+
node << "<td>#{id}</td>"
|
27
|
+
node << "<td>#{parent_id}</td>"
|
28
|
+
node << "<td>#{name}</td>"
|
29
|
+
node << "<td>#{title}</td>"
|
30
|
+
node << "<td>#{image}</td>"
|
31
|
+
node << "</tr>"
|
32
|
+
node.html_safe
|
33
|
+
end
|
34
|
+
end
|
data/lib/org_chart/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: org_chart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Muhammad Irfan
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- LICENSE.txt
|
65
65
|
- README.md
|
66
66
|
- Rakefile
|
67
|
+
- lib/get_org_data.rb
|
67
68
|
- lib/org_chart.rb
|
68
69
|
- lib/org_chart/version.rb
|
69
70
|
- org_chart.gemspec
|