dom-rb 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/csr/dom/browser_ext/node.rb +5 -5
- data/csr/dom/builder/base.rb +1 -1
- data/csr/dom/builder/helpers.rb +4 -4
- data/csr/dom/table/base.rb +23 -11
- data/csr/dom/table/section.rb +27 -18
- data/lib/dom/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cae4bc31b6b58eba444410662c49f6fc38956b8
|
4
|
+
data.tar.gz: 7d6094522646022477e1e18822ec3dbf01ec37f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a6e6c87150dd87203d089ddb08357ecc6a72bf46f26f1f7395198b77a9986985d49aa2c5a210e18caf08a227d84ad980bce334c20a767afdc99dedd567be8bc
|
7
|
+
data.tar.gz: bd12f013b96489a59961d0cebb0f8c6a312ed93e8f2a3eeb4e832dff06f83e26b692e81b28ef2c88d1239e97608db154c845d94c5b6cacb6119dbc144087dcb1
|
data/csr/dom/browser_ext/node.rb
CHANGED
@@ -66,15 +66,15 @@ class Browser
|
|
66
66
|
trigger: 'hover focus',
|
67
67
|
}
|
68
68
|
end
|
69
|
-
debug
|
69
|
+
debug 2, ->{[__FILE__, __LINE__, __method__, "arg=#{arg}"]}
|
70
70
|
check_bootstrap
|
71
|
-
debug
|
71
|
+
debug 2, ->{[__FILE__, __LINE__, __method__, "@native=#{@native}"]}
|
72
72
|
`$(#@native).tooltip(#{arg.to_n})`
|
73
|
-
debug
|
73
|
+
debug 2, ->{[__FILE__, __LINE__, __method__]}
|
74
74
|
end
|
75
75
|
|
76
76
|
def popover(arg=nil)
|
77
|
-
debug
|
77
|
+
debug 2, ->{[__FILE__, __LINE__, __method__]}
|
78
78
|
if String === arg
|
79
79
|
arg = {
|
80
80
|
title: arg,
|
@@ -83,7 +83,7 @@ class Browser
|
|
83
83
|
end
|
84
84
|
check_bootstrap
|
85
85
|
`$(#@native).popover(#{arg.to_n})`
|
86
|
-
debug
|
86
|
+
debug 2, ->{[__FILE__, __LINE__, __method__]}
|
87
87
|
end
|
88
88
|
|
89
89
|
def bindings=(bindings)
|
data/csr/dom/builder/base.rb
CHANGED
data/csr/dom/builder/helpers.rb
CHANGED
@@ -10,7 +10,7 @@ module CSR
|
|
10
10
|
include CSR::DOM::Debug
|
11
11
|
|
12
12
|
def icon(name, callback: nil, attributes: nil, tooltip: nil, popover: nil)
|
13
|
-
debug
|
13
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "name=#{name} callback=#{callback} attributes=#{attributes} tooltip=#{tooltip}" ]}
|
14
14
|
style = {
|
15
15
|
text_align: 'center',
|
16
16
|
color: 'inherit',
|
@@ -33,18 +33,18 @@ module CSR
|
|
33
33
|
}.merge(
|
34
34
|
callback ? { onclick: callback } : {}
|
35
35
|
)
|
36
|
-
debug
|
36
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "attributes=#{attributes}" ]}
|
37
37
|
icon = tag(
|
38
38
|
:span,
|
39
39
|
attributes: attributes
|
40
40
|
)
|
41
|
-
debug
|
41
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "icon=#{icon}" ]}
|
42
42
|
if tooltip
|
43
43
|
icon.tooltip(tooltip)
|
44
44
|
elsif popover
|
45
45
|
icon.popover(popover)
|
46
46
|
end
|
47
|
-
debug
|
47
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "icon=#{icon}" ]}
|
48
48
|
icon
|
49
49
|
end
|
50
50
|
|
data/csr/dom/table/base.rb
CHANGED
@@ -61,6 +61,14 @@ module CSR
|
|
61
61
|
debug 2, ->{[ __FILE__, __LINE__, __method__]}
|
62
62
|
end
|
63
63
|
|
64
|
+
def new_column(*args)
|
65
|
+
CSR::DOM::Table::Column.new(*args)
|
66
|
+
end
|
67
|
+
|
68
|
+
def new_content(*args)
|
69
|
+
CSR::DOM::Content.new(*args)
|
70
|
+
end
|
71
|
+
|
64
72
|
def columns
|
65
73
|
unless @columns
|
66
74
|
@columns = if Proc === @raw_columns
|
@@ -91,6 +99,13 @@ module CSR
|
|
91
99
|
@root
|
92
100
|
end
|
93
101
|
|
102
|
+
def update_root
|
103
|
+
if @root
|
104
|
+
@root.clear
|
105
|
+
@root << content
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
94
109
|
def attributes
|
95
110
|
debug 2, ->{[ __FILE__, __LINE__, __method__ ]}
|
96
111
|
result = {
|
@@ -130,7 +145,7 @@ module CSR
|
|
130
145
|
end
|
131
146
|
|
132
147
|
def section(id)
|
133
|
-
|
148
|
+
sections.detect {|e| e.id == id}
|
134
149
|
end
|
135
150
|
|
136
151
|
def head
|
@@ -186,27 +201,24 @@ module CSR
|
|
186
201
|
end
|
187
202
|
|
188
203
|
def update
|
189
|
-
|
190
|
-
@root = nil
|
204
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__ ]}
|
191
205
|
init_sorting
|
192
|
-
|
193
|
-
update_sections
|
206
|
+
update_root
|
194
207
|
end
|
195
208
|
|
196
209
|
def update_caption
|
197
210
|
@caption.update if @caption
|
198
211
|
end
|
199
212
|
|
200
|
-
def update_sections
|
201
|
-
|
202
|
-
|
203
|
-
# debug 2, ->{[ __FILE__, __LINE__, __method__, "id=#{id} " ]}
|
204
|
-
update_section(id)
|
205
|
-
end
|
213
|
+
def update_sections
|
214
|
+
@sections = nil
|
215
|
+
update_root
|
206
216
|
end
|
207
217
|
|
208
218
|
def update_section(id)
|
219
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "id=#{id} " ]}
|
209
220
|
section = section(id)
|
221
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "section=#{section} " ]}
|
210
222
|
if section
|
211
223
|
section.update
|
212
224
|
end
|
data/csr/dom/table/section.rb
CHANGED
@@ -14,7 +14,7 @@ module CSR
|
|
14
14
|
attr_reader :table, :id
|
15
15
|
|
16
16
|
def initialize(table, id)
|
17
|
-
# self.debug_level =
|
17
|
+
# self.debug_level = 2
|
18
18
|
@table, @id = table, id
|
19
19
|
end
|
20
20
|
|
@@ -32,17 +32,21 @@ module CSR
|
|
32
32
|
|
33
33
|
def update
|
34
34
|
if @root
|
35
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "@id=#{@id} @root=#{@root}" ]}
|
35
36
|
animate do
|
36
|
-
|
37
|
-
|
38
|
-
@root.clear
|
39
|
-
@root << content
|
37
|
+
clear_rows
|
38
|
+
update_root
|
40
39
|
end
|
41
40
|
else
|
42
|
-
|
41
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "@id=#{@id} @root=nil" ]}
|
43
42
|
end
|
44
43
|
end
|
45
44
|
|
45
|
+
def update_root
|
46
|
+
@root.clear
|
47
|
+
@root << content
|
48
|
+
end
|
49
|
+
|
46
50
|
def row_attributes(index)
|
47
51
|
# TODO: implement
|
48
52
|
end
|
@@ -50,18 +54,18 @@ module CSR
|
|
50
54
|
# source should be source (unsorted) index or row source (model)
|
51
55
|
# columns may be column indexes or Column's
|
52
56
|
def update_row(source, _columns = nil)
|
53
|
-
debug
|
57
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "source=#{source} _columns=#{_columns} @rows.size=#{@rows ? @rows.size : 'nil'}" ]}
|
54
58
|
if @rows
|
55
59
|
columns = if _columns
|
56
60
|
_columns.map { |c| Integer === c ? @table.columns[c] : c }
|
57
61
|
end
|
58
|
-
debug
|
62
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "source=#{source} columns=#{columns}" ]}
|
59
63
|
if @id == :body && (columns.nil? || (@table.sort_column && columns.include?(@table.sort_column)))
|
60
|
-
debug
|
64
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "updating whole section" ]}
|
61
65
|
update
|
62
66
|
else
|
63
67
|
row_index = Integer === source ? source : source_index(source)
|
64
|
-
debug
|
68
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "calling @rows[#{row_index}].update(#{columns})" ]}
|
65
69
|
@rows[row_index].update(columns)
|
66
70
|
end
|
67
71
|
end
|
@@ -87,28 +91,28 @@ module CSR
|
|
87
91
|
end
|
88
92
|
|
89
93
|
def attributes
|
90
|
-
debug
|
94
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "@id=#{@id}" ]}
|
91
95
|
result = table.section_attributes(@id)
|
92
|
-
debug
|
96
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "@id=#{@id} result=#{result}" ]}
|
93
97
|
result
|
94
98
|
end
|
95
99
|
|
96
100
|
def content
|
97
|
-
debug
|
101
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "@id=#{@id}" ]}
|
98
102
|
result = rows.map { |row| row.root }
|
99
|
-
debug
|
103
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "@id=#{@id} result=#{result}" ]}
|
100
104
|
result
|
101
105
|
end
|
102
106
|
|
103
107
|
# Returns array of Table::Row's (in table sort order)
|
104
108
|
def rows
|
105
109
|
unless @rows
|
106
|
-
# debug
|
110
|
+
# debug 2, ->{[ __FILE__, __LINE__, __method__, "@id=#{@id}" ]}
|
107
111
|
@rows = []
|
108
112
|
row_indexes.each do |model_index|
|
109
113
|
@rows << Row.new(@table, self, model_index)
|
110
114
|
end
|
111
|
-
# debug
|
115
|
+
# debug 2, ->{[ __FILE__, __LINE__, __method__, "@id=#{@id} @rows=#{@rows.map(&:index)}}" ]}
|
112
116
|
end
|
113
117
|
@rows
|
114
118
|
end
|
@@ -123,9 +127,10 @@ module CSR
|
|
123
127
|
|
124
128
|
def row_sources
|
125
129
|
unless @row_sources
|
126
|
-
|
130
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "@id=#{@id}" ]}
|
127
131
|
source = @table.row_source(@id)
|
128
132
|
source = source.call if Proc === source
|
133
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "source=#{source}" ]}
|
129
134
|
@row_sources = case source
|
130
135
|
when Fixnum
|
131
136
|
source.times.to_a
|
@@ -135,7 +140,7 @@ module CSR
|
|
135
140
|
source
|
136
141
|
end
|
137
142
|
# if body?
|
138
|
-
# debug
|
143
|
+
# debug 2, ->{[ __FILE__, __LINE__, __method__, "@id=#{@id} @row_sources=#{@row_sources.map(&:code)}" ]}
|
139
144
|
# end
|
140
145
|
end
|
141
146
|
@row_sources
|
@@ -178,6 +183,10 @@ module CSR
|
|
178
183
|
|
179
184
|
private
|
180
185
|
|
186
|
+
def clear_rows
|
187
|
+
@row_sources = @row_indexes = @rows = nil
|
188
|
+
end
|
189
|
+
|
181
190
|
def sort_value(column, row_source)
|
182
191
|
content = column.section_content(@id)
|
183
192
|
result = if Content === content
|
data/lib/dom/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dom-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colin Gunn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal-browser
|