author | Clipperz <info@clipperz.com> | 2013-01-18 15:02:39 (UTC) |
---|---|---|
committer | Clipperz <info@clipperz.com> | 2013-01-18 15:02:39 (UTC) |
commit | 969b9f94a25931a765a4cd4765177979f66c1585 (patch) (side-by-side diff) | |
tree | 0b61de265b28c11260dc15256c30184454e7ef08 /frontend/beta | |
parent | fac609cf1507ae82e7069b21724e089a9ac93869 (diff) | |
download | clipperz-969b9f94a25931a765a4cd4765177979f66c1585.zip clipperz-969b9f94a25931a765a4cd4765177979f66c1585.tar.gz clipperz-969b9f94a25931a765a4cd4765177979f66c1585.tar.bz2 |
Fixed error when importing data
-rw-r--r-- | frontend/beta/js/Clipperz/PM/DataModel/User.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/User.js b/frontend/beta/js/Clipperz/PM/DataModel/User.js index b065557..b29d224 100644 --- a/frontend/beta/js/Clipperz/PM/DataModel/User.js +++ b/frontend/beta/js/Clipperz/PM/DataModel/User.js @@ -217,250 +217,255 @@ MochiKit.Logging.logError("- User.errorHandler: " + anErrorString + " (" + anExc } else { //MochiKit.Logging.logDebug("--- User.handleConnectionFallback - an ERROR has occurred - " + aValue); this.resetConnection(); this.setConnectionVersion(Clipperz.PM.Crypto.communicationProtocol.fallbackVersions[this.connectionVersion()]); if (this.connectionVersion() != null) { result = new MochiKit.Async.Deferred(); result.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'connection_tryOlderSchema'); result.addCallback(MochiKit.Base.method(this, 'connect')); result.callback(); } else { result = MochiKit.Async.fail(Clipperz.PM.DataModel.User.exception.LoginFailed); } } //MochiKit.Logging.logDebug("<<< User.handleConnectionFallback"); return result; }, //========================================================================= 'header': function() { if (this._header == null) { this._header = new Clipperz.PM.DataModel.Header({user:this}); } return this._header; }, //------------------------------------------------------------------------- 'statistics': function() { if (this._statistics == null) { this._statistics = new Clipperz.PM.DataModel.Statistics({user:this}); } return this._statistics; }, //------------------------------------------------------------------------- 'records': function() { return this._records; }, //......................................................................... 'addRecord': function(aValue, isBatchUpdate) { this.records()[aValue.reference()] = aValue; if (isBatchUpdate != true) { Clipperz.NotificationCenter.notify(aValue, 'recordAdded', null, true); Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); } }, //----------------------------------------------------------------------------- 'addNewRecord': function() { var record; //MochiKit.Logging.logDebug(">>> User.addNewRecord"); record = new Clipperz.PM.DataModel.Record({user:this}); this.addRecord(record); Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); //MochiKit.Logging.logDebug("<<< User.addNewRecord"); return record; }, //------------------------------------------------------------------------- 'saveRecords': function(someRecords /*, aMethodName*/) { var deferredResult; // var methodName; var result; var i,c; //console.log("User.saveRecords - someRecords", someRecords); // methodName = aMethodName || 'addNewRecords'; Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); //MochiKit.Logging.logDebug(">>> User.saveRecords"); //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] User.saveRecords"); /* MochiKit.Logging.logDebug("--- User.saveRecords - 1"); MochiKit.Iter.forEach(someRecords, function(aRecord) { if (aRecord.headerNotes() != null) { aRecord.setNotes(aRecord.headerNotes()); } aRecord.syncDirectLoginReferenceValues(); aRecord.currentVersion().createNewVersion(); aRecord.updateKey(); }); MochiKit.Logging.logDebug("--- User.saveRecords - 2"); */ - result = {'records': []}; + result = { + 'records': { +// 'deleted': [], + 'updated': [] + } + }; deferredResult = new MochiKit.Async.Deferred(); c = someRecords.length; for (i=0; i<c; i++) { deferredResult.addCallback(function(aRecord) { if (aRecord.headerNotes() != null) { aRecord.setNotes(aRecord.headerNotes()); } aRecord.syncDirectLoginReferenceValues(); aRecord.currentVersion().createNewVersion(); aRecord.updateKey(); }, someRecords[i]); deferredResult.addCallback(MochiKit.Async.wait, 0.1); } //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 1 " + res); return res;}); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_collectRecordInfo'); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 2 " + res); return res;}); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_encryptUserData'); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 3 " + res); return res;}); deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedData')); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 4 " + res); return res;}); deferredResult.addCallback(function(aResult, res) { aResult['user'] = res; return aResult; }, result); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 5 " + res); return res;}); c = someRecords.length; for (i=0; i<c; i++) { var recordData; recordData = {}; //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.1 " + res); return res;}); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_encryptRecordData'); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.2 " + res); return res;}); deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'encryptedData')); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.3 " + res); return res;}); deferredResult.addCallback(function(aResult, res) { aResult['record'] = res; return aResult; }, recordData); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.4 " + res); return res;}); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {} /*'saveCard_encryptRecordVersions'*/); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.5 " + res); return res;}); deferredResult.addCallback(MochiKit.Base.method(someRecords[i].currentVersion(), 'encryptedData')); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.6 " + res); return res;}); deferredResult.addCallback(function(aResult, res) { aResult['currentRecordVersion'] = res; return aResult; }, recordData); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.7 " + res); return res;}); deferredResult.addCallback(function(aResult, res) { - aResult['records'] = { 'updated': [res] }; + aResult['records']['updated'].push(res); return aResult; }, result); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.8 " + res); return res;}); } //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 7 " + res); return res;}); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_sendingData'); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 8 " + res); return res;}); // deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), methodName); deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'saveChanges'); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9 " + res); return res;}); for (i=0; i<c; i++) { //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.1 " + res); return res;}); deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'takeSnapshotOfCurrentData')); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.2 " + res); return res;}); deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'setIsBrandNew'), false); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.3 " + res); return res;}); } //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 10 " + res); return res;}); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'recordUpdated'); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 11 " + res); return res;}); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'directLoginUpdated'); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 12 " + res); return res;}); deferredResult.callback(); return deferredResult; }, //------------------------------------------------------------------------- 'removeRecord': function(aRecord) { //MochiKit.Logging.logDebug(">>> User.removeRecord"); delete this.records()[aRecord.reference()]; //MochiKit.Logging.logDebug("--- User.removeRecord - 1"); Clipperz.NotificationCenter.notify(aRecord, 'recordRemoved', null, false); Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); //MochiKit.Logging.logDebug("<<< User.removeRecord"); }, //------------------------------------------------------------------------- 'deleteRecordsAction': function(someRecords) { var deferredResult; var parameters; //MochiKit.Logging.logDebug(">>> User.deleteRecordsAction - someRecords.length: " + someRecords.length); parameters = {}; deferredResult = new MochiKit.Async.Deferred(); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 1 " + res); return res;}); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_collectData'); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 2 " + res); return res;}); deferredResult.addCallback(function(someParameters, someRecords) { var recordReferences; recordReferences = MochiKit.Base.map(function(aRecord) { var result; result = aRecord.reference(); aRecord.remove(); return result; }, someRecords); // someParameters.recordReferences = recordReferences; someParameters['records'] = { 'deleted': recordReferences}; return someParameters; }, parameters); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 3 " + res); return res;}); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_encryptData'); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 4 " + res); return res;}); deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedData')); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 5 " + res); return res;}); deferredResult.addCallback(function(someParameters, anUserEncryptedData) { someParameters.user = anUserEncryptedData; return someParameters; }, parameters); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 6 " + res); return res;}); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_sendingData'); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecords parameters: " + Clipperz.Base.serializeJSON(res)); return res;}); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 7 " + res); return res;}); // deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'deleteRecords'); deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'saveChanges'); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 8 " + res); return res;}); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_updatingInterface'); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 9 " + res); return res;}); deferredResult.callback(someRecords); //MochiKit.Logging.logDebug("<<< User.deleteRecordsAction"); return deferredResult; }, //------------------------------------------------------------------------- 'resetAllLocalData': function() { |