reactive-record 0.7.8 → 0.7.9
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 870be529a755c9588ae0f02b65dd10ee67c8d21b
|
4
|
+
data.tar.gz: 561c75ec7f9243d9ae106b733aa5356f57e93829
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c502888fcd4ef5ea988a3a20a639b4d2bf3b3bdf4df0248b479162772b8ab073d234004697e79b0d121b6eb25209412344401ba1c4b0a0a1ef20cca98aa9f33
|
7
|
+
data.tar.gz: 57f3139aeaaab187cd2c30dbae45884a44920a7b6162679e02e573fd99f2074933a7c4b24da87969f9a967fb86d442a04242154c8b2702141ec8f553fe16ed82
|
@@ -209,12 +209,11 @@ module ReactiveRecord
|
|
209
209
|
false
|
210
210
|
end
|
211
211
|
|
212
|
-
def sync!(hash = {})
|
212
|
+
def sync!(hash = {}) # does NOT notify (see saved! for notification)
|
213
213
|
@attributes.merge! hash
|
214
214
|
@synced_attributes = @attributes.dup
|
215
215
|
@synced_attributes.each { |key, value| @synced_attributes[key] = value.dup_for_sync if value.is_a? Collection }
|
216
216
|
@saving = false
|
217
|
-
React::State.set_state(self, self, :synced) unless data_loading?
|
218
217
|
self
|
219
218
|
end
|
220
219
|
|
@@ -236,10 +235,20 @@ module ReactiveRecord
|
|
236
235
|
@saving = true
|
237
236
|
end
|
238
237
|
|
238
|
+
def saved!(failed = nil) # sets saving to false AND notifies
|
239
|
+
@saving = false
|
240
|
+
React::State.set_state(self, self, :saved) unless data_loading? or failed
|
241
|
+
self
|
242
|
+
end
|
243
|
+
|
239
244
|
def saving?
|
240
245
|
React::State.get_state(self, self)
|
241
246
|
@saving
|
242
247
|
end
|
248
|
+
|
249
|
+
def new?
|
250
|
+
!id and !vector
|
251
|
+
end
|
243
252
|
|
244
253
|
def find_association(association, id)
|
245
254
|
inverse_of = association.inverse_of
|
@@ -265,7 +274,7 @@ module ReactiveRecord
|
|
265
274
|
|
266
275
|
def apply_method(method)
|
267
276
|
# Fills in the value returned by sending "method" to the corresponding server side db instance
|
268
|
-
if
|
277
|
+
if !new?
|
269
278
|
sync_attribute(
|
270
279
|
method,
|
271
280
|
if association = @model.reflect_on_association(method)
|
@@ -243,16 +243,24 @@ module ReactiveRecord
|
|
243
243
|
|
244
244
|
HTTP.post(`window.ReactiveRecordEnginePath`+"/save", payload: {models: models, associations: associations}).then do |response|
|
245
245
|
|
246
|
-
response.json[:
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
246
|
+
if response.json[:success]
|
247
|
+
response.json[:saved_models].each do |item|
|
248
|
+
internal_id, klass, attributes = item
|
249
|
+
backing_records[internal_id].sync!(attributes)
|
250
|
+
end
|
251
|
+
else
|
252
|
+
backing_records.each { |item| backing_records[item[0]].saved! false }
|
253
|
+
log("Reactive Record Save Failed: #{response.json[:message]}", :error)
|
254
|
+
response.json[:saved_models].each do |model|
|
255
|
+
log(" Model: #{model[1]} Attributes: #{model[2]} Errors: #{model[3]}", :error) if model[3]
|
256
|
+
end
|
253
257
|
end
|
258
|
+
|
254
259
|
yield response.json[:success], response.json[:message], response.json[:saved_models] if block
|
255
260
|
promise.resolve response.json
|
261
|
+
|
262
|
+
backing_records.each { |item| backing_records[item[0]].saved! } if response.json(:success)
|
263
|
+
|
256
264
|
end
|
257
265
|
promise
|
258
266
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reactive-record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mitch VanDuyn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|