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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1bc8d0f694c9f0ecc38fbd07fb2b675e159f942
4
- data.tar.gz: 9f16c13e44ba68e9e8e73242573e15c2475ba721
3
+ metadata.gz: 774247dc9896f0b70a682faea977ce18483704fb
4
+ data.tar.gz: 9888a9b0a076fdf981595e90f5d9a0062dea0a69
5
5
  SHA512:
6
- metadata.gz: bd9486c63d731eafa348af5f2e1450c4ea962a7bc99db3141a32a0e5e270b83c0673c7c419f1ff1c6e50c358fb93e332c1b45278b4baaf905d1d14f50a34bd17
7
- data.tar.gz: 4a42d8888b766c85ad61eaa3fa2688cb0b70bbbea14c0853228f72ce23bebf8ab5a38471d9925efcf94b707dc835d73dee845096c1ed709f05e87bccd57b5648
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
- m2.div class: locale do
98
- if record.respond_to?(:text) && record.respond_to?(:text) && record.respond_to?(:texts) && (text = record.text(locale))
99
- syms = text.try(:editable_columns) || text.try(:content_columns).try(:map, &:name) || []
100
- syms.each do |sym|
101
- column = text.class.columns_hash[sym.to_s]
102
- m2.dt t_xxx(text.class.table_name,sym)
103
- m2.dd { m2 << text_tag(column.type,"#{text.class.table_name}[#{locale}][#{sym}]",text.__send__(sym)) }
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
- if record.respond_to?(:text) && model.respond_to?(:text)
176
- text_model = model.text
177
- mns = text_model.try(:showable_methods) || text_model.content_columns.map(&:name) || []
178
- if mns.present?
179
- lang_model = defined?(::Lang) ? ::Lang : ActiveRecord::Mlang::Lang
180
- langs = lang_model.all.to_a
181
- langs.each do |lang|
182
- text = record.text(lang.code)
183
- mns.each do |mn|
184
- m.div class: lang.code do
185
- m.dt t_xxx(record.class.text.table_name,mn)
186
- m.dd { m << (display_tag(mn,text) || "N/A") }
187
- end
188
- end
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
@@ -1,5 +1,5 @@
1
1
  module WeBridge
2
2
  module AutoViewHelper
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  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.5
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-06 00:00:00.000000000 Z
11
+ date: 2015-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview