author | Clipperz <info@clipperz.com> | 2013-01-31 13:42:04 (UTC) |
---|---|---|
committer | Clipperz <info@clipperz.com> | 2013-01-31 13:42:04 (UTC) |
commit | 07d0357beef5d9328a2dd8d07ad7b39c87ac55e4 (patch) (unidiff) | |
tree | f7a4aed8848302db153c2a211f8e58b944eb4c5b /frontend/gamma/js/Clipperz/PM/DataModel/Record.js | |
parent | 767a3dcf48b6ac911c088af5dd7738a728eb6b99 (diff) | |
download | clipperz-07d0357beef5d9328a2dd8d07ad7b39c87ac55e4.zip clipperz-07d0357beef5d9328a2dd8d07ad7b39c87ac55e4.tar.gz clipperz-07d0357beef5d9328a2dd8d07ad7b39c87ac55e4.tar.bz2 |
Updated Copyright claims
- updated reference dates;
- removed reference to Community Edition;
- normalized logging using Clipperz.log[Warn|Error|Debug]
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/DataModel/Record.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/DataModel/Record.js | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/Record.js b/frontend/gamma/js/Clipperz/PM/DataModel/Record.js index b816f80..3fc1813 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/Record.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/Record.js | |||
@@ -1,114 +1,109 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 25 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
28 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } | 26 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } |
29 | 27 | ||
30 | 28 | ||
31 | Clipperz.PM.DataModel.Record = function(args) { | 29 | Clipperz.PM.DataModel.Record = function(args) { |
32 | //console.log(">>> new Clipperz.PM.DataModel.Record", args); | ||
33 | Clipperz.PM.DataModel.Record.superclass.constructor.apply(this, arguments); | 30 | Clipperz.PM.DataModel.Record.superclass.constructor.apply(this, arguments); |
34 | 31 | ||
35 | this._updateDate = (args.updateDate ? Clipperz.PM.Date.parse(args.updateDate) : Clipperz.Base.exception.raise('MandatoryParameter')); | 32 | this._updateDate = (args.updateDate ? Clipperz.PM.Date.parse(args.updateDate) : Clipperz.Base.exception.raise('MandatoryParameter')); |
36 | 33 | ||
37 | this._retrieveIndexDataFunction = args.retrieveIndexDataFunction|| Clipperz.Base.exception.raise('MandatoryParameter'); | 34 | this._retrieveIndexDataFunction = args.retrieveIndexDataFunction|| Clipperz.Base.exception.raise('MandatoryParameter'); |
38 | this._updateIndexDataFunction = args.updateIndexDataFunction || Clipperz.Base.exception.raise('MandatoryParameter'); | 35 | this._updateIndexDataFunction = args.updateIndexDataFunction || Clipperz.Base.exception.raise('MandatoryParameter'); |
39 | 36 | ||
40 | this._retrieveDirectLoginIndexDataFunction = args.retrieveDirectLoginIndexDataFunction|| null; | 37 | this._retrieveDirectLoginIndexDataFunction = args.retrieveDirectLoginIndexDataFunction|| null; |
41 | this._setDirectLoginIndexDataFunction = args.setDirectLoginIndexDataFunction || null; | 38 | this._setDirectLoginIndexDataFunction = args.setDirectLoginIndexDataFunction || null; |
42 | this._removeDirectLoginIndexDataFunction = args.removeDirectLoginIndexDataFunction|| null; | 39 | this._removeDirectLoginIndexDataFunction = args.removeDirectLoginIndexDataFunction|| null; |
43 | 40 | ||
44 | this._createNewDirectLoginFunction = args.createNewDirectLoginFunction || null; | 41 | this._createNewDirectLoginFunction = args.createNewDirectLoginFunction || null; |
45 | 42 | ||
46 | this._directLogins = {}; | 43 | this._directLogins = {}; |
47 | 44 | ||
48 | this._versions = {}; | 45 | this._versions = {}; |
49 | 46 | ||
50 | this._currentRecordVersion = null; | 47 | this._currentRecordVersion = null; |
51 | if (this.isBrandNew()) { | 48 | if (this.isBrandNew()) { |
52 | var newVersion; | 49 | var newVersion; |
53 | 50 | ||
54 | this.setNotes(''); | 51 | this.setNotes(''); |
55 | newVersion = new Clipperz.PM.DataModel.Record.Version({ | 52 | newVersion = new Clipperz.PM.DataModel.Record.Version({ |
56 | 'retrieveKeyFunction':MochiKit.Base.method(this, 'getVersionKey'), | 53 | 'retrieveKeyFunction':MochiKit.Base.method(this, 'getVersionKey'), |
57 | 'getVersion': MochiKit.Base.method(this, 'getVersion') | 54 | 'getVersion': MochiKit.Base.method(this, 'getVersion') |
58 | 55 | ||
59 | }); | 56 | }); |
60 | this._versions[newVersion.reference()] = newVersion; | 57 | this._versions[newVersion.reference()] = newVersion; |
61 | this._currentVersionReference = newVersion.reference(); | 58 | this._currentVersionReference = newVersion.reference(); |
62 | // this.setLabel(''); | 59 | // this.setLabel(''); |
63 | } | 60 | } |
64 | 61 | ||
65 | //console.log("<<< new Clipperz.PM.DataModel.Record", args); | ||
66 | |||
67 | return this; | 62 | return this; |
68 | } | 63 | } |
69 | 64 | ||
70 | 65 | ||
71 | Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.EncryptedRemoteObject, { | 66 | Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.EncryptedRemoteObject, { |
72 | 67 | ||
73 | 'toString': function() { | 68 | 'toString': function() { |
74 | return "Record (" + this.reference() + ")"; | 69 | return "Record (" + this.reference() + ")"; |
75 | }, | 70 | }, |
76 | 71 | ||
77 | //------------------------------------------------------------------------- | 72 | //------------------------------------------------------------------------- |
78 | 73 | ||
79 | 'reference': function () { | 74 | 'reference': function () { |
80 | return this._reference; | 75 | return this._reference; |
81 | }, | 76 | }, |
82 | 77 | ||
83 | //========================================================================= | 78 | //========================================================================= |
84 | 79 | ||
85 | 'getIndexData': function () { | 80 | 'getIndexData': function () { |
86 | return this._retrieveIndexDataFunction(this.reference()); | 81 | return this._retrieveIndexDataFunction(this.reference()); |
87 | }, | 82 | }, |
88 | 83 | ||
89 | //......................................................................... | 84 | //......................................................................... |
90 | 85 | ||
91 | 'getIndexDataForKey': function (aKey) { | 86 | 'getIndexDataForKey': function (aKey) { |
92 | return Clipperz.Async.callbacks("Record.getIndexDataForKey", [ | 87 | return Clipperz.Async.callbacks("Record.getIndexDataForKey", [ |
93 | MochiKit.Base.method(this, 'getIndexData'), | 88 | MochiKit.Base.method(this, 'getIndexData'), |
94 | MochiKit.Base.itemgetter(aKey) | 89 | MochiKit.Base.itemgetter(aKey) |
95 | ], {trace:false}); | 90 | ], {trace:false}); |
96 | }, | 91 | }, |
97 | 92 | ||
98 | //------------------------------------------------------------------------- | 93 | //------------------------------------------------------------------------- |
99 | 94 | ||
100 | 'setIndexDataForKey': function (aKey, aValue) { | 95 | 'setIndexDataForKey': function (aKey, aValue) { |
101 | // return this._updateIndexDataFunction(this.reference(), aKey, aValue); | 96 | // return this._updateIndexDataFunction(this.reference(), aKey, aValue); |
102 | 97 | ||
103 | var deferredResult; | 98 | var deferredResult; |
104 | 99 | ||
105 | deferredResult = new Clipperz.Async.Deferred("Record.setIndexDataForKey", {trace:false}); | 100 | deferredResult = new Clipperz.Async.Deferred("Record.setIndexDataForKey", {trace:false}); |
106 | deferredResult.addMethod(this, 'getIndexDataForKey', aKey); | 101 | deferredResult.addMethod(this, 'getIndexDataForKey', aKey); |
107 | deferredResult.addCallback(MochiKit.Base.bind(function (aCurrentValue) { | 102 | deferredResult.addCallback(MochiKit.Base.bind(function (aCurrentValue) { |
108 | var result; | 103 | var result; |
109 | var originalValue; | 104 | var originalValue; |
110 | 105 | ||
111 | originalValue = this.transientState().getValue('originalValues.indexData.' + aKey); | 106 | originalValue = this.transientState().getValue('originalValues.indexData.' + aKey); |
112 | if (originalValue == null) { | 107 | if (originalValue == null) { |
113 | originalValue = this.transientState().setValue('originalValues.indexData.' + aKey, aCurrentValue); | 108 | originalValue = this.transientState().setValue('originalValues.indexData.' + aKey, aCurrentValue); |
114 | } | 109 | } |
@@ -165,238 +160,232 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.Encrypt | |||
165 | MochiKit.Base.bind(function (someHeaderNotes) { | 160 | MochiKit.Base.bind(function (someHeaderNotes) { |
166 | var result; | 161 | var result; |
167 | 162 | ||
168 | if ((someHeaderNotes == null) || (typeof(someHeaderNotes) == 'undefined')) { | 163 | if ((someHeaderNotes == null) || (typeof(someHeaderNotes) == 'undefined')) { |
169 | result = this.getValue('notes'); | 164 | result = this.getValue('notes'); |
170 | } else { | 165 | } else { |
171 | result = MochiKit.Async.succeed(someHeaderNotes); | 166 | result = MochiKit.Async.succeed(someHeaderNotes); |
172 | } | 167 | } |
173 | 168 | ||
174 | return result; | 169 | return result; |
175 | }, this) | 170 | }, this) |
176 | ], {trace:false}); | 171 | ], {trace:false}); |
177 | }, | 172 | }, |
178 | 173 | ||
179 | //......................................................................... | 174 | //......................................................................... |
180 | 175 | ||
181 | 'setNotes': function (aValue) { | 176 | 'setNotes': function (aValue) { |
182 | return this.setValue('notes', aValue); | 177 | return this.setValue('notes', aValue); |
183 | }, | 178 | }, |
184 | 179 | ||
185 | //========================================================================= | 180 | //========================================================================= |
186 | 181 | ||
187 | 'updateDate': function () { | 182 | 'updateDate': function () { |
188 | return MochiKit.Async.succeed(this._updateDate); | 183 | return MochiKit.Async.succeed(this._updateDate); |
189 | }, | 184 | }, |
190 | 185 | ||
191 | //========================================================================= | 186 | //========================================================================= |
192 | 187 | ||
193 | 'favicon': function () { | 188 | 'favicon': function () { |
194 | var result; | 189 | var result; |
195 | var directLogins; | 190 | var directLogins; |
196 | 191 | ||
197 | directLogins = MochiKit.Base.values(this.directLogins()); | 192 | directLogins = MochiKit.Base.values(this.directLogins()); |
198 | if (directLogins.length > 0) { | 193 | if (directLogins.length > 0) { |
199 | result = directLogins[0].favicon(); | 194 | result = directLogins[0].favicon(); |
200 | // } else if (/* is there an URL to use for searching a favicon */){ | 195 | // } else if (/* is there an URL to use for searching a favicon */){ |
201 | } else { | 196 | } else { |
202 | result = null; //MochiKit.Async.succeed(Clipperz.PM.Strings['defaultFaviconUrl']); | 197 | result = null; //MochiKit.Async.succeed(Clipperz.PM.Strings['defaultFaviconUrl']); |
203 | } | 198 | } |
204 | 199 | ||
205 | return result; | 200 | return result; |
206 | }, | 201 | }, |
207 | 202 | ||
208 | //------------------------------------------------------------------------- | 203 | //------------------------------------------------------------------------- |
209 | 204 | ||
210 | 'searchableContent': function () { | 205 | 'searchableContent': function () { |
211 | var deferredResult; | 206 | var deferredResult; |
212 | 207 | ||
213 | //console.log(">>> searchableContent"); | ||
214 | deferredResult = new Clipperz.Async.Deferred("Record.searchableContent", {trace:false}); | 208 | deferredResult = new Clipperz.Async.Deferred("Record.searchableContent", {trace:false}); |
215 | 209 | ||
216 | deferredResult.collectResults({ | 210 | deferredResult.collectResults({ |
217 | 'recordLabel': MochiKit.Base.method(this, 'label'), | 211 | 'recordLabel': MochiKit.Base.method(this, 'label'), |
218 | 'directLoginLabels': [ | 212 | 'directLoginLabels': [ |
219 | MochiKit.Base.method(this, 'directLoginReferences'), | 213 | MochiKit.Base.method(this, 'directLoginReferences'), |
220 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.itemgetter('label')) | 214 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.itemgetter('label')) |
221 | ] | 215 | ] |
222 | }) | 216 | }) |
223 | deferredResult.addCallback(function (someValues) { | 217 | deferredResult.addCallback(function (someValues) { |
224 | return someValues['recordLabel'] + ' ' + someValues['directLoginLabels'].join(' '); | 218 | return someValues['recordLabel'] + ' ' + someValues['directLoginLabels'].join(' '); |
225 | }); | 219 | }); |
226 | deferredResult.callback(); | 220 | deferredResult.callback(); |
227 | //console.log("<<< searchableContent"); | ||
228 | 221 | ||
229 | return deferredResult; | 222 | return deferredResult; |
230 | }, | 223 | }, |
231 | 224 | ||
232 | //------------------------------------------------------------------------- | 225 | //------------------------------------------------------------------------- |
233 | 226 | ||
234 | 'isMatching': function (aRegExp) { | 227 | 'isMatching': function (aRegExp) { |
235 | return Clipperz.Async.callbacks("deferredFilterFunction", [ | 228 | return Clipperz.Async.callbacks("deferredFilterFunction", [ |
236 | MochiKit.Base.method(this, 'searchableContent'), | 229 | MochiKit.Base.method(this, 'searchableContent'), |
237 | MochiKit.Base.method(aRegExp, 'test'), | 230 | MochiKit.Base.method(aRegExp, 'test'), |
238 | function (doesItMatch) { | 231 | function (doesItMatch) { |
239 | var result; | 232 | var result; |
240 | 233 | ||
241 | if (doesItMatch) { | 234 | if (doesItMatch) { |
242 | result = MochiKit.Async.succeed('match'); | 235 | result = MochiKit.Async.succeed('match'); |
243 | } else { | 236 | } else { |
244 | result = MochiKit.Async.fail('miss'); | 237 | result = MochiKit.Async.fail('miss'); |
245 | } | 238 | } |
246 | 239 | ||
247 | return result; | 240 | return result; |
248 | } | 241 | } |
249 | ], {trace:false}); | 242 | ], {trace:false}); |
250 | }, | 243 | }, |
251 | 244 | ||
252 | //========================================================================= | 245 | //========================================================================= |
253 | 246 | ||
254 | 'directLogins': function () { | 247 | 'directLogins': function () { |
255 | return this._directLogins; | 248 | return this._directLogins; |
256 | }, | 249 | }, |
257 | 250 | ||
258 | 'addDirectLogin': function (aDirectLogin) { | 251 | 'addDirectLogin': function (aDirectLogin) { |
259 | this._directLogins[aDirectLogin.reference()] = aDirectLogin; | 252 | this._directLogins[aDirectLogin.reference()] = aDirectLogin; |
260 | }, | 253 | }, |
261 | 254 | ||
262 | 'directLoginWithReference': function (aDirectLoginReference) { | 255 | 'directLoginWithReference': function (aDirectLoginReference) { |
263 | return this._directLogins[aDirectLoginReference]; | 256 | return this._directLogins[aDirectLoginReference]; |
264 | }, | 257 | }, |
265 | 258 | ||
266 | 'createNewDirectLoginFunction': function () { | 259 | 'createNewDirectLoginFunction': function () { |
267 | return this._createNewDirectLoginFunction; | 260 | return this._createNewDirectLoginFunction; |
268 | }, | 261 | }, |
269 | 262 | ||
270 | 'saveOriginalDirectLoginStatusToTransientState': function () { | 263 | 'saveOriginalDirectLoginStatusToTransientState': function () { |
271 | if (this.transientState().getValue('directLogins') == null) { | 264 | if (this.transientState().getValue('directLogins') == null) { |
272 | // this.transientState().setValue('directLogins', this._directLogins) | 265 | // this.transientState().setValue('directLogins', this._directLogins) |
273 | //console.log("SET TRANSIENT STATE", Clipperz.Base.serializeJSON(MochiKit.Base.keys(this.transientState().getValue('directLogins')))) | ||
274 | MochiKit.Iter.forEach(MochiKit.Base.keys(this._directLogins), MochiKit.Base.bind(function(aKey) { | 266 | MochiKit.Iter.forEach(MochiKit.Base.keys(this._directLogins), MochiKit.Base.bind(function(aKey) { |
275 | this.transientState().setValue('directLogins' + '.' + aKey, this._directLogins[aKey]) | 267 | this.transientState().setValue('directLogins' + '.' + aKey, this._directLogins[aKey]) |
276 | }, this)) | 268 | }, this)) |
277 | } | 269 | } |
278 | }, | 270 | }, |
279 | 271 | ||
280 | 'createNewDirectLogin': function () { | 272 | 'createNewDirectLogin': function () { |
281 | this.saveOriginalDirectLoginStatusToTransientState(); | 273 | this.saveOriginalDirectLoginStatusToTransientState(); |
282 | 274 | ||
283 | return this.createNewDirectLoginFunction()(this); | 275 | return this.createNewDirectLoginFunction()(this); |
284 | }, | 276 | }, |
285 | 277 | ||
286 | 'removeDirectLogin': function(aDirectLogin) { | 278 | 'removeDirectLogin': function(aDirectLogin) { |
287 | this.saveOriginalDirectLoginStatusToTransientState(); | 279 | this.saveOriginalDirectLoginStatusToTransientState(); |
288 | 280 | ||
289 | return Clipperz.Async.callbacks("Record.removeDirectLogin", [ | 281 | return Clipperz.Async.callbacks("Record.removeDirectLogin", [ |
290 | MochiKit.Base.method(this, 'removeValue', 'directLogins' + '.' + aDirectLogin.reference()), | 282 | MochiKit.Base.method(this, 'removeValue', 'directLogins' + '.' + aDirectLogin.reference()), |
291 | MochiKit.Base.bind(function () { | 283 | MochiKit.Base.bind(function () { |
292 | delete this._directLogins[aDirectLogin.reference()] | 284 | delete this._directLogins[aDirectLogin.reference()] |
293 | }, this) | 285 | }, this) |
294 | ], {trace:false}); | 286 | ], {trace:false}); |
295 | 287 | ||
296 | }, | 288 | }, |
297 | 289 | ||
298 | 'directLoginReferences': function () { | 290 | 'directLoginReferences': function () { |
299 | var result; | 291 | var result; |
300 | 292 | ||
301 | result = Clipperz.Async.callbacks("Record.directLoginReferences", [ | 293 | result = Clipperz.Async.callbacks("Record.directLoginReferences", [ |
302 | MochiKit.Base.method(this, 'directLogins'), | 294 | MochiKit.Base.method(this, 'directLogins'), |
303 | MochiKit.Base.values, | 295 | MochiKit.Base.values, |
304 | function (someDirectLogins) { | 296 | function (someDirectLogins) { |
305 | var result; | 297 | var result; |
306 | var i,c; | 298 | var i,c; |
307 | 299 | ||
308 | result = []; | 300 | result = []; |
309 | c = someDirectLogins.length; | 301 | c = someDirectLogins.length; |
310 | for (i=0; i<c; i++) { | 302 | for (i=0; i<c; i++) { |
311 | result.push(Clipperz.Async.collectResults("Record.directLoginReferences - collectResults", { | 303 | result.push(Clipperz.Async.collectResults("Record.directLoginReferences - collectResults", { |
312 | '_rowObject': MochiKit.Async.succeed, | 304 | '_rowObject': MochiKit.Async.succeed, |
313 | '_reference': MochiKit.Base.methodcaller('reference'), | 305 | '_reference': MochiKit.Base.methodcaller('reference'), |
314 | 'label': MochiKit.Base.methodcaller('label'), | 306 | 'label': MochiKit.Base.methodcaller('label'), |
315 | 'favicon': MochiKit.Base.methodcaller('favicon') | 307 | 'favicon': MochiKit.Base.methodcaller('favicon') |
316 | }, {trace:false})(someDirectLogins[i])); | 308 | }, {trace:false})(someDirectLogins[i])); |
317 | }; | 309 | }; |
318 | 310 | ||
319 | return result; | 311 | return result; |
320 | }, | 312 | }, |
321 | Clipperz.Async.collectAll | 313 | Clipperz.Async.collectAll |
322 | ], {trace:false}); | 314 | ], {trace:false}); |
323 | 315 | ||
324 | return result; | 316 | return result; |
325 | }, | 317 | }, |
326 | 318 | ||
327 | //========================================================================= | 319 | //========================================================================= |
328 | 320 | ||
329 | 'unpackRemoteData': function (someData) { | 321 | 'unpackRemoteData': function (someData) { |
330 | var result; | 322 | var result; |
331 | 323 | ||
332 | //console.log("new Clipperz.PM.DataModel.Record.Version [2]"); | ||
333 | /* | 324 | /* |
334 | this._currentRecordVersion = new Clipperz.PM.DataModel.Record.Version({ | 325 | this._currentRecordVersion = new Clipperz.PM.DataModel.Record.Version({ |
335 | 'reference': someData['currentVersion']['reference'], | 326 | 'reference': someData['currentVersion']['reference'], |
336 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getCurrentRecordVersionKey'), | 327 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getCurrentRecordVersionKey'), |
337 | 'remoteData': someData['currentVersion'], | 328 | 'remoteData': someData['currentVersion'], |
338 | }); | 329 | }); |
339 | */ | 330 | */ |
340 | var versionKey; | 331 | var versionKey; |
341 | 332 | ||
342 | for (versionKey in someData['versions']) { | 333 | for (versionKey in someData['versions']) { |
343 | //console.log("### versionKey", versionKey); | ||
344 | this._versions[versionKey] = new Clipperz.PM.DataModel.Record.Version({ | 334 | this._versions[versionKey] = new Clipperz.PM.DataModel.Record.Version({ |
345 | 'reference': versionKey, | 335 | 'reference': versionKey, |
346 | 'retrieveKeyFunction':MochiKit.Base.method(this, 'getVersionKey'), | 336 | 'retrieveKeyFunction':MochiKit.Base.method(this, 'getVersionKey'), |
347 | 'remoteData': someData['versions'][versionKey], | 337 | 'remoteData': someData['versions'][versionKey], |
348 | 'getVersion': MochiKit.Base.method(this, 'getVersion') | 338 | 'getVersion': MochiKit.Base.method(this, 'getVersion') |
349 | }) | 339 | }) |
350 | } | 340 | } |
351 | 341 | ||
352 | // this._currentVersionReference = someData['currentVersion']['reference']; | 342 | // this._currentVersionReference = someData['currentVersion']['reference']; |
353 | this._currentVersionReference = someData['currentVersion']; | 343 | this._currentVersionReference = someData['currentVersion']; |
354 | //console.log("=== currentVersionReference", this._currentVersionReference, someData); | ||
355 | 344 | ||
356 | result = Clipperz.PM.DataModel.Record.superclass.unpackRemoteData.apply(this, arguments); | 345 | result = Clipperz.PM.DataModel.Record.superclass.unpackRemoteData.apply(this, arguments); |
357 | 346 | ||
358 | return result; | 347 | return result; |
359 | }, | 348 | }, |
360 | 349 | ||
361 | //------------------------------------------------------------------------- | 350 | //------------------------------------------------------------------------- |
362 | 351 | ||
363 | 'unpackData': function (someData) { | 352 | 'unpackData': function (someData) { |
364 | var result; | 353 | var result; |
365 | 354 | ||
366 | result = Clipperz.PM.DataModel.Record.superclass.unpackData.apply(this, arguments); | 355 | result = Clipperz.PM.DataModel.Record.superclass.unpackData.apply(this, arguments); |
367 | 356 | ||
368 | if (MochiKit.Base.isUndefinedOrNull(result['notes'])) { | 357 | if (MochiKit.Base.isUndefinedOrNull(result['notes'])) { |
369 | result['notes'] = '' | 358 | result['notes'] = '' |
370 | } | 359 | } |
371 | 360 | ||
372 | return result; | 361 | return result; |
373 | }, | 362 | }, |
374 | 363 | ||
375 | //------------------------------------------------------------------------- | 364 | //------------------------------------------------------------------------- |
376 | 365 | ||
377 | 'prepareRemoteDataWithKey': function (aKey) { | 366 | 'prepareRemoteDataWithKey': function (aKey) { |
378 | var deferredResult; | 367 | var deferredResult; |
379 | varnewVersionKey; | 368 | varnewVersionKey; |
380 | var result; | 369 | var result; |
381 | 370 | ||
382 | newVersionKey = Clipperz.PM.Crypto.randomKey(); | 371 | newVersionKey = Clipperz.PM.Crypto.randomKey(); |
383 | result = {}; | 372 | result = {}; |
384 | 373 | ||
385 | deferredResult = new Clipperz.Async.Deferred("Record.prepareRemoteDataWithKey", {trace:false}); | 374 | deferredResult = new Clipperz.Async.Deferred("Record.prepareRemoteDataWithKey", {trace:false}); |
386 | deferredResult.addCallbackList([ | 375 | deferredResult.addCallbackList([ |
387 | Clipperz.Async.collectResults("Record.prepareRemoteDataWithKey - collect results", { | 376 | Clipperz.Async.collectResults("Record.prepareRemoteDataWithKey - collect results", { |
388 | 'isBrandNew': MochiKit.Base.method(this, 'isBrandNew'), | 377 | 'isBrandNew': MochiKit.Base.method(this, 'isBrandNew'), |
389 | 'versionHasPendingChanges':[ | 378 | 'versionHasPendingChanges':[ |
390 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), | 379 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), |
391 | // MochiKit.Base.methodcaller('hasPendingChanges') | 380 | // MochiKit.Base.methodcaller('hasPendingChanges') |
392 | MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'hasPendingChanges') | 381 | MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'hasPendingChanges') |
393 | ] | 382 | ] |
394 | }), | 383 | }), |
395 | Clipperz.Async.or, | 384 | Clipperz.Async.or, |
396 | 385 | ||
397 | Clipperz.Async.deferredIf("Current Version has pending changes", [ | 386 | Clipperz.Async.deferredIf("Current Version has pending changes", [ |
398 | MochiKit.Base.method(this, 'createNewRecordVersion'), | 387 | MochiKit.Base.method(this, 'createNewRecordVersion'), |
399 | MochiKit.Base.methodcaller('prepareRemoteDataWithKey', newVersionKey), | 388 | MochiKit.Base.methodcaller('prepareRemoteDataWithKey', newVersionKey), |
400 | MochiKit.Base.partial(Clipperz.Async.setItem, result, 'currentRecordVersion'), | 389 | MochiKit.Base.partial(Clipperz.Async.setItem, result, 'currentRecordVersion'), |
401 | MochiKit.Base.method(this, 'setCurrentRecordVersionKey', newVersionKey) | 390 | MochiKit.Base.method(this, 'setCurrentRecordVersionKey', newVersionKey) |
402 | ], []), | 391 | ], []), |
@@ -491,219 +480,208 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.Encrypt | |||
491 | MochiKit.Base.method(this.transientState(), 'setValue', transientStateKey) | 480 | MochiKit.Base.method(this.transientState(), 'setValue', transientStateKey) |
492 | ],[ | 481 | ],[ |
493 | MochiKit.Async.fail | 482 | MochiKit.Async.fail |
494 | ]) | 483 | ]) |
495 | ], {trace:false}); | 484 | ], {trace:false}); |
496 | } | 485 | } |
497 | 486 | ||
498 | return deferredResult; | 487 | return deferredResult; |
499 | }, | 488 | }, |
500 | 489 | ||
501 | //------------------------------------------------------------------------- | 490 | //------------------------------------------------------------------------- |
502 | 491 | ||
503 | 'versions': function () { | 492 | 'versions': function () { |
504 | return this._versions; | 493 | return this._versions; |
505 | }, | 494 | }, |
506 | 495 | ||
507 | 'getVersions': function () { | 496 | 'getVersions': function () { |
508 | return Clipperz.Async.callbacks("Record.versions", [ | 497 | return Clipperz.Async.callbacks("Record.versions", [ |
509 | MochiKit.Base.method(this, 'getValue', 'fakeKey, just to trigger unpackRemoteData'), | 498 | MochiKit.Base.method(this, 'getValue', 'fakeKey, just to trigger unpackRemoteData'), |
510 | MochiKit.Base.bind(function () { return this._versions; }, this) | 499 | MochiKit.Base.bind(function () { return this._versions; }, this) |
511 | ], {trace:false}); | 500 | ], {trace:false}); |
512 | }, | 501 | }, |
513 | 502 | ||
514 | //------------------------------------------------------------------------- | 503 | //------------------------------------------------------------------------- |
515 | 504 | ||
516 | 'getCurrentRecordVersion': function () { | 505 | 'getCurrentRecordVersion': function () { |
517 | return Clipperz.Async.callbacks("Record.getCurrentRecordVersion", [ | 506 | return Clipperz.Async.callbacks("Record.getCurrentRecordVersion", [ |
518 | // MochiKit.Base.method(this, 'getValue', 'fakeKey, just to trigger unpackRemoteData'), | 507 | // MochiKit.Base.method(this, 'getValue', 'fakeKey, just to trigger unpackRemoteData'), |
519 | // MochiKit.Base.bind(function () { return this._currentRecordVersion; }, this) | 508 | // MochiKit.Base.bind(function () { return this._currentRecordVersion; }, this) |
520 | 509 | ||
521 | MochiKit.Base.method(this, 'versions'), | 510 | MochiKit.Base.method(this, 'versions'), |
522 | MochiKit.Base.itemgetter(this.currentVersionReference()), | 511 | MochiKit.Base.itemgetter(this.currentVersionReference()), |
523 | Clipperz.Async.deferredIf("The current version is available", [ | 512 | Clipperz.Async.deferredIf("The current version is available", [ |
524 | MochiKit.Async.succeed | 513 | MochiKit.Async.succeed |
525 | ], [ | 514 | ], [ |
526 | MochiKit.Base.method(this, 'getVersions'), | 515 | MochiKit.Base.method(this, 'getVersions'), |
527 | MochiKit.Base.bind(function (someVersions) { return someVersions[this.currentVersionReference()]}, this) | 516 | MochiKit.Base.bind(function (someVersions) { return someVersions[this.currentVersionReference()]}, this) |
528 | ]) | 517 | ]) |
529 | ], {trace:false}); | 518 | ], {trace:false}); |
530 | }, | 519 | }, |
531 | 520 | ||
532 | 'setCurrentRecordVersion': function (aRecordVersion) { | 521 | 'setCurrentRecordVersion': function (aRecordVersion) { |
533 | this._currentVersionReference = aRecordVersion.reference(); | 522 | this._currentVersionReference = aRecordVersion.reference(); |
534 | }, | 523 | }, |
535 | 524 | ||
536 | //......................................................................... | 525 | //......................................................................... |
537 | 526 | ||
538 | 'currentVersionReference': function () { | 527 | 'currentVersionReference': function () { |
539 | //console.log("currentVersionReference"); | ||
540 | return this._currentVersionReference; | 528 | return this._currentVersionReference; |
541 | }, | 529 | }, |
542 | 530 | ||
543 | //------------------------------------------------------------------------- | 531 | //------------------------------------------------------------------------- |
544 | 532 | ||
545 | 'createNewRecordVersion': function () { | 533 | 'createNewRecordVersion': function () { |
546 | var deferredResult; | 534 | var deferredResult; |
547 | 535 | ||
548 | if (this.isBrandNew()) { | 536 | if (this.isBrandNew()) { |
549 | deferredResult = this.getCurrentRecordVersion(); | 537 | deferredResult = this.getCurrentRecordVersion(); |
550 | } else { | 538 | } else { |
551 | var newVersion; | 539 | var newVersion; |
552 | 540 | ||
553 | newVersion = new Clipperz.PM.DataModel.Record.Version({ | 541 | newVersion = new Clipperz.PM.DataModel.Record.Version({ |
554 | // 'reference': versionKey, | 542 | // 'reference': versionKey, |
555 | 'retrieveKeyFunction':MochiKit.Base.method(this, 'getVersionKey'), | 543 | 'retrieveKeyFunction':MochiKit.Base.method(this, 'getVersionKey'), |
556 | // 'remoteData': {}, | 544 | // 'remoteData': {}, |
557 | 'getVersion': MochiKit.Base.method(this, 'getVersion') | 545 | 'getVersion': MochiKit.Base.method(this, 'getVersion') |
558 | }) | 546 | }) |
559 | this._versions[newVersion.reference()] = newVersion; | 547 | this._versions[newVersion.reference()] = newVersion; |
560 | 548 | ||
561 | deferredResult = Clipperz.Async.callbacks("Record.createNewRecordVersion", [ | 549 | deferredResult = Clipperz.Async.callbacks("Record.createNewRecordVersion", [ |
562 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), | 550 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), |
563 | // MochiKit.Base.methodcaller('values'), | 551 | // MochiKit.Base.methodcaller('values'), |
564 | MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'values'), | 552 | MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'values'), |
565 | MochiKit.Base.method(newVersion, 'setValues'), | 553 | MochiKit.Base.method(newVersion, 'setValues'), |
566 | 554 | ||
567 | Clipperz.Async.collectResults("Record.createNewRecordVersion [collect results]", { | 555 | Clipperz.Async.collectResults("Record.createNewRecordVersion [collect results]", { |
568 | 'reference':MochiKit.Base.method(this, 'currentVersionReference'), | 556 | 'reference':MochiKit.Base.method(this, 'currentVersionReference'), |
569 | 'key': MochiKit.Base.method(this, 'getCurrentRecordVersionKey') | 557 | 'key': MochiKit.Base.method(this, 'getCurrentRecordVersionKey') |
570 | }, {trace:false}), | 558 | }, {trace:false}), |
571 | MochiKit.Base.method(newVersion, 'setPreviousVersionReferenceAndKey'), | 559 | MochiKit.Base.method(newVersion, 'setPreviousVersionReferenceAndKey'), |
572 | 560 | ||
573 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), | 561 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), |
574 | // MochiKit.Base.method(this, 'revertChanges'), | 562 | // MochiKit.Base.method(this, 'revertChanges'), |
575 | MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'revertChanges'), | 563 | MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'revertChanges'), |
576 | 564 | ||
577 | MochiKit.Base.method(this, 'setCurrentRecordVersion', newVersion), | 565 | MochiKit.Base.method(this, 'setCurrentRecordVersion', newVersion), |
578 | MochiKit.Base.partial(MochiKit.Async.succeed, newVersion) | 566 | MochiKit.Base.partial(MochiKit.Async.succeed, newVersion) |
579 | ], {trace:false}); | 567 | ], {trace:false}); |
580 | } | 568 | } |
581 | 569 | ||
582 | return deferredResult; | 570 | return deferredResult; |
583 | }, | 571 | }, |
584 | 572 | ||
585 | //------------------------------------------------------------------------- | 573 | //------------------------------------------------------------------------- |
586 | 574 | ||
587 | 'getCurrentRecordVersionKey': function () { | 575 | 'getCurrentRecordVersionKey': function () { |
588 | //console.log("getCurrentRecordVersionKey"); | ||
589 | return Clipperz.Async.callbacks("Record.getCurrentRecordVersionKey", [ | 576 | return Clipperz.Async.callbacks("Record.getCurrentRecordVersionKey", [ |
590 | MochiKit.Base.method(this, 'getValue', 'currentVersionKey'), | 577 | MochiKit.Base.method(this, 'getValue', 'currentVersionKey'), |
591 | Clipperz.Async.deferredIf("currentVersionKey is NOT null", [ | 578 | Clipperz.Async.deferredIf("currentVersionKey is NOT null", [ |
592 | MochiKit.Async.succeed | 579 | MochiKit.Async.succeed |
593 | ], [ | 580 | ], [ |
594 | MochiKit.Base.method(this, 'getKey') | 581 | MochiKit.Base.method(this, 'getKey') |
595 | ]) | 582 | ]) |
596 | ], {trace:false}); | 583 | ], {trace:false}); |
597 | }, | 584 | }, |
598 | 585 | ||
599 | 'setCurrentRecordVersionKey': function (aValue) { | 586 | 'setCurrentRecordVersionKey': function (aValue) { |
600 | //TODO: triple check this method! | 587 | //TODO: triple check this method! |
601 | return Clipperz.Async.callbacks("Record.setCurrentRecordVersionKey", [ | 588 | return Clipperz.Async.callbacks("Record.setCurrentRecordVersionKey", [ |
602 | MochiKit.Base.method(this, 'setValue', 'currentVersionKey', aValue) | 589 | MochiKit.Base.method(this, 'setValue', 'currentVersionKey', aValue) |
603 | ], {trace:false}); | 590 | ], {trace:false}); |
604 | }, | 591 | }, |
605 | 592 | ||
606 | //------------------------------------------------------------------------- | 593 | //------------------------------------------------------------------------- |
607 | 594 | ||
608 | 'invokeCurrentRecordVersionMethod': function (aMethodName, someValues) { | 595 | 'invokeCurrentRecordVersionMethod': function (aMethodName, someValues) { |
609 | //console.log(">>> invokeCurrentRecordVersionMethod", aMethodName); | ||
610 | return Clipperz.Async.callbacks("Record.invokeCurrentRecordVersionMethod", [ | 596 | return Clipperz.Async.callbacks("Record.invokeCurrentRecordVersionMethod", [ |
611 | MochiKit.Base.method(this, 'getCurrentRecordVersion'), | 597 | MochiKit.Base.method(this, 'getCurrentRecordVersion'), |
612 | //function (aValue) { console.log("=== getCurrentRecordVersion", aValue); return aValue}, | ||
613 | MochiKit.Base.methodcaller(aMethodName, someValues) | 598 | MochiKit.Base.methodcaller(aMethodName, someValues) |
614 | ], {trace:false}); | 599 | ], {trace:false}); |
615 | }, | 600 | }, |
616 | 601 | ||
617 | 602 | ||
618 | 'lazilyinvokeCurrentRecordVersionMethod': function (aMethodName, someValues, defaultResult) { | 603 | 'lazilyinvokeCurrentRecordVersionMethod': function (aMethodName, someValues, defaultResult) { |
619 | return Clipperz.Async.callbacks("Record.lazilyinvokeCurrentRecordVersionMethod", [ | 604 | return Clipperz.Async.callbacks("Record.lazilyinvokeCurrentRecordVersionMethod", [ |
620 | MochiKit.Base.method(this, 'currentVersionReference'), | 605 | MochiKit.Base.method(this, 'currentVersionReference'), |
621 | //function (aValue) { console.log("LAZY -> versions", aValue); return aValue; }, | ||
622 | Clipperz.Async.deferredIf("versions has been loaded", [ | 606 | Clipperz.Async.deferredIf("versions has been loaded", [ |
623 | //function (aValue) { console.log("LAZY -> then"); return aValue; }, | ||
624 | MochiKit.Base.method(this, 'getCurrentRecordVersion'), | 607 | MochiKit.Base.method(this, 'getCurrentRecordVersion'), |
625 | MochiKit.Base.methodcaller(aMethodName, someValues), | 608 | MochiKit.Base.methodcaller(aMethodName, someValues), |
626 | //function (aValue) { console.log("LAZY <- then"); return aValue; } | ||
627 | ], [ | 609 | ], [ |
628 | //function (aValue) { console.log("LAZY -> else"); return aValue; }, | ||
629 | MochiKit.Base.partial(MochiKit.Async.succeed, defaultResult), | 610 | MochiKit.Base.partial(MochiKit.Async.succeed, defaultResult), |
630 | //function (aValue) { console.log("LAZY <- else"); return aValue; } | ||
631 | ]) | 611 | ]) |
632 | ], {trace:false}); | 612 | ], {trace:false}); |
633 | }, | 613 | }, |
634 | 614 | ||
635 | //========================================================================= | 615 | //========================================================================= |
636 | 616 | ||
637 | 'hasPendingChanges': function () { | 617 | 'hasPendingChanges': function () { |
638 | var deferredResult; | 618 | var deferredResult; |
639 | 619 | ||
640 | if (this.hasInitiatedObjectDataStore()) { | 620 | if (this.hasInitiatedObjectDataStore()) { |
641 | deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.hasPendingChanges", {trace:false}); | 621 | deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.hasPendingChanges", {trace:false}); |
642 | deferredResult.collectResults({ | 622 | deferredResult.collectResults({ |
643 | 'super': MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.hasPendingChanges, this), | 623 | 'super': MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.hasPendingChanges, this), |
644 | 'currentVersion': [ | 624 | 'currentVersion': [ |
645 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), | 625 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), |
646 | // MochiKit.Base.methodcaller('hasPendingChanges') | 626 | // MochiKit.Base.methodcaller('hasPendingChanges') |
647 | MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'hasPendingChanges') | 627 | MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'hasPendingChanges') |
648 | ], | 628 | ], |
649 | 'directLogins': [ | 629 | 'directLogins': [ |
650 | MochiKit.Base.method(this, 'directLogins'), | 630 | MochiKit.Base.method(this, 'directLogins'), |
651 | //function (aValue) { console.log("Record.directLogins", aValue); return aValue; }, | ||
652 | MochiKit.Base.values, | 631 | MochiKit.Base.values, |
653 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasPendingChanges')), | 632 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasPendingChanges')), |
654 | Clipperz.Async.collectAll, | 633 | Clipperz.Async.collectAll, |
655 | Clipperz.Async.or | 634 | Clipperz.Async.or |
656 | // function(someValues) { | 635 | // function(someValues) { |
657 | // return MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); | 636 | // return MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); |
658 | // } | 637 | // } |
659 | ] | 638 | ] |
660 | }); | 639 | }); |
661 | //deferredResult.addCallback(function (aValue) { console.log("Record.hasPendingResults", aValue); return aValue; }); | ||
662 | deferredResult.addCallback(MochiKit.Base.values); | 640 | deferredResult.addCallback(MochiKit.Base.values); |
663 | deferredResult.addCallback(MochiKit.Base.bind(function(someValues) { | 641 | deferredResult.addCallback(MochiKit.Base.bind(function(someValues) { |
664 | var result; | 642 | var result; |
665 | result = MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); | 643 | result = MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); |
666 | 644 | ||
667 | if ((result == false) && (this.isBrandNew() == false)) { | 645 | if ((result == false) && (this.isBrandNew() == false)) { |
668 | result = MochiKit.Iter.some(MochiKit.Base.values(this.transientState().getValue('hasPendingChanges.indexData')), MochiKit.Base.operator.identity); | 646 | result = MochiKit.Iter.some(MochiKit.Base.values(this.transientState().getValue('hasPendingChanges.indexData')), MochiKit.Base.operator.identity); |
669 | } | 647 | } |
670 | 648 | ||
671 | return result; | 649 | return result; |
672 | }, this)); | 650 | }, this)); |
673 | 651 | ||
674 | deferredResult.callback(); | 652 | deferredResult.callback(); |
675 | } else { | 653 | } else { |
676 | deferredResult = Clipperz.Async.callbacks("Recrod.hasPendingChanges [hasInitiatedObjectDataStore == false]", [ | 654 | deferredResult = Clipperz.Async.callbacks("Recrod.hasPendingChanges [hasInitiatedObjectDataStore == false]", [ |
677 | MochiKit.Base.method(this, 'directLogins'), | 655 | MochiKit.Base.method(this, 'directLogins'), |
678 | MochiKit.Base.values, | 656 | MochiKit.Base.values, |
679 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasPendingChanges')), | 657 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasPendingChanges')), |
680 | Clipperz.Async.collectAll, | 658 | Clipperz.Async.collectAll, |
681 | Clipperz.Async.or | 659 | Clipperz.Async.or |
682 | // function(someValues) { | 660 | // function(someValues) { |
683 | // return MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); | 661 | // return MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); |
684 | // } | 662 | // } |
685 | ], {trace:false}) | 663 | ], {trace:false}) |
686 | } | 664 | } |
687 | 665 | ||
688 | return deferredResult; | 666 | return deferredResult; |
689 | }, | 667 | }, |
690 | 668 | ||
691 | //------------------------------------------------------------------------- | 669 | //------------------------------------------------------------------------- |
692 | 670 | ||
693 | 'hasPendingChangesWhenBrandNew': function () { | 671 | 'hasPendingChangesWhenBrandNew': function () { |
694 | var deferredResult; | 672 | var deferredResult; |
695 | 673 | ||
696 | deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.hasPendingChangesWhenBrandNew", {trace:false}); | 674 | deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.hasPendingChangesWhenBrandNew", {trace:false}); |
697 | deferredResult.collectResults({ | 675 | deferredResult.collectResults({ |
698 | 'label': [ | 676 | 'label': [ |
699 | MochiKit.Base.method(this, 'label'), | 677 | MochiKit.Base.method(this, 'label'), |
700 | MochiKit.Base.partial(MochiKit.Base.operator.ne, '') | 678 | MochiKit.Base.partial(MochiKit.Base.operator.ne, '') |
701 | ], | 679 | ], |
702 | 'notes': [ | 680 | 'notes': [ |
703 | MochiKit.Base.method(this, 'notes'), | 681 | MochiKit.Base.method(this, 'notes'), |
704 | MochiKit.Base.partial(MochiKit.Base.operator.ne, '') | 682 | MochiKit.Base.partial(MochiKit.Base.operator.ne, '') |
705 | ] | 683 | ] |
706 | }); | 684 | }); |
707 | // deferredResult.addCallback(MochiKit.Base.values); | 685 | // deferredResult.addCallback(MochiKit.Base.values); |
708 | // deferredResult.addCallback(function(someValues) { | 686 | // deferredResult.addCallback(function(someValues) { |
709 | // return MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); | 687 | // return MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); |
@@ -731,137 +709,135 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.Encrypt | |||
731 | 709 | ||
732 | return deferredResult; | 710 | return deferredResult; |
733 | }, | 711 | }, |
734 | 712 | ||
735 | //========================================================================= | 713 | //========================================================================= |
736 | 714 | ||
737 | 'revertChanges': function () { | 715 | 'revertChanges': function () { |
738 | var deferredResult; | 716 | var deferredResult; |
739 | 717 | ||
740 | if (this.isBrandNew() == false) { | 718 | if (this.isBrandNew() == false) { |
741 | deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.revertChanges", {trace:false}); | 719 | deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.revertChanges", {trace:false}); |
742 | deferredResult.addMethod(this, 'hasPendingChanges'); | 720 | deferredResult.addMethod(this, 'hasPendingChanges'); |
743 | deferredResult.addIf([ | 721 | deferredResult.addIf([ |
744 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), | 722 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), |
745 | // MochiKit.Base.methodcaller('revertChanges'), | 723 | // MochiKit.Base.methodcaller('revertChanges'), |
746 | MochiKit.Base.method(this,'invokeCurrentRecordVersionMethod', 'revertChanges'), | 724 | MochiKit.Base.method(this,'invokeCurrentRecordVersionMethod', 'revertChanges'), |
747 | 725 | ||
748 | MochiKit.Base.method(this, 'directLogins'), | 726 | MochiKit.Base.method(this, 'directLogins'), |
749 | MochiKit.Base.values, | 727 | MochiKit.Base.values, |
750 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('revertChanges')), | 728 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('revertChanges')), |
751 | 729 | ||
752 | MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.revertChanges, this) | 730 | MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.revertChanges, this) |
753 | ], [ | 731 | ], [ |
754 | MochiKit.Async.succeed | 732 | MochiKit.Async.succeed |
755 | ]); | 733 | ]); |
756 | deferredResult.callback(); | 734 | deferredResult.callback(); |
757 | } else { | 735 | } else { |
758 | // this.deleteAllCleanTextData(); | 736 | // this.deleteAllCleanTextData(); |
759 | deferredResult = MochiKit.Async.succeed(); | 737 | deferredResult = MochiKit.Async.succeed(); |
760 | } | 738 | } |
761 | 739 | ||
762 | return deferredResult; | 740 | return deferredResult; |
763 | }, | 741 | }, |
764 | 742 | ||
765 | //------------------------------------------------------------------------- | 743 | //------------------------------------------------------------------------- |
766 | 744 | ||
767 | 'resetTransientState': function (isCommitting) { | 745 | 'resetTransientState': function (isCommitting) { |
768 | // if ((isCommitting == false) && (this.transientState().getValue('directLogins') != null)) { | 746 | // if ((isCommitting == false) && (this.transientState().getValue('directLogins') != null)) { |
769 | // this._directLogins = this.transientState().getValue('directLogins'); | 747 | // this._directLogins = this.transientState().getValue('directLogins'); |
770 | // } | 748 | // } |
771 | 749 | ||
772 | return Clipperz.Async.callbacks("Record.resetTransientState", [ | 750 | return Clipperz.Async.callbacks("Record.resetTransientState", [ |
773 | //- MochiKit.Base.method(this, 'getCurrentRecordVersion'), | 751 | //- MochiKit.Base.method(this, 'getCurrentRecordVersion'), |
774 | //- MochiKit.Base.methodcaller('resetTransientState'), | 752 | //- MochiKit.Base.methodcaller('resetTransientState'), |
775 | // MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'resetTransientState'), | 753 | // MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'resetTransientState'), |
776 | MochiKit.Base.method(this, 'lazilyinvokeCurrentRecordVersionMethod', 'resetTransientState'), | 754 | MochiKit.Base.method(this, 'lazilyinvokeCurrentRecordVersionMethod', 'resetTransientState'), |
777 | 755 | ||
778 | MochiKit.Base.method(this, 'directLogins'), | 756 | MochiKit.Base.method(this, 'directLogins'), |
779 | //function (aValue) { console.log("resetTransientState - directLogins", aValue); return aValue; }, | ||
780 | MochiKit.Base.values, | 757 | MochiKit.Base.values, |
781 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('resetTransientState')), | 758 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('resetTransientState')), |
782 | 759 | ||
783 | MochiKit.Base.bind(function () { | 760 | MochiKit.Base.bind(function () { |
784 | if ((isCommitting == false) && (this.transientState().getValue('directLogins') != null)) { | 761 | if ((isCommitting == false) && (this.transientState().getValue('directLogins') != null)) { |
785 | this._directLogins = this.transientState().getValue('directLogins'); | 762 | this._directLogins = this.transientState().getValue('directLogins'); |
786 | } | 763 | } |
787 | }, this), | 764 | }, this), |
788 | 765 | ||
789 | MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.resetTransientState, this, isCommitting) | 766 | MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.resetTransientState, this, isCommitting) |
790 | ], {trace:false}) | 767 | ], {trace:false}) |
791 | }, | 768 | }, |
792 | 769 | ||
793 | //------------------------------------------------------------------------- | 770 | //------------------------------------------------------------------------- |
794 | 771 | ||
795 | 'commitTransientState': function () { | 772 | 'commitTransientState': function () { |
796 | var deferredResult; | 773 | var deferredResult; |
797 | 774 | ||
798 | deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.commitTransientState", {trace:false}); | 775 | deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.commitTransientState", {trace:false}); |
799 | deferredResult.addMethod(this, 'hasPendingChanges'); | 776 | deferredResult.addMethod(this, 'hasPendingChanges'); |
800 | deferredResult.addIf([ | 777 | deferredResult.addIf([ |
801 | MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.commitTransientState, this), | 778 | MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.commitTransientState, this), |
802 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), | 779 | // MochiKit.Base.method(this, 'getCurrentRecordVersion'), |
803 | // MochiKit.Base.methodcaller('commitTransientState'), | 780 | // MochiKit.Base.methodcaller('commitTransientState'), |
804 | MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'commitTransientState'), | 781 | MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'commitTransientState'), |
805 | MochiKit.Base.method(this, 'directLogins'), | 782 | MochiKit.Base.method(this, 'directLogins'), |
806 | MochiKit.Base.values, | 783 | MochiKit.Base.values, |
807 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('commitTransientState')) | 784 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('commitTransientState')) |
808 | ], [ | 785 | ], [ |
809 | MochiKit.Async.succeed | 786 | MochiKit.Async.succeed |
810 | ]); | 787 | ]); |
811 | deferredResult.callback(); | 788 | deferredResult.callback(); |
812 | 789 | ||
813 | return deferredResult; | 790 | return deferredResult; |
814 | }, | 791 | }, |
815 | 792 | ||
816 | //========================================================================= | 793 | //========================================================================= |
817 | 794 | ||
818 | 'retrieveDirectLoginIndexDataFunction': function () { | 795 | 'retrieveDirectLoginIndexDataFunction': function () { |
819 | //console.log("Record.retrieveDirectLoginIndexDataFunction", this._retrieveDirectLoginIndexDataFunction); | ||
820 | return this._retrieveDirectLoginIndexDataFunction; | 796 | return this._retrieveDirectLoginIndexDataFunction; |
821 | }, | 797 | }, |
822 | 798 | ||
823 | 'setDirectLoginIndexDataFunction': function () { | 799 | 'setDirectLoginIndexDataFunction': function () { |
824 | return this._setDirectLoginIndexDataFunction; | 800 | return this._setDirectLoginIndexDataFunction; |
825 | }, | 801 | }, |
826 | 802 | ||
827 | 'removeDirectLoginIndexDataFunction': function () { | 803 | 'removeDirectLoginIndexDataFunction': function () { |
828 | return this._removeDirectLoginIndexDataFunction; | 804 | return this._removeDirectLoginIndexDataFunction; |
829 | }, | 805 | }, |
830 | 806 | ||
831 | //========================================================================= | 807 | //========================================================================= |
832 | 808 | ||
833 | 'deleteAllCleanTextData': function () { | 809 | 'deleteAllCleanTextData': function () { |
834 | // return Clipperz.PM.DataModel.Record.superclass.deleteAllCleanTextData.apply(this, arguments); | 810 | // return Clipperz.PM.DataModel.Record.superclass.deleteAllCleanTextData.apply(this, arguments); |
835 | 811 | ||
836 | return Clipperz.Async.callbacks("Record.deleteAllCleanTextData", [ | 812 | return Clipperz.Async.callbacks("Record.deleteAllCleanTextData", [ |
837 | MochiKit.Base.method(this, 'versions'), | 813 | MochiKit.Base.method(this, 'versions'), |
838 | MochiKit.Base.values, | 814 | MochiKit.Base.values, |
839 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('deleteAllCleanTextData')), | 815 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('deleteAllCleanTextData')), |
840 | 816 | ||
841 | MochiKit.Base.method(this, 'directLogins'), | 817 | MochiKit.Base.method(this, 'directLogins'), |
842 | MochiKit.Base.values, | 818 | MochiKit.Base.values, |
843 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('deleteAllCleanTextData')), | 819 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('deleteAllCleanTextData')), |
844 | 820 | ||
845 | MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.deleteAllCleanTextData, this) | 821 | MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.deleteAllCleanTextData, this) |
846 | ], {trace:false}); | 822 | ], {trace:false}); |
847 | }, | 823 | }, |
848 | 824 | ||
849 | 'hasAnyCleanTextData': function () { | 825 | 'hasAnyCleanTextData': function () { |
850 | // return Clipperz.PM.DataModel.Record.superclass.hasAnyCleanTextData.apply(this, arguments); | 826 | // return Clipperz.PM.DataModel.Record.superclass.hasAnyCleanTextData.apply(this, arguments); |
851 | 827 | ||
852 | return Clipperz.Async.callbacks("Record.hasAnyCleanTextData", [ | 828 | return Clipperz.Async.callbacks("Record.hasAnyCleanTextData", [ |
853 | Clipperz.Async.collectResults("Record.hasAnyCleanTextData [collect results]", { | 829 | Clipperz.Async.collectResults("Record.hasAnyCleanTextData [collect results]", { |
854 | 'versions':[ | 830 | 'versions':[ |
855 | MochiKit.Base.method(this, 'versions'), | 831 | MochiKit.Base.method(this, 'versions'), |
856 | MochiKit.Base.values, | 832 | MochiKit.Base.values, |
857 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasAnyCleanTextData')), | 833 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasAnyCleanTextData')), |
858 | Clipperz.Async.collectAll | 834 | Clipperz.Async.collectAll |
859 | ], | 835 | ], |
860 | 'directLogins': [ | 836 | 'directLogins': [ |
861 | MochiKit.Base.method(this, 'directLogins'), | 837 | MochiKit.Base.method(this, 'directLogins'), |
862 | MochiKit.Base.values, | 838 | MochiKit.Base.values, |
863 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasAnyCleanTextData')), | 839 | MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasAnyCleanTextData')), |
864 | Clipperz.Async.collectAll | 840 | Clipperz.Async.collectAll |
865 | ], | 841 | ], |
866 | 'super': [ | 842 | 'super': [ |
867 | MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.hasAnyCleanTextData, this) | 843 | MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.hasAnyCleanTextData, this) |