we_bridge-auto_view_helper 0.0.3 → 0.0.4

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16ed5c768d1a20be4a65ae38f86c906501e8a0ef
4
- data.tar.gz: 63c72e5af5ad134559c020b70018a963bdebef6d
3
+ metadata.gz: 6c2147712b44d45924880bc3a8a2065f09c4d44a
4
+ data.tar.gz: 936adad2606e216d85c48a9c150bfae3692e88f3
5
5
  SHA512:
6
- metadata.gz: 5664b3c6e98c477f18769929146d2709d2b5c96e02cb9a9c2e3336f6691e2830c73c486de21f9b2e9f50b909e375aa466668ddecf07f39a749a203e48100cbd6
7
- data.tar.gz: 6ec20ad809dfa84da3a1c408163f3046db9779d461e4bfcd77b94ad5a01708f0c30e9ed32dfe38abf84ac26ae1a6502ee576ae1ff7d20c443b2501c0036116ce
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::Common::Layouts.default_options.merge options.symbolize_keys
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.respond_to?(:showable_methods) ? model.showable_methods : model.content_columns.map(&:name)
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
- if text_model.respond_to? :showable_methods
137
- mns = text_model.showable_methods
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|
@@ -1,5 +1,5 @@
1
1
  module WeBridge
2
2
  module AutoViewHelper
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shinjiro Itagaki