quick_script 0.0.50 → 0.0.51
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.
@@ -363,9 +363,16 @@ class @Model
|
|
363
363
|
else
|
364
364
|
obj[prop] = @[prop]()
|
365
365
|
obj
|
366
|
+
toJSON : (flds)=>
|
367
|
+
JSON.stringify(@toJS(flds))
|
366
368
|
absorb : (model) =>
|
367
369
|
@reset()
|
368
370
|
@handleData(model.toJS())
|
371
|
+
Model.includeCollection = (self)->
|
372
|
+
self.Collection = class extends Collection
|
373
|
+
init : ->
|
374
|
+
@adapter = self.adapter
|
375
|
+
@model = self
|
369
376
|
|
370
377
|
class @FileModel extends @Model
|
371
378
|
extend : ->
|
@@ -390,11 +397,10 @@ class @FileModel extends @Model
|
|
390
397
|
|
391
398
|
class @Collection
|
392
399
|
init : ->
|
393
|
-
constructor: (opts
|
400
|
+
constructor: (opts) ->
|
394
401
|
@opts = opts || {}
|
395
402
|
@events = {}
|
396
403
|
@_reqid = 0
|
397
|
-
@parent = parent
|
398
404
|
@scope = ko.observable(@opts.scope || [])
|
399
405
|
@items = ko.observableArray([])
|
400
406
|
@views = ko.observableArray([])
|
@@ -404,8 +410,8 @@ class @Collection
|
|
404
410
|
@limit = ko.observable(@opts.limit || 4)
|
405
411
|
@title = ko.observable(@opts.title || 'Collection')
|
406
412
|
@extra_params = ko.observable(@opts.extra_params || {})
|
407
|
-
@model = @opts.model
|
408
|
-
@adapter = new ModelAdapter()
|
413
|
+
@model = @opts.model || Model
|
414
|
+
@adapter = @opts.adapter || new ModelAdapter()
|
409
415
|
@template = ko.observable(@opts.template)
|
410
416
|
@model_state = ko.observable(0)
|
411
417
|
@is_ready = ko.dependentObservable ->
|
@@ -492,7 +498,6 @@ class @Collection
|
|
492
498
|
if !op? || op == Collection.REPLACE
|
493
499
|
@items(models)
|
494
500
|
@views(views)
|
495
|
-
console.log("Items loaded")
|
496
501
|
else if op == Collection.INSERT
|
497
502
|
@items(models.concat(@items()))
|
498
503
|
@views(views.concat(@views()))
|
@@ -508,17 +513,26 @@ class @Collection
|
|
508
513
|
@update()
|
509
514
|
hasItems : ->
|
510
515
|
@items().length > 0
|
516
|
+
addItem : (item)->
|
517
|
+
cls = @view_model()
|
518
|
+
@items.push(item)
|
519
|
+
@views.push(new cls("view-#{item.id()}", @view_owner(), item))
|
511
520
|
getItemById : (id)->
|
512
521
|
list = @items().filter ((item)=> item.id() == id)
|
513
522
|
ret = if list.length > 0 then list[0] else null
|
514
523
|
removeDuplicates : ->
|
515
524
|
ids = []
|
516
|
-
@items().forEach (item, idx, array)
|
525
|
+
@items().forEach (item, idx, array)=>
|
517
526
|
if ids.includes(item.id())
|
518
527
|
@items.splice(idx, 1)
|
519
528
|
@views.splice(idx, 1)
|
520
529
|
else
|
521
530
|
ids.push(item.id())
|
531
|
+
removeIf : (callback)->
|
532
|
+
@items().forEach (item, idx, array)=>
|
533
|
+
if callback(item, idx)
|
534
|
+
@items.splice(idx, 1)
|
535
|
+
@views.splice(idx, 1)
|
522
536
|
getTemplate : ->
|
523
537
|
@template()
|
524
538
|
reset : ->
|
@@ -689,6 +703,7 @@ class @AppView extends @View
|
|
689
703
|
@handlePath(path)
|
690
704
|
handlePath : (path) ->
|
691
705
|
setUser : (data)->
|
706
|
+
console.log(data)
|
692
707
|
@current_user.handleData(data) if data != null
|
693
708
|
redirectTo : (path) ->
|
694
709
|
$.history.load(path)
|
data/lib/quick_script/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quick_script
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 121
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 51
|
10
|
+
version: 0.0.51
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alan Graham
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-03-
|
18
|
+
date: 2012-03-25 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: Framework for single-page web applications
|