summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/PM/Components/Import/CSVImportComponent.js
Unidiff
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.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImportComponent.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImportComponent.js
index c1dd1a9..bd305c3 100644
--- a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImportComponent.js
+++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImportComponent.js
@@ -1,214 +1,212 @@
1/* 1/*
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2013 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz, the online password manager.
6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 6For further information about its features and functionalities please
8refer to http://www.clipperz.com. 7refer 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
26if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } 24if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
27if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } 25if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
28if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } 26if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; }
29if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } 27if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; }
30 28
31//############################################################################# 29//#############################################################################
32 30
33Clipperz.PM.Components.Import.CSVImportComponent = function(anElement, args) { 31Clipperz.PM.Components.Import.CSVImportComponent = function(anElement, args) {
34 args = args || {}; 32 args = args || {};
35 33
36 this._steps = this._steps || ['CSV_EDIT', 'CSV_COLUMNS', 'CSV_HEADER', 'CSV_TITLE', 'CSV_NOTES', 'CSV_FIELDS', 'PREVIEW', 'IMPORT']; 34 this._steps = this._steps || ['CSV_EDIT', 'CSV_COLUMNS', 'CSV_HEADER', 'CSV_TITLE', 'CSV_NOTES', 'CSV_FIELDS', 'PREVIEW', 'IMPORT'];
37 35
38 Clipperz.PM.Components.Import.CSVImportComponent.superclass.constructor.call(this, anElement, args); 36 Clipperz.PM.Components.Import.CSVImportComponent.superclass.constructor.call(this, anElement, args);
39 37
40 this._step1Component = null; 38 this._step1Component = null;
41 this._step2Component = null; 39 this._step2Component = null;
42 this._step3Component = null; 40 this._step3Component = null;
43 this._step4Component = null; 41 this._step4Component = null;
44 this._step5Component = null; 42 this._step5Component = null;
45 43
46 this._isFirstRowHeader = false; 44 this._isFirstRowHeader = false;
47 this._titleColumnIndex = -1; 45 this._titleColumnIndex = -1;
48 this._notesColumnIndex = -1; 46 this._notesColumnIndex = -1;
49 this._fieldSettings = {}; 47 this._fieldSettings = {};
50 this._skippedColumns = new Clipperz.Set(); 48 this._skippedColumns = new Clipperz.Set();
51 49
52 this.render(); 50 this.render();
53 51
54 return this; 52 return this;
55} 53}
56 54
57//============================================================================= 55//=============================================================================
58 56
59YAHOO.extendX(Clipperz.PM.Components.Import.CSVImportComponent, Clipperz.PM.Components.Import.GenericImportComponent, { 57YAHOO.extendX(Clipperz.PM.Components.Import.CSVImportComponent, Clipperz.PM.Components.Import.GenericImportComponent, {
60 58
61 'toString': function() { 59 'toString': function() {
62 return "Clipperz.PM.Components.Import.CSVImportComponent component"; 60 return "Clipperz.PM.Components.Import.CSVImportComponent component";
63 }, 61 },
64 62
65 //------------------------------------------------------------------------- 63 //-------------------------------------------------------------------------
66 64
67 'render': function() { 65 'render': function() {
68 this.domHelper().append(this.element(), {tag:'div', cls:'csvImportWizard', children:[ 66 this.domHelper().append(this.element(), {tag:'div', cls:'csvImportWizard', children:[
69 {tag:'h3', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Title']}, 67 {tag:'h3', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Title']},
70 {tag:'div', cls:'importSteps', id:this.getId('importSteps')}, 68 {tag:'div', cls:'importSteps', id:this.getId('importSteps')},
71 {tag:'div', cls:'importStepBlocks', children:[ 69 {tag:'div', cls:'importStepBlocks', children:[
72 {tag:'div', cls:'step_0', id:this.getId('step_0'), children:[ 70 {tag:'div', cls:'step_0', id:this.getId('step_0'), children:[
73 {tag:'div', children:[ 71 {tag:'div', children:[
74 {tag:'div', cls:'importOptionsDescription', htmlString:Clipperz.PM.Strings['importOptions_csv_description']}, 72 {tag:'div', cls:'importOptionsDescription', htmlString:Clipperz.PM.Strings['importOptions_csv_description']},
75 {tag:'div', cls:'importOptionsParameters', children:[ 73 {tag:'div', cls:'importOptionsParameters', children:[
76 {tag:'div', cls:'CSVImportOptionsParameters', children:[ 74 {tag:'div', cls:'CSVImportOptionsParameters', children:[
77 {tag:'ul', children:[ 75 {tag:'ul', children:[
78 {tag:'li', children:[ 76 {tag:'li', children:[
79 {tag:'label', 'for':this.getId('CSV_inputOptions_separator'), html:"separator"}, 77 {tag:'label', 'for':this.getId('CSV_inputOptions_separator'), html:"separator"},
80 {tag:'select', name:this.getId('CSV_inputOptions_separator'), id:this.getId('CSV_inputOptions_separator'), children:[ 78 {tag:'select', name:this.getId('CSV_inputOptions_separator'), id:this.getId('CSV_inputOptions_separator'), children:[
81 {tag:'option', name:'comma', value:',', html:"comma (,)", selected:true}, 79 {tag:'option', name:'comma', value:',', html:"comma (,)", selected:true},
82 {tag:'option', name:'tab', value:'\t', html:"tab"} 80 {tag:'option', name:'tab', value:'\t', html:"tab"}
83 ]} 81 ]}
84 ]}, 82 ]},
85 83
86 {tag:'li', children:[ 84 {tag:'li', children:[
87 {tag:'label', 'for':this.getId('CSV_inputOptions_quote'), html:"quote"}, 85 {tag:'label', 'for':this.getId('CSV_inputOptions_quote'), html:"quote"},
88 {tag:'select', name:this.getId('CSV_inputOptions_quote'), id:this.getId('CSV_inputOptions_quote'), children:[ 86 {tag:'select', name:this.getId('CSV_inputOptions_quote'), id:this.getId('CSV_inputOptions_quote'), children:[
89 {tag:'option', name:'doubleQuote', value:'\"', html:"double quote (\")", selected:true}, 87 {tag:'option', name:'doubleQuote', value:'\"', html:"double quote (\")", selected:true},
90 {tag:'option', name:'singleQuote', value:'\'', html:"single quote (\')"} 88 {tag:'option', name:'singleQuote', value:'\'', html:"single quote (\')"}
91 ]} 89 ]}
92 ]}, 90 ]},
93 91
94 {tag:'li', children:[ 92 {tag:'li', children:[
95 {tag:'label', 'for':this.getId('CSV_inputOptions_escape'), html:"escape"}, 93 {tag:'label', 'for':this.getId('CSV_inputOptions_escape'), html:"escape"},
96 {tag:'select', name:this.getId('CSV_inputOptions_escape'), id:this.getId('CSV_inputOptions_escape'), children:[ 94 {tag:'select', name:this.getId('CSV_inputOptions_escape'), id:this.getId('CSV_inputOptions_escape'), children:[
97 {tag:'option', name:'doubleQuote', value:'\"', html:"double quote (\")", selected:true}, 95 {tag:'option', name:'doubleQuote', value:'\"', html:"double quote (\")", selected:true},
98 {tag:'option', name:'slash', value:'\/', html:"slash (\/)"}, 96 {tag:'option', name:'slash', value:'\/', html:"slash (\/)"},
99 {tag:'option', name:'backslash', value:'\\', html:"backslash (\\)"} 97 {tag:'option', name:'backslash', value:'\\', html:"backslash (\\)"}
100 ]} 98 ]}
101 ]} 99 ]}
102 ]} 100 ]}
103 ]} 101 ]}
104 ]}, 102 ]},
105 this.textAreaConfig() 103 this.textAreaConfig()
106 ]} 104 ]}
107 ]}, 105 ]},
108 {tag:'div', cls:'step_1', id:this.getId('step_1'), children:[]}, 106 {tag:'div', cls:'step_1', id:this.getId('step_1'), children:[]},
109 {tag:'div', cls:'step_2', id:this.getId('step_2'), children:[]}, 107 {tag:'div', cls:'step_2', id:this.getId('step_2'), children:[]},
110 {tag:'div', cls:'step_3', id:this.getId('step_3'), children:[]}, 108 {tag:'div', cls:'step_3', id:this.getId('step_3'), children:[]},
111 {tag:'div', cls:'step_4', id:this.getId('step_4'), children:[]}, 109 {tag:'div', cls:'step_4', id:this.getId('step_4'), children:[]},
112 {tag:'div', cls:'step_5', id:this.getId('step_5'), children:[]}, 110 {tag:'div', cls:'step_5', id:this.getId('step_5'), children:[]},
113 {tag:'div', cls:'step_6', id:this.getId('step_6'), children:[ 111 {tag:'div', cls:'step_6', id:this.getId('step_6'), children:[
114 {tag:'div', children:[ 112 {tag:'div', children:[
115 {tag:'div', id:this.getId('previewDiv'), html:"preview"} 113 {tag:'div', id:this.getId('previewDiv'), html:"preview"}
116 ]} 114 ]}
117 ]}, 115 ]},
118 {tag:'div', cls:'step_7', id:this.getId('step_7'), children:[ 116 {tag:'div', cls:'step_7', id:this.getId('step_7'), children:[
119 {tag:'div', children:[ 117 {tag:'div', children:[
120 {tag:'h4', html:"done"} 118 {tag:'h4', html:"done"}
121 ]} 119 ]}
122 ]} 120 ]}
123 ]}, 121 ]},
124 {tag:'div', cls:'importOptionsButtons', children:[ 122 {tag:'div', cls:'importOptionsButtons', children:[
125 {tag:'table', children:[ 123 {tag:'table', children:[
126 {tag:'tbody', children:[ 124 {tag:'tbody', children:[
127 {tag:'tr', children:[ 125 {tag:'tr', children:[
128 {tag:'td', html:'&nbsp;'}, 126 {tag:'td', html:'&nbsp;'},
129 {tag:'td', children:[ 127 {tag:'td', children:[
130 {tag:'div', id:this.getId('backActionButton')} 128 {tag:'div', id:this.getId('backActionButton')}
131 ]}, 129 ]},
132 {tag:'td', html:'&nbsp;'}, 130 {tag:'td', html:'&nbsp;'},
133 {tag:'td', children:[ 131 {tag:'td', children:[
134 {tag:'div', id:this.getId('nextActionButton')} 132 {tag:'div', id:this.getId('nextActionButton')}
135 ]}, 133 ]},
136 {tag:'td', html:'&nbsp;'} 134 {tag:'td', html:'&nbsp;'}
137 ]} 135 ]}
138 ]} 136 ]}
139 ]} 137 ]}
140 ]} 138 ]}
141 ]}); 139 ]});
142 140
143 this.setBackButton(new YAHOO.ext.Button(this.getDom('backActionButton'), {text:"back", handler:this.backAction, scope:this})); 141 this.setBackButton(new YAHOO.ext.Button(this.getDom('backActionButton'), {text:"back", handler:this.backAction, scope:this}));
144 this.setNextButton(new YAHOO.ext.Button(this.getDom('nextActionButton'), {text:"next", handler:this.nextAction, scope:this})); 142 this.setNextButton(new YAHOO.ext.Button(this.getDom('nextActionButton'), {text:"next", handler:this.nextAction, scope:this}));
145 143
146 this.updateSteps(); 144 this.updateSteps();
147 145
148 this.getElement('step_0').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show() 146 this.getElement('step_0').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show()
149 this.getElement('step_1').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); 147 this.getElement('step_1').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
150 this.getElement('step_2').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); 148 this.getElement('step_2').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
151 this.getElement('step_3').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); 149 this.getElement('step_3').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
152 this.getElement('step_4').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); 150 this.getElement('step_4').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
153 this.getElement('step_5').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); 151 this.getElement('step_5').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
154 this.getElement('step_6').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); 152 this.getElement('step_6').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
155 this.getElement('step_7').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); 153 this.getElement('step_7').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
156 154
157 // this.backButton().disable(); 155 // this.backButton().disable();
158 }, 156 },
159 157
160 //------------------------------------------------------------------------- 158 //-------------------------------------------------------------------------
161 159
162 'nextAction': function() { 160 'nextAction': function() {
163 switch (this.currentStep()) { 161 switch (this.currentStep()) {
164 case 0: //-> 1 162 case 0: //-> 1
165 Clipperz.PM.Components.MessageBox.showProgressPanel( 163 Clipperz.PM.Components.MessageBox.showProgressPanel(
166 MochiKit.Base.method(this, 'deferredParseValues'), 164 MochiKit.Base.method(this, 'deferredParseValues'),
167 MochiKit.Base.method(this, 'handleParseError'), 165 MochiKit.Base.method(this, 'handleParseError'),
168 this.getDom('nextActionButton') 166 this.getDom('nextActionButton')
169 ); 167 );
170 break; 168 break;
171 case 1: //-> 2 169 case 1: //-> 2
172 this.getElement('step_1').hide(); 170 this.getElement('step_1').hide();
173 this.step2Component().render(); 171 this.step2Component().render();
174 this.setCurrentStep(2); 172 this.setCurrentStep(2);
175 this.getElement('step_2').show(); 173 this.getElement('step_2').show();
176 break; 174 break;
177 case 2: //-> 3 175 case 2: //-> 3
178 this.getElement('step_2').hide(); 176 this.getElement('step_2').hide();
179 this.step3Component().render(); 177 this.step3Component().render();
180 this.setCurrentStep(3); 178 this.setCurrentStep(3);
181 this.getElement('step_3').show(); 179 this.getElement('step_3').show();
182 break; 180 break;
183 case 3: //-> 4 181 case 3: //-> 4
184 this.getElement('step_3').hide(); 182 this.getElement('step_3').hide();
185 this.step4Component().render(); 183 this.step4Component().render();
186 this.setCurrentStep(4); 184 this.setCurrentStep(4);
187 this.getElement('step_4').show(); 185 this.getElement('step_4').show();
188 break; 186 break;
189 case 4: //-> 5 187 case 4: //-> 5
190 this.getElement('step_4').hide(); 188 this.getElement('step_4').hide();
191 this.step5Component().render(); 189 this.step5Component().render();
192 this.setCurrentStep(5); 190 this.setCurrentStep(5);
193 this.getElement('step_5').show(); 191 this.getElement('step_5').show();
194 break; 192 break;
195 case 5: //-> 6 193 case 5: //-> 6
196 this.previewValues(); 194 this.previewValues();
197 break; 195 break;
198 case 6: //-> 7 196 case 6: //-> 7
199 this.importValues(); 197 this.importValues();
200 break; 198 break;
201 } 199 }
202 }, 200 },
203 201
204 //------------------------------------------------------------------------- 202 //-------------------------------------------------------------------------
205 203
206 'deferredParseValues': function() { 204 'deferredParseValues': function() {
207 var deferredResult; 205 var deferredResult;
208 206
209 deferredResult = new MochiKit.Async.Deferred(); 207 deferredResult = new MochiKit.Async.Deferred();
210//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 1 " + res.substring(0,50)); return res;}); 208//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 1 " + res.substring(0,50)); return res;});
211 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'parseImportData'); 209 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'parseImportData');
212//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 2 " + res.substring(0,50)); return res;}); 210//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 2 " + res.substring(0,50)); return res;});
213 deferredResult.addCallback(MochiKit.Base.bind(function(res) { 211 deferredResult.addCallback(MochiKit.Base.bind(function(res) {
214 this.startProcessing(); 212 this.startProcessing();