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) (show whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js212
1 files changed, 212 insertions, 0 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
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
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
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
11refer 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
29if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
30if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
31if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; }
32if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; }
33if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; }
34
35//#############################################################################
36
37Clipperz.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
48YAHOO.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>') : '&nbsp;')}]};
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>') : '&nbsp;')});
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