Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/Import/CSVImport') (more/less context) (ignore whitespace changes)
5 files changed, 1062 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportColumns.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportColumns.js new file mode 100644 index 0000000..18b36da --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportColumns.js | |||
@@ -0,0 +1,174 @@ | |||
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 | if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; } | ||
34 | |||
35 | //############################################################################# | ||
36 | |||
37 | Clipperz.PM.Components.Import.CSVImport.CSVImportColumns = function(anElement, args) { | ||
38 | args = args || {}; | ||
39 | |||
40 | Clipperz.PM.Components.Import.CSVImport.CSVImportColumns.superclass.constructor.call(this, anElement, args); | ||
41 | this._mainComponent = args.mainComponent; | ||
42 | |||
43 | return this; | ||
44 | } | ||
45 | |||
46 | //============================================================================= | ||
47 | |||
48 | YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportColumns, Clipperz.PM.Components.BaseComponent, { | ||
49 | |||
50 | 'toString': function() { | ||
51 | return "Clipperz.PM.Components.Import.CSVImport.CSVImportColumns component"; | ||
52 | }, | ||
53 | |||
54 | //------------------------------------------------------------------------- | ||
55 | |||
56 | 'mainComponent': function() { | ||
57 | return this._mainComponent; | ||
58 | }, | ||
59 | |||
60 | //------------------------------------------------------------------------- | ||
61 | |||
62 | 'render': function() { | ||
63 | var i,c; | ||
64 | var columnSelectorCheckboxCells; | ||
65 | var checkboxes; | ||
66 | var data; | ||
67 | |||
68 | //MochiKit.Logging.logDebug(">>> CSVImportColumns.render"); | ||
69 | Clipperz.NotificationCenter.unregister(this); | ||
70 | MochiKit.Signal.disconnectAllTo(this); | ||
71 | |||
72 | this.element().update(""); | ||
73 | |||
74 | data = this.mainComponent().parsedValues(); | ||
75 | columnSelectorCheckboxCells = []; | ||
76 | |||
77 | c =data[0].length; | ||
78 | for (i=0; i<c; i++) { | ||
79 | columnSelectorCheckboxCells.push({tag:'th', valign:'top', cls:(this.mainComponent().isColumnSelected(i) ? 'selectedColumn': 'skippedColumn'), children:[ | ||
80 | {tag:'input', type:'checkbox', id:this.getId('columnCheckbox_' + i), value:i} | ||
81 | ]}) | ||
82 | } | ||
83 | |||
84 | this.domHelper().append(this.element(), {tag:'div', children:[ | ||
85 | {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Columns']}, | ||
86 | {tag:'div', id:this.getId('dataDiv'), cls:'csvImportPreview', children:[ | ||
87 | {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview columns', cellspacing:'0', children:[ | ||
88 | {tag:'thead', id:this.getId('previewData_thead'), children:[ | ||
89 | {tag:'tr', children:columnSelectorCheckboxCells} | ||
90 | ]}, | ||
91 | {tag:'tbody', id:this.getId('previewData_tbody'), children:[]} | ||
92 | ]} | ||
93 | ]} | ||
94 | ]}); | ||
95 | |||
96 | c =data[0].length; | ||
97 | for (i=0; i<c; i++) { | ||
98 | if (this.mainComponent().isColumnSelected(i)) { | ||
99 | this.getDom('columnCheckbox_' + i).checked = true; | ||
100 | } | ||
101 | } | ||
102 | |||
103 | this.renderData(this.getElement('previewData_tbody'), data); | ||
104 | |||
105 | checkboxes = MochiKit.DOM.getElementsByTagAndClassName('input', null, this.getDom('previewData_thead')); | ||
106 | c = checkboxes.length; | ||
107 | for (i=0; i<c; i++) { | ||
108 | MochiKit.Signal.connect(checkboxes[i], 'onclick', this, 'renderDataHandler'); | ||
109 | } | ||
110 | //MochiKit.Logging.logDebug("<<< CSVImportColumns.render"); | ||
111 | }, | ||
112 | |||
113 | //------------------------------------------------------------------------- | ||
114 | |||
115 | 'renderData': function(anElement, someData) { | ||
116 | var config; | ||
117 | var i,c; | ||
118 | |||
119 | //MochiKit.Logging.logDebug(">>> CSVImportColumns.renderData"); | ||
120 | // anElement.update(""); | ||
121 | MochiKit.DOM.replaceChildNodes(anElement.dom); | ||
122 | |||
123 | config = MochiKit.Base.map(MochiKit.Base.bind(function(aRowData) { | ||
124 | var result; | ||
125 | var i,c; | ||
126 | |||
127 | result = {tag:'tr', children:[]}; | ||
128 | c = aRowData.length; | ||
129 | for (i=0; i<c; i++) { | ||
130 | var field; | ||
131 | |||
132 | field = aRowData[i]; | ||
133 | result.children.push({tag:'td', valign:'top', cls:(this.mainComponent().isColumnSelected(i) ? 'selectedColumn': 'skippedColumn'), html:(MochiKit.Base.isNotEmpty(field) ? field.replace(/\n/g, '<br>') : ' ')}); | ||
134 | } | ||
135 | |||
136 | return result; | ||
137 | }, this), someData); | ||
138 | |||
139 | MochiKit.Base.map(function(aRowConfig) {Clipperz.YUI.DomHelper.append(anElement, aRowConfig);}, config); | ||
140 | |||
141 | Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada')); | ||
142 | //MochiKit.Logging.logDebug("<<< CSVImportColumns.renderData"); | ||
143 | }, | ||
144 | |||
145 | //------------------------------------------------------------------------- | ||
146 | |||
147 | 'renderDataHandler': function(anEvent) { | ||
148 | var thElement; | ||
149 | |||
150 | thElement = YAHOO.ext.Element.get(anEvent.src().parentNode); | ||
151 | |||
152 | if (anEvent.src().checked == true) { | ||
153 | this.mainComponent().skippedColumns().remove(anEvent.src().value); | ||
154 | thElement.addClass('selectedColumn'); | ||
155 | thElement.removeClass('skippedColumn'); | ||
156 | } else { | ||
157 | this.mainComponent().skippedColumns().add(anEvent.src().value); | ||
158 | thElement.removeClass('selectedColumn'); | ||
159 | thElement.addClass('skippedColumn'); | ||
160 | } | ||
161 | |||
162 | if (this.mainComponent().skippedColumns().allItems().length == this.mainComponent().parsedValues()[0].length) { | ||
163 | this.mainComponent().nextButton().disable(); | ||
164 | } else { | ||
165 | this.mainComponent().nextButton().enable(); | ||
166 | } | ||
167 | |||
168 | this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues()); | ||
169 | }, | ||
170 | |||
171 | //------------------------------------------------------------------------- | ||
172 | __syntaxFix__: "syntax fix" | ||
173 | }); | ||
174 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js new file mode 100644 index 0000000..a368747 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js | |||
@@ -0,0 +1,247 @@ | |||
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 | if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; } | ||
34 | |||
35 | //############################################################################# | ||
36 | |||
37 | Clipperz.PM.Components.Import.CSVImport.CSVImportFields = function(anElement, args) { | ||
38 | args = args || {}; | ||
39 | |||
40 | Clipperz.PM.Components.Import.CSVImport.CSVImportFields.superclass.constructor.call(this, anElement, args); | ||
41 | this._mainComponent = args.mainComponent; | ||
42 | |||
43 | return this; | ||
44 | } | ||
45 | |||
46 | //============================================================================= | ||
47 | |||
48 | YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportFields, Clipperz.PM.Components.BaseComponent, { | ||
49 | |||
50 | 'toString': function() { | ||
51 | return "Clipperz.PM.Components.Import.CSVImport.CSVImportFields component"; | ||
52 | }, | ||
53 | |||
54 | //------------------------------------------------------------------------- | ||
55 | |||
56 | 'mainComponent': function() { | ||
57 | return this._mainComponent; | ||
58 | }, | ||
59 | |||
60 | //------------------------------------------------------------------------- | ||
61 | |||
62 | 'render': function() { | ||
63 | varfieldsHeaderCells; | ||
64 | var titleColumnIndex; | ||
65 | var notesColumnIndex; | ||
66 | var i,c; | ||
67 | |||
68 | Clipperz.NotificationCenter.unregister(this); | ||
69 | MochiKit.Signal.disconnectAllTo(this); | ||
70 | |||
71 | this.element().update(""); | ||
72 | |||
73 | titleColumnIndex = this.mainComponent().titleColumnIndex() | ||
74 | notesColumnIndex = this.mainComponent().notesColumnIndex() | ||
75 | |||
76 | fieldsHeaderCells = []; | ||
77 | fieldsHeaderCells.push({tag:'td', valign:'top', cls:'title', html:this.mainComponent().labelForColumn(titleColumnIndex)}); | ||
78 | |||
79 | c =this.mainComponent().parsedValues()[0].length; | ||
80 | for (i=0; i<c; i++) { | ||
81 | if ((i != titleColumnIndex) && (i != notesColumnIndex) && (this.mainComponent().isColumnSelected(i))) { | ||
82 | var trimmedLabel; | ||
83 | |||
84 | 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:[ | ||
86 | {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:[ | ||
88 | {tag:'option', value:'UNDEFINED', html:"select data type", cls:'disabledOption'}, | ||
89 | {tag:'option', value:'TXT', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['TXT']['shortDescription']}, | ||
90 | {tag:'option', value:'PWD', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['PWD']['shortDescription']}, | ||
91 | {tag:'option', value:'URL', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['URL']['shortDescription']}, | ||
92 | {tag:'option', value:'DATE', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['DATE']['shortDescription']}, | ||
93 | {tag:'option', value:'ADDR', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['ADDR']['shortDescription']} | ||
94 | ]} | ||
95 | ]}) | ||
96 | } | ||
97 | } | ||
98 | |||
99 | if (notesColumnIndex != -1) { | ||
100 | fieldsHeaderCells.push({tag:'td', valign:'top', cls:'notes', html:this.mainComponent().labelForColumn(notesColumnIndex)}); | ||
101 | } | ||
102 | |||
103 | this.domHelper().append(this.element(), {tag:'div', children:[ | ||
104 | {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Fields']}, | ||
105 | {tag:'div', id:this.getId('dataDiv'), children:[ | ||
106 | {tag:'div', children:[ | ||
107 | ]}, | ||
108 | {tag:'div', cls:'csvImportPreview', children:[ | ||
109 | {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview', cellspacing:'0', children:[ | ||
110 | {tag:'thead', id:this.getId('previewData_thead'), children:[ | ||
111 | {tag:'tr', cls:'CSV_previewData_header', children:fieldsHeaderCells} | ||
112 | ]}, | ||
113 | {tag:'tbody', id:this.getId('previewData_tbody'), children:[]} | ||
114 | ]} | ||
115 | ]} | ||
116 | ]} | ||
117 | ]}); | ||
118 | |||
119 | for (i=0; i<c; i++) { | ||
120 | if ((i != titleColumnIndex) && (i != notesColumnIndex) && (this.mainComponent().isColumnSelected(i))) { | ||
121 | Clipperz.DOM.selectOptionMatchingValue(this.getDom('select_' + i), this.mainComponent().typeForColumn(i)); | ||
122 | MochiKit.Signal.connect(this.getDom('select_' + i), 'onchange', this, 'renderDataRowsHandler'); | ||
123 | } | ||
124 | } | ||
125 | |||
126 | this.renderDataRows(this.getElement('previewData_tbody')); | ||
127 | // Clipperz.NotificationCenter.register(null, 'updatedCSVImportColumnHeader', this, 'renderDataRowsHandler'); | ||
128 | }, | ||
129 | |||
130 | //------------------------------------------------------------------------- | ||
131 | |||
132 | 'isColumnSetup': function(aColumnIndex) { | ||
133 | return ((Clipperz.Base.trim(this.mainComponent().labelForColumn(aColumnIndex)) != "") && (this.mainComponent().typeForColumn(aColumnIndex) != 'UNDEFINED')); | ||
134 | }, | ||
135 | |||
136 | //------------------------------------------------------------------------- | ||
137 | |||
138 | 'renderDataRowsHandler': function(anEvent) { | ||
139 | var columnIndex; | ||
140 | var tdElement; | ||
141 | |||
142 | //MochiKit.Logging.logDebug(">>> renderDataRowsHandler") | ||
143 | columnIndex = anEvent.src().name; | ||
144 | this.mainComponent().setTypeForColumn(anEvent.src().value, columnIndex); | ||
145 | |||
146 | tdElement = this.getElement('fieldHeaderTD_' + columnIndex); | ||
147 | |||
148 | if (this.isColumnSetup(columnIndex)) { | ||
149 | tdElement.removeClass('unconfiguredColumn'); | ||
150 | tdElement.addClass('configuredColumn'); | ||
151 | } else { | ||
152 | tdElement.addClass('unconfiguredColumn'); | ||
153 | tdElement.removeClass('configuredColumn'); | ||
154 | } | ||
155 | |||
156 | this.renderDataRows(this.getElement('previewData_tbody')); | ||
157 | }, | ||
158 | |||
159 | //------------------------------------------------------------------------- | ||
160 | |||
161 | 'renderDataRows': function(anElement) { | ||
162 | var titleColumnIndex; | ||
163 | var notesColumnIndex; | ||
164 | var data | ||
165 | var i,c; | ||
166 | |||
167 | //MochiKit.Logging.logDebug("#### >> renderDataRows"); | ||
168 | // anElement.update(""); | ||
169 | MochiKit.DOM.replaceChildNodes(anElement.dom); | ||
170 | |||
171 | if (this.mainComponent().isFirstRowHeader()) { | ||
172 | data = this.mainComponent().parsedValues().slice(1); | ||
173 | } else { | ||
174 | data = this.mainComponent().parsedValues(); | ||
175 | } | ||
176 | |||
177 | |||
178 | titleColumnIndex = this.mainComponent().titleColumnIndex(); | ||
179 | notesColumnIndex = this.mainComponent().notesColumnIndex(); | ||
180 | |||
181 | c = data.length; | ||
182 | for (i=0; i<c; i++) { | ||
183 | var rowData; | ||
184 | var rowConfig; | ||
185 | var ii, cc; | ||
186 | |||
187 | rowData = data[i]; | ||
188 | |||
189 | rowConfig = {tag:'tr', children:[ | ||
190 | {tag:'td', valign:'top', cls:'title', html:(MochiKit.Base.isNotEmpty(rowData[titleColumnIndex]) ? rowData[titleColumnIndex].replace(/\n/g, '<br>') : ' ')} | ||
191 | ]}; | ||
192 | |||
193 | cc = rowData.length; | ||
194 | for (ii=0; ii<cc; ii++) { | ||
195 | // if ((ii != titleColumnIndex) && (ii != notesColumnIndex)) { | ||
196 | if ((ii != titleColumnIndex) && (ii != notesColumnIndex) && (this.mainComponent().isColumnSelected(ii))) { | ||
197 | rowConfig.children.push({ | ||
198 | tag:'td', | ||
199 | valign:'top', | ||
200 | cls:(this.isColumnSetup(ii) ? 'configuredColumn' : 'unconfiguredColumn'), | ||
201 | html:(MochiKit.Base.isNotEmpty(rowData[ii]) ? rowData[ii].replace(/\n/g, '<br>') : ' ') | ||
202 | }); | ||
203 | } | ||
204 | } | ||
205 | 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>') : ' ')}); | ||
207 | } | ||
208 | |||
209 | this.domHelper().append(anElement, rowConfig); | ||
210 | } | ||
211 | |||
212 | Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada')); | ||
213 | |||
214 | this.checkWetherToEnableNextButton(); | ||
215 | //MochiKit.Logging.logDebug("#### << renderDataRows"); | ||
216 | }, | ||
217 | |||
218 | //------------------------------------------------------------------------- | ||
219 | |||
220 | 'checkWetherToEnableNextButton': function() { | ||
221 | var result; | ||
222 | var titleColumnIndex; | ||
223 | var notesColumnIndex; | ||
224 | var i,c; | ||
225 | |||
226 | titleColumnIndex = this.mainComponent().titleColumnIndex() | ||
227 | notesColumnIndex = this.mainComponent().notesColumnIndex() | ||
228 | |||
229 | result = true; | ||
230 | c =this.mainComponent().parsedValues()[0].length; | ||
231 | for (i=0; i<c; i++) { | ||
232 | if ((i != titleColumnIndex) && (i != notesColumnIndex) && (this.mainComponent().isColumnSelected(i))) { | ||
233 | result = result && this.isColumnSetup(i); | ||
234 | } | ||
235 | } | ||
236 | |||
237 | if (result) { | ||
238 | this.mainComponent().nextButton().enable(); | ||
239 | } else { | ||
240 | this.mainComponent().nextButton().disable(); | ||
241 | } | ||
242 | }, | ||
243 | |||
244 | //------------------------------------------------------------------------- | ||
245 | __syntaxFix__: "syntax fix" | ||
246 | }); | ||
247 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportHeader.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportHeader.js new file mode 100644 index 0000000..ebd243a --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportHeader.js | |||
@@ -0,0 +1,240 @@ | |||
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 | if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; } | ||
34 | |||
35 | //############################################################################# | ||
36 | |||
37 | Clipperz.PM.Components.Import.CSVImport.CSVImportHeader = function(anElement, args) { | ||
38 | args = args || {}; | ||
39 | |||
40 | Clipperz.PM.Components.Import.CSVImport.CSVImportHeader.superclass.constructor.call(this, anElement, args); | ||
41 | this._mainComponent = args.mainComponent; | ||
42 | |||
43 | this._pendingDeferredLabelFieldHandlerEvents = 0; | ||
44 | |||
45 | return this; | ||
46 | } | ||
47 | |||
48 | //============================================================================= | ||
49 | |||
50 | YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportHeader, Clipperz.PM.Components.BaseComponent, { | ||
51 | |||
52 | 'toString': function() { | ||
53 | return "Clipperz.PM.Components.Import.CSVImport.CSVImportHeader component"; | ||
54 | }, | ||
55 | |||
56 | //------------------------------------------------------------------------- | ||
57 | |||
58 | 'mainComponent': function() { | ||
59 | return this._mainComponent; | ||
60 | }, | ||
61 | |||
62 | //------------------------------------------------------------------------- | ||
63 | |||
64 | 'render': function() { | ||
65 | var thConfigs; | ||
66 | var i,c; | ||
67 | |||
68 | //MochiKit.Logging.logDebug(">>> CSVImportHeader.render"); | ||
69 | Clipperz.NotificationCenter.unregister(this); | ||
70 | MochiKit.Signal.disconnectAllTo(this); | ||
71 | |||
72 | thConfigs = []; | ||
73 | c = this.mainComponent().parsedValues()[0].length; | ||
74 | for (i=0; i<c; i++) { | ||
75 | if (this.mainComponent().isColumnSelected(i)) { | ||
76 | // thConfigs.push({tag:'th', children:[{tag:'input', type:'text', id:this.getId('headerTextField_' + i), value:this.mainComponent().labelForColumn(i)}]}); | ||
77 | thConfigs.push({tag:'th', children:[{tag:'input', type:'text', id:this.getId('headerTextField_' + i), value:""}]}); | ||
78 | } | ||
79 | } | ||
80 | |||
81 | this.element().update(""); | ||
82 | this.domHelper().append(this.element(), {tag:'div', children:[ | ||
83 | {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Header']}, | ||
84 | {tag:'div', cls:'importStepParameters', children:[ | ||
85 | {tag:'input', type:'checkbox', name:'isFistRowHeader', id:this.getId('isFirstRowHeader_checkbox')}, | ||
86 | {tag:'span', id:this.getId('isFirstRowHeader_span'), cls:'clickableSpan', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Header_Settings_firstRowHeaderLabel']} | ||
87 | ]}, | ||
88 | {tag:'div', id:this.getId('dataDiv'), children:[ | ||
89 | {tag:'div', cls:'csvImportPreview', children:[ | ||
90 | {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview header', cellspacing:'0', children:[ | ||
91 | {tag:'thead', children:[{tag:'tr', children:thConfigs}]}, | ||
92 | {tag:'tbody', id:this.getId('previewData_tbody')} | ||
93 | ]} | ||
94 | ]} | ||
95 | ]} | ||
96 | ]}); | ||
97 | |||
98 | for (i=0; i<c; i++) { | ||
99 | if (this.mainComponent().isColumnSelected(i)) { | ||
100 | this.getElement('headerTextField_' + i).dom.value = this.mainComponent().labelForColumn(i); | ||
101 | } | ||
102 | } | ||
103 | |||
104 | this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues()); | ||
105 | |||
106 | if (this.mainComponent().isFirstRowHeader()) { | ||
107 | this.getDom('isFirstRowHeader_checkbox').click(); | ||
108 | } | ||
109 | |||
110 | c = this.mainComponent().parsedValues()[0].length; | ||
111 | for (i=0; i<c; i++) { | ||
112 | if (this.mainComponent().isColumnSelected(i)) { | ||
113 | MochiKit.Signal.connect(this.getDom('headerTextField_' + i), 'onchange', MochiKit.Base.partial(MochiKit.Base.method(this, 'labelFieldHandler'), i)); | ||
114 | MochiKit.Signal.connect(this.getDom('headerTextField_' + i), 'onkeypress', MochiKit.Base.partial(MochiKit.Base.method(this, 'deferredLabelFieldHandler'), i)); | ||
115 | } | ||
116 | } | ||
117 | |||
118 | MochiKit.Signal.connect(this.getDom('isFirstRowHeader_checkbox'), 'onclick', this, 'toggleFirstRowHeaderCheckboxHandler'); | ||
119 | if (Clipperz_IEisBroken != true) { | ||
120 | MochiKit.Signal.connect(this.getDom('isFirstRowHeader_span'), 'onclick', this.getDom('isFirstRowHeader_checkbox'), 'click'); | ||
121 | } | ||
122 | //MochiKit.Logging.logDebug("<<< CSVImportHeader.render"); | ||
123 | }, | ||
124 | |||
125 | //------------------------------------------------------------------------- | ||
126 | |||
127 | 'renderData': function(anElement, someData) { | ||
128 | var trConfigs; | ||
129 | var data; | ||
130 | var i,c; | ||
131 | |||
132 | // anElement.update(""); | ||
133 | MochiKit.DOM.replaceChildNodes(anElement.dom); | ||
134 | |||
135 | if (this.mainComponent().isFirstRowHeader()) { | ||
136 | data = someData.slice(1); | ||
137 | } else { | ||
138 | data = someData; | ||
139 | } | ||
140 | |||
141 | trConfigs = MochiKit.Base.map(MochiKit.Base.bind(function(aRowData) { | ||
142 | var result; | ||
143 | var i,c; | ||
144 | |||
145 | result = {tag:'tr', children:[]}; | ||
146 | c = aRowData.length; | ||
147 | for (i=0; i<c; i++) { | ||
148 | if (this.mainComponent().isColumnSelected(i)) { | ||
149 | result.children.push({tag:'td', valign:'top', html:(MochiKit.Base.isNotEmpty(aRowData[i]) ? aRowData[i].replace(/\n/g, '<br>') : ' ')}); | ||
150 | } | ||
151 | } | ||
152 | |||
153 | return result; | ||
154 | }, this), data); | ||
155 | |||
156 | MochiKit.Base.map(function(aRowConfig) {Clipperz.YUI.DomHelper.append(anElement, aRowConfig);}, trConfigs); | ||
157 | |||
158 | Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada')); | ||
159 | }, | ||
160 | |||
161 | //------------------------------------------------------------------------- | ||
162 | |||
163 | 'toggleFirstRowHeaderCheckboxHandler': function() { | ||
164 | var firstRowData; | ||
165 | var i,c; | ||
166 | |||
167 | //MochiKit.Logging.logDebug(">>> toggleFirstRowHeaderCheckboxHandler"); | ||
168 | this.mainComponent().setIsFirstRowHeader(this.getDom('isFirstRowHeader_checkbox').checked); | ||
169 | |||
170 | firstRowData = this.mainComponent().parsedValues()[0]; | ||
171 | |||
172 | c = firstRowData.length; | ||
173 | for (i=0; i<c; i++) { | ||
174 | if (this.mainComponent().isColumnSelected(i)) { | ||
175 | var label; | ||
176 | |||
177 | if (this.mainComponent().isFirstRowHeader()) { | ||
178 | label = firstRowData[i]; | ||
179 | } else { | ||
180 | label = null; | ||
181 | } | ||
182 | |||
183 | this.mainComponent().setLabelForColumn(label, i); | ||
184 | } | ||
185 | }; | ||
186 | |||
187 | this.updateInputFieldValues(); | ||
188 | this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues()); | ||
189 | //MochiKit.Logging.logDebug("<<< toggleFirstRowHeaderCheckboxHandler"); | ||
190 | }, | ||
191 | |||
192 | //------------------------------------------------------------------------- | ||
193 | |||
194 | 'updateInputFieldValues': function() { | ||
195 | var i,c; | ||
196 | |||
197 | //MochiKit.Logging.logDebug(">>> updateInputFieldValues"); | ||
198 | c = this.mainComponent().parsedValues()[0].length; | ||
199 | for (i=0; i<c; i++) { | ||
200 | if (this.mainComponent().isColumnSelected(i)) { | ||
201 | this.getDom('headerTextField_' + i).value = this.mainComponent().labelForColumn(i); | ||
202 | } | ||
203 | } | ||
204 | //console.log('[1] fieldSettings', fieldSettings); | ||
205 | //MochiKit.Logging.logDebug("<<< updateInputFieldValues"); | ||
206 | }, | ||
207 | |||
208 | //------------------------------------------------------------------------- | ||
209 | |||
210 | 'labelFieldHandler': function(aColumnIndex, anEvent) { | ||
211 | var inputField; | ||
212 | |||
213 | //MochiKit.Logging.logDebug(">>> labelFieldHandler"); | ||
214 | inputField = anEvent.src(); | ||
215 | |||
216 | this.mainComponent().setLabelForColumn(inputField.value, aColumnIndex); | ||
217 | //MochiKit.Logging.logDebug("##### [" + anEvent.src().id + "] -> label[" + aColumnIndex + "]: '" + inputField.value + "'"); | ||
218 | //MochiKit.Logging.logDebug("<<< labelFieldHandler"); | ||
219 | }, | ||
220 | |||
221 | 'deferredLabelFieldHandler': function(aColumnIndex, anEvent) { | ||
222 | //MochiKit.Logging.logDebug(">>> deferredLabelFieldHandler"); | ||
223 | this._pendingDeferredLabelFieldHandlerEvents ++; | ||
224 | MochiKit.Async.callLater(1, MochiKit.Base.partial(MochiKit.Base.method(this, 'deferredLabelFieldHandlerCatcher'), aColumnIndex, anEvent)); | ||
225 | //MochiKit.Logging.logDebug("<<< deferredLabelFieldHandler"); | ||
226 | }, | ||
227 | |||
228 | 'deferredLabelFieldHandlerCatcher': function(aColumnIndex, anEvent) { | ||
229 | //MochiKit.Logging.logDebug(">>> deferredLabelFieldHandlerCatcher"); | ||
230 | this._pendingDeferredLabelFieldHandlerEvents --; | ||
231 | if (this._pendingDeferredLabelFieldHandlerEvents == 0) { | ||
232 | this.labelFieldHandler(aColumnIndex, anEvent); | ||
233 | } | ||
234 | //MochiKit.Logging.logDebug("<<< deferredLabelFieldHandlerCatcher"); | ||
235 | }, | ||
236 | |||
237 | //------------------------------------------------------------------------- | ||
238 | __syntaxFix__: "syntax fix" | ||
239 | }); | ||
240 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js new file mode 100644 index 0000000..a53c531 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js | |||
@@ -0,0 +1,212 @@ | |||
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 | if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; } | ||
34 | |||
35 | //############################################################################# | ||
36 | |||
37 | Clipperz.PM.Components.Import.CSVImport.CSVImportNotes = function(anElement, args) { | ||
38 | args = args || {}; | ||
39 | |||
40 | Clipperz.PM.Components.Import.CSVImport.CSVImportNotes.superclass.constructor.call(this, anElement, args); | ||
41 | this._mainComponent = args.mainComponent; | ||
42 | |||
43 | return this; | ||
44 | } | ||
45 | |||
46 | //============================================================================= | ||
47 | |||
48 | YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportNotes, Clipperz.PM.Components.BaseComponent, { | ||
49 | |||
50 | 'toString': function() { | ||
51 | return "Clipperz.PM.Components.Import.CSVImport.CSVImportNotes component"; | ||
52 | }, | ||
53 | |||
54 | //------------------------------------------------------------------------- | ||
55 | |||
56 | 'mainComponent': function() { | ||
57 | return this._mainComponent; | ||
58 | }, | ||
59 | |||
60 | //------------------------------------------------------------------------- | ||
61 | |||
62 | 'render': function() { | ||
63 | varnotesSelectorCheckboxCells; | ||
64 | var totalNumberOfColumns; | ||
65 | var titleColumnIndex; | ||
66 | var notesColumnIndex; | ||
67 | var i,c; | ||
68 | |||
69 | Clipperz.NotificationCenter.unregister(this); | ||
70 | MochiKit.Signal.disconnectAllTo(this); | ||
71 | |||
72 | this.element().update(""); | ||
73 | |||
74 | titleColumnIndex = this.mainComponent().titleColumnIndex() | ||
75 | notesColumnIndex = this.mainComponent().notesColumnIndex() | ||
76 | |||
77 | totalNumberOfColumns = this.mainComponent().parsedValues()[0].length; | ||
78 | |||
79 | notesSelectorCheckboxCells = [{tag:'th', cls:'title', html:this.mainComponent().labelForColumn(titleColumnIndex)}]; | ||
80 | c =totalNumberOfColumns; | ||
81 | for (i=0; i<c; i++) { | ||
82 | if ((i != titleColumnIndex) && (this.mainComponent().isColumnSelected(i))) { | ||
83 | notesSelectorCheckboxCells.push({tag:'th', id:this.getId('th_' + i), valign:'top', children:[ | ||
84 | {tag:'input', type:'radio', id:this.getId('radio_' + i), name:'CSVImportNotesColumn', value:i}, | ||
85 | {tag:'span', cls:'clickableSpan', id:this.getId('columnLabel_' + i), html:this.mainComponent().labelForColumn(i)} | ||
86 | ]}) | ||
87 | } | ||
88 | } | ||
89 | |||
90 | this.domHelper().append(this.element(), {tag:'div', children:[ | ||
91 | {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Notes']}, | ||
92 | {tag:'div', id:this.getId('dataDiv'), children:[ | ||
93 | {tag:'div', cls:'importStepParameters', children:[ | ||
94 | {tag:'input', id:this.getId('doNotSetNotes_radio'), type:'radio', name:'CSVImportNotesColumn', value:-1}, | ||
95 | {tag:'span', id:this.getId('doNotSetNotes_span'), cls:'clickableSpan', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Notes_Settings_noSelectionLabel']} | ||
96 | ]}, | ||
97 | {tag:'div', cls:'csvImportPreview', children:[ | ||
98 | {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview', cellspacing:'0', children:[ | ||
99 | {tag:'thead', id:this.getId('previewData_thead'), children:[ | ||
100 | {tag:'tr', children:notesSelectorCheckboxCells} | ||
101 | ]}, | ||
102 | {tag:'tbody', id:this.getId('previewData_tbody'), children:[]} | ||
103 | ]} | ||
104 | ]} | ||
105 | ]} | ||
106 | ]}); | ||
107 | |||
108 | this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues()); | ||
109 | |||
110 | if ((notesColumnIndex >= totalNumberOfColumns) || (notesColumnIndex == titleColumnIndex) || !(this.mainComponent().isColumnSelected(notesColumnIndex))) { | ||
111 | this.mainComponent().setNotesColumnIndex(-1); | ||
112 | notesColumnIndex = -1; | ||
113 | } | ||
114 | |||
115 | c =totalNumberOfColumns; | ||
116 | for (i=0; i<c; i++) { | ||
117 | if ((i != titleColumnIndex) && (this.mainComponent().isColumnSelected(i))) { | ||
118 | MochiKit.Signal.connect(this.getDom('radio_' + i), 'onclick', this, 'renderDataHandler'); | ||
119 | if (Clipperz_IEisBroken != true) { | ||
120 | MochiKit.Signal.connect(this.getDom('columnLabel_' + i), 'onclick', this.getDom('radio_' + i), 'click'); | ||
121 | } | ||
122 | } | ||
123 | } | ||
124 | |||
125 | MochiKit.Signal.connect(this.getDom('doNotSetNotes_radio'), 'onclick', this, 'renderDataHandler'); | ||
126 | if (Clipperz_IEisBroken != true) { | ||
127 | MochiKit.Signal.connect(this.getDom('doNotSetNotes_span'), 'onclick', this.getDom('doNotSetNotes_radio'), 'click'); | ||
128 | } | ||
129 | |||
130 | if (notesColumnIndex == -1) { | ||
131 | this.getDom('doNotSetNotes_radio').click(); | ||
132 | } else { | ||
133 | this.getDom('radio_' + notesColumnIndex).click(); | ||
134 | } | ||
135 | }, | ||
136 | |||
137 | //------------------------------------------------------------------------- | ||
138 | |||
139 | 'renderData': function(anElement, someData) { | ||
140 | var data; | ||
141 | var config; | ||
142 | var titleColumnIndex; | ||
143 | var notesColumnIndex; | ||
144 | var i,c; | ||
145 | |||
146 | // anElement.update(""); | ||
147 | MochiKit.DOM.replaceChildNodes(anElement.dom); | ||
148 | |||
149 | titleColumnIndex = this.mainComponent().titleColumnIndex(); | ||
150 | notesColumnIndex = this.mainComponent().notesColumnIndex(); | ||
151 | |||
152 | if (this.mainComponent().isFirstRowHeader()) { | ||
153 | data = someData.slice(1); | ||
154 | } else { | ||
155 | data = someData; | ||
156 | } | ||
157 | |||
158 | |||
159 | // config = [{tag:'tr', cls:'CSV_previewData_header', children:[{tag:'td', valign:'top', html:header[titleColumnIndex], cls:'title'}]}]; | ||
160 | // c = header.length; | ||
161 | // for (i=0; i<c; i++) { | ||
162 | // if (i != titleColumnIndex) { | ||
163 | // config[0].children.push({tag:'td', valign:'top', html:header[i], cls:((notesColumnIndex == i) ? 'notesColumn': '')}) | ||
164 | // } | ||
165 | // } | ||
166 | |||
167 | config = MochiKit.Base.map(MochiKit.Base.bind(function(aTitleColumnIndex, aRowData) { | ||
168 | var result; | ||
169 | var i,c; | ||
170 | |||
171 | result = {tag:'tr', children:[{tag:'td', valign:'top', cls:'title', html:(MochiKit.Base.isNotEmpty(aRowData[aTitleColumnIndex]) ? aRowData[aTitleColumnIndex].replace(/\n/g, '<br>') : ' ')}]}; | ||
172 | c = aRowData.length; | ||
173 | for (i=0; i<c; i++) { | ||
174 | if ((i != titleColumnIndex) && (this.mainComponent().isColumnSelected(i))) { | ||
175 | result.children.push({tag:'td', valign:'top', cls:((notesColumnIndex == i) ? 'notesColumn': ''), html:(MochiKit.Base.isNotEmpty(aRowData[i]) ? aRowData[i].replace(/\n/g, '<br>') : ' ')}); | ||
176 | } | ||
177 | } | ||
178 | |||
179 | return result; | ||
180 | }, this, titleColumnIndex), data); | ||
181 | |||
182 | MochiKit.Base.map(function(aRowConfig) {Clipperz.YUI.DomHelper.append(anElement, aRowConfig);}, config); | ||
183 | |||
184 | Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada')); | ||
185 | }, | ||
186 | |||
187 | //------------------------------------------------------------------------- | ||
188 | |||
189 | 'renderDataHandler': function(anEvent) { | ||
190 | var titleColumnIndex; | ||
191 | var i,c; | ||
192 | |||
193 | this.mainComponent().setNotesColumnIndex(anEvent.src().value); | ||
194 | titleColumnIndex = this.mainComponent().titleColumnIndex(); | ||
195 | |||
196 | c = this.mainComponent().parsedValues()[0].length; | ||
197 | for (i=0; i<c; i++) { | ||
198 | if ((i != titleColumnIndex) && (this.mainComponent().isColumnSelected(i))) { | ||
199 | this.getElement('th_' + i).removeClass('notesColumn'); | ||
200 | } | ||
201 | } | ||
202 | if (anEvent.src().value != -1) { | ||
203 | this.getElement('th_' + anEvent.src().value).addClass('notesColumn'); | ||
204 | } | ||
205 | |||
206 | this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues()); | ||
207 | }, | ||
208 | |||
209 | //------------------------------------------------------------------------- | ||
210 | __syntaxFix__: "syntax fix" | ||
211 | }); | ||
212 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportTitle.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportTitle.js new file mode 100644 index 0000000..9162867 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportTitle.js | |||
@@ -0,0 +1,189 @@ | |||
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 | if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; } | ||
34 | |||
35 | //############################################################################# | ||
36 | |||
37 | Clipperz.PM.Components.Import.CSVImport.CSVImportTitle = function(anElement, args) { | ||
38 | args = args || {}; | ||
39 | |||
40 | Clipperz.PM.Components.Import.CSVImport.CSVImportTitle.superclass.constructor.call(this, anElement, args); | ||
41 | this._mainComponent = args.mainComponent; | ||
42 | |||
43 | return this; | ||
44 | } | ||
45 | |||
46 | //============================================================================= | ||
47 | |||
48 | YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportTitle, Clipperz.PM.Components.BaseComponent, { | ||
49 | |||
50 | 'toString': function() { | ||
51 | return "Clipperz.PM.Components.Import.CSVImport.CSVImportTitle component"; | ||
52 | }, | ||
53 | |||
54 | //------------------------------------------------------------------------- | ||
55 | |||
56 | 'mainComponent': function() { | ||
57 | return this._mainComponent; | ||
58 | }, | ||
59 | |||
60 | //------------------------------------------------------------------------- | ||
61 | |||
62 | 'render': function() { | ||
63 | vartitleSelectorCheckboxCells; | ||
64 | var titleColumnIndex; | ||
65 | var i,c; | ||
66 | |||
67 | Clipperz.NotificationCenter.unregister(this); | ||
68 | MochiKit.Signal.disconnectAllTo(this); | ||
69 | |||
70 | this.element().update(""); | ||
71 | |||
72 | titleColumnIndex = this.mainComponent().titleColumnIndex() | ||
73 | titleSelectorCheckboxCells = []; | ||
74 | c =this.mainComponent().parsedValues()[0].length; | ||
75 | for (i=0; i<c; i++) { | ||
76 | if (this.mainComponent().isColumnSelected(i)) { | ||
77 | titleSelectorCheckboxCells.push({tag:'th', valign:'top', id:this.getId('th_' + i), children:[ | ||
78 | {tag:'input', type:'radio', id:this.getId('radio_' + i), name:'CSVImportTitleColumn', value:i}, | ||
79 | {tag:'span', cls:'clickableSpan', id:this.getId('columnLabel_' + i), html:this.mainComponent().labelForColumn(i)} | ||
80 | ]}) | ||
81 | } | ||
82 | } | ||
83 | |||
84 | if (titleColumnIndex >= titleSelectorCheckboxCells.length) { | ||
85 | this.mainComponent().setTitleColumnIndex(-1); | ||
86 | } | ||
87 | |||
88 | this.domHelper().append(this.element(), {tag:'div', children:[ | ||
89 | {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Title']}, | ||
90 | {tag:'div', id:this.getId('dataDiv'), cls:'csvImportPreview', children:[ | ||
91 | {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview', cellspacing:'0', children:[ | ||
92 | {tag:'thead', id:this.getId('previewData_thead'), children:[ | ||
93 | {tag:'tr', children:titleSelectorCheckboxCells} | ||
94 | ]}, | ||
95 | {tag:'tbody', id:this.getId('previewData_tbody'), children:[]} | ||
96 | ]} | ||
97 | ]} | ||
98 | ]}); | ||
99 | |||
100 | this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues()); | ||
101 | |||
102 | c =this.mainComponent().parsedValues()[0].length; | ||
103 | for (i=0; i<c; i++) { | ||
104 | if (this.mainComponent().isColumnSelected(i)) { | ||
105 | MochiKit.Signal.connect(this.getDom('radio_' + i), 'onclick', this, 'renderDataHandler'); | ||
106 | if (Clipperz_IEisBroken != true) { | ||
107 | MochiKit.Signal.connect(this.getDom('columnLabel_' + i), 'onclick', this.getDom('radio_' + i), 'click'); | ||
108 | } | ||
109 | } | ||
110 | } | ||
111 | |||
112 | if (titleColumnIndex != -1) { | ||
113 | this.getDom('radio_' + titleColumnIndex).click(); | ||
114 | } else { | ||
115 | this.mainComponent().nextButton().disable(); | ||
116 | } | ||
117 | |||
118 | }, | ||
119 | |||
120 | //------------------------------------------------------------------------- | ||
121 | |||
122 | 'renderData': function(anElement, someData) { | ||
123 | var data; | ||
124 | var config; | ||
125 | var titleColumnIndex; | ||
126 | var i,c; | ||
127 | |||
128 | // anElement.update(""); | ||
129 | MochiKit.DOM.replaceChildNodes(anElement.dom); | ||
130 | |||
131 | titleColumnIndex = this.mainComponent().titleColumnIndex() | ||
132 | |||
133 | if (this.mainComponent().isFirstRowHeader()) { | ||
134 | data = someData.slice(1); | ||
135 | } else { | ||
136 | data = someData; | ||
137 | } | ||
138 | |||
139 | config = MochiKit.Base.map(MochiKit.Base.bind(function(aRowData) { | ||
140 | var result; | ||
141 | var i,c; | ||
142 | |||
143 | result = {tag:'tr', children:[]}; | ||
144 | c = aRowData.length; | ||
145 | for (i=0; i<c; i++) { | ||
146 | if (this.mainComponent().isColumnSelected(i)) { | ||
147 | var field; | ||
148 | |||
149 | field = aRowData[i]; | ||
150 | result.children.push({tag:'td', valign:'top', cls:((titleColumnIndex == i) ? 'titleColumn': ''), html:(MochiKit.Base.isNotEmpty(field) ? field.replace(/\n/g, '<br>') : ' ')}); | ||
151 | } | ||
152 | } | ||
153 | |||
154 | return result; | ||
155 | }, this), data); | ||
156 | |||
157 | MochiKit.Base.map(function(aRowConfig) {Clipperz.YUI.DomHelper.append(anElement, aRowConfig);}, config); | ||
158 | |||
159 | Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada')); | ||
160 | }, | ||
161 | |||
162 | //------------------------------------------------------------------------- | ||
163 | |||
164 | 'renderDataHandler': function(anEvent) { | ||
165 | var i,c; | ||
166 | |||
167 | this.mainComponent().setTitleColumnIndex(anEvent.src().value); | ||
168 | |||
169 | c = this.mainComponent().parsedValues()[0].length; | ||
170 | for (i=0; i<c; i++) { | ||
171 | if (this.mainComponent().isColumnSelected(i)) { | ||
172 | this.getElement('th_' + i).removeClass('titleColumn'); | ||
173 | } | ||
174 | } | ||
175 | this.getElement('th_' + anEvent.src().value).addClass('titleColumn'); | ||
176 | |||
177 | if (anEvent.src().value != -1) { | ||
178 | this.mainComponent().nextButton().enable(); | ||
179 | } else { | ||
180 | this.mainComponent().nextButton().disable(); | ||
181 | } | ||
182 | |||
183 | this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues()); | ||
184 | }, | ||
185 | |||
186 | //------------------------------------------------------------------------- | ||
187 | __syntaxFix__: "syntax fix" | ||
188 | }); | ||
189 | |||