king_views 1.1.4 → 1.1.5
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/Rakefile +2 -2
- data/VERSION +1 -1
- data/king_form/lib/king_form/builder/form_fields.rb +1 -0
- data/king_form/lib/king_form/builder/labeled.rb +1 -0
- data/king_form/lib/king_form/nested_form_helper.rb +1 -1
- data/king_format/README.rdoc +1 -1
- data/king_format/lib/helpers/formatting_helper.rb +3 -5
- data/king_format/lib/helpers/money_helper.rb +2 -0
- data/king_list/lib/king_list/list_helper.rb +17 -12
- data/king_views.gemspec +3 -3
- metadata +5 -5
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.5
|
@@ -43,7 +43,7 @@ module KingForm
|
|
43
43
|
#The current objects classname is always present in partial so:
|
44
44
|
#when Object is LineItem locals has :line_item => object
|
45
45
|
:locals => {name.to_sym => f.object, :f => f}.merge( opts[:locals] || {} )
|
46
|
-
}.merge( opts[:render] || {} ) )
|
46
|
+
}.merge( opts[:render] || {} ) )
|
47
47
|
end
|
48
48
|
end
|
49
49
|
output.join
|
data/king_format/README.rdoc
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Define fields being of type date, currency or percent. When the fields are shown
|
4
4
|
within KingList/KingForm views, their format is detected and the output is
|
5
5
|
automatically formatted. Default formats of date and currency fields can be set
|
6
|
-
|
6
|
+
or they take the current I18n.locale into account.
|
7
7
|
|
8
8
|
KingFormat consists of two different formatting helper regions:
|
9
9
|
|
@@ -43,8 +43,8 @@ module KingFormat
|
|
43
43
|
# one differs eg. in precision
|
44
44
|
# 3. @default_currency_format
|
45
45
|
# 4. I18n actually resided in rails
|
46
|
-
#
|
47
|
-
#
|
46
|
+
# Whatever you use be aware to always pass all formatting options since rails
|
47
|
+
# merges unavailable keys with i18n defaults
|
48
48
|
def strfval( object, fld, val=nil, opts={} )
|
49
49
|
# If no value given, call fld on object to get the current value
|
50
50
|
#return the content(a pointer) or an empty string OR nil of field is not available
|
@@ -61,14 +61,12 @@ module KingFormat
|
|
61
61
|
elsif (object.class.is_percent_field?(fld) rescue nil)
|
62
62
|
(val && !val.blank?) ? number_to_percentage_auto_precision(val) : ''
|
63
63
|
elsif (object.class.is_money_field?(fld) rescue nil) || opts[:currency]
|
64
|
-
# field is defined as money field OR currency options are passed in
|
65
64
|
format_method = "#{fld}_format_opts".to_sym
|
66
65
|
# check if the object has a custom money format method => price_total_format_opts
|
67
66
|
fopts = object && object.respond_to?(format_method) ? object.send(format_method) : opts[:currency]
|
68
67
|
strfmoney(val, fopts)
|
69
68
|
elsif ( val.is_a?(Date) || (object.class.is_date_field?(fld) rescue nil) || opts[:date] )
|
70
|
-
|
71
|
-
return val if val.blank? # blank value can occur when a is_date_field is empty
|
69
|
+
return val if val.blank? # blank value can occur when a is_date_field is empty
|
72
70
|
# get date from opts or default or fallback into i18n
|
73
71
|
format = opts[:date] || default_date_format
|
74
72
|
format.blank? ? ::I18n.localize(val) : val.strftime(format)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module KingList
|
2
|
-
# The List Helper
|
2
|
+
# The List Helper provides methods for lists and detail views:
|
3
3
|
# tables, action icons, action buttons and action links, definition list helper
|
4
4
|
module ListHelper
|
5
5
|
|
@@ -34,7 +34,7 @@ module KingList
|
|
34
34
|
end
|
35
35
|
|
36
36
|
haml_tag :dl, options do
|
37
|
-
yield KingList::Builder::Show.new(object_name, object,
|
37
|
+
yield KingList::Builder::Show.new(object_name, object, render_context)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -60,16 +60,16 @@ module KingList
|
|
60
60
|
|
61
61
|
caption ||= options.delete(:caption)
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
render_context.haml_tag :fieldset, options do
|
64
|
+
render_context.haml_tag :legend, caption unless caption.blank?
|
65
|
+
render_context.haml_concat render_context.capture_haml(&block)
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
# Create a div for form actions
|
70
70
|
def actions(options = {}, &block)
|
71
|
-
|
72
|
-
|
71
|
+
render_context.haml_tag :div, options.merge(:class => 'form_actions') do
|
72
|
+
render_context.haml_concat render_context.capture_haml(&block)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -103,7 +103,7 @@ module KingList
|
|
103
103
|
def table_for(collection, options={}, html_options={}, &block)
|
104
104
|
return if collection.nil? || collection.empty?
|
105
105
|
|
106
|
-
builder = KingList::Builder::Table.new(
|
106
|
+
builder = KingList::Builder::Table.new(render_context, collection)
|
107
107
|
# extract options
|
108
108
|
builder.sorting = options.delete(:sorting) != false # default => true
|
109
109
|
|
@@ -132,7 +132,7 @@ module KingList
|
|
132
132
|
collection.each do |c|
|
133
133
|
tr_options = {}
|
134
134
|
# zebra styling
|
135
|
-
tr_options[:class] =
|
135
|
+
tr_options[:class] = render_context.cycle('odd','even')
|
136
136
|
|
137
137
|
haml_tag :tr, tr_options do
|
138
138
|
builder.start_row(c)
|
@@ -252,7 +252,7 @@ module KingList
|
|
252
252
|
# </form>
|
253
253
|
#
|
254
254
|
def action_button(fieldname, options)
|
255
|
-
|
255
|
+
render_context.capture_haml do
|
256
256
|
haml_tag :li, :class=>'form_btn' do
|
257
257
|
haml_concat mini_action_form(fieldname, options)
|
258
258
|
end
|
@@ -300,7 +300,7 @@ module KingList
|
|
300
300
|
haml_tag :ol, options do
|
301
301
|
collection.each_with_index do |c,i|
|
302
302
|
li_options = {}
|
303
|
-
li_options[:class] =
|
303
|
+
li_options[:class] = render_context.cycle('odd','even')
|
304
304
|
li_options[:value] = collection.length - i if descending
|
305
305
|
haml_tag :li, li_options do
|
306
306
|
yield(c)
|
@@ -314,7 +314,7 @@ module KingList
|
|
314
314
|
# Internal method used by action_text, action_button and action_icon
|
315
315
|
# Directly returns a haml string into the template
|
316
316
|
def action(kind, name_or_title, link_options, li_options={}, html_options={})
|
317
|
-
|
317
|
+
render_context.capture_haml do
|
318
318
|
haml_tag :li, li_options do
|
319
319
|
case kind
|
320
320
|
when :icon then haml_concat link_to('', link_options, html_options)
|
@@ -325,5 +325,10 @@ module KingList
|
|
325
325
|
end
|
326
326
|
end
|
327
327
|
|
328
|
+
def render_context
|
329
|
+
@template || view_context
|
330
|
+
# if rails < 2 ..
|
331
|
+
end
|
332
|
+
|
328
333
|
end #ListHelper
|
329
334
|
end#module
|
data/king_views.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{king_views}
|
8
|
-
s.version = "1.1.
|
8
|
+
s.version = "1.1.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Georg Leciejewski"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-12-25}
|
13
13
|
s.description = %q{Clean up your Forms using king_form for dl or labeled forms. Use king_list for an easy markup of tables in your lists and dl-enabled listings in your detail views. }
|
14
14
|
s.email = %q{gl@salesking.eu}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -63,7 +63,7 @@ Gem::Specification.new do |s|
|
|
63
63
|
]
|
64
64
|
s.homepage = %q{http://github.com/salesking/king_views}
|
65
65
|
s.require_paths = ["lib"]
|
66
|
-
s.rubygems_version = %q{1.
|
66
|
+
s.rubygems_version = %q{1.6.2}
|
67
67
|
s.summary = %q{Ultraclean haml views with list and forms helpers for rails}
|
68
68
|
|
69
69
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: king_views
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 5
|
10
|
+
version: 1.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Georg Leciejewski
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-12-25 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
102
|
requirements: []
|
103
103
|
|
104
104
|
rubyforge_project:
|
105
|
-
rubygems_version: 1.
|
105
|
+
rubygems_version: 1.6.2
|
106
106
|
signing_key:
|
107
107
|
specification_version: 3
|
108
108
|
summary: Ultraclean haml views with list and forms helpers for rails
|