[Jifty-commit] jifty branch, jifty_client, updated. 57d769d4386cacf8dd42611c45e16ab0b1dfe2fc
Jifty commits
jifty-commit at lists.jifty.org
Sun May 2 03:44:18 EDT 2010
The branch, jifty_client has been updated
via 57d769d4386cacf8dd42611c45e16ab0b1dfe2fc (commit)
via eafc89e69932e5d84dad5a2a0ce93aeb0640c9ee (commit)
from 47af7c57e5bcafc62f472f2b2ac9bf49b25e56a2 (commit)
Summary of changes:
share/web/static/js/jifty_client.js | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
- Log -----------------------------------------------------------------
commit eafc89e69932e5d84dad5a2a0ce93aeb0640c9ee
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Sun May 2 15:42:46 2010 +0800
Keep track of the original result of loading a record
For syncing later
diff --git a/share/web/static/js/jifty_client.js b/share/web/static/js/jifty_client.js
index 1a6d054..2db1774 100644
--- a/share/web/static/js/jifty_client.js
+++ b/share/web/static/js/jifty_client.js
@@ -15,6 +15,7 @@ Class("JiftyModel", {
if (result.id) {
var record = that.meta.instantiate(result);
record.jiftyClient = that.jiftyClient;
+ record._original = result;
onSuccess(record);
}
else {
commit 57d769d4386cacf8dd42611c45e16ab0b1dfe2fc
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Sun May 2 15:43:22 2010 +0800
Sync only the diff between the current state and the previous state
diff --git a/share/web/static/js/jifty_client.js b/share/web/static/js/jifty_client.js
index 2db1774..5a5e0fb 100644
--- a/share/web/static/js/jifty_client.js
+++ b/share/web/static/js/jifty_client.js
@@ -1,9 +1,22 @@
Class("JiftyModel", {
methods: {
sync: function (onSuccess, onFailure) {
- var className = this.meta.getName();
+ var record = this;
+ var className = record.meta.getName();
var actionName = "update" + className;
- this.jiftyClient.runAction(actionName, JSON.parse(JSON.stringify(this)), onSuccess, onFailure);
+ var diff = {
+ id: record.id // we must always send this
+ };
+
+ Joose.O.eachSafe(record._original, function (value, field) {
+ if (record[field] != value) {
+ diff[field] = record[field];
+ }
+ });
+
+ // should we abort if diff contains only id?
+
+ this.jiftyClient.runAction(actionName, diff, onSuccess, onFailure);
}
},
classMethods: {
-----------------------------------------------------------------------
More information about the Jifty-commit
mailing list