showbuilder 0.0.14 → 0.0.15
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32ee9bcc1c4f5f88ee4f6191a8d489194f491703
|
4
|
+
data.tar.gz: b68a583691b7a77da7ac3f93096625d5f99f965a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5b90a76044211aa13a9606559b2503e344015e38f5faf80b1f7601f17c9fad1f39767908d953e8e513256f4ca0e16fab9b0af997bd20ea608d50ec8cf729227
|
7
|
+
data.tar.gz: 64b27343c2caeaefcecd48f006ce24258049b8a2c261ccb7083f427872803e7ed8cb22a7ef4533894bf932c955e948f62a83839c04ccc5f24208512424301bb5
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'showbuilder/builders/template_methods'
|
2
|
+
require 'showbuilder/sequence_manager'
|
2
3
|
require 'showbuilder/i18n_text'
|
3
4
|
|
4
5
|
module Showbuilder
|
@@ -15,6 +16,16 @@ module Showbuilder
|
|
15
16
|
@template = template
|
16
17
|
end
|
17
18
|
|
19
|
+
# show_sequence_column
|
20
|
+
# show_sequence_column :code
|
21
|
+
def show_sequence_column(*args)
|
22
|
+
args = :sequence if args.empty?
|
23
|
+
return show_header_column(args) if is_header
|
24
|
+
|
25
|
+
sequence = SequenceManager.get_sequence
|
26
|
+
content_tag :td, sequence.to_s, :class => 'sequence'
|
27
|
+
end
|
28
|
+
|
18
29
|
# show_text_column :number
|
19
30
|
# show_text_column :sale, :number
|
20
31
|
def show_text_column(*methods)
|
@@ -116,8 +127,9 @@ module Showbuilder
|
|
116
127
|
end
|
117
128
|
end
|
118
129
|
|
119
|
-
|
120
|
-
|
130
|
+
# show_header_column
|
131
|
+
# show_header_column :balance
|
132
|
+
# show_header_column :reminder
|
121
133
|
def show_header_column(methods = nil)
|
122
134
|
text = ''
|
123
135
|
if methods
|
@@ -128,6 +140,8 @@ module Showbuilder
|
|
128
140
|
content_tag :th, text
|
129
141
|
end
|
130
142
|
|
143
|
+
private
|
144
|
+
|
131
145
|
def show_column_link(name, methods)
|
132
146
|
link_option = get_link_option(methods)
|
133
147
|
show_model_link_to name, link_option
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Showbuilder
|
2
|
+
class SequenceManager
|
3
|
+
class << self
|
4
|
+
|
5
|
+
attr_accessor :current_sequence
|
6
|
+
|
7
|
+
def initialize_sequence(params)
|
8
|
+
self.current_sequence = get_sequence_start_point(params)
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_sequence
|
12
|
+
sequence = self.current_sequence
|
13
|
+
self.current_sequence += 1
|
14
|
+
return sequence
|
15
|
+
end
|
16
|
+
|
17
|
+
# per_page: 10
|
18
|
+
# page: 1, start_point: 1
|
19
|
+
# page: 2, start_point: 10
|
20
|
+
# page: 3, start_point: 20
|
21
|
+
# per_page: 20
|
22
|
+
# page: 1, start_point: 1
|
23
|
+
# page: 2, start_point: 21
|
24
|
+
# page: 3, start_point: 31
|
25
|
+
# per_page: 30
|
26
|
+
# page: 1, start_point: 1
|
27
|
+
# page: 2, start_point: 31
|
28
|
+
# page: 3, start_point: 61
|
29
|
+
def get_sequence_start_point(params)
|
30
|
+
param_page = params[:page] || 1
|
31
|
+
param_per_page = params[:per_page] || 10
|
32
|
+
|
33
|
+
current_page = param_page.to_i
|
34
|
+
current_per_page = param_per_page.to_i
|
35
|
+
|
36
|
+
offset = (current_page - 1) * current_per_page
|
37
|
+
|
38
|
+
start_point = offset + 1
|
39
|
+
return start_point
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'showbuilder/builders/model_table_row_builder'
|
2
|
+
require 'showbuilder/sequence_manager'
|
2
3
|
|
3
4
|
module Showbuilder
|
4
5
|
module ShowModelTable
|
@@ -24,6 +25,8 @@ module Showbuilder
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def show_model_table_body(models, &block)
|
28
|
+
SequenceManager.initialize_sequence(params)
|
29
|
+
|
27
30
|
contents_tag :tbody do |contents|
|
28
31
|
models.each do |model|
|
29
32
|
contents << show_model_table_body_row(model, &block)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: showbuilder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ery Wang, Mario Du
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A Rails View Helper. Base on Twitter Bootstrap v2.0.4. Fast show model/s
|
14
14
|
as view, form, table.
|
@@ -22,6 +22,7 @@ files:
|
|
22
22
|
- lib/showbuilder/show_paginate_renderer.rb
|
23
23
|
- lib/showbuilder/i18n_text.rb
|
24
24
|
- lib/showbuilder/show_form.rb
|
25
|
+
- lib/showbuilder/sequence_manager.rb
|
25
26
|
- lib/showbuilder/show_model_view.rb
|
26
27
|
- lib/showbuilder/corekit.rb
|
27
28
|
- lib/showbuilder/builders/form_builder.rb
|