Diffstat (limited to 'frontend/beta/js/Clipperz/PM/DataModel/Record.js') (more/less context) (show whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/DataModel/Record.js | 8 |
1 files changed, 7 insertions, 1 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 @@ -199,194 +199,200 @@ Clipperz.PM.DataModel.Record.prototype = MochiKit.Base.update(null, { //------------------------------------------------------------------------- 'shouldDecryptData': function() { return this._shouldDecryptData; }, 'setShouldDecryptData': function(aValue) { this._shouldDecryptData = aValue; }, //------------------------------------------------------------------------- 'shouldProcessData': function() { return this._shouldProcessData; }, 'setShouldProcessData': function(aValue) { this._shouldProcessData = aValue; }, //------------------------------------------------------------------------- 'loadData': function() { var result; //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.loadData - this: " + this); if (this.shouldLoadData()) { var deferredResult; deferredResult = new MochiKit.Async.Deferred(); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'loadingRecordData'); deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'getRecordDetail', {reference: this.reference()}); deferredResult.addCallback(MochiKit.Base.method(this,'setServerData')); deferredResult.callback(); result = deferredResult; } else { result = MochiKit.Async.succeed(this.serverData()); } //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.loadData"); return result; }, //------------------------------------------------------------------------- 'decryptData': function(anEncryptedData) { var result; //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.decryptData - this: " + this + " (" + anEncryptedData + ")"); if (this.shouldDecryptData()) { var deferredResult; deferredResult = new MochiKit.Async.Deferred(); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'decryptingRecordData'); deferredResult.addCallback(Clipperz.PM.Crypto.deferredDecrypt, this.key(), anEncryptedData['data'], anEncryptedData['version']); deferredResult.addCallback(function(anEncryptedData, someDecryptedValues) { var result; result = anEncryptedData; result['data'] = someDecryptedValues; return result; }, anEncryptedData); deferredResult.addCallback(MochiKit.Base.method(this, 'setDecryptedData')); deferredResult.callback(); result = deferredResult; } else { result = MochiKit.Async.succeed(this.decryptedData()); } //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.decryptData"); return result; }, //------------------------------------------------------------------------- 'processData': function(someValues) { //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.processData"); //MochiKit.Logging.logDebug("--- Record.processData: " + Clipperz.Base.serializeJSON(someValues)); if (this.shouldProcessData()) { var currentVersionParameters; console.log("Record.processData", someValues); this.processDataToExtractLegacyValues(someValues['data']); if (typeof(someValues['data']['notes']) != 'undefined') { this.setNotes(someValues['data']['notes']); } if (someValues['data']['currentVersionKey'] != null) { this.setCurrentVersionKey(someValues['data']['currentVersionKey']); } else { this.setCurrentVersionKey(this.key()); } -// currentVersionParameters = someValues['currentVersion']; +// community edition doesn't currently pass version +// information + if (someValues['versions'] == null) { + currentVersionParameters = someValues['currentVersion']; + } else { currentVersionParameters = someValues['versions'][someValues['currentVersion']]; + } + console.log("Record.processData - this.currentVersionKey()", this.currentVersionKey()); console.log("Record.processData - currentVersionParameters", currentVersionParameters); currentVersionParameters['key'] = this.currentVersionKey(); this.setCurrentVersion(new Clipperz.PM.DataModel.RecordVersion(this, currentVersionParameters)); if (someValues['data']['directLogins'] != null) { var directLoginReference; for (directLoginReference in someValues['data']['directLogins']) { var directLogin; var directLoginParameters; directLoginParameters = someValues['data']['directLogins'][directLoginReference]; directLoginParameters.record = this; directLoginParameters.reference = directLoginReference; directLogin = new Clipperz.PM.DataModel.DirectLogin(directLoginParameters); this.addDirectLogin(directLogin, true); } } this.setShouldProcessData(false); } Clipperz.NotificationCenter.notify(this, 'recordDataReady'); //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.processData"); //MochiKit.Logging.logDebug("<<< Record.processData"); return this; }, //------------------------------------------------------------------------- 'processDataToExtractLegacyValues': function(someValues) { //MochiKit.Logging.logDebug(">>> Record.processDataToExtractLegacyValues"); if (someValues['data'] != null) { this.setNotes(someValues['data']); } if ( (typeof(someValues['loginFormData']) != "undefined") && (typeof(someValues['loginBindings'] != "undefined")) && (someValues['loginFormData'] != "") && (someValues['loginBindings'] != "") ) { var directLogin; directLogin = new Clipperz.PM.DataModel.DirectLogin({ record:this, label:this.label() + Clipperz.PM.Strings['newDirectLoginLabelSuffix'], reference:Clipperz.Crypto.SHA.sha256(new Clipperz.ByteArray(this.label() + someValues['loginFormData'] + someValues['loginBindings'])).toHexString().substring(2), formData:Clipperz.Base.evalJSON(someValues['loginFormData']), legacyBindingData:Clipperz.Base.evalJSON(someValues['loginBindings']), bookmarkletVersion:'0.1' }); this.addDirectLogin(directLogin, true); } //MochiKit.Logging.logDebug("<<< Record.processDataToExtractLegacyValues"); }, //------------------------------------------------------------------------- 'getReadyBeforeUpdatingVersionValues': function() { }, //------------------------------------------------------------------------- 'addNewField': function() { var newField; //MochiKit.Logging.logDebug(">>> Record.addNewField - " + this); this.getReadyBeforeUpdatingVersionValues(); newField = this.currentVersion().addNewField(); Clipperz.NotificationCenter.notify(this, 'recordUpdated'); //MochiKit.Logging.logDebug("<<< Record.addNewField"); return newField; }, //------------------------------------------------------------------------- 'removeField': function(aField) { this.getReadyBeforeUpdatingVersionValues(); this.currentVersion().removeField(aField); Clipperz.NotificationCenter.notify(this, 'recordUpdated'); }, 'removeEmptyFields': function() { MochiKit.Iter.forEach(MochiKit.Base.values(this.currentVersion().fields()), MochiKit.Base.bind(function(aField) { if (aField.isEmpty()) { this.removeField(aField); // this.currentVersion().removeField(aField); } }, this)); }, |