author | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2011-10-02 23:56:18 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2011-10-02 23:56:18 (UTC) |
commit | ef68436ac04da078ffdcacd7e1f785473a303d45 (patch) (unidiff) | |
tree | c403752d66a2c4775f00affd4fa8431b29c5b68c /frontend/beta/js/Clipperz/PM/Components/Import/CSVImportComponent.js | |
parent | 597ecfbc0249d83e1b856cbd558340c01237a360 (diff) | |
download | clipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.zip clipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.tar.gz clipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.tar.bz2 |
First version of the newly restructured repository
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/Import/CSVImportComponent.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Components/Import/CSVImportComponent.js | 548 |
1 files changed, 548 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImportComponent.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImportComponent.js new file mode 100644 index 0000000..707a3d2 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImportComponent.js | |||
@@ -0,0 +1,548 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 2008-2011 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz's Javascript Crypto Library. | ||
6 | Javascript Crypto Library provides web developers with an extensive | ||
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | ||
11 | refer 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 | |||
29 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.Import.CSVImportComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | this._steps = this._steps || ['CSV_EDIT', 'CSV_COLUMNS', 'CSV_HEADER', 'CSV_TITLE', 'CSV_NOTES', 'CSV_FIELDS', 'PREVIEW', 'IMPORT']; | ||
40 | |||
41 | Clipperz.PM.Components.Import.CSVImportComponent.superclass.constructor.call(this, anElement, args); | ||
42 | |||
43 | this._step1Component = null; | ||
44 | this._step2Component = null; | ||
45 | this._step3Component = null; | ||
46 | this._step4Component = null; | ||
47 | this._step5Component = null; | ||
48 | |||
49 | this._isFirstRowHeader = false; | ||
50 | this._titleColumnIndex = -1; | ||
51 | this._notesColumnIndex = -1; | ||
52 | this._fieldSettings = {}; | ||
53 | this._skippedColumns = new Clipperz.Set(); | ||
54 | |||
55 | this.render(); | ||
56 | |||
57 | return this; | ||
58 | } | ||
59 | |||
60 | //============================================================================= | ||
61 | |||
62 | YAHOO.extendX(Clipperz.PM.Components.Import.CSVImportComponent, Clipperz.PM.Components.Import.GenericImportComponent, { | ||
63 | |||
64 | 'toString': function() { | ||
65 | return "Clipperz.PM.Components.Import.CSVImportComponent component"; | ||
66 | }, | ||
67 | |||
68 | //------------------------------------------------------------------------- | ||
69 | |||
70 | 'render': function() { | ||
71 | this.domHelper().append(this.element(), {tag:'div', cls:'csvImportWizard', children:[ | ||
72 | {tag:'h3', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Title']}, | ||
73 | {tag:'div', cls:'importSteps', id:this.getId('importSteps')}, | ||
74 | {tag:'div', cls:'importStepBlocks', children:[ | ||
75 | {tag:'div', cls:'step_0', id:this.getId('step_0'), children:[ | ||
76 | {tag:'div', children:[ | ||
77 | {tag:'div', cls:'importOptionsDescription', htmlString:Clipperz.PM.Strings['importOptions_csv_description']}, | ||
78 | {tag:'div', cls:'importOptionsParameters', children:[ | ||
79 | {tag:'div', cls:'CSVImportOptionsParameters', children:[ | ||
80 | {tag:'ul', children:[ | ||
81 | {tag:'li', children:[ | ||
82 | {tag:'label', 'for':this.getId('CSV_inputOptions_separator'), html:"separator"}, | ||
83 | {tag:'select', name:this.getId('CSV_inputOptions_separator'), id:this.getId('CSV_inputOptions_separator'), children:[ | ||
84 | {tag:'option', name:'comma', value:',', html:"comma (,)", selected:true}, | ||
85 | {tag:'option', name:'tab', value:'\t', html:"tab"} | ||
86 | ]} | ||
87 | ]}, | ||
88 | |||
89 | {tag:'li', children:[ | ||
90 | {tag:'label', 'for':this.getId('CSV_inputOptions_quote'), html:"quote"}, | ||
91 | {tag:'select', name:this.getId('CSV_inputOptions_quote'), id:this.getId('CSV_inputOptions_quote'), children:[ | ||
92 | {tag:'option', name:'doubleQuote', value:'\"', html:"double quote (\")", selected:true}, | ||
93 | {tag:'option', name:'singleQuote', value:'\'', html:"single quote (\')"} | ||
94 | ]} | ||
95 | ]}, | ||
96 | |||
97 | {tag:'li', children:[ | ||
98 | {tag:'label', 'for':this.getId('CSV_inputOptions_escape'), html:"escape"}, | ||
99 | {tag:'select', name:this.getId('CSV_inputOptions_escape'), id:this.getId('CSV_inputOptions_escape'), children:[ | ||
100 | {tag:'option', name:'doubleQuote', value:'\"', html:"double quote (\")", selected:true}, | ||
101 | {tag:'option', name:'slash', value:'\/', html:"slash (\/)"}, | ||
102 | {tag:'option', name:'backslash', value:'\\', html:"backslash (\\)"} | ||
103 | ]} | ||
104 | ]} | ||
105 | ]} | ||
106 | ]} | ||
107 | ]}, | ||
108 | this.textAreaConfig() | ||
109 | ]} | ||
110 | ]}, | ||
111 | {tag:'div', cls:'step_1', id:this.getId('step_1'), children:[]}, | ||
112 | {tag:'div', cls:'step_2', id:this.getId('step_2'), children:[]}, | ||
113 | {tag:'div', cls:'step_3', id:this.getId('step_3'), children:[]}, | ||
114 | {tag:'div', cls:'step_4', id:this.getId('step_4'), children:[]}, | ||
115 | {tag:'div', cls:'step_5', id:this.getId('step_5'), children:[]}, | ||
116 | {tag:'div', cls:'step_6', id:this.getId('step_6'), children:[ | ||
117 | {tag:'div', children:[ | ||
118 | {tag:'div', id:this.getId('previewDiv'), html:"preview"} | ||
119 | ]} | ||
120 | ]}, | ||
121 | {tag:'div', cls:'step_7', id:this.getId('step_7'), children:[ | ||
122 | {tag:'div', children:[ | ||
123 | {tag:'h4', html:"done"} | ||
124 | ]} | ||
125 | ]} | ||
126 | ]}, | ||
127 | {tag:'div', cls:'importOptionsButtons', children:[ | ||
128 | {tag:'table', children:[ | ||
129 | {tag:'tbody', children:[ | ||
130 | {tag:'tr', children:[ | ||
131 | {tag:'td', html:' '}, | ||
132 | {tag:'td', children:[ | ||
133 | {tag:'div', id:this.getId('backActionButton')} | ||
134 | ]}, | ||
135 | {tag:'td', html:' '}, | ||
136 | {tag:'td', children:[ | ||
137 | {tag:'div', id:this.getId('nextActionButton')} | ||
138 | ]}, | ||
139 | {tag:'td', html:' '} | ||
140 | ]} | ||
141 | ]} | ||
142 | ]} | ||
143 | ]} | ||
144 | ]}); | ||
145 | |||
146 | this.setBackButton(new YAHOO.ext.Button(this.getDom('backActionButton'), {text:"back", handler:this.backAction, scope:this})); | ||
147 | this.setNextButton(new YAHOO.ext.Button(this.getDom('nextActionButton'), {text:"next", handler:this.nextAction, scope:this})); | ||
148 | |||
149 | this.updateSteps(); | ||
150 | |||
151 | this.getElement('step_0').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show() | ||
152 | this.getElement('step_1').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
153 | this.getElement('step_2').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
154 | this.getElement('step_3').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
155 | this.getElement('step_4').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
156 | this.getElement('step_5').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
157 | this.getElement('step_6').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
158 | this.getElement('step_7').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
159 | |||
160 | // this.backButton().disable(); | ||
161 | }, | ||
162 | |||
163 | //------------------------------------------------------------------------- | ||
164 | |||
165 | 'nextAction': function() { | ||
166 | switch (this.currentStep()) { | ||
167 | case 0: //-> 1 | ||
168 | Clipperz.PM.Components.MessageBox.showProgressPanel( | ||
169 | MochiKit.Base.method(this, 'deferredParseValues'), | ||
170 | MochiKit.Base.method(this, 'handleParseError'), | ||
171 | this.getDom('nextActionButton') | ||
172 | ); | ||
173 | break; | ||
174 | case 1: //-> 2 | ||
175 | this.getElement('step_1').hide(); | ||
176 | this.step2Component().render(); | ||
177 | this.setCurrentStep(2); | ||
178 | this.getElement('step_2').show(); | ||
179 | break; | ||
180 | case 2: //-> 3 | ||
181 | this.getElement('step_2').hide(); | ||
182 | this.step3Component().render(); | ||
183 | this.setCurrentStep(3); | ||
184 | this.getElement('step_3').show(); | ||
185 | break; | ||
186 | case 3: //-> 4 | ||
187 | this.getElement('step_3').hide(); | ||
188 | this.step4Component().render(); | ||
189 | this.setCurrentStep(4); | ||
190 | this.getElement('step_4').show(); | ||
191 | break; | ||
192 | case 4: //-> 5 | ||
193 | this.getElement('step_4').hide(); | ||
194 | this.step5Component().render(); | ||
195 | this.setCurrentStep(5); | ||
196 | this.getElement('step_5').show(); | ||
197 | break; | ||
198 | case 5: //-> 6 | ||
199 | this.previewValues(); | ||
200 | break; | ||
201 | case 6: //-> 7 | ||
202 | this.importValues(); | ||
203 | break; | ||
204 | } | ||
205 | }, | ||
206 | |||
207 | //------------------------------------------------------------------------- | ||
208 | |||
209 | 'deferredParseValues': function() { | ||
210 | var deferredResult; | ||
211 | |||
212 | deferredResult = new MochiKit.Async.Deferred(); | ||
213 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 1 " + res.substring(0,50)); return res;}); | ||
214 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'parseImportData'); | ||
215 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 2 " + res.substring(0,50)); return res;}); | ||
216 | deferredResult.addCallback(MochiKit.Base.bind(function(res) { | ||
217 | this.startProcessing(); | ||
218 | |||
219 | return res; | ||
220 | }, this)); | ||
221 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 3 " + res.substring(0,50)); return res;}); | ||
222 | deferredResult.addCallback(MochiKit.Base.method(this, 'parseCSVValues')); | ||
223 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 4 " + res); return res;}); | ||
224 | deferredResult.addCallback(MochiKit.Base.method(this, 'setParsedValues')); | ||
225 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 5 " + res); return res;}); | ||
226 | deferredResult.addCallback(MochiKit.Base.method(this.step1Component(), 'render')); | ||
227 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 6 " + res); return res;}); | ||
228 | deferredResult.addCallback(MochiKit.Base.bind(function(res) { | ||
229 | this.processingDone(); | ||
230 | this.getElement('step_0').hide(); | ||
231 | this.getElement('step_1').show(); | ||
232 | this.backButton().enable(); | ||
233 | |||
234 | return res; | ||
235 | }, this)); | ||
236 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 7 " + res); return res;}); | ||
237 | deferredResult.callback(this.textAreaContent()); | ||
238 | |||
239 | return deferredResult; | ||
240 | }, | ||
241 | |||
242 | //------------------------------------------------------------------------- | ||
243 | |||
244 | 'deferredPreviewValues': function() { | ||
245 | var deferredResult; | ||
246 | |||
247 | //MochiKit.Logging.logDebug(">>> CSVImportComponent.deferredPreviewValues"); | ||
248 | deferredResult = new MochiKit.Async.Deferred(); | ||
249 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 1 " + res); return res;}); | ||
250 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'previewImportData'); | ||
251 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 2 " + res); return res;}); | ||
252 | deferredResult.addCallback(MochiKit.Base.bind(function(res) { | ||
253 | this.startProcessing(); | ||
254 | |||
255 | return res; | ||
256 | }, this)); | ||
257 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 3 " + res); return res;}); | ||
258 | deferredResult.addCallback(MochiKit.Base.method(this, 'processCSVParsedValues')); | ||
259 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 4 " + res); return res;}); | ||
260 | deferredResult.addCallback(MochiKit.Base.method(this, 'setProcessedValues')); | ||
261 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 5 " + res); return res;}); | ||
262 | deferredResult.addCallback(MochiKit.Base.method(this, 'previewRecordValues')); | ||
263 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 6 " + res); return res;}); | ||
264 | deferredResult.addCallback(MochiKit.Base.bind(function(res) { | ||
265 | this.processingDone(); | ||
266 | this.getElement('step_5').hide(); | ||
267 | this.getElement('step_6').show(); | ||
268 | this.backButton().enable(); | ||
269 | |||
270 | return res; | ||
271 | }, this)); | ||
272 | deferredResult.callback(this.parsedValues()); | ||
273 | //MochiKit.Logging.logDebug("<<< CSVImportComponent.deferredPreviewValues"); | ||
274 | |||
275 | return deferredResult; | ||
276 | }, | ||
277 | |||
278 | //------------------------------------------------------------------------- | ||
279 | |||
280 | 'csvProcessor': function() { | ||
281 | return new Clipperz.CSVProcessor({ | ||
282 | quoteChar: this.getDom('CSV_inputOptions_quote').value, | ||
283 | escapeChar: this.getDom('CSV_inputOptions_escape').value, | ||
284 | separatorChar:this.getDom('CSV_inputOptions_separator').value, | ||
285 | binary:true | ||
286 | }); | ||
287 | }, | ||
288 | |||
289 | //------------------------------------------------------------------------- | ||
290 | |||
291 | 'parseCSVValues': function(someData) { | ||
292 | var deferredResult; | ||
293 | var csvProcessor; | ||
294 | |||
295 | csvProcessor = this.csvProcessor(); | ||
296 | deferredResult = new MochiKit.Async.Deferred(); | ||
297 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.parseKeePassValues - 1 " + res.substring(0,50)); return res;}); | ||
298 | deferredResult.addCallback(function(res) { | ||
299 | return Clipperz.NotificationCenter.deferredNotification(this, 'updatedProgressState', {steps:(res.length)}, res); | ||
300 | }) | ||
301 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.parseKeePassValues - 2 " + res.substring(0,50)); return res;}); | ||
302 | deferredResult.addCallback(MochiKit.Base.method(csvProcessor, 'deferredParse')); | ||
303 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.parseKeePassValues - 3 " + res); return res;}); | ||
304 | deferredResult.callback(someData); | ||
305 | |||
306 | return deferredResult; | ||
307 | }, | ||
308 | |||
309 | //------------------------------------------------------------------------- | ||
310 | |||
311 | 'processCSVParsedValues': function (someValues) { | ||
312 | var deferredResult; | ||
313 | var records; | ||
314 | var titleColumnIndex; | ||
315 | var notesColumnIndex; | ||
316 | var i,c; | ||
317 | |||
318 | deferredResult = new MochiKit.Async.Deferred(); | ||
319 | records = []; | ||
320 | |||
321 | titleColumnIndex = this.titleColumnIndex(); | ||
322 | notesColumnIndex = this.notesColumnIndex(); | ||
323 | |||
324 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {steps:(someValues.length)}); | ||
325 | |||
326 | c = someValues.length; | ||
327 | if (this.isFirstRowHeader()) { | ||
328 | i = 1; | ||
329 | } else { | ||
330 | i = 0; | ||
331 | } | ||
332 | |||
333 | for( ; i<c; i++) { | ||
334 | deferredResult.addCallback(MochiKit.Async.wait, 0.2); | ||
335 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {}); | ||
336 | deferredResult.addCallback(MochiKit.Base.bind(function(someRecords, someData) { | ||
337 | var record; | ||
338 | var recordVersion; | ||
339 | var ii; | ||
340 | |||
341 | record = new Clipperz.PM.DataModel.Record({user:this.user()}); | ||
342 | record.setLabel(someData[titleColumnIndex]); | ||
343 | if (notesColumnIndex != -1) { | ||
344 | record.setNotes(someData[notesColumnIndex]); | ||
345 | } | ||
346 | recordVersion = record.currentVersion() | ||
347 | |||
348 | for (ii in someData) { | ||
349 | // if ((ii != titleColumnIndex) && (ii != notesColumnIndex) && (typeof(this.fieldSettings()[ii]) != 'undefined')) { | ||
350 | if ((ii != titleColumnIndex) && (ii != notesColumnIndex) && (this.isColumnSelected(ii))) { | ||
351 | var recordField; | ||
352 | |||
353 | recordField = new Clipperz.PM.DataModel.RecordField({ | ||
354 | recordVersion:recordVersion, | ||
355 | label: this.labelForColumn(ii), | ||
356 | value: someData[ii], | ||
357 | type: this.typeForColumn(ii) | ||
358 | }); | ||
359 | recordVersion.addField(recordField); | ||
360 | } | ||
361 | } | ||
362 | |||
363 | someRecords.push(record); | ||
364 | |||
365 | return someRecords; | ||
366 | }, this), records, someValues[i]); | ||
367 | } | ||
368 | deferredResult.addCallback(MochiKit.Async.succeed, records); | ||
369 | deferredResult.callback(); | ||
370 | |||
371 | return deferredResult; | ||
372 | }, | ||
373 | |||
374 | //------------------------------------------------------------------------- | ||
375 | |||
376 | 'step1Component': function() { | ||
377 | if (this._step1Component == null) { | ||
378 | this._step1Component = new Clipperz.PM.Components.Import.CSVImport.CSVImportColumns(this.getElement('step_1'), {mainComponent:this}); | ||
379 | } | ||
380 | |||
381 | return this._step1Component; | ||
382 | }, | ||
383 | |||
384 | 'step2Component': function() { | ||
385 | if (this._step2Component == null) { | ||
386 | this._step2Component = new Clipperz.PM.Components.Import.CSVImport.CSVImportHeader(this.getElement('step_2'), {mainComponent:this}); | ||
387 | } | ||
388 | |||
389 | return this._step2Component; | ||
390 | }, | ||
391 | |||
392 | 'step3Component': function() { | ||
393 | if (this._step3Component == null) { | ||
394 | this._step3Component = new Clipperz.PM.Components.Import.CSVImport.CSVImportTitle(this.getElement('step_3'), {mainComponent:this}); | ||
395 | } | ||
396 | |||
397 | return this._step3Component; | ||
398 | }, | ||
399 | |||
400 | 'step4Component': function() { | ||
401 | if (this._step4Component == null) { | ||
402 | this._step4Component = new Clipperz.PM.Components.Import.CSVImport.CSVImportNotes(this.getElement('step_4'), {mainComponent:this}); | ||
403 | } | ||
404 | |||
405 | return this._step4Component; | ||
406 | }, | ||
407 | |||
408 | 'step5Component': function() { | ||
409 | if (this._step5Component == null) { | ||
410 | this._step5Component = new Clipperz.PM.Components.Import.CSVImport.CSVImportFields(this.getElement('step_5'), {mainComponent:this}); | ||
411 | } | ||
412 | |||
413 | return this._step5Component; | ||
414 | }, | ||
415 | |||
416 | //------------------------------------------------------------------------- | ||
417 | |||
418 | 'isFirstRowHeader': function() { | ||
419 | return this._isFirstRowHeader; | ||
420 | }, | ||
421 | |||
422 | 'setIsFirstRowHeader': function(aValue) { | ||
423 | this._isFirstRowHeader = aValue; | ||
424 | }, | ||
425 | |||
426 | //------------------------------------------------------------------------- | ||
427 | |||
428 | 'titleColumnIndex': function() { | ||
429 | return this._titleColumnIndex; | ||
430 | }, | ||
431 | |||
432 | 'setTitleColumnIndex': function(aValue) { | ||
433 | this._titleColumnIndex = aValue; | ||
434 | }, | ||
435 | |||
436 | //------------------------------------------------------------------------- | ||
437 | |||
438 | 'notesColumnIndex': function() { | ||
439 | return this._notesColumnIndex; | ||
440 | }, | ||
441 | |||
442 | 'setNotesColumnIndex': function(aValue) { | ||
443 | this._notesColumnIndex = aValue; | ||
444 | }, | ||
445 | |||
446 | //------------------------------------------------------------------------- | ||
447 | |||
448 | 'fieldSettings': function() { | ||
449 | return this._fieldSettings; | ||
450 | }, | ||
451 | |||
452 | //------------------------------------------------------------------------- | ||
453 | |||
454 | 'skippedColumns': function() { | ||
455 | return this._skippedColumns; | ||
456 | }, | ||
457 | |||
458 | //------------------------------------------------------------------------- | ||
459 | |||
460 | 'isColumnSelected': function(aColumnIndex) { | ||
461 | return !this.skippedColumns().contains("" + aColumnIndex); | ||
462 | }, | ||
463 | |||
464 | //========================================================================= | ||
465 | |||
466 | 'labelForColumn': function(aColumnIndex) { | ||
467 | var result; | ||
468 | |||
469 | if ((typeof(this.fieldSettings()) != 'undefined') && (typeof(this.fieldSettings()[aColumnIndex]) != 'undefined')) { | ||
470 | if (this.isFirstRowHeader()) { | ||
471 | result = this.fieldSettings()[aColumnIndex]['_firstRowLabel']; | ||
472 | //MochiKit.Logging.logDebug("--- updateInputFieldValues - [" + aColumnIndex + "] _firstRowLabel: " + label); | ||
473 | } else { | ||
474 | result = this.fieldSettings()[aColumnIndex]['_emptyLabel']; | ||
475 | //MochiKit.Logging.logDebug("--- updateInputFieldValues - [" + aColumnIndex + "] _emptyLabel: " + label); | ||
476 | } | ||
477 | } else { | ||
478 | result = ""; | ||
479 | } | ||
480 | |||
481 | return result; | ||
482 | }, | ||
483 | |||
484 | //------------------------------------------------------------------------- | ||
485 | |||
486 | 'setLabelForColumn': function(aLabel, aColumnIndex) { | ||
487 | var fieldSettings; | ||
488 | |||
489 | //MochiKit.Logging.logDebug(">>> setLabelForColumn[" + aColumnIndex + "]: " + aLabel); | ||
490 | fieldSettings = this.fieldSettings(); | ||
491 | |||
492 | if (typeof(fieldSettings[aColumnIndex]) == 'undefined') { | ||
493 | fieldSettings[aColumnIndex] = {} | ||
494 | } | ||
495 | |||
496 | if (this.isFirstRowHeader()) { | ||
497 | //MochiKit.Logging.logDebug("--- setLabelForColumn -> _firstRowLabel"); | ||
498 | fieldSettings[aColumnIndex]['_firstRowLabel'] = aLabel; | ||
499 | } else { | ||
500 | if (typeof(fieldSettings[aColumnIndex]['_emptyLabel']) == 'undefined') { | ||
501 | if (aLabel == null) { | ||
502 | //MochiKit.Logging.logDebug("--- setLabelForColumn -> _emptyLabel = \"\""); | ||
503 | fieldSettings[aColumnIndex]['_emptyLabel'] = ""; | ||
504 | } else { | ||
505 | fieldSettings[aColumnIndex]['_emptyLabel'] = aLabel; | ||
506 | } | ||
507 | } else { | ||
508 | //MochiKit.Logging.logDebug("--- setLabelForColumn -> _emptyLabel = " + aLabel); | ||
509 | if (aLabel != null) { | ||
510 | fieldSettings[aColumnIndex]['_emptyLabel'] = aLabel; | ||
511 | } | ||
512 | } | ||
513 | } | ||
514 | //MochiKit.Logging.logDebug("<<< setLabelForColumn[" + aColumnIndex + "]: " + aLabel); | ||
515 | }, | ||
516 | |||
517 | //========================================================================= | ||
518 | |||
519 | 'typeForColumn': function(aColumnIndex) { | ||
520 | var result; | ||
521 | |||
522 | if ((typeof(this.fieldSettings()) != 'undefined') && (typeof(this.fieldSettings()[aColumnIndex]) != 'undefined') && (typeof(this.fieldSettings()[aColumnIndex]['type']) != 'undefined')) { | ||
523 | result = this.fieldSettings()[aColumnIndex]['type']; | ||
524 | } else { | ||
525 | result = 'UNDEFINED'; | ||
526 | } | ||
527 | |||
528 | return result; | ||
529 | }, | ||
530 | |||
531 | //------------------------------------------------------------------------- | ||
532 | |||
533 | 'setTypeForColumn': function(aType, aColumnIndex) { | ||
534 | var fieldSettings; | ||
535 | |||
536 | fieldSettings = this.fieldSettings(); | ||
537 | |||
538 | if (typeof(fieldSettings[aColumnIndex]) == 'undefined') { | ||
539 | fieldSettings[aColumnIndex] = {} | ||
540 | } | ||
541 | |||
542 | fieldSettings[aColumnIndex]['type'] = aType; | ||
543 | }, | ||
544 | |||
545 | //========================================================================= | ||
546 | __syntaxFix__: "syntax fix" | ||
547 | }); | ||
548 | |||