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 | |
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 | |||
217 | } else { | 217 | } else { |
218 | 218 | ||
219 | //MochiKit.Logging.logDebug("--- User.handleConnectionFallback - an ERROR has occurred - " + aValue); | 219 | //MochiKit.Logging.logDebug("--- User.handleConnectionFallback - an ERROR has occurred - " + aValue); |
220 | this.resetConnection(); | 220 | this.resetConnection(); |
221 | this.setConnectionVersion(Clipperz.PM.Crypto.communicationProtocol.fallbackVersions[this.connectionVersion()]); | 221 | this.setConnectionVersion(Clipperz.PM.Crypto.communicationProtocol.fallbackVersions[this.connectionVersion()]); |
222 | 222 | ||
223 | if (this.connectionVersion() != null) { | 223 | if (this.connectionVersion() != null) { |
224 | result = new MochiKit.Async.Deferred(); | 224 | result = new MochiKit.Async.Deferred(); |
225 | 225 | ||
226 | result.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'connection_tryOlderSchema'); | 226 | result.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'connection_tryOlderSchema'); |
227 | result.addCallback(MochiKit.Base.method(this, 'connect')); | 227 | result.addCallback(MochiKit.Base.method(this, 'connect')); |
228 | result.callback(); | 228 | result.callback(); |
229 | } else { | 229 | } else { |
230 | result = MochiKit.Async.fail(Clipperz.PM.DataModel.User.exception.LoginFailed); | 230 | result = MochiKit.Async.fail(Clipperz.PM.DataModel.User.exception.LoginFailed); |
231 | } | 231 | } |
232 | } | 232 | } |
233 | //MochiKit.Logging.logDebug("<<< User.handleConnectionFallback"); | 233 | //MochiKit.Logging.logDebug("<<< User.handleConnectionFallback"); |
234 | return result; | 234 | return result; |
235 | }, | 235 | }, |
236 | 236 | ||
237 | //========================================================================= | 237 | //========================================================================= |
238 | 238 | ||
239 | 'header': function() { | 239 | 'header': function() { |
240 | if (this._header == null) { | 240 | if (this._header == null) { |
241 | this._header = new Clipperz.PM.DataModel.Header({user:this}); | 241 | this._header = new Clipperz.PM.DataModel.Header({user:this}); |
242 | } | 242 | } |
243 | return this._header; | 243 | return this._header; |
244 | }, | 244 | }, |
245 | 245 | ||
246 | //------------------------------------------------------------------------- | 246 | //------------------------------------------------------------------------- |
247 | 247 | ||
248 | 'statistics': function() { | 248 | 'statistics': function() { |
249 | if (this._statistics == null) { | 249 | if (this._statistics == null) { |
250 | this._statistics = new Clipperz.PM.DataModel.Statistics({user:this}); | 250 | this._statistics = new Clipperz.PM.DataModel.Statistics({user:this}); |
251 | } | 251 | } |
252 | return this._statistics; | 252 | return this._statistics; |
253 | }, | 253 | }, |
254 | 254 | ||
255 | //------------------------------------------------------------------------- | 255 | //------------------------------------------------------------------------- |
256 | 256 | ||
257 | 'records': function() { | 257 | 'records': function() { |
258 | return this._records; | 258 | return this._records; |
259 | }, | 259 | }, |
260 | 260 | ||
261 | //......................................................................... | 261 | //......................................................................... |
262 | 262 | ||
263 | 'addRecord': function(aValue, isBatchUpdate) { | 263 | 'addRecord': function(aValue, isBatchUpdate) { |
264 | this.records()[aValue.reference()] = aValue; | 264 | this.records()[aValue.reference()] = aValue; |
265 | 265 | ||
266 | if (isBatchUpdate != true) { | 266 | if (isBatchUpdate != true) { |
267 | Clipperz.NotificationCenter.notify(aValue, 'recordAdded', null, true); | 267 | Clipperz.NotificationCenter.notify(aValue, 'recordAdded', null, true); |
268 | Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); | 268 | Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); |
269 | } | 269 | } |
270 | }, | 270 | }, |
271 | 271 | ||
272 | //----------------------------------------------------------------------------- | 272 | //----------------------------------------------------------------------------- |
273 | 273 | ||
274 | 'addNewRecord': function() { | 274 | 'addNewRecord': function() { |
275 | varrecord; | 275 | varrecord; |
276 | 276 | ||
277 | //MochiKit.Logging.logDebug(">>> User.addNewRecord"); | 277 | //MochiKit.Logging.logDebug(">>> User.addNewRecord"); |
278 | record = new Clipperz.PM.DataModel.Record({user:this}); | 278 | record = new Clipperz.PM.DataModel.Record({user:this}); |
279 | this.addRecord(record); | 279 | this.addRecord(record); |
280 | Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); | 280 | Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); |
281 | //MochiKit.Logging.logDebug("<<< User.addNewRecord"); | 281 | //MochiKit.Logging.logDebug("<<< User.addNewRecord"); |
282 | 282 | ||
283 | return record; | 283 | return record; |
284 | }, | 284 | }, |
285 | 285 | ||
286 | //------------------------------------------------------------------------- | 286 | //------------------------------------------------------------------------- |
287 | 287 | ||
288 | 'saveRecords': function(someRecords /*, aMethodName*/) { | 288 | 'saveRecords': function(someRecords /*, aMethodName*/) { |
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; |
338 | return aResult; | 343 | return aResult; |
339 | }, result); | 344 | }, result); |
340 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 5 " + res); return res;}); | 345 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 5 " + res); return res;}); |
341 | 346 | ||
342 | c = someRecords.length; | 347 | c = someRecords.length; |
343 | for (i=0; i<c; i++) { | 348 | for (i=0; i<c; i++) { |
344 | var recordData; | 349 | var recordData; |
345 | 350 | ||
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'); |
395 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 12 " + res); return res;}); | 400 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 12 " + res); return res;}); |
396 | deferredResult.callback(); | 401 | deferredResult.callback(); |
397 | 402 | ||
398 | return deferredResult; | 403 | return deferredResult; |
399 | }, | 404 | }, |
400 | 405 | ||
401 | //------------------------------------------------------------------------- | 406 | //------------------------------------------------------------------------- |
402 | 407 | ||
403 | 'removeRecord': function(aRecord) { | 408 | 'removeRecord': function(aRecord) { |
404 | //MochiKit.Logging.logDebug(">>> User.removeRecord"); | 409 | //MochiKit.Logging.logDebug(">>> User.removeRecord"); |
405 | delete this.records()[aRecord.reference()]; | 410 | delete this.records()[aRecord.reference()]; |
406 | //MochiKit.Logging.logDebug("--- User.removeRecord - 1"); | 411 | //MochiKit.Logging.logDebug("--- User.removeRecord - 1"); |
407 | Clipperz.NotificationCenter.notify(aRecord, 'recordRemoved', null, false); | 412 | Clipperz.NotificationCenter.notify(aRecord, 'recordRemoved', null, false); |
408 | Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); | 413 | Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); |
409 | //MochiKit.Logging.logDebug("<<< User.removeRecord"); | 414 | //MochiKit.Logging.logDebug("<<< User.removeRecord"); |
410 | }, | 415 | }, |
411 | 416 | ||
412 | //------------------------------------------------------------------------- | 417 | //------------------------------------------------------------------------- |
413 | 418 | ||
414 | 'deleteRecordsAction': function(someRecords) { | 419 | 'deleteRecordsAction': function(someRecords) { |
415 | vardeferredResult; | 420 | vardeferredResult; |
416 | var parameters; | 421 | var parameters; |
417 | 422 | ||
418 | //MochiKit.Logging.logDebug(">>> User.deleteRecordsAction - someRecords.length: " + someRecords.length); | 423 | //MochiKit.Logging.logDebug(">>> User.deleteRecordsAction - someRecords.length: " + someRecords.length); |
419 | parameters = {}; | 424 | parameters = {}; |
420 | deferredResult = new MochiKit.Async.Deferred(); | 425 | deferredResult = new MochiKit.Async.Deferred(); |
421 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 1 " + res); return res;}); | 426 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 1 " + res); return res;}); |
422 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_collectData'); | 427 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_collectData'); |
423 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 2 " + res); return res;}); | 428 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 2 " + res); return res;}); |
424 | deferredResult.addCallback(function(someParameters, someRecords) { | 429 | deferredResult.addCallback(function(someParameters, someRecords) { |
425 | var recordReferences; | 430 | var recordReferences; |
426 | 431 | ||
427 | recordReferences = MochiKit.Base.map(function(aRecord) { | 432 | recordReferences = MochiKit.Base.map(function(aRecord) { |
428 | var result; | 433 | var result; |
429 | 434 | ||
430 | result = aRecord.reference(); | 435 | result = aRecord.reference(); |
431 | aRecord.remove(); | 436 | aRecord.remove(); |
432 | 437 | ||
433 | return result; | 438 | return result; |
434 | }, someRecords); | 439 | }, someRecords); |
435 | // someParameters.recordReferences = recordReferences; | 440 | // someParameters.recordReferences = recordReferences; |
436 | someParameters['records'] = { 'deleted': recordReferences}; | 441 | someParameters['records'] = { 'deleted': recordReferences}; |
437 | 442 | ||
438 | return someParameters; | 443 | return someParameters; |
439 | }, parameters); | 444 | }, parameters); |
440 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 3 " + res); return res;}); | 445 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 3 " + res); return res;}); |
441 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_encryptData'); | 446 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_encryptData'); |
442 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 4 " + res); return res;}); | 447 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 4 " + res); return res;}); |
443 | deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedData')); | 448 | deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedData')); |
444 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 5 " + res); return res;}); | 449 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 5 " + res); return res;}); |
445 | deferredResult.addCallback(function(someParameters, anUserEncryptedData) { | 450 | deferredResult.addCallback(function(someParameters, anUserEncryptedData) { |
446 | someParameters.user = anUserEncryptedData; | 451 | someParameters.user = anUserEncryptedData; |
447 | return someParameters; | 452 | return someParameters; |
448 | }, parameters); | 453 | }, parameters); |
449 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 6 " + res); return res;}); | 454 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 6 " + res); return res;}); |
450 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_sendingData'); | 455 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_sendingData'); |
451 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecords parameters: " + Clipperz.Base.serializeJSON(res)); return res;}); | 456 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecords parameters: " + Clipperz.Base.serializeJSON(res)); return res;}); |
452 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 7 " + res); return res;}); | 457 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 7 " + res); return res;}); |
453 | // deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'deleteRecords'); | 458 | // deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'deleteRecords'); |
454 | deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'saveChanges'); | 459 | deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'saveChanges'); |
455 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 8 " + res); return res;}); | 460 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 8 " + res); return res;}); |
456 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_updatingInterface'); | 461 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_updatingInterface'); |
457 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 9 " + res); return res;}); | 462 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 9 " + res); return res;}); |
458 | deferredResult.callback(someRecords); | 463 | deferredResult.callback(someRecords); |
459 | //MochiKit.Logging.logDebug("<<< User.deleteRecordsAction"); | 464 | //MochiKit.Logging.logDebug("<<< User.deleteRecordsAction"); |
460 | 465 | ||
461 | return deferredResult; | 466 | return deferredResult; |
462 | }, | 467 | }, |
463 | 468 | ||
464 | //------------------------------------------------------------------------- | 469 | //------------------------------------------------------------------------- |
465 | 470 | ||
466 | 'resetAllLocalData': function() { | 471 | 'resetAllLocalData': function() { |