king_views 1.0.4 → 1.0.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/CHANGELOG.rdoc +8 -0
- data/VERSION +1 -1
- data/king_list/README.rdoc +22 -6
- data/king_list/lib/king_list/builder/table.rb +14 -22
- data/king_list/lib/king_list/list_helper.rb +1 -1
- data/king_views.gemspec +4 -3
- metadata +5 -4
data/CHANGELOG.rdoc
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
= King Views Changelog
|
2
|
+
|
3
|
+
2010.08.31
|
4
|
+
|
5
|
+
* dropped support for KingList table cell alignment option, so instead of t.column :name, align=>:right go for :class=>:right and 'right' will be set as class on both th and td
|
6
|
+
* more KingList documentation
|
7
|
+
|
8
|
+
.. older read git commit messages
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.5
|
data/king_list/README.rdoc
CHANGED
@@ -1,16 +1,25 @@
|
|
1
1
|
= KingList
|
2
2
|
|
3
|
-
King List provides helpers
|
4
|
-
It has function
|
5
|
-
forms used to simulate PUT or DELETE
|
3
|
+
King List provides helpers for table listings and detail views.
|
4
|
+
It has function to create list(ul) with action icons(li+hidden a), buttons,
|
5
|
+
actions links(li+a) and icons with hidden forms used to simulate PUT or DELETE
|
6
|
+
requests.
|
7
|
+
All of those output ul->li->a structure with some css classes, so they need to be
|
8
|
+
formated via css (Examples follow, see salesking.eu for now).
|
6
9
|
|
7
|
-
|
10
|
+
You also get automatic lookup of translations (I18n) for active record objects and
|
11
|
+
their fields.
|
12
|
+
|
13
|
+
== Examples
|
8
14
|
Please read the files in lib/ for further documentation and examples
|
9
15
|
|
10
|
-
|
11
|
-
- table_for(@
|
16
|
+
Build a table for an array of AR objects
|
17
|
+
- table_for(@ar_objects) do |t, obj|
|
12
18
|
= t.column :firstname
|
13
19
|
= t.column :lastname, :sorting=>false
|
20
|
+
= t.column :number, :link=>true # links content to the object
|
21
|
+
= t.column :email, :value=>"custom content #{obj.email}", :title=>'custom th'
|
22
|
+
= t.column :created_at, :class=>'rgt', :sort_fields=>'users.updated_at,users.created_at'
|
14
23
|
|
15
24
|
A definition list view
|
16
25
|
- dl_for current_object do |f|
|
@@ -18,4 +27,11 @@ A definition list view
|
|
18
27
|
= f.show :created_at
|
19
28
|
= f.show :updated_at
|
20
29
|
|
30
|
+
== Dependencies
|
31
|
+
|
32
|
+
* haml
|
33
|
+
* activerecord
|
34
|
+
* I18n
|
35
|
+
* king_format(included in this gem)
|
36
|
+
|
21
37
|
Copyright (c) 2009 Georg Leciejewski, released under the MIT license
|
@@ -21,7 +21,7 @@ module KingList
|
|
21
21
|
# options<Hash{Hash, Symbol=>String}>:: A bunch of options to customize the th, td or content of the column
|
22
22
|
#
|
23
23
|
# ==== Options hash:
|
24
|
-
# :object => The record to use. If not set the current_object is used
|
24
|
+
# :object => The record to use. If not set, the current_object is used
|
25
25
|
# :value => cell content (if not set, it will be determined by calling field_name on object/current_record) => @client.name
|
26
26
|
# :link => if set, the value is wrapped in a link_to with the given link (if TRUE, the current object is used)
|
27
27
|
# :row_link => if set, the value is wrapped in a link_to with the given link (if TRUE, the current object is used)
|
@@ -32,7 +32,7 @@ module KingList
|
|
32
32
|
# :class:: the class to set on the th
|
33
33
|
# :td_options{Symbol=>String}:: options for the <td>
|
34
34
|
# :class:: the class to set on the th
|
35
|
-
# :
|
35
|
+
# :class => class as Symbol or String used on TH and TD used f.ex. for alignment.
|
36
36
|
def column(field_name, options = {})
|
37
37
|
options = options.deep_clone # for not changing outer variable
|
38
38
|
th_options = options[:th_options] || {}
|
@@ -41,10 +41,11 @@ module KingList
|
|
41
41
|
# Use given object from options (or current_record as default)
|
42
42
|
object = options.has_key?(:object) ? options.delete(:object) : current_record
|
43
43
|
|
44
|
-
#
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
# :class given so add to TH and TD f.ex cell alignment :class=>'rgt'
|
45
|
+
if css_class = options.delete(:class)
|
46
|
+
(th_options[:class] ||= '') << " #{css_class}"
|
47
|
+
(td_options[:class] ||= '') << " #{css_class}"
|
48
|
+
end
|
48
49
|
|
49
50
|
self.current_column_number += 1
|
50
51
|
|
@@ -77,37 +78,29 @@ module KingList
|
|
77
78
|
# otherwise just plain text (no sorting link)
|
78
79
|
title = title_text
|
79
80
|
end
|
80
|
-
#mark the first and last columns with css classes
|
81
|
+
# mark the first and last columns with css classes
|
81
82
|
if self.current_column_number == 1
|
82
83
|
(th_options[:class] ||= '') << ' first'
|
83
84
|
elsif self.current_column_number == self.number_of_columns
|
84
|
-
(th_options[:class] ||= '') <<
|
85
|
+
(th_options[:class] ||= '') << ' last'
|
85
86
|
end
|
86
87
|
@template.capture_haml do
|
87
88
|
@template.haml_tag(:th, title.to_s, th_options)
|
88
|
-
end
|
89
|
-
|
89
|
+
end
|
90
90
|
|
91
91
|
when :content
|
92
92
|
# Use given value (or formatted value as default)
|
93
93
|
value = options.delete(:value) || @template.formatted_value(object, field_name, value)
|
94
94
|
|
95
95
|
# If link option is set, then link to this
|
96
|
-
#
|
97
|
-
# ===Example
|
98
|
-
#
|
96
|
+
# === Example #
|
99
97
|
# :link => true : uses current object show link
|
100
|
-
#
|
101
98
|
# :link => nil or blank no linking
|
102
|
-
#
|
103
99
|
if link = options.delete(:link)
|
104
|
-
#link to current_oject if true given
|
100
|
+
# link to current_oject if true given
|
105
101
|
link = object if link == true
|
106
|
-
|
107
|
-
|
108
|
-
else #leave col text empty
|
109
|
-
value = ''
|
110
|
-
end
|
102
|
+
# link and linked text is present else leave col text empty
|
103
|
+
value = (!value.blank? && !link.blank?) ? @template.link_to(value, link) : ''
|
111
104
|
end
|
112
105
|
|
113
106
|
# If row_link option is set, then link to the current object
|
@@ -122,7 +115,6 @@ module KingList
|
|
122
115
|
@template.capture_haml do
|
123
116
|
@template.haml_tag(:td, value.to_s, td_options)
|
124
117
|
end
|
125
|
-
# @template.haml_concat
|
126
118
|
end # case mode
|
127
119
|
end
|
128
120
|
|
@@ -43,7 +43,7 @@ module KingList
|
|
43
43
|
# generates a fieldset with optional legend
|
44
44
|
#
|
45
45
|
# === Example haml
|
46
|
-
# - section :caption =>
|
46
|
+
# - section :caption => t('legend.user.details'), :class => 'my_css_class' do
|
47
47
|
# %p= "This is the content"
|
48
48
|
#
|
49
49
|
# => # <fieldset>
|
data/king_views.gemspec
CHANGED
@@ -5,18 +5,19 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{king_views}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.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{2010-08-
|
12
|
+
s.date = %q{2010-08-31}
|
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 = [
|
16
16
|
"README.rdoc"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
|
-
"
|
19
|
+
"CHANGELOG.rdoc",
|
20
|
+
"MIT-LICENSE",
|
20
21
|
"README.rdoc",
|
21
22
|
"Rakefile",
|
22
23
|
"VERSION",
|
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: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 5
|
10
|
+
version: 1.0.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: 2010-08-
|
18
|
+
date: 2010-08-31 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -28,6 +28,7 @@ extensions: []
|
|
28
28
|
extra_rdoc_files:
|
29
29
|
- README.rdoc
|
30
30
|
files:
|
31
|
+
- CHANGELOG.rdoc
|
31
32
|
- MIT-LICENSE
|
32
33
|
- README.rdoc
|
33
34
|
- Rakefile
|