summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js
Unidiff
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js
index 6344e06..ccfdeca 100644
--- a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js
+++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js
@@ -1,209 +1,207 @@
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 = {}; }
30if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; } 28if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; }
31 29
32//############################################################################# 30//#############################################################################
33 31
34Clipperz.PM.Components.Import.CSVImport.CSVImportNotes = function(anElement, args) { 32Clipperz.PM.Components.Import.CSVImport.CSVImportNotes = function(anElement, args) {
35 args = args || {}; 33 args = args || {};
36 34
37 Clipperz.PM.Components.Import.CSVImport.CSVImportNotes.superclass.constructor.call(this, anElement, args); 35 Clipperz.PM.Components.Import.CSVImport.CSVImportNotes.superclass.constructor.call(this, anElement, args);
38 this._mainComponent = args.mainComponent; 36 this._mainComponent = args.mainComponent;
39 37
40 return this; 38 return this;
41} 39}
42 40
43//============================================================================= 41//=============================================================================
44 42
45YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportNotes, Clipperz.PM.Components.BaseComponent, { 43YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportNotes, Clipperz.PM.Components.BaseComponent, {
46 44
47 'toString': function() { 45 'toString': function() {
48 return "Clipperz.PM.Components.Import.CSVImport.CSVImportNotes component"; 46 return "Clipperz.PM.Components.Import.CSVImport.CSVImportNotes component";
49 }, 47 },
50 48
51 //------------------------------------------------------------------------- 49 //-------------------------------------------------------------------------
52 50
53 'mainComponent': function() { 51 'mainComponent': function() {
54 return this._mainComponent; 52 return this._mainComponent;
55 }, 53 },
56 54
57 //------------------------------------------------------------------------- 55 //-------------------------------------------------------------------------
58 56
59 'render': function() { 57 'render': function() {
60 varnotesSelectorCheckboxCells; 58 varnotesSelectorCheckboxCells;
61 var totalNumberOfColumns; 59 var totalNumberOfColumns;
62 var titleColumnIndex; 60 var titleColumnIndex;
63 var notesColumnIndex; 61 var notesColumnIndex;
64 var i,c; 62 var i,c;
65 63
66 Clipperz.NotificationCenter.unregister(this); 64 Clipperz.NotificationCenter.unregister(this);
67 MochiKit.Signal.disconnectAllTo(this); 65 MochiKit.Signal.disconnectAllTo(this);
68 66
69 this.element().update(""); 67 this.element().update("");
70 68
71 titleColumnIndex = this.mainComponent().titleColumnIndex() 69 titleColumnIndex = this.mainComponent().titleColumnIndex()
72 notesColumnIndex = this.mainComponent().notesColumnIndex() 70 notesColumnIndex = this.mainComponent().notesColumnIndex()
73 71
74 totalNumberOfColumns = this.mainComponent().parsedValues()[0].length; 72 totalNumberOfColumns = this.mainComponent().parsedValues()[0].length;
75 73
76 notesSelectorCheckboxCells = [{tag:'th', cls:'title', html:this.mainComponent().labelForColumn(titleColumnIndex)}]; 74 notesSelectorCheckboxCells = [{tag:'th', cls:'title', html:this.mainComponent().labelForColumn(titleColumnIndex)}];
77 c =totalNumberOfColumns; 75 c =totalNumberOfColumns;
78 for (i=0; i<c; i++) { 76 for (i=0; i<c; i++) {
79 if ((i != titleColumnIndex) && (this.mainComponent().isColumnSelected(i))) { 77 if ((i != titleColumnIndex) && (this.mainComponent().isColumnSelected(i))) {
80 notesSelectorCheckboxCells.push({tag:'th', id:this.getId('th_' + i), valign:'top', children:[ 78 notesSelectorCheckboxCells.push({tag:'th', id:this.getId('th_' + i), valign:'top', children:[
81 {tag:'input', type:'radio', id:this.getId('radio_' + i), name:'CSVImportNotesColumn', value:i}, 79 {tag:'input', type:'radio', id:this.getId('radio_' + i), name:'CSVImportNotesColumn', value:i},
82 {tag:'span', cls:'clickableSpan', id:this.getId('columnLabel_' + i), html:this.mainComponent().labelForColumn(i)} 80 {tag:'span', cls:'clickableSpan', id:this.getId('columnLabel_' + i), html:this.mainComponent().labelForColumn(i)}
83 ]}) 81 ]})
84 } 82 }
85 } 83 }
86 84
87 this.domHelper().append(this.element(), {tag:'div', children:[ 85 this.domHelper().append(this.element(), {tag:'div', children:[
88 {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Notes']}, 86 {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Notes']},
89 {tag:'div', id:this.getId('dataDiv'), children:[ 87 {tag:'div', id:this.getId('dataDiv'), children:[
90 {tag:'div', cls:'importStepParameters', children:[ 88 {tag:'div', cls:'importStepParameters', children:[
91 {tag:'input', id:this.getId('doNotSetNotes_radio'), type:'radio', name:'CSVImportNotesColumn', value:-1}, 89 {tag:'input', id:this.getId('doNotSetNotes_radio'), type:'radio', name:'CSVImportNotesColumn', value:-1},
92 {tag:'span', id:this.getId('doNotSetNotes_span'), cls:'clickableSpan', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Notes_Settings_noSelectionLabel']} 90 {tag:'span', id:this.getId('doNotSetNotes_span'), cls:'clickableSpan', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Notes_Settings_noSelectionLabel']}
93 ]}, 91 ]},
94 {tag:'div', cls:'csvImportPreview', children:[ 92 {tag:'div', cls:'csvImportPreview', children:[
95 {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview', cellspacing:'0', children:[ 93 {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview', cellspacing:'0', children:[
96 {tag:'thead', id:this.getId('previewData_thead'), children:[ 94 {tag:'thead', id:this.getId('previewData_thead'), children:[
97 {tag:'tr', children:notesSelectorCheckboxCells} 95 {tag:'tr', children:notesSelectorCheckboxCells}
98 ]}, 96 ]},
99 {tag:'tbody', id:this.getId('previewData_tbody'), children:[]} 97 {tag:'tbody', id:this.getId('previewData_tbody'), children:[]}
100 ]} 98 ]}
101 ]} 99 ]}
102 ]} 100 ]}
103 ]}); 101 ]});
104 102
105 this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues()); 103 this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues());
106 104
107 if ((notesColumnIndex >= totalNumberOfColumns) || (notesColumnIndex == titleColumnIndex) || !(this.mainComponent().isColumnSelected(notesColumnIndex))) { 105 if ((notesColumnIndex >= totalNumberOfColumns) || (notesColumnIndex == titleColumnIndex) || !(this.mainComponent().isColumnSelected(notesColumnIndex))) {
108 this.mainComponent().setNotesColumnIndex(-1); 106 this.mainComponent().setNotesColumnIndex(-1);
109 notesColumnIndex = -1; 107 notesColumnIndex = -1;
110 } 108 }
111 109
112 c =totalNumberOfColumns; 110 c =totalNumberOfColumns;
113 for (i=0; i<c; i++) { 111 for (i=0; i<c; i++) {
114 if ((i != titleColumnIndex) && (this.mainComponent().isColumnSelected(i))) { 112 if ((i != titleColumnIndex) && (this.mainComponent().isColumnSelected(i))) {
115 MochiKit.Signal.connect(this.getDom('radio_' + i), 'onclick', this, 'renderDataHandler'); 113 MochiKit.Signal.connect(this.getDom('radio_' + i), 'onclick', this, 'renderDataHandler');
116 if (Clipperz_IEisBroken != true) { 114 if (Clipperz_IEisBroken != true) {
117 MochiKit.Signal.connect(this.getDom('columnLabel_' + i), 'onclick', this.getDom('radio_' + i), 'click'); 115 MochiKit.Signal.connect(this.getDom('columnLabel_' + i), 'onclick', this.getDom('radio_' + i), 'click');
118 } 116 }
119 } 117 }
120 } 118 }
121 119
122 MochiKit.Signal.connect(this.getDom('doNotSetNotes_radio'), 'onclick', this, 'renderDataHandler'); 120 MochiKit.Signal.connect(this.getDom('doNotSetNotes_radio'), 'onclick', this, 'renderDataHandler');
123 if (Clipperz_IEisBroken != true) { 121 if (Clipperz_IEisBroken != true) {
124 MochiKit.Signal.connect(this.getDom('doNotSetNotes_span'), 'onclick', this.getDom('doNotSetNotes_radio'), 'click'); 122 MochiKit.Signal.connect(this.getDom('doNotSetNotes_span'), 'onclick', this.getDom('doNotSetNotes_radio'), 'click');
125 } 123 }
126 124
127 if (notesColumnIndex == -1) { 125 if (notesColumnIndex == -1) {
128 this.getDom('doNotSetNotes_radio').click(); 126 this.getDom('doNotSetNotes_radio').click();
129 } else { 127 } else {
130 this.getDom('radio_' + notesColumnIndex).click(); 128 this.getDom('radio_' + notesColumnIndex).click();
131 } 129 }
132 }, 130 },
133 131
134 //------------------------------------------------------------------------- 132 //-------------------------------------------------------------------------
135 133
136 'renderData': function(anElement, someData) { 134 'renderData': function(anElement, someData) {
137 var data; 135 var data;
138 var config; 136 var config;
139 var titleColumnIndex; 137 var titleColumnIndex;
140 var notesColumnIndex; 138 var notesColumnIndex;
141 var i,c; 139 var i,c;
142 140
143 // anElement.update(""); 141 // anElement.update("");
144 MochiKit.DOM.replaceChildNodes(anElement.dom); 142 MochiKit.DOM.replaceChildNodes(anElement.dom);
145 143
146 titleColumnIndex = this.mainComponent().titleColumnIndex(); 144 titleColumnIndex = this.mainComponent().titleColumnIndex();
147 notesColumnIndex = this.mainComponent().notesColumnIndex(); 145 notesColumnIndex = this.mainComponent().notesColumnIndex();
148 146
149 if (this.mainComponent().isFirstRowHeader()) { 147 if (this.mainComponent().isFirstRowHeader()) {
150 data = someData.slice(1); 148 data = someData.slice(1);
151 } else { 149 } else {
152 data = someData; 150 data = someData;
153 } 151 }
154 152
155 153
156 // config = [{tag:'tr', cls:'CSV_previewData_header', children:[{tag:'td', valign:'top', html:header[titleColumnIndex], cls:'title'}]}]; 154 // config = [{tag:'tr', cls:'CSV_previewData_header', children:[{tag:'td', valign:'top', html:header[titleColumnIndex], cls:'title'}]}];
157 // c = header.length; 155 // c = header.length;
158 // for (i=0; i<c; i++) { 156 // for (i=0; i<c; i++) {
159 // if (i != titleColumnIndex) { 157 // if (i != titleColumnIndex) {
160 // config[0].children.push({tag:'td', valign:'top', html:header[i], cls:((notesColumnIndex == i) ? 'notesColumn': '')}) 158 // config[0].children.push({tag:'td', valign:'top', html:header[i], cls:((notesColumnIndex == i) ? 'notesColumn': '')})
161 // } 159 // }
162 // } 160 // }
163 161
164 config = MochiKit.Base.map(MochiKit.Base.bind(function(aTitleColumnIndex, aRowData) { 162 config = MochiKit.Base.map(MochiKit.Base.bind(function(aTitleColumnIndex, aRowData) {
165 var result; 163 var result;
166 var i,c; 164 var i,c;
167 165
168 result = {tag:'tr', children:[{tag:'td', valign:'top', cls:'title', html:(MochiKit.Base.isNotEmpty(aRowData[aTitleColumnIndex]) ? aRowData[aTitleColumnIndex].replace(/\n/g, '<br>') : '&nbsp;')}]}; 166 result = {tag:'tr', children:[{tag:'td', valign:'top', cls:'title', html:(MochiKit.Base.isNotEmpty(aRowData[aTitleColumnIndex]) ? aRowData[aTitleColumnIndex].replace(/\n/g, '<br>') : '&nbsp;')}]};
169 c = aRowData.length; 167 c = aRowData.length;
170 for (i=0; i<c; i++) { 168 for (i=0; i<c; i++) {
171 if ((i != titleColumnIndex) && (this.mainComponent().isColumnSelected(i))) { 169 if ((i != titleColumnIndex) && (this.mainComponent().isColumnSelected(i))) {
172 result.children.push({tag:'td', valign:'top', cls:((notesColumnIndex == i) ? 'notesColumn': ''), html:(MochiKit.Base.isNotEmpty(aRowData[i]) ? aRowData[i].replace(/\n/g, '<br>') : '&nbsp;')}); 170 result.children.push({tag:'td', valign:'top', cls:((notesColumnIndex == i) ? 'notesColumn': ''), html:(MochiKit.Base.isNotEmpty(aRowData[i]) ? aRowData[i].replace(/\n/g, '<br>') : '&nbsp;')});
173 } 171 }
174 } 172 }
175 173
176 return result; 174 return result;
177 }, this, titleColumnIndex), data); 175 }, this, titleColumnIndex), data);
178 176
179 MochiKit.Base.map(function(aRowConfig) {Clipperz.YUI.DomHelper.append(anElement, aRowConfig);}, config); 177 MochiKit.Base.map(function(aRowConfig) {Clipperz.YUI.DomHelper.append(anElement, aRowConfig);}, config);
180 178
181 Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada')); 179 Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada'));
182 }, 180 },
183 181
184 //------------------------------------------------------------------------- 182 //-------------------------------------------------------------------------
185 183
186 'renderDataHandler': function(anEvent) { 184 'renderDataHandler': function(anEvent) {
187 var titleColumnIndex; 185 var titleColumnIndex;
188 var i,c; 186 var i,c;
189 187
190 this.mainComponent().setNotesColumnIndex(anEvent.src().value); 188 this.mainComponent().setNotesColumnIndex(anEvent.src().value);
191 titleColumnIndex = this.mainComponent().titleColumnIndex(); 189 titleColumnIndex = this.mainComponent().titleColumnIndex();
192 190
193 c = this.mainComponent().parsedValues()[0].length; 191 c = this.mainComponent().parsedValues()[0].length;
194 for (i=0; i<c; i++) { 192 for (i=0; i<c; i++) {
195 if ((i != titleColumnIndex) && (this.mainComponent().isColumnSelected(i))) { 193 if ((i != titleColumnIndex) && (this.mainComponent().isColumnSelected(i))) {
196 this.getElement('th_' + i).removeClass('notesColumn'); 194 this.getElement('th_' + i).removeClass('notesColumn');
197 } 195 }
198 } 196 }
199 if (anEvent.src().value != -1) { 197 if (anEvent.src().value != -1) {
200 this.getElement('th_' + anEvent.src().value).addClass('notesColumn'); 198 this.getElement('th_' + anEvent.src().value).addClass('notesColumn');
201 } 199 }
202 200
203 this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues()); 201 this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues());
204 }, 202 },
205 203
206 //------------------------------------------------------------------------- 204 //-------------------------------------------------------------------------
207 __syntaxFix__: "syntax fix" 205 __syntaxFix__: "syntax fix"
208}); 206});
209 207