we_bridge-auto_view_helper 0.0.5 → 0.0.6
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 +47 -22
- data/lib/we_bridge/auto_view_helper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 774247dc9896f0b70a682faea977ce18483704fb
|
4
|
+
data.tar.gz: 9888a9b0a076fdf981595e90f5d9a0062dea0a69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6322e251d8f270429e17926e2c9bcbe04160b45664499513c713e909e403467e1deb7d5a83684074e4dde2ceee819cb78c6c1125b8d320c911156227f6ed5e8f
|
7
|
+
data.tar.gz: deb8eda3359f8567062e4781b17937028aed10837848c1a9d7948d171bc2e9b64333abcf91f0da37c72480161fb38365e3b2f68f7319b6968478078d7f43cf5e
|
@@ -81,30 +81,42 @@ module WeBridge
|
|
81
81
|
|
82
82
|
title ||= "Edit " + record.class.name
|
83
83
|
method = options[:method]
|
84
|
+
|
85
|
+
klass = record.class
|
86
|
+
|
84
87
|
markup do |m|
|
85
88
|
m.section do
|
86
89
|
m.h2 title
|
87
90
|
m << form_tag(url, method: method || :post, multipart: true) do
|
88
91
|
markup do |m2|
|
89
92
|
m2.dl do
|
90
|
-
klass = record.class
|
91
93
|
syms = klass.try(:editable_columns) || klass.try(:content_columns).try(:map, &:name) || []
|
92
94
|
syms.each do |sym|
|
93
95
|
m2.dt t_xxx(record.class.table_name,sym)
|
94
96
|
m2.dd { m2 << auto_input_tag(sym,record.class,"#{record.class.table_name}[#{sym}]",record.__send__(sym)) }
|
95
97
|
end
|
98
|
+
end
|
96
99
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
100
|
+
if text_class = klass.try(:text)
|
101
|
+
text_table_name = text_class.table_name
|
102
|
+
lang_model = defined?(::Lang) ? ::Lang : ActiveRecord::Mlang::Lang
|
103
|
+
langs = lang_model.all.to_a
|
104
|
+
langs.each do |lang|
|
105
|
+
m2.fieldset class: lang.code do
|
106
|
+
m2.legend lang.code
|
107
|
+
syms = text_class.try(:editable_columns) || text_class.try(:content_columns).try(:map, &:name) || []
|
108
|
+
text = record.try(:text,lang.code) || text_class.new
|
109
|
+
m2.dl do
|
110
|
+
syms.each do |sym|
|
111
|
+
column = text_class.columns_hash[sym.to_s]
|
112
|
+
m2.dt t_xxx(text_table_name,sym)
|
113
|
+
m2.dd { m2 << auto_input_tag(sym,text_class,"#{text_table_name}[#{lang.code}][#{sym}]",text.__send__(sym)) }
|
114
|
+
end
|
104
115
|
end
|
105
116
|
end
|
106
117
|
end
|
107
118
|
end
|
119
|
+
|
108
120
|
m2 << submit_tag("Save")
|
109
121
|
end.html_safe
|
110
122
|
end
|
@@ -141,6 +153,7 @@ module WeBridge
|
|
141
153
|
m.section do
|
142
154
|
m.h2 "show "
|
143
155
|
m << self.show_record(record)
|
156
|
+
m << self.show_record_text(record)
|
144
157
|
if edit_path
|
145
158
|
m.div do
|
146
159
|
m.a "Edit", href: edit_path
|
@@ -171,21 +184,33 @@ module WeBridge
|
|
171
184
|
m.dt t_xxx(record.class.table_name,mn)
|
172
185
|
m.dd { m << display_tag(mn,record) }
|
173
186
|
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
174
190
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
191
|
+
def show_record_text(record)
|
192
|
+
model = record.class
|
193
|
+
if !((text_model = model.try(:text)) && record.respond_to?(:text))
|
194
|
+
return ""
|
195
|
+
end
|
196
|
+
|
197
|
+
mns = text_model.try(:showable_methods) || text_model.content_columns.map(&:name) || []
|
198
|
+
|
199
|
+
if !mns.present?
|
200
|
+
return ""
|
201
|
+
end
|
202
|
+
|
203
|
+
lang_model = defined?(::Lang) ? ::Lang : ActiveRecord::Mlang::Lang
|
204
|
+
langs = lang_model.all.to_a
|
205
|
+
markup do |m|
|
206
|
+
langs.each do |lang|
|
207
|
+
text = record.text(lang.code)
|
208
|
+
m.fieldset class: lang.code do
|
209
|
+
m.legend lang.code
|
210
|
+
m.dl do
|
211
|
+
mns.each do |mn|
|
212
|
+
m.dt t_xxx(text_model.table_name,mn)
|
213
|
+
m.dd { m << (display_tag(mn,text) || "N/A") }
|
189
214
|
end
|
190
215
|
end
|
191
216
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: we_bridge-auto_view_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shinjiro Itagaki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|