ende 0.3.11 → 0.3.12

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: 651a1f0a7bf111187f08f0eeab0f48b2a566d908
4
- data.tar.gz: 7ee2ab2f06f2adaf262962166e4a2117593dc06b
3
+ metadata.gz: 0da97c41b5dc3465944322b1ece15ec3be43654c
4
+ data.tar.gz: a98863c9f0045fd41a98637525489715140fa862
5
5
  SHA512:
6
- metadata.gz: 2fc675100ab3df6bc3d1f53795caba3baa5221e18deea33410e8e480e38ecac4c8b369a04d920c09859b89e344db495afa5b4e6559f1e72a13b7b550e7dc36d3
7
- data.tar.gz: 8cd7cdff7a658afe0a2fad0156362c982fd439973df268e22508e40049ec10934a6a6d4d0bec3a062f58c8fe22fcc9e1e0515ae2d0322748af50253b59c443fe
6
+ metadata.gz: 044da7f2be4b59eafdcd02a44e7812408664e4e5fc72fe07e774cfed10e80157cde7bcdbc065300b92a29ab8fdc08d0a4f61e8f1ef2e02b6539a7812f2920002
7
+ data.tar.gz: f077995aab9837b6ab9ca75a69e9e7361bb6412febe1858e04b83da7b0506a6345b6ff67ac1c3f535eb6aed244790163d02f0800c5d838089bca7a96320b9003
@@ -177,16 +177,14 @@ define [
177
177
  sent_scope = @inflector.singularize scope.resource.toString()
178
178
  current_scope = @inflector.singularize @scope.resource.toString()
179
179
 
180
+ deferred = @sandbox.data.deferred()
181
+
180
182
  if sent_scope != current_scope
181
183
  throw new TypeError "Invalid scope sent to viewer@#{@identifier} sent: '#{sent_scope}', expected: '#{current_scope}'"
182
184
 
183
185
  # For sobsequent usages we must store the scope
184
186
  @scope = scope
185
187
 
186
- # TODO better hierachical event distribution
187
- for { _widget: widget } in @sandbox._children?
188
- widget.scope_to? child_scope
189
-
190
188
  @sandbox.emit "viewer.#{@identifier}.scope_changed", @scope
191
189
 
192
190
  # TODO better scope data binding, and updating
@@ -196,6 +194,15 @@ define [
196
194
 
197
195
  @repopulate()
198
196
 
197
+ # TODO rename this method
198
+ # TODO also move this to an external tag
199
+ statused: (status) ->
200
+ if status
201
+ @status = status
202
+ @sandbox.emit "viewer.#{@identifier}.status_changed", status
203
+ else
204
+ @status
205
+
199
206
  repopulate: ->
200
207
  unless @fetching?
201
208
  if @load?
@@ -209,6 +216,7 @@ define [
209
216
  @load = @sandbox.ui.loader @$el.find '.results .items'
210
217
 
211
218
  # TODO implement status for viewer widget
219
+ @statused 'loading'
212
220
  @$el.addClass 'idle'
213
221
  @$el.removeClass 'loading'
214
222
 
@@ -243,6 +251,7 @@ define [
243
251
 
244
252
  @fetching.always =>
245
253
  # TODO implement status for viewer widget
254
+ @statused 'loading'
246
255
  @$el.addClass 'idle'
247
256
  @$el.removeClass 'loading'
248
257
 
@@ -257,6 +266,7 @@ define [
257
266
  @load = @sandbox.ui.loader @$results
258
267
 
259
268
  # TODO implement status for viewer widget
269
+ @statused 'loading'
260
270
  @$el.removeClass 'idle'
261
271
  @$el.addClass 'loading'
262
272
 
@@ -310,7 +320,7 @@ define [
310
320
 
311
321
 
312
322
  plugins: (options) ->
313
- deferreds = []
323
+ deferreds = [@]
314
324
 
315
325
  deferreds.push paginable widget: @ if options.page
316
326
  deferreds.push scrollable widget: @ if options.scroll
@@ -426,21 +436,27 @@ define [
426
436
 
427
437
  @sandbox.on "viewer.#{@identifier}.scope", @scope_to, @
428
438
 
429
- # Iniitalize plugins
439
+ # Initalize plugins
440
+ # TODO think how to implement plugins api
430
441
  loading = @plugins options
431
442
 
443
+ @statused 'idle'
432
444
  @$el.addClass "viewer widget #{@inflector.cssify @identifier} idle clearfix"
433
445
 
434
- loading.done => @require_custom options
446
+ loading.done (widget) ->
447
+ widget.require_custom options.resource
448
+
449
+ # TODO externalize this code to an extension
450
+ require_custom: (resource) ->
451
+ deferred = @sandbox.data.deferred()
435
452
 
436
- require_custom: (options) ->
437
453
  # Fetch custom templates
438
454
  # TODO better custom templates structure and custom presenter
439
455
  # TODO better segregation of concerns on this code
440
456
  # TODO handle case where custom presenter does not exist!
441
457
  require [
442
- "text!./widgets/viewer/templates/default/#{options.resource}.html"
443
- "./widgets/viewer/presenters/#{options.resource}"
458
+ "text!./widgets/viewer/templates/default/#{resource}.html"
459
+ "./widgets/viewer/presenters/#{resource}"
444
460
  ], (custom_default_template, custom_presenter) =>
445
461
 
446
462
  # TODO Better way to preserve widgets handlers
@@ -460,12 +476,19 @@ define [
460
476
 
461
477
  presenter.handlers = handlers
462
478
 
463
- custom_default_template and templates[options.resource] = custom_default_template
464
- @presenter = @sandbox.util.extend custom_presenter, presenter if custom_presenter
479
+ custom_default_template and templates[resource] = custom_default_template
480
+ @presenter = @sandbox.util.extend custom_presenter, presenter if custom_presenter
465
481
 
466
- @$results = @$el.find '.results .items'
482
+ @$results ||= @$el.find '.results .items'
467
483
 
468
484
  # Fetch default data
469
485
  @populate handlers
470
486
 
471
- true
487
+ deferred.resolveWith @, [resource]
488
+
489
+ , (error) =>
490
+ # TODO handle other status codes with xhr error
491
+ @sandbox.logger.error "Error when loading presenter and template for resource '#{resource}':\n\n", error.message + "\n\n", error
492
+ deferred.rejectWith @, arguments
493
+
494
+ deferred
data/lib/ende/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ende
2
- VERSION = "0.3.11"
2
+ VERSION = "0.3.12"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ende
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.11
4
+ version: 0.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Heitor Salazar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-18 00:00:00.000000000 Z
11
+ date: 2014-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler