Permalink
Browse files

issue #19735: Tweak so global edits work.

  • Loading branch information...
1 parent 93dd809 commit 99e080ec2436a0790a762275a376b37bd3213cf5 John Rogelstad committed Mar 16, 2013
Showing with 7 additions and 6 deletions.
  1. +7 −6 node-datasource/routes/data.js
View
13 node-datasource/routes/data.js
@@ -20,12 +20,13 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */
the same. Notably, we have to massage the client-expected callback to fit into
the backboney callback system of XT.dataSource.
*/
- var createGlobalOptions = function (payload, globalUsername, callback) {
- var options = JSON.parse(JSON.stringify(payload)); // clone
+ var createGlobalOptions = function (payload, globalUsername, callback, returnsModel) {
+ var options = JSON.parse(JSON.stringify(payload)), // clone
+ resp = returnsModel !== false ? 1 : 0;
options.username = globalUsername;
- options.success = function (resp) {
- callback({data: resp});
+ options.success = function () {
+ callback({data: arguments[resp]});
};
options.error = function (model, err) {
callback({isError: true, message: err});
@@ -110,7 +111,7 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */
var options;
if (payload && payload.databaseType === 'global') {
// Run this query against the global database.
- options = createGlobalOptions(payload, session.passport.user.id, callback);
+ options = createGlobalOptions(payload, session.passport.user.id, callback, false);
XT.dataSource.dispatch(payload.className, payload.functionName, payload.parameters, options);
} else {
@@ -130,7 +131,7 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */
if (payload && payload.databaseType === 'global') {
// run this query against the global database
options = createGlobalOptions(payload, session.passport.user.id, callback);
- XT.dataSource.fetch(null, options);
+ XT.dataSource.fetch([], options);
} else {
// run this query against an instance database

0 comments on commit 99e080e

Please sign in to comment.