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) (unidiff) | |
tree | 0b61de265b28c11260dc15256c30184454e7ef08 /frontend/beta/js/Clipperz | |
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 | |||
@@ -289,49 +289,54 @@ MochiKit.Logging.logError("- User.errorHandler: " + anErrorString + " (" + anExc | |||
289 | var deferredResult; | 289 | var deferredResult; |
290 | // var methodName; | 290 | // var methodName; |
291 | varresult; | 291 | varresult; |
292 | var i,c; | 292 | var i,c; |
293 | 293 | ||
294 | //console.log("User.saveRecords - someRecords", someRecords); | 294 | //console.log("User.saveRecords - someRecords", someRecords); |
295 | // methodName = aMethodName || 'addNewRecords'; | 295 | // methodName = aMethodName || 'addNewRecords'; |
296 | 296 | ||
297 | Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); | 297 | Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); |
298 | //MochiKit.Logging.logDebug(">>> User.saveRecords"); | 298 | //MochiKit.Logging.logDebug(">>> User.saveRecords"); |
299 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] User.saveRecords"); | 299 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] User.saveRecords"); |
300 | /* | 300 | /* |
301 | MochiKit.Logging.logDebug("--- User.saveRecords - 1"); | 301 | MochiKit.Logging.logDebug("--- User.saveRecords - 1"); |
302 | MochiKit.Iter.forEach(someRecords, function(aRecord) { | 302 | MochiKit.Iter.forEach(someRecords, function(aRecord) { |
303 | if (aRecord.headerNotes() != null) { | 303 | if (aRecord.headerNotes() != null) { |
304 | aRecord.setNotes(aRecord.headerNotes()); | 304 | aRecord.setNotes(aRecord.headerNotes()); |
305 | } | 305 | } |
306 | aRecord.syncDirectLoginReferenceValues(); | 306 | aRecord.syncDirectLoginReferenceValues(); |
307 | aRecord.currentVersion().createNewVersion(); | 307 | aRecord.currentVersion().createNewVersion(); |
308 | aRecord.updateKey(); | 308 | aRecord.updateKey(); |
309 | }); | 309 | }); |
310 | MochiKit.Logging.logDebug("--- User.saveRecords - 2"); | 310 | MochiKit.Logging.logDebug("--- User.saveRecords - 2"); |
311 | */ | 311 | */ |
312 | 312 | ||
313 | result = {'records': []}; | 313 | result = { |
314 | 'records': { | ||
315 | // 'deleted': [], | ||
316 | 'updated': [] | ||
317 | } | ||
318 | }; | ||
314 | 319 | ||
315 | deferredResult = new MochiKit.Async.Deferred(); | 320 | deferredResult = new MochiKit.Async.Deferred(); |
316 | c = someRecords.length; | 321 | c = someRecords.length; |
317 | for (i=0; i<c; i++) { | 322 | for (i=0; i<c; i++) { |
318 | deferredResult.addCallback(function(aRecord) { | 323 | deferredResult.addCallback(function(aRecord) { |
319 | if (aRecord.headerNotes() != null) { | 324 | if (aRecord.headerNotes() != null) { |
320 | aRecord.setNotes(aRecord.headerNotes()); | 325 | aRecord.setNotes(aRecord.headerNotes()); |
321 | } | 326 | } |
322 | aRecord.syncDirectLoginReferenceValues(); | 327 | aRecord.syncDirectLoginReferenceValues(); |
323 | aRecord.currentVersion().createNewVersion(); | 328 | aRecord.currentVersion().createNewVersion(); |
324 | aRecord.updateKey(); | 329 | aRecord.updateKey(); |
325 | }, someRecords[i]); | 330 | }, someRecords[i]); |
326 | deferredResult.addCallback(MochiKit.Async.wait, 0.1); | 331 | deferredResult.addCallback(MochiKit.Async.wait, 0.1); |
327 | } | 332 | } |
328 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 1 " + res); return res;}); | 333 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 1 " + res); return res;}); |
329 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_collectRecordInfo'); | 334 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_collectRecordInfo'); |
330 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 2 " + res); return res;}); | 335 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 2 " + res); return res;}); |
331 | 336 | ||
332 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_encryptUserData'); | 337 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_encryptUserData'); |
333 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 3 " + res); return res;}); | 338 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 3 " + res); return res;}); |
334 | deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedData')); | 339 | deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedData')); |
335 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 4 " + res); return res;}); | 340 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 4 " + res); return res;}); |
336 | deferredResult.addCallback(function(aResult, res) { | 341 | deferredResult.addCallback(function(aResult, res) { |
337 | aResult['user'] = res; | 342 | aResult['user'] = res; |
@@ -346,49 +351,49 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2"); | |||
346 | recordData = {}; | 351 | recordData = {}; |
347 | 352 | ||
348 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.1 " + res); return res;}); | 353 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.1 " + res); return res;}); |
349 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_encryptRecordData'); | 354 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_encryptRecordData'); |
350 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.2 " + res); return res;}); | 355 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.2 " + res); return res;}); |
351 | deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'encryptedData')); | 356 | deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'encryptedData')); |
352 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.3 " + res); return res;}); | 357 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.3 " + res); return res;}); |
353 | deferredResult.addCallback(function(aResult, res) { | 358 | deferredResult.addCallback(function(aResult, res) { |
354 | aResult['record'] = res; | 359 | aResult['record'] = res; |
355 | return aResult; | 360 | return aResult; |
356 | }, recordData); | 361 | }, recordData); |
357 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.4 " + res); return res;}); | 362 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.4 " + res); return res;}); |
358 | 363 | ||
359 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {} /*'saveCard_encryptRecordVersions'*/); | 364 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {} /*'saveCard_encryptRecordVersions'*/); |
360 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.5 " + res); return res;}); | 365 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.5 " + res); return res;}); |
361 | deferredResult.addCallback(MochiKit.Base.method(someRecords[i].currentVersion(), 'encryptedData')); | 366 | deferredResult.addCallback(MochiKit.Base.method(someRecords[i].currentVersion(), 'encryptedData')); |
362 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.6 " + res); return res;}); | 367 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.6 " + res); return res;}); |
363 | deferredResult.addCallback(function(aResult, res) { | 368 | deferredResult.addCallback(function(aResult, res) { |
364 | aResult['currentRecordVersion'] = res; | 369 | aResult['currentRecordVersion'] = res; |
365 | return aResult; | 370 | return aResult; |
366 | }, recordData); | 371 | }, recordData); |
367 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.7 " + res); return res;}); | 372 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.7 " + res); return res;}); |
368 | 373 | ||
369 | deferredResult.addCallback(function(aResult, res) { | 374 | deferredResult.addCallback(function(aResult, res) { |
370 | aResult['records'] = { 'updated': [res] }; | 375 | aResult['records']['updated'].push(res); |
371 | return aResult; | 376 | return aResult; |
372 | }, result); | 377 | }, result); |
373 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.8 " + res); return res;}); | 378 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.8 " + res); return res;}); |
374 | } | 379 | } |
375 | 380 | ||
376 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 7 " + res); return res;}); | 381 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 7 " + res); return res;}); |
377 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_sendingData'); | 382 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_sendingData'); |
378 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 8 " + res); return res;}); | 383 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 8 " + res); return res;}); |
379 | // deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), methodName); | 384 | // deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), methodName); |
380 | deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'saveChanges'); | 385 | deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'saveChanges'); |
381 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9 " + res); return res;}); | 386 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9 " + res); return res;}); |
382 | 387 | ||
383 | for (i=0; i<c; i++) { | 388 | for (i=0; i<c; i++) { |
384 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.1 " + res); return res;}); | 389 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.1 " + res); return res;}); |
385 | deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'takeSnapshotOfCurrentData')); | 390 | deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'takeSnapshotOfCurrentData')); |
386 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.2 " + res); return res;}); | 391 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.2 " + res); return res;}); |
387 | deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'setIsBrandNew'), false); | 392 | deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'setIsBrandNew'), false); |
388 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.3 " + res); return res;}); | 393 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.3 " + res); return res;}); |
389 | } | 394 | } |
390 | 395 | ||
391 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 10 " + res); return res;}); | 396 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 10 " + res); return res;}); |
392 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'recordUpdated'); | 397 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'recordUpdated'); |
393 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 11 " + res); return res;}); | 398 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 11 " + res); return res;}); |
394 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'directLoginUpdated'); | 399 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'directLoginUpdated'); |