volt 0.9.7.pre3 → 0.9.7.pre5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/volt/models/volt_app_property.rb +2 -0
- data/lib/volt/controllers/model_controller.rb +51 -20
- data/lib/volt/helpers/time/volt_time.rb +2 -2
- data/lib/volt/models/associations.rb +3 -5
- data/lib/volt/models/persistors/query/query_listener.rb +0 -1
- data/lib/volt/page/bindings/view_binding.rb +1 -0
- data/lib/volt/page/bindings/view_binding/controller_handler.rb +8 -0
- data/lib/volt/page/document_events.rb +4 -0
- data/lib/volt/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: 3cdc140dec9dafbccfdc80fbe5f9e98695b46394
|
4
|
+
data.tar.gz: c4e30bbd6a618229e594cfdbff8b40f4dcedaae8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba0802d6f9adcbf18ec68a28b95629ecfb59a9fa2cb2ea29f3c1c8e922c7e918af509647f95d28e8f23b840c7bda0bb91ff2451df02e9794eb9236b24ce574d6
|
7
|
+
data.tar.gz: e65b951533259dacf018849c1a0e0c2cf46f23205a1d11fdd9a8ab469aaa7d6d624fc6d075950b616cad916867a3a417e4844a9e3923fcc9480c1d27f227627e
|
@@ -103,26 +103,12 @@ module Volt
|
|
103
103
|
|
104
104
|
# Sets the current model on this controller
|
105
105
|
def model=(val)
|
106
|
-
|
107
|
-
|
108
|
-
self.last_promise = val
|
106
|
+
# Clear the proc watcher
|
107
|
+
stop_proc_watcher
|
109
108
|
|
110
|
-
|
111
|
-
# Only assign if nothing else has been assigned since we started the resolve
|
112
|
-
self.model = result if last_promise == val
|
113
|
-
end.fail do |err|
|
114
|
-
Volt.logger.error("Unable to resolve promise assigned to model on #{inspect}")
|
115
|
-
end
|
116
|
-
|
117
|
-
return
|
118
|
-
end
|
119
|
-
|
120
|
-
# Clear
|
109
|
+
# Clear last promise
|
121
110
|
self.last_promise = nil
|
122
111
|
|
123
|
-
# Start with a nil reactive value.
|
124
|
-
self.current_model ||= Model.new
|
125
|
-
|
126
112
|
if Symbol === val || String === val
|
127
113
|
collections = [:page, :store, :params, :controller]
|
128
114
|
if collections.include?(val.to_sym)
|
@@ -130,16 +116,61 @@ module Volt
|
|
130
116
|
else
|
131
117
|
fail "#{val} is not the name of a valid model, choose from: #{collections.join(', ')}"
|
132
118
|
end
|
119
|
+
|
120
|
+
return
|
121
|
+
end
|
122
|
+
# If the val is a proc, then we need to call the proc in a watch, and
|
123
|
+
# run the rest of the assign after
|
124
|
+
|
125
|
+
if val.is_a?(Proc)
|
126
|
+
@model_proc_watcher = proc do
|
127
|
+
# unwrap in a proc
|
128
|
+
new_val = val.call
|
129
|
+
|
130
|
+
# The assignment part we don't want to watch on because it will be
|
131
|
+
# changing the current_model reactive_accessor.
|
132
|
+
u do
|
133
|
+
assign_current_model(new_val)
|
134
|
+
end
|
135
|
+
end.watch!
|
133
136
|
else
|
134
|
-
|
137
|
+
assign_current_model(val)
|
135
138
|
end
|
136
139
|
end
|
137
140
|
|
141
|
+
def stop_proc_watcher
|
142
|
+
@model_proc_watcher.stop if @model_proc_watcher
|
143
|
+
@model_proc_watcher = nil
|
144
|
+
end
|
145
|
+
|
146
|
+
def controller_removed!
|
147
|
+
stop_proc_watcher
|
148
|
+
end
|
149
|
+
|
150
|
+
def assign_current_model(val)
|
151
|
+
if val.is_a?(Promise)
|
152
|
+
# Resolve the promise before setting
|
153
|
+
self.last_promise = val
|
154
|
+
|
155
|
+
val.then do |result|
|
156
|
+
# Only assign if nothing else has been assigned since we started the resolve
|
157
|
+
self.current_model = result if last_promise == val
|
158
|
+
self.last_promise = nil
|
159
|
+
end.fail do |err|
|
160
|
+
Volt.logger.error("Unable to resolve promise assigned to ModelController: #{inspect}")
|
161
|
+
end
|
162
|
+
|
163
|
+
return
|
164
|
+
end
|
165
|
+
|
166
|
+
self.current_model = val
|
167
|
+
end
|
168
|
+
|
138
169
|
def model
|
139
170
|
model = self.current_model
|
140
171
|
|
141
|
-
# If the model is a proc, call it now
|
142
|
-
model = model.call if model && model.is_a?(Proc)
|
172
|
+
# # If the model is a proc, call it now
|
173
|
+
# model = model.call if model && model.is_a?(Proc)
|
143
174
|
|
144
175
|
model
|
145
176
|
end
|
@@ -49,10 +49,10 @@ class VoltTime
|
|
49
49
|
# Live now acts just like now, except it invalidates any computations the
|
50
50
|
# VoltTime object is used in at every interval. This makes it easy to
|
51
51
|
# display live timer's.
|
52
|
-
def live_now(
|
52
|
+
def live_now(seconds=1)
|
53
53
|
dep = Volt::Dependency.new
|
54
54
|
dep.depend
|
55
|
-
Volt::Timers.client_set_timeout(
|
55
|
+
Volt::Timers.client_set_timeout(seconds * 1000) do
|
56
56
|
dep.changed!
|
57
57
|
end
|
58
58
|
VoltTime.new
|
@@ -22,11 +22,9 @@ module Volt
|
|
22
22
|
|
23
23
|
# setter
|
24
24
|
define_method(:"#{method_name}=") do |obj|
|
25
|
-
#
|
26
|
-
obj.
|
27
|
-
|
28
|
-
# Associate on the method name
|
29
|
-
set(method_name, obj)
|
25
|
+
# Associate the local key
|
26
|
+
foreign_key_value = obj.get(foreign_key)
|
27
|
+
set(local_key, foreign_key_value)
|
30
28
|
end
|
31
29
|
end
|
32
30
|
|
@@ -142,6 +142,7 @@ module Volt
|
|
142
142
|
# Remove existing controller and template and call _removed
|
143
143
|
if @current_controller_handler
|
144
144
|
@current_controller_handler.call_action('before', 'remove')
|
145
|
+
@current_controller_handler.send_controller_removed!
|
145
146
|
end
|
146
147
|
|
147
148
|
if @current_template
|
@@ -59,6 +59,14 @@ module Volt
|
|
59
59
|
false
|
60
60
|
end
|
61
61
|
|
62
|
+
# If the controller wants to know, provide a general way the controller can
|
63
|
+
# know if its being removed. This lets us cleanup any watches.
|
64
|
+
def send_controller_removed!
|
65
|
+
if @controller.respond_to?(:controller_removed!)
|
66
|
+
@controller.controller_removed!
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
62
70
|
# Fetch the controller class
|
63
71
|
def self.get_controller_and_action(controller_path)
|
64
72
|
fail "Invalid controller path: #{controller_path.inspect}" unless controller_path && controller_path.size > 0
|
@@ -32,6 +32,10 @@ module Volt
|
|
32
32
|
element = `$(event.target || event.originalEvent.target)`
|
33
33
|
|
34
34
|
loop do
|
35
|
+
if `event.isPropagationStopped()`
|
36
|
+
break
|
37
|
+
end
|
38
|
+
|
35
39
|
# Lookup the handler, make sure to not assume the group
|
36
40
|
# exists.
|
37
41
|
# TODO: Sometimes the event doesn't exist, but we still get
|
data/lib/volt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: volt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.7.
|
4
|
+
version: 0.9.7.pre5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Stout
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|