org_chart 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTQ3YzI0MDAyYmYxNWJmNWNhMzgwZWI4Y2E0YjVkYWUzNWVlMDU5MQ==
4
+ NTYxM2EzNjZiYjg4NTkzOWJkZGNiNjM2NWNkOGQ2MmNhYjRjNzczMw==
5
5
  data.tar.gz: !binary |-
6
- ZjcwM2RhNDZiODBhYjEzZWU3ZjA3MTdlZjViY2RjOGQ0Nzg1NmJhMg==
6
+ ZTYwNTcyYzg4OWIxNGJlNWI1Y2Y2Y2UwM2ZmNDVlNzY2OTJlNDBmZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MGFmNTRlYzA5NGY3ZjgxNDc2NjJkNjk0YjBjZWJjMDY1ZDg0MmQyM2E5MTVi
10
- OTE2MGIwMmIxYTEwODE4ZjIyYjY1ZDJjMmViODIzNjc3MTZmMjY5YjVmNWIx
11
- MTMzYWE0ZGIzMmE0NWEwNzJlYjJkOWM2YjhkMDdiZGRmODM0OTg=
9
+ NzA3MDMyNjI4NzRmMTI5ODViMjBlOTQ5ZjUwMDkwZTEyZDA4NjQ3N2YxNmY1
10
+ NjVkZTUxN2JhZDBjNzUwOGZiZjcwNTZjNzI5MmJlM2Y3YzY3ZmY1MzU5OGIy
11
+ OGM5NjBkOTY2OGE4M2MyOThjYmViZDM4N2Y0ZmU3NzVhNmQzMjA=
12
12
  data.tar.gz: !binary |-
13
- OWM5NjE1MGU0YjRiYWViMTkzOGE4M2IwNTY3NjdmODVmZDUwMzdlYjA4ZWJh
14
- ZDNhM2I2NjRkYTg3MTk3NTAwZTk2ZGYyNjQ1ZGVjNWEwYTA3NmFiYjk5NzVl
15
- NTA3Y2M5ZmU3YTJkNTJlNDdmNWQyMDg5MDJlZjAxZjRmYmE2MzE=
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
- Finally, if you want to use the default CSS, add the following to your
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module OrgChart
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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.2
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