we_bridge-auto_view_helper 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/we_bridge/auto_view_helper.rb +15 -17
- data/lib/we_bridge/auto_view_helper/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c2147712b44d45924880bc3a8a2065f09c4d44a
|
4
|
+
data.tar.gz: 936adad2606e216d85c48a9c150bfae3692e88f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88288baf6b81cde0e96020db35f413dae7e09d343121fb29da109584a489611744a43b00dace868623384a69b4d2c29d9c60de54241d2bbfc9cd912058fe7218
|
7
|
+
data.tar.gz: 25888c8024da5743a8510541272c4cb5b3c636b14f09d096b1d86a8e4904ccecb2c65e9b184255c23a7f4aaf0e3ebc225fc19fef222bfb8d82f068cf8672befd
|
@@ -43,13 +43,7 @@ module WeBridge
|
|
43
43
|
markup do |m2|
|
44
44
|
m2.dl do
|
45
45
|
klass = record.class
|
46
|
-
syms = []
|
47
|
-
if klass.respond_to? :editable_columns
|
48
|
-
syms = klass.editable_columns
|
49
|
-
else
|
50
|
-
syms = klass.content_columns.map(&:name)
|
51
|
-
end
|
52
|
-
|
46
|
+
syms = klass.try(:editable_columns) || klass.try(:content_columns).try(:map, &:name) || []
|
53
47
|
syms.each do |sym|
|
54
48
|
m2.dt t_xxx(record.class.table_name,sym)
|
55
49
|
m2.dd { m2 << auto_input_tag(sym,record.class,"#{record.class.table_name}[#{sym}]",record.__send__(sym)) }
|
@@ -57,12 +51,7 @@ module WeBridge
|
|
57
51
|
|
58
52
|
m2.div class: locale do
|
59
53
|
if record.respond_to?(:text) && record.respond_to?(:text) && record.respond_to?(:texts) && (text = record.text(locale))
|
60
|
-
syms = []
|
61
|
-
if text.respond_to? :editable_columns
|
62
|
-
syms = text.editable_columns
|
63
|
-
else
|
64
|
-
syms = text.content_columns.map(&:name)
|
65
|
-
end
|
54
|
+
syms = text.try(:editable_columns) || text.try(:content_columns).try(:map, &:name) || []
|
66
55
|
syms.each do |sym|
|
67
56
|
column = text.class.columns_hash[sym.to_s]
|
68
57
|
m2.dt t_xxx(text.class.table_name,sym)
|
@@ -97,9 +86,10 @@ module WeBridge
|
|
97
86
|
end
|
98
87
|
|
99
88
|
def show_common(record,options={})
|
100
|
-
options = WeBridge::
|
89
|
+
options = WeBridge::AutoViewHelper.default_options.merge options.symbolize_keys
|
101
90
|
|
102
91
|
edit_path = options[:edit_path]
|
92
|
+
back_path = options[:back_path]
|
103
93
|
root_path = options[:root_path]
|
104
94
|
|
105
95
|
markup do |m|
|
@@ -112,6 +102,12 @@ module WeBridge
|
|
112
102
|
end
|
113
103
|
end
|
114
104
|
|
105
|
+
if back_path
|
106
|
+
m.div do
|
107
|
+
m.a "Back", href: back_path
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
115
111
|
if root_path
|
116
112
|
m.div do
|
117
113
|
m.a "Top", href: root_path
|
@@ -125,7 +121,9 @@ module WeBridge
|
|
125
121
|
model = record.class
|
126
122
|
markup do |m|
|
127
123
|
m.dl class: :table do
|
128
|
-
method_names = model.
|
124
|
+
method_names = model.try(:showable_methods) || model.content_columns.map(&:name)
|
125
|
+
|
126
|
+
m.div method_names.inspect
|
129
127
|
method_names.each do |mn|
|
130
128
|
m.dt t_xxx(record.class.table_name,mn)
|
131
129
|
m.dd { m << display_tag(mn,record) }
|
@@ -133,8 +131,8 @@ module WeBridge
|
|
133
131
|
|
134
132
|
if record.respond_to?(:text) && model.respond_to?(:text)
|
135
133
|
text_model = model.text
|
136
|
-
|
137
|
-
|
134
|
+
mns = text_model.try(:showable_methods) || text_model.content_columns.map(&:name) || []
|
135
|
+
if mns.present?
|
138
136
|
lang_model = defined?(::Lang) ? ::Lang : ActiveRecord::Mlang::Lang
|
139
137
|
langs = lang_model.all.to_a
|
140
138
|
langs.each do |lang|
|