kolo 0.2.8 → 0.2.9
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.
- data/lib/assets/javascripts/data-access.js.coffee +24 -4
- data/lib/kolo/version.rb +1 -1
- metadata +4 -4
@@ -36,16 +36,21 @@ class AdminViewModel extends ViewModel
|
|
36
36
|
# db.onAfterLoad = function() { ... }
|
37
37
|
|
38
38
|
class Db
|
39
|
-
constructor: (@name,
|
39
|
+
constructor: (@name, url, @pushStateUri)->
|
40
|
+
@url = ko.observable url
|
40
41
|
@items = ko.observableArray []
|
41
42
|
@selected = ko.observable null
|
42
43
|
@plural = "#{@name}s"
|
43
44
|
@sortFunction = null
|
44
45
|
@onBeforeLoad = null
|
45
46
|
@onAfterLoad = null
|
47
|
+
@autoLoading = false
|
48
|
+
@url.subscribe (newValue)=>
|
49
|
+
if newValue?
|
50
|
+
@load(false)
|
46
51
|
if @pushStateUri? && history.pushState?
|
47
52
|
@selected.subscribe (newValue)=>
|
48
|
-
if newValue?
|
53
|
+
if newValue? and newValue.id?
|
49
54
|
history.pushState @selected().name(), @selected().name(), "#{@pushStateUri}/#{@selected().id}"
|
50
55
|
else
|
51
56
|
history.pushState '', '', @pushStateUri
|
@@ -67,17 +72,32 @@ class Db
|
|
67
72
|
viewModel.systemNotification @plural, 'loading'
|
68
73
|
viewModel.loading true
|
69
74
|
@onBeforeLoad() if @onBeforeLoad?
|
70
|
-
$.get @url, (data)=>
|
75
|
+
$.get @url(), (data)=>
|
71
76
|
@doLoad(data)
|
72
77
|
@onAfterLoad() if @onAfterLoad?
|
73
78
|
viewModel.loading false
|
74
79
|
viewModel.systemNotification @plural, 'loaded'
|
75
80
|
if autoReload
|
81
|
+
@autoLoading = true
|
76
82
|
setTimeout =>
|
77
83
|
@load(true)
|
78
84
|
, 30000
|
79
85
|
return false
|
80
86
|
|
87
|
+
postTo: (url, data)->
|
88
|
+
viewModel.systemNotification @name, 'saving'
|
89
|
+
viewModel.loading true
|
90
|
+
$.ajax
|
91
|
+
url: url
|
92
|
+
dataType: 'json'
|
93
|
+
type: 'POST'
|
94
|
+
data: data
|
95
|
+
success: (data)=>
|
96
|
+
viewModel.systemNotification @name, 'saved'
|
97
|
+
viewModel.loading false
|
98
|
+
@load(false)
|
99
|
+
return true
|
100
|
+
|
81
101
|
add: =>
|
82
102
|
itemToAdd = @newItem(null)
|
83
103
|
@selected(itemToAdd)
|
@@ -102,7 +122,7 @@ class Db
|
|
102
122
|
viewModel.systemNotification @name, 'saving'
|
103
123
|
viewModel.loading true
|
104
124
|
$.ajax
|
105
|
-
url: @url
|
125
|
+
url: @url()
|
106
126
|
dataType: 'json'
|
107
127
|
type: 'POST'
|
108
128
|
data: @toJS(item)
|
data/lib/kolo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kolo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -93,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
93
|
version: '0'
|
94
94
|
segments:
|
95
95
|
- 0
|
96
|
-
hash: -
|
96
|
+
hash: -479694545
|
97
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
98
|
none: false
|
99
99
|
requirements:
|
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
102
|
version: '0'
|
103
103
|
segments:
|
104
104
|
- 0
|
105
|
-
hash: -
|
105
|
+
hash: -479694545
|
106
106
|
requirements: []
|
107
107
|
rubyforge_project:
|
108
108
|
rubygems_version: 1.8.24
|