introspective_admin 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e3df509ea69dc1bffd24bc0faa12f5bf6d5127e
4
- data.tar.gz: 644a77509efc50e5c530a2081f3dee007a284963
3
+ metadata.gz: b9a18513acd371f5dc9deeebf46976c7d1c81ceb
4
+ data.tar.gz: 57621ecaac26a7df9b9b7e14d36b1d95a0dfea66
5
5
  SHA512:
6
- metadata.gz: 804bc5a17511a681d7fcf53fac8f072f21b5bc5f96a28509eefe8c39d0aeb5598844391deaf1b2a13ab30414bf2dc73bba8476675e793713727f2d3bd5c04e26
7
- data.tar.gz: e04f67870640ef7d0b7cb8db59e6dcd262bd6c54f1715fb77eb02b32d69dbe1765b16107ba04f22da7b7af63c0d5f185dc678777d4b2a62486c040758c3c0ee1
6
+ metadata.gz: 1ea656420a6f9e6574a5979d92c89540b43ddccc2e02fd6fe55b844cc36bf75f6f5db76c635803f829993c58dc871c4ddf610eea1f25361f0b96b4ae8ed19bb5
7
+ data.tar.gz: c757ca3da6dddddbae8ab663a025b376d165aa6d96135ac19180bce29c312b04890d52d23d2539b0e91ec8ce158a3c349e35c9581797bf02552662261c95cde8
@@ -45,11 +45,11 @@ module IntrospectiveAdmin
45
45
  }+extras
46
46
  end
47
47
 
48
- def link_record(record)
48
+ def link_record(dsl, record)
49
49
  link_text = record.try(:name) || record.try(:title) || record.class.to_s
50
- link_href = begin eval("admin_#{record.class.name.underscore}_path(#{record.id})") rescue false end
50
+ link_href = begin dsl.send("admin_#{record.class.name.underscore}_path", record.id) rescue false end
51
51
  if link_href
52
- link_to link_text, link_href
52
+ dsl.link_to link_text, link_href
53
53
  elsif link_text
54
54
  link_text
55
55
  else
@@ -91,7 +91,14 @@ module IntrospectiveAdmin
91
91
  selectable_column
92
92
  cols = model.columns.map(&:name)-klass.exclude_params
93
93
  cols.each_with_index do |c,i|
94
- column c
94
+ reflection = model.reflections.detect {|k,v| v.foreign_key == c }
95
+ if reflection
96
+ column c do |o|
97
+ klass.link_record(self,o.send(reflection.first))
98
+ end
99
+ else
100
+ column c
101
+ end
95
102
  end
96
103
  actions
97
104
  end
@@ -102,7 +109,15 @@ module IntrospectiveAdmin
102
109
  attributes_table do
103
110
  model.columns.each do |c|
104
111
  next if (c.name =~ /password/)
105
- row c.name
112
+ reflection = model.reflections.detect {|k,v| v.foreign_key == c.name }
113
+ if reflection
114
+ row c.name do |o|
115
+ klass.link_record(self,instance.send(reflection.first))
116
+ end
117
+ else
118
+ row c.name
119
+ end
120
+
106
121
  end
107
122
 
108
123
  nested_config.each do |assoc,options|
@@ -111,7 +126,7 @@ module IntrospectiveAdmin
111
126
  options[:columns].each do |c|
112
127
  if options[:class].reflections[c]
113
128
  column( c ) do |r|
114
- klass.link_record(r.send(c)) if r
129
+ klass.link_record(self,r.send(c)) if r
115
130
  end
116
131
  else
117
132
  column c
@@ -1,3 +1,3 @@
1
1
  module IntrospectiveAdmin
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: introspective_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Buermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-14 00:00:00.000000000 Z
11
+ date: 2016-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sass-rails