Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportColumns.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportColumns.js | 22 |
1 files changed, 10 insertions, 12 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 index 3f4952d..fef8e9e 100644 --- a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportColumns.js +++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportColumns.js | |||
@@ -1,171 +1,169 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer 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 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 25 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
28 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | 26 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } |
29 | if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } | 27 | if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } |
30 | if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; } | 28 | if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; } |
31 | 29 | ||
32 | //############################################################################# | 30 | //############################################################################# |
33 | 31 | ||
34 | Clipperz.PM.Components.Import.CSVImport.CSVImportColumns = function(anElement, args) { | 32 | Clipperz.PM.Components.Import.CSVImport.CSVImportColumns = function(anElement, args) { |
35 | args = args || {}; | 33 | args = args || {}; |
36 | 34 | ||
37 | Clipperz.PM.Components.Import.CSVImport.CSVImportColumns.superclass.constructor.call(this, anElement, args); | 35 | Clipperz.PM.Components.Import.CSVImport.CSVImportColumns.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 | ||
45 | YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportColumns, Clipperz.PM.Components.BaseComponent, { | 43 | YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportColumns, Clipperz.PM.Components.BaseComponent, { |
46 | 44 | ||
47 | 'toString': function() { | 45 | 'toString': function() { |
48 | return "Clipperz.PM.Components.Import.CSVImport.CSVImportColumns component"; | 46 | return "Clipperz.PM.Components.Import.CSVImport.CSVImportColumns 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 | var i,c; | 58 | var i,c; |
61 | var columnSelectorCheckboxCells; | 59 | var columnSelectorCheckboxCells; |
62 | var checkboxes; | 60 | var checkboxes; |
63 | var data; | 61 | var data; |
64 | 62 | ||
65 | //MochiKit.Logging.logDebug(">>> CSVImportColumns.render"); | 63 | //MochiKit.Logging.logDebug(">>> CSVImportColumns.render"); |
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 | data = this.mainComponent().parsedValues(); | 69 | data = this.mainComponent().parsedValues(); |
72 | columnSelectorCheckboxCells = []; | 70 | columnSelectorCheckboxCells = []; |
73 | 71 | ||
74 | c =data[0].length; | 72 | c =data[0].length; |
75 | for (i=0; i<c; i++) { | 73 | for (i=0; i<c; i++) { |
76 | columnSelectorCheckboxCells.push({tag:'th', valign:'top', cls:(this.mainComponent().isColumnSelected(i) ? 'selectedColumn': 'skippedColumn'), children:[ | 74 | columnSelectorCheckboxCells.push({tag:'th', valign:'top', cls:(this.mainComponent().isColumnSelected(i) ? 'selectedColumn': 'skippedColumn'), children:[ |
77 | {tag:'input', type:'checkbox', id:this.getId('columnCheckbox_' + i), value:i} | 75 | {tag:'input', type:'checkbox', id:this.getId('columnCheckbox_' + i), value:i} |
78 | ]}) | 76 | ]}) |
79 | } | 77 | } |
80 | 78 | ||
81 | this.domHelper().append(this.element(), {tag:'div', children:[ | 79 | this.domHelper().append(this.element(), {tag:'div', children:[ |
82 | {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Columns']}, | 80 | {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Columns']}, |
83 | {tag:'div', id:this.getId('dataDiv'), cls:'csvImportPreview', children:[ | 81 | {tag:'div', id:this.getId('dataDiv'), cls:'csvImportPreview', children:[ |
84 | {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview columns', cellspacing:'0', children:[ | 82 | {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview columns', cellspacing:'0', children:[ |
85 | {tag:'thead', id:this.getId('previewData_thead'), children:[ | 83 | {tag:'thead', id:this.getId('previewData_thead'), children:[ |
86 | {tag:'tr', children:columnSelectorCheckboxCells} | 84 | {tag:'tr', children:columnSelectorCheckboxCells} |
87 | ]}, | 85 | ]}, |
88 | {tag:'tbody', id:this.getId('previewData_tbody'), children:[]} | 86 | {tag:'tbody', id:this.getId('previewData_tbody'), children:[]} |
89 | ]} | 87 | ]} |
90 | ]} | 88 | ]} |
91 | ]}); | 89 | ]}); |
92 | 90 | ||
93 | c =data[0].length; | 91 | c =data[0].length; |
94 | for (i=0; i<c; i++) { | 92 | for (i=0; i<c; i++) { |
95 | if (this.mainComponent().isColumnSelected(i)) { | 93 | if (this.mainComponent().isColumnSelected(i)) { |
96 | this.getDom('columnCheckbox_' + i).checked = true; | 94 | this.getDom('columnCheckbox_' + i).checked = true; |
97 | } | 95 | } |
98 | } | 96 | } |
99 | 97 | ||
100 | this.renderData(this.getElement('previewData_tbody'), data); | 98 | this.renderData(this.getElement('previewData_tbody'), data); |
101 | 99 | ||
102 | checkboxes = MochiKit.DOM.getElementsByTagAndClassName('input', null, this.getDom('previewData_thead')); | 100 | checkboxes = MochiKit.DOM.getElementsByTagAndClassName('input', null, this.getDom('previewData_thead')); |
103 | c = checkboxes.length; | 101 | c = checkboxes.length; |
104 | for (i=0; i<c; i++) { | 102 | for (i=0; i<c; i++) { |
105 | MochiKit.Signal.connect(checkboxes[i], 'onclick', this, 'renderDataHandler'); | 103 | MochiKit.Signal.connect(checkboxes[i], 'onclick', this, 'renderDataHandler'); |
106 | } | 104 | } |
107 | //MochiKit.Logging.logDebug("<<< CSVImportColumns.render"); | 105 | //MochiKit.Logging.logDebug("<<< CSVImportColumns.render"); |
108 | }, | 106 | }, |
109 | 107 | ||
110 | //------------------------------------------------------------------------- | 108 | //------------------------------------------------------------------------- |
111 | 109 | ||
112 | 'renderData': function(anElement, someData) { | 110 | 'renderData': function(anElement, someData) { |
113 | var config; | 111 | var config; |
114 | var i,c; | 112 | var i,c; |
115 | 113 | ||
116 | //MochiKit.Logging.logDebug(">>> CSVImportColumns.renderData"); | 114 | //MochiKit.Logging.logDebug(">>> CSVImportColumns.renderData"); |
117 | // anElement.update(""); | 115 | // anElement.update(""); |
118 | MochiKit.DOM.replaceChildNodes(anElement.dom); | 116 | MochiKit.DOM.replaceChildNodes(anElement.dom); |
119 | 117 | ||
120 | config = MochiKit.Base.map(MochiKit.Base.bind(function(aRowData) { | 118 | config = MochiKit.Base.map(MochiKit.Base.bind(function(aRowData) { |
121 | var result; | 119 | var result; |
122 | var i,c; | 120 | var i,c; |
123 | 121 | ||
124 | result = {tag:'tr', children:[]}; | 122 | result = {tag:'tr', children:[]}; |
125 | c = aRowData.length; | 123 | c = aRowData.length; |
126 | for (i=0; i<c; i++) { | 124 | for (i=0; i<c; i++) { |
127 | var field; | 125 | var field; |
128 | 126 | ||
129 | field = aRowData[i]; | 127 | field = aRowData[i]; |
130 | result.children.push({tag:'td', valign:'top', cls:(this.mainComponent().isColumnSelected(i) ? 'selectedColumn': 'skippedColumn'), html:(MochiKit.Base.isNotEmpty(field) ? field.replace(/\n/g, '<br>') : ' ')}); | 128 | result.children.push({tag:'td', valign:'top', cls:(this.mainComponent().isColumnSelected(i) ? 'selectedColumn': 'skippedColumn'), html:(MochiKit.Base.isNotEmpty(field) ? field.replace(/\n/g, '<br>') : ' ')}); |
131 | } | 129 | } |
132 | 130 | ||
133 | return result; | 131 | return result; |
134 | }, this), someData); | 132 | }, this), someData); |
135 | 133 | ||
136 | MochiKit.Base.map(function(aRowConfig) {Clipperz.YUI.DomHelper.append(anElement, aRowConfig);}, config); | 134 | MochiKit.Base.map(function(aRowConfig) {Clipperz.YUI.DomHelper.append(anElement, aRowConfig);}, config); |
137 | 135 | ||
138 | Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada')); | 136 | Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada')); |
139 | //MochiKit.Logging.logDebug("<<< CSVImportColumns.renderData"); | 137 | //MochiKit.Logging.logDebug("<<< CSVImportColumns.renderData"); |
140 | }, | 138 | }, |
141 | 139 | ||
142 | //------------------------------------------------------------------------- | 140 | //------------------------------------------------------------------------- |
143 | 141 | ||
144 | 'renderDataHandler': function(anEvent) { | 142 | 'renderDataHandler': function(anEvent) { |
145 | var thElement; | 143 | var thElement; |
146 | 144 | ||
147 | thElement = YAHOO.ext.Element.get(anEvent.src().parentNode); | 145 | thElement = YAHOO.ext.Element.get(anEvent.src().parentNode); |
148 | 146 | ||
149 | if (anEvent.src().checked == true) { | 147 | if (anEvent.src().checked == true) { |
150 | this.mainComponent().skippedColumns().remove(anEvent.src().value); | 148 | this.mainComponent().skippedColumns().remove(anEvent.src().value); |
151 | thElement.addClass('selectedColumn'); | 149 | thElement.addClass('selectedColumn'); |
152 | thElement.removeClass('skippedColumn'); | 150 | thElement.removeClass('skippedColumn'); |
153 | } else { | 151 | } else { |
154 | this.mainComponent().skippedColumns().add(anEvent.src().value); | 152 | this.mainComponent().skippedColumns().add(anEvent.src().value); |
155 | thElement.removeClass('selectedColumn'); | 153 | thElement.removeClass('selectedColumn'); |
156 | thElement.addClass('skippedColumn'); | 154 | thElement.addClass('skippedColumn'); |
157 | } | 155 | } |
158 | 156 | ||
159 | if (this.mainComponent().skippedColumns().allItems().length == this.mainComponent().parsedValues()[0].length) { | 157 | if (this.mainComponent().skippedColumns().allItems().length == this.mainComponent().parsedValues()[0].length) { |
160 | this.mainComponent().nextButton().disable(); | 158 | this.mainComponent().nextButton().disable(); |
161 | } else { | 159 | } else { |
162 | this.mainComponent().nextButton().enable(); | 160 | this.mainComponent().nextButton().enable(); |
163 | } | 161 | } |
164 | 162 | ||
165 | this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues()); | 163 | this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues()); |
166 | }, | 164 | }, |
167 | 165 | ||
168 | //------------------------------------------------------------------------- | 166 | //------------------------------------------------------------------------- |
169 | __syntaxFix__: "syntax fix" | 167 | __syntaxFix__: "syntax fix" |
170 | }); | 168 | }); |
171 | 169 | ||