grand_central-dev_tools 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/grand_central/dev_tools/version.rb +1 -1
- data/opal/grand_central/dev_tools.rb +64 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6ad719db4ae179ed632575a58957572dd3c7bd48
|
4
|
+
data.tar.gz: e91f7d6b6238760d22d0d2e9048a9369076a016d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7497c238832791ea4a311fd5e99706d5010296f4a1f932322300d668e084cb85af2d8363334ed700e8c90e54af836eab8d6c9f9f7110be134f98043570fd5f9
|
7
|
+
data.tar.gz: 8715a8108d8b3c3bb3a2de33a3e14333233f33e243b3f78a42283ecfe0f34fd7309c53e73a734acd902a49a6fbc8204b907e3f2064470a24ff2c4c9da7550066
|
@@ -221,20 +221,82 @@ module GrandCentral
|
|
221
221
|
end
|
222
222
|
|
223
223
|
class ArrayPresenter < Presenter
|
224
|
+
SEGMENT_SIZE = 100
|
225
|
+
|
224
226
|
alias array model
|
225
227
|
|
226
228
|
def render
|
227
229
|
div({ style: { display: 'inline-block' } }, [
|
228
230
|
'[',
|
229
|
-
button({ onclick: set(:show_contents, !@show_contents) },
|
231
|
+
button({ onclick: set(:show_contents, !@show_contents) }, [
|
232
|
+
@show_contents ? '-' : "#{array.count} items",
|
233
|
+
]),
|
234
|
+
|
230
235
|
if @show_contents
|
231
236
|
div({ style: { padding_left: '1em' } }, [
|
232
|
-
array.
|
237
|
+
if array.size > SEGMENT_SIZE
|
238
|
+
segments
|
239
|
+
else
|
240
|
+
array.map { |item| div(serialize_value(item)) }
|
241
|
+
end
|
233
242
|
])
|
234
243
|
end,
|
244
|
+
|
235
245
|
']',
|
236
246
|
])
|
237
247
|
end
|
248
|
+
|
249
|
+
def segments
|
250
|
+
array.each_slice(SEGMENT_SIZE).map.with_index do |slice, index|
|
251
|
+
start = SEGMENT_SIZE * index
|
252
|
+
finish = start + slice.size
|
253
|
+
Segment.memoize(slice, self, start...finish, open: index.zero? && slice.size < SEGMENT_SIZE)
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
class Segment < Presenter
|
258
|
+
attr_reader :segment
|
259
|
+
|
260
|
+
def initialize segment, presenter, range, open: false
|
261
|
+
update segment, presenter, range
|
262
|
+
@open = open
|
263
|
+
end
|
264
|
+
|
265
|
+
def update segment, presenter, range
|
266
|
+
return unless segment
|
267
|
+
|
268
|
+
@segment = segment
|
269
|
+
@presenter = presenter
|
270
|
+
@range = range
|
271
|
+
end
|
272
|
+
|
273
|
+
def render
|
274
|
+
`console.log('render', self)`
|
275
|
+
div([
|
276
|
+
if open?
|
277
|
+
[
|
278
|
+
button({ onclick: set { @open = false } }, '-'),
|
279
|
+
segment.map do |item|
|
280
|
+
div(serialize_value(item))
|
281
|
+
end
|
282
|
+
]
|
283
|
+
else
|
284
|
+
button({ onclick: set { @open = true } }, @range.inspect)
|
285
|
+
end
|
286
|
+
])
|
287
|
+
end
|
288
|
+
|
289
|
+
def open?
|
290
|
+
@open
|
291
|
+
end
|
292
|
+
|
293
|
+
def set
|
294
|
+
proc do
|
295
|
+
yield
|
296
|
+
update_self
|
297
|
+
end
|
298
|
+
end
|
299
|
+
end
|
238
300
|
end
|
239
301
|
|
240
302
|
class HashPresenter < Presenter
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grand_central-dev_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Gaskins
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
95
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.
|
96
|
+
rubygems_version: 2.6.12
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: Client-side developer tools for GrandCentral
|