-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 | |||
@@ -103,386 +103,392 @@ Clipperz.PM.DataModel.Record.prototype = MochiKit.Base.update(null, { | |||
103 | //------------------------------------------------------------------------- | 103 | //------------------------------------------------------------------------- |
104 | 104 | ||
105 | 'key': function() { | 105 | 'key': function() { |
106 | return this._key; | 106 | return this._key; |
107 | }, | 107 | }, |
108 | 108 | ||
109 | 'updateKey': function() { | 109 | 'updateKey': function() { |
110 | this._key = Clipperz.PM.Crypto.randomKey(); | 110 | this._key = Clipperz.PM.Crypto.randomKey(); |
111 | }, | 111 | }, |
112 | 112 | ||
113 | //------------------------------------------------------------------------- | 113 | //------------------------------------------------------------------------- |
114 | 114 | ||
115 | 'label': function() { | 115 | 'label': function() { |
116 | return this._label; | 116 | return this._label; |
117 | }, | 117 | }, |
118 | 118 | ||
119 | 'setLabel': function(aValue) { | 119 | 'setLabel': function(aValue) { |
120 | this._label = aValue; | 120 | this._label = aValue; |
121 | }, | 121 | }, |
122 | 122 | ||
123 | 'lowerCaseLabel': function() { | 123 | 'lowerCaseLabel': function() { |
124 | return this.label().toLowerCase(); | 124 | return this.label().toLowerCase(); |
125 | }, | 125 | }, |
126 | 126 | ||
127 | //------------------------------------------------------------------------- | 127 | //------------------------------------------------------------------------- |
128 | 128 | ||
129 | 'versions': function() { | 129 | 'versions': function() { |
130 | return this._versions; | 130 | return this._versions; |
131 | }, | 131 | }, |
132 | 132 | ||
133 | //------------------------------------------------------------------------- | 133 | //------------------------------------------------------------------------- |
134 | 134 | ||
135 | 'currentVersion': function() { | 135 | 'currentVersion': function() { |
136 | return this._currentVersion; | 136 | return this._currentVersion; |
137 | }, | 137 | }, |
138 | 138 | ||
139 | 'setCurrentVersion': function(aValue) { | 139 | 'setCurrentVersion': function(aValue) { |
140 | this._currentVersion = aValue; | 140 | this._currentVersion = aValue; |
141 | }, | 141 | }, |
142 | 142 | ||
143 | //------------------------------------------------------------------------- | 143 | //------------------------------------------------------------------------- |
144 | 144 | ||
145 | 'currentVersionKey': function() { | 145 | 'currentVersionKey': function() { |
146 | return this._currentVersionKey; | 146 | return this._currentVersionKey; |
147 | }, | 147 | }, |
148 | 148 | ||
149 | 'setCurrentVersionKey': function(aValue) { | 149 | 'setCurrentVersionKey': function(aValue) { |
150 | this._currentVersionKey = aValue; | 150 | this._currentVersionKey = aValue; |
151 | }, | 151 | }, |
152 | 152 | ||
153 | //------------------------------------------------------------------------- | 153 | //------------------------------------------------------------------------- |
154 | 154 | ||
155 | 'deferredData': function() { | 155 | 'deferredData': function() { |
156 | vardeferredResult; | 156 | vardeferredResult; |
157 | 157 | ||
158 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.deferredData - this: " + this); | 158 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.deferredData - this: " + this); |
159 | deferredResult = new MochiKit.Async.Deferred(); | 159 | deferredResult = new MochiKit.Async.Deferred(); |
160 | deferredResult.addCallback(MochiKit.Base.method(this, 'loadData')); | 160 | deferredResult.addCallback(MochiKit.Base.method(this, 'loadData')); |
161 | deferredResult.addCallback(MochiKit.Base.method(this, 'decryptData')); | 161 | deferredResult.addCallback(MochiKit.Base.method(this, 'decryptData')); |
162 | deferredResult.addCallback(MochiKit.Base.method(this, 'processData')); | 162 | deferredResult.addCallback(MochiKit.Base.method(this, 'processData')); |
163 | deferredResult.addCallback(function(aRecord) { | 163 | deferredResult.addCallback(function(aRecord) { |
164 | return aRecord.currentVersion().deferredData(); | 164 | return aRecord.currentVersion().deferredData(); |
165 | }); | 165 | }); |
166 | deferredResult.addCallback(MochiKit.Base.method(this, 'takeSnapshotOfCurrentData')); | 166 | deferredResult.addCallback(MochiKit.Base.method(this, 'takeSnapshotOfCurrentData')); |
167 | deferredResult.addCallback(MochiKit.Async.succeed, this); | 167 | deferredResult.addCallback(MochiKit.Async.succeed, this); |
168 | deferredResult.callback(); | 168 | deferredResult.callback(); |
169 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.deferredData"); | 169 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.deferredData"); |
170 | 170 | ||
171 | return deferredResult; | 171 | return deferredResult; |
172 | }, | 172 | }, |
173 | 173 | ||
174 | //------------------------------------------------------------------------- | 174 | //------------------------------------------------------------------------- |
175 | 175 | ||
176 | 'exportedData': function() { | 176 | 'exportedData': function() { |
177 | var result; | 177 | var result; |
178 | 178 | ||
179 | result = {}; | 179 | result = {}; |
180 | result['label'] = this.label(); | 180 | result['label'] = this.label(); |
181 | result['data'] = this.serializedData(); | 181 | result['data'] = this.serializedData(); |
182 | result['currentVersion'] = this.currentVersion().serializedData(); | 182 | result['currentVersion'] = this.currentVersion().serializedData(); |
183 | result['currentVersion']['reference'] = this.currentVersion().reference(); | 183 | result['currentVersion']['reference'] = this.currentVersion().reference(); |
184 | // result['versions'] = MochiKit.Base.map(MochiKit.Base.methodcaller("serializedData"), MochiKit.Base.values(this.versions())); | 184 | // result['versions'] = MochiKit.Base.map(MochiKit.Base.methodcaller("serializedData"), MochiKit.Base.values(this.versions())); |
185 | 185 | ||
186 | return Clipperz.Base.serializeJSON(result); | 186 | return Clipperz.Base.serializeJSON(result); |
187 | }, | 187 | }, |
188 | 188 | ||
189 | //------------------------------------------------------------------------- | 189 | //------------------------------------------------------------------------- |
190 | 190 | ||
191 | 'shouldLoadData': function() { | 191 | 'shouldLoadData': function() { |
192 | return this._shouldLoadData; | 192 | return this._shouldLoadData; |
193 | }, | 193 | }, |
194 | 194 | ||
195 | 'setShouldLoadData': function(aValue) { | 195 | 'setShouldLoadData': function(aValue) { |
196 | this._shouldLoadData = aValue; | 196 | this._shouldLoadData = aValue; |
197 | }, | 197 | }, |
198 | 198 | ||
199 | //------------------------------------------------------------------------- | 199 | //------------------------------------------------------------------------- |
200 | 200 | ||
201 | 'shouldDecryptData': function() { | 201 | 'shouldDecryptData': function() { |
202 | return this._shouldDecryptData; | 202 | return this._shouldDecryptData; |
203 | }, | 203 | }, |
204 | 204 | ||
205 | 'setShouldDecryptData': function(aValue) { | 205 | 'setShouldDecryptData': function(aValue) { |
206 | this._shouldDecryptData = aValue; | 206 | this._shouldDecryptData = aValue; |
207 | }, | 207 | }, |
208 | 208 | ||
209 | //------------------------------------------------------------------------- | 209 | //------------------------------------------------------------------------- |
210 | 210 | ||
211 | 'shouldProcessData': function() { | 211 | 'shouldProcessData': function() { |
212 | return this._shouldProcessData; | 212 | return this._shouldProcessData; |
213 | }, | 213 | }, |
214 | 214 | ||
215 | 'setShouldProcessData': function(aValue) { | 215 | 'setShouldProcessData': function(aValue) { |
216 | this._shouldProcessData = aValue; | 216 | this._shouldProcessData = aValue; |
217 | }, | 217 | }, |
218 | 218 | ||
219 | //------------------------------------------------------------------------- | 219 | //------------------------------------------------------------------------- |
220 | 220 | ||
221 | 'loadData': function() { | 221 | 'loadData': function() { |
222 | var result; | 222 | var result; |
223 | 223 | ||
224 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.loadData - this: " + this); | 224 | //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.loadData - this: " + this); |
225 | if (this.shouldLoadData()) { | 225 | if (this.shouldLoadData()) { |
226 | var deferredResult; | 226 | var deferredResult; |
227 | 227 | ||
228 | deferredResult = new MochiKit.Async.Deferred(); | 228 | deferredResult = new MochiKit.Async.Deferred(); |
229 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'loadingRecordData'); | 229 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'loadingRecordData'); |
230 | deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'getRecordDetail', {reference: this.reference()}); | 230 | deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'getRecordDetail', {reference: this.reference()}); |
231 | deferredResult.addCallback(MochiKit.Base.method(this,'setServerData')); | 231 | deferredResult.addCallback(MochiKit.Base.method(this,'setServerData')); |
232 | deferredResult.callback(); | 232 | deferredResult.callback(); |
233 | result = deferredResult; | 233 | result = deferredResult; |
234 | } else { | 234 | } else { |
235 | result = MochiKit.Async.succeed(this.serverData()); | 235 | result = MochiKit.Async.succeed(this.serverData()); |
236 | } | 236 | } |
237 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.loadData"); | 237 | //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.loadData"); |
238 | 238 | ||
239 | return result; | 239 | return result; |
240 | }, | 240 | }, |
241 | 241 | ||
242 | //------------------------------------------------------------------------- | 242 | //------------------------------------------------------------------------- |
243 | 243 | ||
244 | 'decryptData': function(anEncryptedData) { | 244 | 'decryptData': function(anEncryptedData) { |
245 | var result; | 245 | var result; |
246 | 246 | ||
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, |
345 | label:this.label() + Clipperz.PM.Strings['newDirectLoginLabelSuffix'], | 351 | label:this.label() + Clipperz.PM.Strings['newDirectLoginLabelSuffix'], |
346 | reference:Clipperz.Crypto.SHA.sha256(new Clipperz.ByteArray(this.label() + | 352 | reference:Clipperz.Crypto.SHA.sha256(new Clipperz.ByteArray(this.label() + |
347 | someValues['loginFormData'] + | 353 | someValues['loginFormData'] + |
348 | someValues['loginBindings'])).toHexString().substring(2), | 354 | someValues['loginBindings'])).toHexString().substring(2), |
349 | formData:Clipperz.Base.evalJSON(someValues['loginFormData']), | 355 | formData:Clipperz.Base.evalJSON(someValues['loginFormData']), |
350 | legacyBindingData:Clipperz.Base.evalJSON(someValues['loginBindings']), | 356 | legacyBindingData:Clipperz.Base.evalJSON(someValues['loginBindings']), |
351 | bookmarkletVersion:'0.1' | 357 | bookmarkletVersion:'0.1' |
352 | }); | 358 | }); |
353 | this.addDirectLogin(directLogin, true); | 359 | this.addDirectLogin(directLogin, true); |
354 | } | 360 | } |
355 | //MochiKit.Logging.logDebug("<<< Record.processDataToExtractLegacyValues"); | 361 | //MochiKit.Logging.logDebug("<<< Record.processDataToExtractLegacyValues"); |
356 | }, | 362 | }, |
357 | 363 | ||
358 | //------------------------------------------------------------------------- | 364 | //------------------------------------------------------------------------- |
359 | 365 | ||
360 | 'getReadyBeforeUpdatingVersionValues': function() { | 366 | 'getReadyBeforeUpdatingVersionValues': function() { |
361 | }, | 367 | }, |
362 | 368 | ||
363 | //------------------------------------------------------------------------- | 369 | //------------------------------------------------------------------------- |
364 | 370 | ||
365 | 'addNewField': function() { | 371 | 'addNewField': function() { |
366 | varnewField; | 372 | varnewField; |
367 | 373 | ||
368 | //MochiKit.Logging.logDebug(">>> Record.addNewField - " + this); | 374 | //MochiKit.Logging.logDebug(">>> Record.addNewField - " + this); |
369 | this.getReadyBeforeUpdatingVersionValues(); | 375 | this.getReadyBeforeUpdatingVersionValues(); |
370 | newField = this.currentVersion().addNewField(); | 376 | newField = this.currentVersion().addNewField(); |
371 | Clipperz.NotificationCenter.notify(this, 'recordUpdated'); | 377 | Clipperz.NotificationCenter.notify(this, 'recordUpdated'); |
372 | //MochiKit.Logging.logDebug("<<< Record.addNewField"); | 378 | //MochiKit.Logging.logDebug("<<< Record.addNewField"); |
373 | 379 | ||
374 | return newField; | 380 | return newField; |
375 | }, | 381 | }, |
376 | 382 | ||
377 | //------------------------------------------------------------------------- | 383 | //------------------------------------------------------------------------- |
378 | 384 | ||
379 | 'removeField': function(aField) { | 385 | 'removeField': function(aField) { |
380 | this.getReadyBeforeUpdatingVersionValues(); | 386 | this.getReadyBeforeUpdatingVersionValues(); |
381 | this.currentVersion().removeField(aField); | 387 | this.currentVersion().removeField(aField); |
382 | Clipperz.NotificationCenter.notify(this, 'recordUpdated'); | 388 | Clipperz.NotificationCenter.notify(this, 'recordUpdated'); |
383 | }, | 389 | }, |
384 | 390 | ||
385 | 'removeEmptyFields': function() { | 391 | 'removeEmptyFields': function() { |
386 | MochiKit.Iter.forEach(MochiKit.Base.values(this.currentVersion().fields()), MochiKit.Base.bind(function(aField) { | 392 | MochiKit.Iter.forEach(MochiKit.Base.values(this.currentVersion().fields()), MochiKit.Base.bind(function(aField) { |
387 | if (aField.isEmpty()) { | 393 | if (aField.isEmpty()) { |
388 | this.removeField(aField); | 394 | this.removeField(aField); |
389 | // this.currentVersion().removeField(aField); | 395 | // this.currentVersion().removeField(aField); |
390 | } | 396 | } |
391 | }, this)); | 397 | }, this)); |
392 | }, | 398 | }, |
393 | 399 | ||
394 | //------------------------------------------------------------------------- | 400 | //------------------------------------------------------------------------- |
395 | 401 | ||
396 | 'notes': function() { | 402 | 'notes': function() { |
397 | return this._notes; | 403 | return this._notes; |
398 | }, | 404 | }, |
399 | 405 | ||
400 | 'setNotes': function(aValue) { | 406 | 'setNotes': function(aValue) { |
401 | this._notes = aValue; | 407 | this._notes = aValue; |
402 | this.setHeaderNotes(null); | 408 | this.setHeaderNotes(null); |
403 | }, | 409 | }, |
404 | 410 | ||
405 | //------------------------------------------------------------------------- | 411 | //------------------------------------------------------------------------- |
406 | 412 | ||
407 | 'headerNotes': function() { | 413 | 'headerNotes': function() { |
408 | return this._headerNotes; | 414 | return this._headerNotes; |
409 | }, | 415 | }, |
410 | 416 | ||
411 | 'setHeaderNotes': function(aValue) { | 417 | 'setHeaderNotes': function(aValue) { |
412 | this._headerNotes = aValue; | 418 | this._headerNotes = aValue; |
413 | }, | 419 | }, |
414 | 420 | ||
415 | //------------------------------------------------------------------------- | 421 | //------------------------------------------------------------------------- |
416 | 422 | ||
417 | 'remove': function() { | 423 | 'remove': function() { |
418 | //MochiKit.Logging.logDebug(">>> Record.remove - " + this); | 424 | //MochiKit.Logging.logDebug(">>> Record.remove - " + this); |
419 | MochiKit.Iter.forEach(MochiKit.Base.values(this.directLogins()), MochiKit.Base.method(this, 'removeDirectLogin')); | 425 | MochiKit.Iter.forEach(MochiKit.Base.values(this.directLogins()), MochiKit.Base.method(this, 'removeDirectLogin')); |
420 | 426 | ||
421 | this.syncDirectLoginReferenceValues(); | 427 | this.syncDirectLoginReferenceValues(); |
422 | this.user().removeRecord(this); | 428 | this.user().removeRecord(this); |
423 | //MochiKit.Logging.logDebug("<<< Record.remove"); | 429 | //MochiKit.Logging.logDebug("<<< Record.remove"); |
424 | }, | 430 | }, |
425 | 431 | ||
426 | //------------------------------------------------------------------------- | 432 | //------------------------------------------------------------------------- |
427 | 433 | ||
428 | 'directLogins': function() { | 434 | 'directLogins': function() { |
429 | return this._directLogins; | 435 | return this._directLogins; |
430 | }, | 436 | }, |
431 | 437 | ||
432 | 'addDirectLogin': function(aDirectLogin, shouldUpdateUser) { | 438 | 'addDirectLogin': function(aDirectLogin, shouldUpdateUser) { |
433 | this.directLogins()[aDirectLogin.reference()] = aDirectLogin; | 439 | this.directLogins()[aDirectLogin.reference()] = aDirectLogin; |
434 | if (shouldUpdateUser == true) { | 440 | if (shouldUpdateUser == true) { |
435 | this.user().addDirectLogin(aDirectLogin); | 441 | this.user().addDirectLogin(aDirectLogin); |
436 | } | 442 | } |
437 | }, | 443 | }, |
438 | 444 | ||
439 | 'removeDirectLogin': function(aDirectLogin) { | 445 | 'removeDirectLogin': function(aDirectLogin) { |
440 | this.removedDirectLogins().push(aDirectLogin); | 446 | this.removedDirectLogins().push(aDirectLogin); |
441 | delete this.directLogins()[aDirectLogin.reference()]; | 447 | delete this.directLogins()[aDirectLogin.reference()]; |
442 | // this.user().removeDirectLogin(aDirectLogin); | 448 | // this.user().removeDirectLogin(aDirectLogin); |
443 | }, | 449 | }, |
444 | 450 | ||
445 | 'resetDirectLogins': function() { | 451 | 'resetDirectLogins': function() { |
446 | this._directLogins = {}; | 452 | this._directLogins = {}; |
447 | }, | 453 | }, |
448 | 454 | ||
449 | 'removedDirectLogins': function() { | 455 | 'removedDirectLogins': function() { |
450 | return this._removedDirectLogins; | 456 | return this._removedDirectLogins; |
451 | }, | 457 | }, |
452 | 458 | ||
453 | 'resetRemovedDirectLogins': function() { | 459 | 'resetRemovedDirectLogins': function() { |
454 | this._removedDirectLogins = []; | 460 | this._removedDirectLogins = []; |
455 | }, | 461 | }, |
456 | 462 | ||
457 | //------------------------------------------------------------------------- | 463 | //------------------------------------------------------------------------- |
458 | 464 | ||
459 | 'serverData': function() { | 465 | 'serverData': function() { |
460 | return this._serverData; | 466 | return this._serverData; |
461 | }, | 467 | }, |
462 | 468 | ||
463 | 'setServerData': function(aValue) { | 469 | 'setServerData': function(aValue) { |
464 | this._serverData = aValue; | 470 | this._serverData = aValue; |
465 | this.setShouldLoadData(false); | 471 | this.setShouldLoadData(false); |
466 | return aValue; | 472 | return aValue; |
467 | }, | 473 | }, |
468 | 474 | ||
469 | //------------------------------------------------------------------------- | 475 | //------------------------------------------------------------------------- |
470 | 476 | ||
471 | 'decryptedData': function() { | 477 | 'decryptedData': function() { |
472 | return this._decryptedData; | 478 | return this._decryptedData; |
473 | }, | 479 | }, |
474 | 480 | ||
475 | 'setDecryptedData': function(aValue) { | 481 | 'setDecryptedData': function(aValue) { |
476 | this._decryptedData = aValue; | 482 | this._decryptedData = aValue; |
477 | this.setShouldDecryptData(false); | 483 | this.setShouldDecryptData(false); |
478 | return aValue; | 484 | return aValue; |
479 | }, | 485 | }, |
480 | 486 | ||
481 | //------------------------------------------------------------------------- | 487 | //------------------------------------------------------------------------- |
482 | 488 | ||
483 | 'cachedData': function() { | 489 | 'cachedData': function() { |
484 | return this._cachedData; | 490 | return this._cachedData; |
485 | }, | 491 | }, |
486 | 492 | ||
487 | 'setCachedData': function(aValue) { | 493 | 'setCachedData': function(aValue) { |
488 | //MochiKit.Logging.logDebug(">>> Record.setCachedData"); | 494 | //MochiKit.Logging.logDebug(">>> Record.setCachedData"); |