summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/PM/DataModel/RecordField.js
Unidiff
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/DataModel/RecordField.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/DataModel/RecordField.js220
1 files changed, 220 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/RecordField.js b/frontend/beta/js/Clipperz/PM/DataModel/RecordField.js
new file mode 100644
index 0000000..2063825
--- a/dev/null
+++ b/frontend/beta/js/Clipperz/PM/DataModel/RecordField.js
@@ -0,0 +1,220 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer to http://www.clipperz.com
12
13* Javascript Crypto Library is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public
15 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version.
17
18* Javascript Crypto Library is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details.
22
23* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see
25 <http://www.gnu.org/licenses/>.
26
27*/
28
29if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
30if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
31if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; }
32
33//#############################################################################
34
35Clipperz.PM.DataModel.RecordField = function(args) {
36 args = args || {};
37
38 this._recordVersion = args.recordVersion || null;
39 this._key = args.key || Clipperz.PM.Crypto.randomKey();
40 this.setLabel(args.label || '');
41 this.setValue(args.value || '');
42 this.setType(args.type || 'TXT'); //valid types: 'TXT', 'PWD', 'URL', 'DATE', 'ADDR', 'CHECK', 'RADIO', ('NOTE' probably not), ...
43 this._hidden = args.hidden || (args.type == 'PWD') || false;
44
45 return this;
46}
47
48Clipperz.PM.DataModel.RecordField.prototype = MochiKit.Base.update(null, {
49
50 'toString': function() {
51 return "Clipperz.PM.DataModel.RecordField - " + this.label() + " (" + this.key() + ")";
52 },
53
54 //-------------------------------------------------------------------------
55
56 'recordVersion': function() {
57 return this._recordVersion;
58 },
59
60 //-------------------------------------------------------------------------
61
62 'key': function() {
63 return this._key;
64 },
65
66 //-------------------------------------------------------------------------
67
68 'label': function() {
69 return this._label;
70 },
71
72 'setLabel': function(aValue) {
73 this._label = aValue;
74 },
75
76 //-------------------------------------------------------------------------
77
78 'value': function() {
79 return this._value;
80 },
81
82 'setValue': function(aValue) {
83 this._value = aValue;
84 },
85
86 //-------------------------------------------------------------------------
87
88 'type': function() {
89 return this._type;
90 },
91
92 'setType': function(aValue) {
93 this._type = aValue;
94
95 if (aValue == 'PWD') {
96 this.setHidden(true);
97 } else {
98 this.setHidden(false);
99 }
100 },
101
102 //-------------------------------------------------------------------------
103
104 'serializeData': function() {
105 var result;
106
107//MochiKit.Logging.logDebug(">>> RecordField.serializeData - " + this);
108 result = {
109 label: this.label(),
110 value:this.value(),
111 type: this.type(),
112 hidden: this.hidden()
113 };
114//MochiKit.Logging.logDebug("<<< RecordField.serializeData");
115
116 return result;
117 },
118
119 //-------------------------------------------------------------------------
120
121 'typeShortDescription': function() {
122 // return Clipperz.PM.DataModel.RecordField.TypeDescriptions[this.type()]['shortDescription'];
123 return Clipperz.PM.Strings['recordFieldTypologies'][this.type()]['shortDescription'];
124 },
125
126 //-------------------------------------------------------------------------
127
128 'hidden': function() {
129 return this._hidden;
130 },
131
132 'setHidden': function(aValue) {
133 this._hidden = aValue;
134 },
135
136 //-------------------------------------------------------------------------
137
138 'clone': function(aRecordVersion) {
139 var result;
140
141 result = new Clipperz.PM.DataModel.RecordField({
142 recordVersion:aRecordVersion,
143 label:this.label(),
144 value:this.value(),
145 type:this.type(),
146 hidden:this.hidden()
147 });
148
149 return result;
150 },
151
152 //-------------------------------------------------------------------------
153
154 'isEmpty': function() {
155 var result;
156
157 if ((this.label() == "") && (this.value() == "") && (this.type() == 'TXT')) {
158 result = true;
159 } else {
160 result = false;
161 }
162
163 return result;
164 },
165
166 //-------------------------------------------------------------------------
167 __syntaxFix__: "syntax fix"
168
169});
170
171//#############################################################################
172/*
173Clipperz.PM.DataModel.RecordField.TypeDescriptions = {
174 'TXT': {
175 description: 'simple text field',
176 shortDescription: 'txt'
177 },
178 'PWD': {
179 description: 'simple text field, with default status set to hidden',
180 shortDescription: 'pwd'
181 },
182 'URL': {
183 description: 'simple text field in edit mode, that became an active url in view mode',
184 shortDescription: 'url'
185 },
186 'DATE': {
187 description: 'a value set with a calendar helper',
188 shortDescription: 'date'
189 },
190 'ADDR': {
191 description: 'just like the URL, but the active link points to Google Maps (or similar service) passing the address value as argument',
192 shortDescription: 'addr'
193 },
194 'CHECK': {
195 description: 'check description',
196 shortDescription: 'check'
197 },
198 'RADIO': {
199 description: 'radio description',
200 shortDescription: 'radio'
201 },
202 'SELECT': {
203 description: 'select description',
204 shortDescription: 'select'
205 }
206
207 //'NOTE': {
208 // description: 'a simple text field, but with a bigger component dimension; possibly with "smart edit components"',
209 // shortDescription: 'note'
210 //}
211};
212
213Clipperz.PM.DataModel.RecordField.InputTypeToRecordFieldType = {
214 'text': 'TXT',
215 'password': 'PWD',
216 'checkbox': 'CHECK',
217 'radio': 'RADIO',
218 'select': 'SELECT'
219};
220*/