summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js
Unidiff
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js15
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js
index a368747..f7dbd5d 100644
--- a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js
+++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js
@@ -1,247 +1,244 @@
1/* 1/*
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz's Javascript Crypto Library. 5This file is part of Clipperz Community Edition.
6Javascript Crypto Library provides web developers with an extensive 6Clipperz Community Edition is an online password manager.
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 7For further information about its features and functionalities please
11refer to http://www.clipperz.com 8refer to http://www.clipperz.com.
12 9
13* Javascript Crypto Library is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public 11 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 12 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
17 14
18* Javascript Crypto Library is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
22 19
23* You should have received a copy of the GNU Affero General Public 20* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see 21 License along with Clipperz Community Edition. If not, see
25 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
26 23
27*/ 24*/
28 25
29if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } 26if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
30if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } 27if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
31if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } 28if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; }
32if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } 29if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; }
33if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; } 30if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; }
34 31
35//############################################################################# 32//#############################################################################
36 33
37Clipperz.PM.Components.Import.CSVImport.CSVImportFields = function(anElement, args) { 34Clipperz.PM.Components.Import.CSVImport.CSVImportFields = function(anElement, args) {
38 args = args || {}; 35 args = args || {};
39 36
40 Clipperz.PM.Components.Import.CSVImport.CSVImportFields.superclass.constructor.call(this, anElement, args); 37 Clipperz.PM.Components.Import.CSVImport.CSVImportFields.superclass.constructor.call(this, anElement, args);
41 this._mainComponent = args.mainComponent; 38 this._mainComponent = args.mainComponent;
42 39
43 return this; 40 return this;
44} 41}
45 42
46//============================================================================= 43//=============================================================================
47 44
48YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportFields, Clipperz.PM.Components.BaseComponent, { 45YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportFields, Clipperz.PM.Components.BaseComponent, {
49 46
50 'toString': function() { 47 'toString': function() {
51 return "Clipperz.PM.Components.Import.CSVImport.CSVImportFields component"; 48 return "Clipperz.PM.Components.Import.CSVImport.CSVImportFields component";
52 }, 49 },
53 50
54 //------------------------------------------------------------------------- 51 //-------------------------------------------------------------------------
55 52
56 'mainComponent': function() { 53 'mainComponent': function() {
57 return this._mainComponent; 54 return this._mainComponent;
58 }, 55 },
59 56
60 //------------------------------------------------------------------------- 57 //-------------------------------------------------------------------------
61 58
62 'render': function() { 59 'render': function() {
63 varfieldsHeaderCells; 60 varfieldsHeaderCells;
64 var titleColumnIndex; 61 var titleColumnIndex;
65 var notesColumnIndex; 62 var notesColumnIndex;
66 var i,c; 63 var i,c;
67 64
68 Clipperz.NotificationCenter.unregister(this); 65 Clipperz.NotificationCenter.unregister(this);
69 MochiKit.Signal.disconnectAllTo(this); 66 MochiKit.Signal.disconnectAllTo(this);
70 67
71 this.element().update(""); 68 this.element().update("");
72 69
73 titleColumnIndex = this.mainComponent().titleColumnIndex() 70 titleColumnIndex = this.mainComponent().titleColumnIndex()
74 notesColumnIndex = this.mainComponent().notesColumnIndex() 71 notesColumnIndex = this.mainComponent().notesColumnIndex()
75 72
76 fieldsHeaderCells = []; 73 fieldsHeaderCells = [];
77 fieldsHeaderCells.push({tag:'td', valign:'top', cls:'title', html:this.mainComponent().labelForColumn(titleColumnIndex)}); 74 fieldsHeaderCells.push({tag:'td', valign:'top', cls:'title', html:this.mainComponent().labelForColumn(titleColumnIndex)});
78 75
79 c =this.mainComponent().parsedValues()[0].length; 76 c =this.mainComponent().parsedValues()[0].length;
80 for (i=0; i<c; i++) { 77 for (i=0; i<c; i++) {
81 if ((i != titleColumnIndex) && (i != notesColumnIndex) && (this.mainComponent().isColumnSelected(i))) { 78 if ((i != titleColumnIndex) && (i != notesColumnIndex) && (this.mainComponent().isColumnSelected(i))) {
82 var trimmedLabel; 79 var trimmedLabel;
83 80
84 trimmedLabel = Clipperz.Base.trim(this.mainComponent().labelForColumn(i)); 81 trimmedLabel = Clipperz.Base.trim(this.mainComponent().labelForColumn(i));
85 fieldsHeaderCells.push({tag:'td', valign:'top', id:this.getId('fieldHeaderTD_' + i), cls:((trimmedLabel == "") ? 'missingLabelWarning' : (this.isColumnSetup(i) ? 'configuredColumn': 'unconfiguredColumn')), children:[ 82 fieldsHeaderCells.push({tag:'td', valign:'top', id:this.getId('fieldHeaderTD_' + i), cls:((trimmedLabel == "") ? 'missingLabelWarning' : (this.isColumnSetup(i) ? 'configuredColumn': 'unconfiguredColumn')), children:[
86 {tag:'span', html:((trimmedLabel == "") ? Clipperz.PM.Strings['CSV_ImportWizard_Fields_MissingLabelWarning'] : trimmedLabel)/*, cls:((trimmedLabel == "") ? 'missingLabelWarning' : '')*/}, 83 {tag:'span', html:((trimmedLabel == "") ? Clipperz.PM.Strings['CSV_ImportWizard_Fields_MissingLabelWarning'] : trimmedLabel)/*, cls:((trimmedLabel == "") ? 'missingLabelWarning' : '')*/},
87 {tag:'select', id:this.getId('select_' + i), name:i, children:[ 84 {tag:'select', id:this.getId('select_' + i), name:i, children:[
88 {tag:'option', value:'UNDEFINED', html:"select data type", cls:'disabledOption'}, 85 {tag:'option', value:'UNDEFINED', html:"select data type", cls:'disabledOption'},
89 {tag:'option', value:'TXT', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['TXT']['shortDescription']}, 86 {tag:'option', value:'TXT', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['TXT']['shortDescription']},
90 {tag:'option', value:'PWD', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['PWD']['shortDescription']}, 87 {tag:'option', value:'PWD', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['PWD']['shortDescription']},
91 {tag:'option', value:'URL', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['URL']['shortDescription']}, 88 {tag:'option', value:'URL', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['URL']['shortDescription']},
92 {tag:'option', value:'DATE', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['DATE']['shortDescription']}, 89 {tag:'option', value:'DATE', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['DATE']['shortDescription']},
93 {tag:'option', value:'ADDR', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['ADDR']['shortDescription']} 90 {tag:'option', value:'ADDR', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['ADDR']['shortDescription']}
94 ]} 91 ]}
95 ]}) 92 ]})
96 } 93 }
97 } 94 }
98 95
99 if (notesColumnIndex != -1) { 96 if (notesColumnIndex != -1) {
100 fieldsHeaderCells.push({tag:'td', valign:'top', cls:'notes', html:this.mainComponent().labelForColumn(notesColumnIndex)}); 97 fieldsHeaderCells.push({tag:'td', valign:'top', cls:'notes', html:this.mainComponent().labelForColumn(notesColumnIndex)});
101 } 98 }
102 99
103 this.domHelper().append(this.element(), {tag:'div', children:[ 100 this.domHelper().append(this.element(), {tag:'div', children:[
104 {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Fields']}, 101 {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Fields']},
105 {tag:'div', id:this.getId('dataDiv'), children:[ 102 {tag:'div', id:this.getId('dataDiv'), children:[
106 {tag:'div', children:[ 103 {tag:'div', children:[
107 ]}, 104 ]},
108 {tag:'div', cls:'csvImportPreview', children:[ 105 {tag:'div', cls:'csvImportPreview', children:[
109 {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview', cellspacing:'0', children:[ 106 {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview', cellspacing:'0', children:[
110 {tag:'thead', id:this.getId('previewData_thead'), children:[ 107 {tag:'thead', id:this.getId('previewData_thead'), children:[
111 {tag:'tr', cls:'CSV_previewData_header', children:fieldsHeaderCells} 108 {tag:'tr', cls:'CSV_previewData_header', children:fieldsHeaderCells}
112 ]}, 109 ]},
113 {tag:'tbody', id:this.getId('previewData_tbody'), children:[]} 110 {tag:'tbody', id:this.getId('previewData_tbody'), children:[]}
114 ]} 111 ]}
115 ]} 112 ]}
116 ]} 113 ]}
117 ]}); 114 ]});
118 115
119 for (i=0; i<c; i++) { 116 for (i=0; i<c; i++) {
120 if ((i != titleColumnIndex) && (i != notesColumnIndex) && (this.mainComponent().isColumnSelected(i))) { 117 if ((i != titleColumnIndex) && (i != notesColumnIndex) && (this.mainComponent().isColumnSelected(i))) {
121 Clipperz.DOM.selectOptionMatchingValue(this.getDom('select_' + i), this.mainComponent().typeForColumn(i)); 118 Clipperz.DOM.selectOptionMatchingValue(this.getDom('select_' + i), this.mainComponent().typeForColumn(i));
122 MochiKit.Signal.connect(this.getDom('select_' + i), 'onchange', this, 'renderDataRowsHandler'); 119 MochiKit.Signal.connect(this.getDom('select_' + i), 'onchange', this, 'renderDataRowsHandler');
123 } 120 }
124 } 121 }
125 122
126 this.renderDataRows(this.getElement('previewData_tbody')); 123 this.renderDataRows(this.getElement('previewData_tbody'));
127 // Clipperz.NotificationCenter.register(null, 'updatedCSVImportColumnHeader', this, 'renderDataRowsHandler'); 124 // Clipperz.NotificationCenter.register(null, 'updatedCSVImportColumnHeader', this, 'renderDataRowsHandler');
128 }, 125 },
129 126
130 //------------------------------------------------------------------------- 127 //-------------------------------------------------------------------------
131 128
132 'isColumnSetup': function(aColumnIndex) { 129 'isColumnSetup': function(aColumnIndex) {
133 return ((Clipperz.Base.trim(this.mainComponent().labelForColumn(aColumnIndex)) != "") && (this.mainComponent().typeForColumn(aColumnIndex) != 'UNDEFINED')); 130 return ((Clipperz.Base.trim(this.mainComponent().labelForColumn(aColumnIndex)) != "") && (this.mainComponent().typeForColumn(aColumnIndex) != 'UNDEFINED'));
134 }, 131 },
135 132
136 //------------------------------------------------------------------------- 133 //-------------------------------------------------------------------------
137 134
138 'renderDataRowsHandler': function(anEvent) { 135 'renderDataRowsHandler': function(anEvent) {
139 var columnIndex; 136 var columnIndex;
140 var tdElement; 137 var tdElement;
141 138
142//MochiKit.Logging.logDebug(">>> renderDataRowsHandler") 139//MochiKit.Logging.logDebug(">>> renderDataRowsHandler")
143 columnIndex = anEvent.src().name; 140 columnIndex = anEvent.src().name;
144 this.mainComponent().setTypeForColumn(anEvent.src().value, columnIndex); 141 this.mainComponent().setTypeForColumn(anEvent.src().value, columnIndex);
145 142
146 tdElement = this.getElement('fieldHeaderTD_' + columnIndex); 143 tdElement = this.getElement('fieldHeaderTD_' + columnIndex);
147 144
148 if (this.isColumnSetup(columnIndex)) { 145 if (this.isColumnSetup(columnIndex)) {
149 tdElement.removeClass('unconfiguredColumn'); 146 tdElement.removeClass('unconfiguredColumn');
150 tdElement.addClass('configuredColumn'); 147 tdElement.addClass('configuredColumn');
151 } else { 148 } else {
152 tdElement.addClass('unconfiguredColumn'); 149 tdElement.addClass('unconfiguredColumn');
153 tdElement.removeClass('configuredColumn'); 150 tdElement.removeClass('configuredColumn');
154 } 151 }
155 152
156 this.renderDataRows(this.getElement('previewData_tbody')); 153 this.renderDataRows(this.getElement('previewData_tbody'));
157 }, 154 },
158 155
159 //------------------------------------------------------------------------- 156 //-------------------------------------------------------------------------
160 157
161 'renderDataRows': function(anElement) { 158 'renderDataRows': function(anElement) {
162 var titleColumnIndex; 159 var titleColumnIndex;
163 var notesColumnIndex; 160 var notesColumnIndex;
164 var data 161 var data
165 var i,c; 162 var i,c;
166 163
167//MochiKit.Logging.logDebug("#### >> renderDataRows"); 164//MochiKit.Logging.logDebug("#### >> renderDataRows");
168 // anElement.update(""); 165 // anElement.update("");
169 MochiKit.DOM.replaceChildNodes(anElement.dom); 166 MochiKit.DOM.replaceChildNodes(anElement.dom);
170 167
171 if (this.mainComponent().isFirstRowHeader()) { 168 if (this.mainComponent().isFirstRowHeader()) {
172 data = this.mainComponent().parsedValues().slice(1); 169 data = this.mainComponent().parsedValues().slice(1);
173 } else { 170 } else {
174 data = this.mainComponent().parsedValues(); 171 data = this.mainComponent().parsedValues();
175 } 172 }
176 173
177 174
178 titleColumnIndex = this.mainComponent().titleColumnIndex(); 175 titleColumnIndex = this.mainComponent().titleColumnIndex();
179 notesColumnIndex = this.mainComponent().notesColumnIndex(); 176 notesColumnIndex = this.mainComponent().notesColumnIndex();
180 177
181 c = data.length; 178 c = data.length;
182 for (i=0; i<c; i++) { 179 for (i=0; i<c; i++) {
183 var rowData; 180 var rowData;
184 var rowConfig; 181 var rowConfig;
185 var ii, cc; 182 var ii, cc;
186 183
187 rowData = data[i]; 184 rowData = data[i];
188 185
189 rowConfig = {tag:'tr', children:[ 186 rowConfig = {tag:'tr', children:[
190 {tag:'td', valign:'top', cls:'title', html:(MochiKit.Base.isNotEmpty(rowData[titleColumnIndex]) ? rowData[titleColumnIndex].replace(/\n/g, '<br>') : '&nbsp;')} 187 {tag:'td', valign:'top', cls:'title', html:(MochiKit.Base.isNotEmpty(rowData[titleColumnIndex]) ? rowData[titleColumnIndex].replace(/\n/g, '<br>') : '&nbsp;')}
191 ]}; 188 ]};
192 189
193 cc = rowData.length; 190 cc = rowData.length;
194 for (ii=0; ii<cc; ii++) { 191 for (ii=0; ii<cc; ii++) {
195 // if ((ii != titleColumnIndex) && (ii != notesColumnIndex)) { 192 // if ((ii != titleColumnIndex) && (ii != notesColumnIndex)) {
196 if ((ii != titleColumnIndex) && (ii != notesColumnIndex) && (this.mainComponent().isColumnSelected(ii))) { 193 if ((ii != titleColumnIndex) && (ii != notesColumnIndex) && (this.mainComponent().isColumnSelected(ii))) {
197 rowConfig.children.push({ 194 rowConfig.children.push({
198 tag:'td', 195 tag:'td',
199 valign:'top', 196 valign:'top',
200 cls:(this.isColumnSetup(ii) ? 'configuredColumn' : 'unconfiguredColumn'), 197 cls:(this.isColumnSetup(ii) ? 'configuredColumn' : 'unconfiguredColumn'),
201 html:(MochiKit.Base.isNotEmpty(rowData[ii]) ? rowData[ii].replace(/\n/g, '<br>') : '&nbsp;') 198 html:(MochiKit.Base.isNotEmpty(rowData[ii]) ? rowData[ii].replace(/\n/g, '<br>') : '&nbsp;')
202 }); 199 });
203 } 200 }
204 } 201 }
205 if (notesColumnIndex != -1) { 202 if (notesColumnIndex != -1) {
206 rowConfig.children.push({tag:'td', valign:'top', cls:'notes', html:(MochiKit.Base.isNotEmpty(rowData[notesColumnIndex]) ? rowData[notesColumnIndex].replace(/\n/g, '<br>') : '&nbsp;')}); 203 rowConfig.children.push({tag:'td', valign:'top', cls:'notes', html:(MochiKit.Base.isNotEmpty(rowData[notesColumnIndex]) ? rowData[notesColumnIndex].replace(/\n/g, '<br>') : '&nbsp;')});
207 } 204 }
208 205
209 this.domHelper().append(anElement, rowConfig); 206 this.domHelper().append(anElement, rowConfig);
210 } 207 }
211 208
212 Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada')); 209 Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada'));
213 210
214 this.checkWetherToEnableNextButton(); 211 this.checkWetherToEnableNextButton();
215//MochiKit.Logging.logDebug("#### << renderDataRows"); 212//MochiKit.Logging.logDebug("#### << renderDataRows");
216 }, 213 },
217 214
218 //------------------------------------------------------------------------- 215 //-------------------------------------------------------------------------
219 216
220 'checkWetherToEnableNextButton': function() { 217 'checkWetherToEnableNextButton': function() {
221 var result; 218 var result;
222 var titleColumnIndex; 219 var titleColumnIndex;
223 var notesColumnIndex; 220 var notesColumnIndex;
224 var i,c; 221 var i,c;
225 222
226 titleColumnIndex = this.mainComponent().titleColumnIndex() 223 titleColumnIndex = this.mainComponent().titleColumnIndex()
227 notesColumnIndex = this.mainComponent().notesColumnIndex() 224 notesColumnIndex = this.mainComponent().notesColumnIndex()
228 225
229 result = true; 226 result = true;
230 c =this.mainComponent().parsedValues()[0].length; 227 c =this.mainComponent().parsedValues()[0].length;
231 for (i=0; i<c; i++) { 228 for (i=0; i<c; i++) {
232 if ((i != titleColumnIndex) && (i != notesColumnIndex) && (this.mainComponent().isColumnSelected(i))) { 229 if ((i != titleColumnIndex) && (i != notesColumnIndex) && (this.mainComponent().isColumnSelected(i))) {
233 result = result && this.isColumnSetup(i); 230 result = result && this.isColumnSetup(i);
234 } 231 }
235 } 232 }
236 233
237 if (result) { 234 if (result) {
238 this.mainComponent().nextButton().enable(); 235 this.mainComponent().nextButton().enable();
239 } else { 236 } else {
240 this.mainComponent().nextButton().disable(); 237 this.mainComponent().nextButton().disable();
241 } 238 }
242 }, 239 },
243 240
244 //------------------------------------------------------------------------- 241 //-------------------------------------------------------------------------
245 __syntaxFix__: "syntax fix" 242 __syntaxFix__: "syntax fix"
246}); 243});
247 244