showbuilder 0.0.11 → 0.0.12
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.
- data/lib/showbuilder.rb +2 -2
- data/lib/showbuilder/builders/model_table_row_builder.rb +20 -9
- metadata +18 -38
data/lib/showbuilder.rb
CHANGED
@@ -51,8 +51,8 @@ module Showbuilder
|
|
51
51
|
self.controller_name.to_s.singularize
|
52
52
|
end
|
53
53
|
|
54
|
-
def show_model_link_to(name,
|
55
|
-
self.link_to name,
|
54
|
+
def show_model_link_to(name, options)
|
55
|
+
self.link_to name, options
|
56
56
|
end
|
57
57
|
|
58
58
|
::ActionView::Base.send :include, self
|
@@ -46,6 +46,7 @@ module Showbuilder
|
|
46
46
|
# show_text_link_column :sale, :number
|
47
47
|
# show_text_link_column :sale, :number, :link => :sale
|
48
48
|
# show_text_link_column :sale, :number, :link => [:sale, :customer]
|
49
|
+
# show_text_link_column :sale, :number, :link => ->(book){ book_path(book) }
|
49
50
|
def show_text_link_column(*methods)
|
50
51
|
return show_header_column(methods) if is_header
|
51
52
|
|
@@ -59,6 +60,7 @@ module Showbuilder
|
|
59
60
|
# show_date_link_column :sale, :create_at
|
60
61
|
# show_date_link_column :sale, :create_at, :link => :sale
|
61
62
|
# show_date_link_column :sale, :create_at, :link => [:sale, :customer]
|
63
|
+
# show_date_link_column :sale, :create_at, :link => ->(book){ book_path(book) }
|
62
64
|
def show_date_link_column(*methods)
|
63
65
|
return show_header_column(methods) if is_header
|
64
66
|
|
@@ -72,6 +74,7 @@ module Showbuilder
|
|
72
74
|
# show_time_link_column :sale, :create_at
|
73
75
|
# show_time_link_column :sale, :create_at, :link => :sale
|
74
76
|
# show_time_link_column :sale, :create_at, :link => [:sale, :customer]
|
77
|
+
# show_time_link_column :sale, :create_at, :link => ->(book){ book_path(book) }
|
75
78
|
def show_time_link_column(*methods)
|
76
79
|
return show_header_column(methods) if is_header
|
77
80
|
|
@@ -83,8 +86,9 @@ module Showbuilder
|
|
83
86
|
|
84
87
|
# show_currency_link_column :price
|
85
88
|
# show_currency_link_column :product, :price
|
86
|
-
# show_currency_link_column :product, :price,
|
87
|
-
# show_currency_link_column :product, :price,
|
89
|
+
# show_currency_link_column :product, :price, :link => :product
|
90
|
+
# show_currency_link_column :product, :price, :link => [:sale, :customer]
|
91
|
+
# show_currency_link_column :product, :create_at, :link => ->(book){ book_path(book) }
|
88
92
|
def show_currency_link_column(*methods)
|
89
93
|
return show_header_column(methods) if is_header
|
90
94
|
|
@@ -107,22 +111,29 @@ module Showbuilder
|
|
107
111
|
end
|
108
112
|
|
109
113
|
def show_column_link(name, methods)
|
110
|
-
|
111
|
-
show_model_link_to name,
|
114
|
+
link_option = get_link_option(methods)
|
115
|
+
show_model_link_to name, link_option
|
112
116
|
end
|
113
117
|
|
114
|
-
def
|
118
|
+
def get_link_option(methods)
|
115
119
|
if methods.count == 1
|
116
120
|
return model
|
117
121
|
end
|
118
122
|
|
119
123
|
link_methods = get_methods_option(methods, :link)
|
120
|
-
|
121
|
-
|
122
|
-
|
124
|
+
|
125
|
+
case link_methods
|
126
|
+
when Proc
|
127
|
+
link_option = link_methods.call(model)
|
128
|
+
when String, Symbol, Array
|
129
|
+
link_option = call_object_methods(model, link_methods)
|
130
|
+
when NIL
|
131
|
+
link_option = model
|
132
|
+
else
|
133
|
+
raise 'Unknow type #{link_methods}.'
|
123
134
|
end
|
124
135
|
|
125
|
-
return
|
136
|
+
return link_option
|
126
137
|
end
|
127
138
|
|
128
139
|
def get_methods_text_value(model, methods)
|
metadata
CHANGED
@@ -1,32 +1,22 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: showbuilder
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.12
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 11
|
10
|
-
version: 0.0.11
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Ery Wang, Mario Du
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2012-08-21 00:00:00 Z
|
12
|
+
date: 2012-08-21 00:00:00.000000000 Z
|
19
13
|
dependencies: []
|
20
|
-
|
21
14
|
description: A Rails View Helper. Show model/s as view, form, table.
|
22
15
|
email: ery@baoleihang.com
|
23
16
|
executables: []
|
24
|
-
|
25
17
|
extensions: []
|
26
|
-
|
27
18
|
extra_rdoc_files: []
|
28
|
-
|
29
|
-
files:
|
19
|
+
files:
|
30
20
|
- lib/showbuilder.rb
|
31
21
|
- lib/showbuilder/show_model_view.rb
|
32
22
|
- lib/showbuilder/i18n_text.rb
|
@@ -42,36 +32,26 @@ files:
|
|
42
32
|
- lib/showbuilder/show_form.rb
|
43
33
|
homepage: https://github.com/ery/showbuilder
|
44
34
|
licenses: []
|
45
|
-
|
46
35
|
post_install_message:
|
47
36
|
rdoc_options: []
|
48
|
-
|
49
|
-
require_paths:
|
37
|
+
require_paths:
|
50
38
|
- lib
|
51
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
40
|
none: false
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
|
57
|
-
|
58
|
-
- 0
|
59
|
-
version: "0"
|
60
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
46
|
none: false
|
62
|
-
requirements:
|
63
|
-
- -
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
|
66
|
-
segments:
|
67
|
-
- 0
|
68
|
-
version: "0"
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
69
51
|
requirements: []
|
70
|
-
|
71
52
|
rubyforge_project:
|
72
|
-
rubygems_version: 1.8.
|
53
|
+
rubygems_version: 1.8.10
|
73
54
|
signing_key:
|
74
55
|
specification_version: 3
|
75
56
|
summary: A Rails View Helper.
|
76
57
|
test_files: []
|
77
|
-
|