qui-index-table 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc ADDED
@@ -0,0 +1,7 @@
1
+ =QUI: index-table
2
+
3
+ Gem for rails to create nice tables with a few lines o code.
4
+
5
+ See: {http://qui.saepia.net}[http://qui.saepia.net] for details.
6
+
7
+ Copyright (c) 2010 [Marcin Lewandowski], released under the MIT license.
@@ -0,0 +1,65 @@
1
+ module QUI
2
+ module IndexTable
3
+ module MainHelper
4
+ def index_table(data, options = {}, &b)
5
+ @index_table_count ||= 0
6
+ raise RuntimeError, "@index_table_count must be integer" unless @index_table_count.is_a? Fixnum
7
+
8
+ options[:headers] ||= []
9
+ default_id = "index_table_#{@index_table_count}"
10
+ options[:id] ||= default_id
11
+
12
+ concat pagination(data) if data.is_a? WillPaginate::Collection if defined?(WillPaginate) and defined?(pagination)
13
+
14
+ concat "<table class=\"index\" id=\"#{options[:id]}\"><thead><tr>"
15
+
16
+ options[:headers].each do |h|
17
+ if h.is_a? Symbol
18
+ concat content_tag(:th, t(h))
19
+ elsif h.is_a? Hash
20
+ name = h.keys.first
21
+ if name
22
+ name = t(name)
23
+ else
24
+ name = "&nbsp;"
25
+ end
26
+
27
+ if h.values.first[:width] == :oneicon
28
+ concat content_tag(:th, name, :class => "oneicon")
29
+ elsif h.values.first[:width] == :expand
30
+ concat content_tag(:th, name)
31
+ else
32
+ concat content_tag(:th, name)
33
+ end
34
+ end
35
+ end
36
+ concat "</tr></thead><tbody>"
37
+
38
+ options[:h1][:last_value] == nil if options[:h1]
39
+ data.each do |row|
40
+ if options[:h1]
41
+ if options[:h1][:last_value] != row.send(options[:h1][:check])
42
+ concat "<tr class=\"h1\">"
43
+ concat options[:h1][:onchange].call(row)
44
+ concat "</tr>"
45
+
46
+ options[:h1][:last_value] = row.send(options[:h1][:check])
47
+ reset_cycle(options[:id])
48
+ end
49
+ end
50
+
51
+ concat "<tr class=\"#{cycle("even", "odd", :name => options[:id])}\">"
52
+ b.call row
53
+ concat "</tr>"
54
+ end
55
+
56
+ concat "</tbody></table>"
57
+
58
+ concat pagination(data) if data.is_a? WillPaginate::Collection if defined?(WillPaginate) and defined?(pagination)
59
+
60
+ @index_table_count += 1
61
+ end
62
+
63
+ end
64
+ end
65
+ end
@@ -0,0 +1 @@
1
+ require 'qui-index-table-main-helper.rb'
data/rails/init.rb ADDED
@@ -0,0 +1 @@
1
+ ActionView::Base.send :include, QUI::IndexTable::MainHelper
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: qui-index-table
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
11
+ platform: ruby
12
+ authors:
13
+ - Marcin Lewandowski
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-07-18 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: "qUI: rails helpers for generating index tables"
23
+ email: saepia@saepia.net
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README.rdoc
30
+ files:
31
+ - lib/qui-index-table-main-helper.rb
32
+ - lib/qui-index-table.rb
33
+ - rails/init.rb
34
+ - README.rdoc
35
+ has_rdoc: true
36
+ homepage: http://qui.saepia.net
37
+ licenses: []
38
+
39
+ post_install_message:
40
+ rdoc_options:
41
+ - --charset=UTF-8
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ hash: 3
50
+ segments:
51
+ - 0
52
+ version: "0"
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ requirements: []
63
+
64
+ rubyforge_project:
65
+ rubygems_version: 1.3.7
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: "qUI: rails helpers for generating index tables"
69
+ test_files: []
70
+