author | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2012-06-16 07:22:01 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2012-06-16 07:22:01 (UTC) |
commit | 9ae34bd825e9390eedb1a8c9842b2515699dac99 (patch) (unidiff) | |
tree | f2efea0a967f890ce9235871fd26a96515596bc4 /frontend/beta/js/Clipperz | |
parent | 36ff1deefcbbd24aceca97eb39a13f9da4af8ff5 (diff) | |
parent | 36b3236415b856ddd0ad2804e82e410b5240ff4f (diff) | |
download | clipperz-9ae34bd825e9390eedb1a8c9842b2515699dac99.zip clipperz-9ae34bd825e9390eedb1a8c9842b2515699dac99.tar.gz clipperz-9ae34bd825e9390eedb1a8c9842b2515699dac99.tar.bz2 |
Merge pull request #40 from jokajak/issue37
fix the cancel button for editing cards
-rw-r--r-- | frontend/beta/js/Clipperz/PM/DataModel/Record.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/Record.js b/frontend/beta/js/Clipperz/PM/DataModel/Record.js index ffb45de..9e496de 100644 --- a/frontend/beta/js/Clipperz/PM/DataModel/Record.js +++ b/frontend/beta/js/Clipperz/PM/DataModel/Record.js | |||
@@ -247,98 +247,104 @@ Clipperz.PM.DataModel.Record.prototype = MochiKit.Base.update(null, { | |||
247 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.decryptData - this: " + this + " (" + anEncryptedData + ")"); | 247 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.decryptData - this: " + this + " (" + anEncryptedData + ")"); |
248 | if (this.shouldDecryptData()) { | 248 | if (this.shouldDecryptData()) { |
249 | var deferredResult; | 249 | var deferredResult; |
250 | 250 | ||
251 | deferredResult = new MochiKit.Async.Deferred(); | 251 | deferredResult = new MochiKit.Async.Deferred(); |
252 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'decryptingRecordData'); | 252 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'decryptingRecordData'); |
253 | deferredResult.addCallback(Clipperz.PM.Crypto.deferredDecrypt, this.key(), anEncryptedData['data'], anEncryptedData['version']); | 253 | deferredResult.addCallback(Clipperz.PM.Crypto.deferredDecrypt, this.key(), anEncryptedData['data'], anEncryptedData['version']); |
254 | deferredResult.addCallback(function(anEncryptedData, someDecryptedValues) { | 254 | deferredResult.addCallback(function(anEncryptedData, someDecryptedValues) { |
255 | varresult; | 255 | varresult; |
256 | 256 | ||
257 | result = anEncryptedData; | 257 | result = anEncryptedData; |
258 | result['data'] = someDecryptedValues; | 258 | result['data'] = someDecryptedValues; |
259 | 259 | ||
260 | return result; | 260 | return result; |
261 | }, anEncryptedData); | 261 | }, anEncryptedData); |
262 | deferredResult.addCallback(MochiKit.Base.method(this, 'setDecryptedData')); | 262 | deferredResult.addCallback(MochiKit.Base.method(this, 'setDecryptedData')); |
263 | deferredResult.callback(); | 263 | deferredResult.callback(); |
264 | 264 | ||
265 | result = deferredResult; | 265 | result = deferredResult; |
266 | } else { | 266 | } else { |
267 | result = MochiKit.Async.succeed(this.decryptedData()); | 267 | result = MochiKit.Async.succeed(this.decryptedData()); |
268 | } | 268 | } |
269 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.decryptData"); | 269 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.decryptData"); |
270 | 270 | ||
271 | return result; | 271 | return result; |
272 | }, | 272 | }, |
273 | 273 | ||
274 | //------------------------------------------------------------------------- | 274 | //------------------------------------------------------------------------- |
275 | 275 | ||
276 | 'processData': function(someValues) { | 276 | 'processData': function(someValues) { |
277 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.processData"); | 277 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.processData"); |
278 | //MochiKit.Logging.logDebug("--- Record.processData: " + Clipperz.Base.serializeJSON(someValues)); | 278 | //MochiKit.Logging.logDebug("--- Record.processData: " + Clipperz.Base.serializeJSON(someValues)); |
279 | if (this.shouldProcessData()) { | 279 | if (this.shouldProcessData()) { |
280 | var currentVersionParameters; | 280 | var currentVersionParameters; |
281 | 281 | ||
282 | console.log("Record.processData", someValues); | 282 | console.log("Record.processData", someValues); |
283 | this.processDataToExtractLegacyValues(someValues['data']); | 283 | this.processDataToExtractLegacyValues(someValues['data']); |
284 | 284 | ||
285 | if (typeof(someValues['data']['notes']) != 'undefined') { | 285 | if (typeof(someValues['data']['notes']) != 'undefined') { |
286 | this.setNotes(someValues['data']['notes']); | 286 | this.setNotes(someValues['data']['notes']); |
287 | } | 287 | } |
288 | 288 | ||
289 | if (someValues['data']['currentVersionKey'] != null) { | 289 | if (someValues['data']['currentVersionKey'] != null) { |
290 | this.setCurrentVersionKey(someValues['data']['currentVersionKey']); | 290 | this.setCurrentVersionKey(someValues['data']['currentVersionKey']); |
291 | } else { | 291 | } else { |
292 | this.setCurrentVersionKey(this.key()); | 292 | this.setCurrentVersionKey(this.key()); |
293 | } | 293 | } |
294 | 294 | ||
295 | // currentVersionParameters = someValues['currentVersion']; | 295 | // community edition doesn't currently pass version |
296 | currentVersionParameters = someValues['versions'][someValues['currentVersion']]; | 296 | // information |
297 | if (someValues['versions'] == null) { | ||
298 | currentVersionParameters = someValues['currentVersion']; | ||
299 | } else { | ||
300 | currentVersionParameters = someValues['versions'][someValues['currentVersion']]; | ||
301 | } | ||
302 | |||
297 | console.log("Record.processData - this.currentVersionKey()", this.currentVersionKey()); | 303 | console.log("Record.processData - this.currentVersionKey()", this.currentVersionKey()); |
298 | console.log("Record.processData - currentVersionParameters", currentVersionParameters); | 304 | console.log("Record.processData - currentVersionParameters", currentVersionParameters); |
299 | currentVersionParameters['key'] = this.currentVersionKey(); | 305 | currentVersionParameters['key'] = this.currentVersionKey(); |
300 | this.setCurrentVersion(new Clipperz.PM.DataModel.RecordVersion(this, currentVersionParameters)); | 306 | this.setCurrentVersion(new Clipperz.PM.DataModel.RecordVersion(this, currentVersionParameters)); |
301 | 307 | ||
302 | if (someValues['data']['directLogins'] != null) { | 308 | if (someValues['data']['directLogins'] != null) { |
303 | vardirectLoginReference; | 309 | vardirectLoginReference; |
304 | 310 | ||
305 | for (directLoginReference in someValues['data']['directLogins']) { | 311 | for (directLoginReference in someValues['data']['directLogins']) { |
306 | var directLogin; | 312 | var directLogin; |
307 | var directLoginParameters; | 313 | var directLoginParameters; |
308 | 314 | ||
309 | directLoginParameters = someValues['data']['directLogins'][directLoginReference]; | 315 | directLoginParameters = someValues['data']['directLogins'][directLoginReference]; |
310 | directLoginParameters.record = this; | 316 | directLoginParameters.record = this; |
311 | directLoginParameters.reference = directLoginReference; | 317 | directLoginParameters.reference = directLoginReference; |
312 | 318 | ||
313 | directLogin = new Clipperz.PM.DataModel.DirectLogin(directLoginParameters); | 319 | directLogin = new Clipperz.PM.DataModel.DirectLogin(directLoginParameters); |
314 | this.addDirectLogin(directLogin, true); | 320 | this.addDirectLogin(directLogin, true); |
315 | } | 321 | } |
316 | } | 322 | } |
317 | this.setShouldProcessData(false); | 323 | this.setShouldProcessData(false); |
318 | } | 324 | } |
319 | 325 | ||
320 | Clipperz.NotificationCenter.notify(this, 'recordDataReady'); | 326 | Clipperz.NotificationCenter.notify(this, 'recordDataReady'); |
321 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.processData"); | 327 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.processData"); |
322 | //MochiKit.Logging.logDebug("<<< Record.processData"); | 328 | //MochiKit.Logging.logDebug("<<< Record.processData"); |
323 | 329 | ||
324 | return this; | 330 | return this; |
325 | }, | 331 | }, |
326 | 332 | ||
327 | //------------------------------------------------------------------------- | 333 | //------------------------------------------------------------------------- |
328 | 334 | ||
329 | 'processDataToExtractLegacyValues': function(someValues) { | 335 | 'processDataToExtractLegacyValues': function(someValues) { |
330 | //MochiKit.Logging.logDebug(">>> Record.processDataToExtractLegacyValues"); | 336 | //MochiKit.Logging.logDebug(">>> Record.processDataToExtractLegacyValues"); |
331 | if (someValues['data'] != null) { | 337 | if (someValues['data'] != null) { |
332 | this.setNotes(someValues['data']); | 338 | this.setNotes(someValues['data']); |
333 | } | 339 | } |
334 | 340 | ||
335 | if ( | 341 | if ( |
336 | (typeof(someValues['loginFormData']) != "undefined") | 342 | (typeof(someValues['loginFormData']) != "undefined") |
337 | &&(typeof(someValues['loginBindings'] != "undefined")) | 343 | &&(typeof(someValues['loginBindings'] != "undefined")) |
338 | &&(someValues['loginFormData'] != "") | 344 | &&(someValues['loginFormData'] != "") |
339 | &&(someValues['loginBindings'] != "") | 345 | &&(someValues['loginBindings'] != "") |
340 | ) { | 346 | ) { |
341 | vardirectLogin; | 347 | vardirectLogin; |
342 | 348 | ||
343 | directLogin = new Clipperz.PM.DataModel.DirectLogin({ | 349 | directLogin = new Clipperz.PM.DataModel.DirectLogin({ |
344 | record:this, | 350 | record:this, |