Diffstat (limited to 'frontend/delta/js/Clipperz/PM/DataModel/DirectLoginBinding.js') (more/less context) (show whitespace changes)
-rw-r--r-- | frontend/delta/js/Clipperz/PM/DataModel/DirectLoginBinding.js | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/frontend/delta/js/Clipperz/PM/DataModel/DirectLoginBinding.js b/frontend/delta/js/Clipperz/PM/DataModel/DirectLoginBinding.js new file mode 100644 index 0000000..a8ebb97 --- a/dev/null +++ b/frontend/delta/js/Clipperz/PM/DataModel/DirectLoginBinding.js | |||
@@ -0,0 +1,120 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 2008-2013 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz, the online password manager. | ||
6 | For further information about its features and functionalities please | ||
7 | refer to http://www.clipperz.com. | ||
8 | |||
9 | * Clipperz is free software: you can redistribute it and/or modify it | ||
10 | under the terms of the GNU Affero General Public License as published | ||
11 | by the Free Software Foundation, either version 3 of the License, or | ||
12 | (at your option) any later version. | ||
13 | |||
14 | * Clipperz is distributed in the hope that it will be useful, but | ||
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
17 | See the GNU Affero General Public License for more details. | ||
18 | |||
19 | * You should have received a copy of the GNU Affero General Public | ||
20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. | ||
21 | |||
22 | */ | ||
23 | |||
24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
25 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
26 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } | ||
27 | |||
28 | |||
29 | //############################################################################# | ||
30 | |||
31 | Clipperz.PM.DataModel.DirectLoginBinding = function(aDirectLogin, args) { | ||
32 | args = args || {}; | ||
33 | |||
34 | this._directLogin = aDirectLogin|| Clipperz.Base.exception.raise('MandatoryParameter'); | ||
35 | |||
36 | this._key = args.key|| Clipperz.Base.exception.raise('MandatoryParameter'); | ||
37 | this._fieldKey = args.field || /* this.directLogin().fieldWithName(args.fieldName).reference() || */null; | ||
38 | |||
39 | return this; | ||
40 | } | ||
41 | |||
42 | Clipperz.PM.DataModel.DirectLoginBinding.prototype = MochiKit.Base.update(null, { | ||
43 | |||
44 | 'toString': function() { | ||
45 | return "DirectLoginBinding (" + this.key() + ", " + this.fieldKey() + ")"; | ||
46 | }, | ||
47 | |||
48 | //------------------------------------------------------------------------- | ||
49 | |||
50 | 'directLogin': function () { | ||
51 | return this._directLogin; | ||
52 | }, | ||
53 | |||
54 | //------------------------------------------------------------------------- | ||
55 | |||
56 | 'key': function() { | ||
57 | return this._key; | ||
58 | }, | ||
59 | |||
60 | //------------------------------------------------------------------------- | ||
61 | |||
62 | 'fieldKey': function() { | ||
63 | return this._fieldKey; | ||
64 | }, | ||
65 | |||
66 | 'setFieldKey': function(aValue) { | ||
67 | this._fieldKey = aValue; | ||
68 | |||
69 | return this.directLogin().setValue('bindingData' + '.' + this.key(), aValue); | ||
70 | }, | ||
71 | |||
72 | //'fieldName': function() { | ||
73 | // return this._fieldName; | ||
74 | //}, | ||
75 | |||
76 | //------------------------------------------------------------------------- | ||
77 | |||
78 | 'field': function() { | ||
79 | var deferredResult; | ||
80 | |||
81 | if (this.fieldKey() != null) { | ||
82 | deferredResult = Clipperz.Async.callbacks("DirectLoginBinding.field [1]", [ | ||
83 | MochiKit.Base.method(this.directLogin().record(), 'fields'), | ||
84 | MochiKit.Base.itemgetter(this.fieldKey()) | ||
85 | ], {trace:false}); | ||
86 | // } else if (this.fieldName() != null) { | ||
87 | // WTF = TODO; | ||
88 | // result = this.directLogin().record().fieldWithName(this.fieldName()); | ||
89 | // | ||
90 | // this.setFieldKey(result.key()); | ||
91 | } else { | ||
92 | deferredResult = MochiKit.Async.succeed(null); | ||
93 | } | ||
94 | |||
95 | return deferredResult; | ||
96 | }, | ||
97 | |||
98 | 'setField': function (aField) { | ||
99 | this.setFieldKey(aField.reference()); | ||
100 | }, | ||
101 | |||
102 | //------------------------------------------------------------------------- | ||
103 | /* | ||
104 | 'fieldValue': function () { | ||
105 | return Clipperz.Async.callbacks("DirectLoginBinding.fieldValue", [ | ||
106 | MochiKit.Base.method('field'), | ||
107 | MochiKit.Base.methodcaller('value') | ||
108 | ], {trace:false}); | ||
109 | }, | ||
110 | */ | ||
111 | //------------------------------------------------------------------------- | ||
112 | |||
113 | 'serializedData': function() { | ||
114 | return this.fieldKey(); | ||
115 | }, | ||
116 | |||
117 | //------------------------------------------------------------------------- | ||
118 | __syntaxFix__: "syntax fix" | ||
119 | }); | ||
120 | |||