author | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-03 16:04:12 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-03 16:04:12 (UTC) |
commit | 541bb378ddece2eab135a8066a16994e94436dea (patch) (unidiff) | |
tree | ff160ea3e26f7fe07fcfd401387c5a0232ca715e /frontend/beta/js/Clipperz/PM/Components/Import/ClipperzImportComponent.js | |
parent | 1bf431fd3d45cbdf4afa3e12afefe5d24f4d3bc7 (diff) | |
parent | ecad5e895831337216544e81f1a467e0c68c4a6a (diff) | |
download | clipperz-541bb378ddece2eab135a8066a16994e94436dea.zip clipperz-541bb378ddece2eab135a8066a16994e94436dea.tar.gz clipperz-541bb378ddece2eab135a8066a16994e94436dea.tar.bz2 |
Merge pull request #1 from gcsolaroli/master
First version of the restructured repository
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/Import/ClipperzImportComponent.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Components/Import/ClipperzImportComponent.js | 212 |
1 files changed, 212 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/ClipperzImportComponent.js b/frontend/beta/js/Clipperz/PM/Components/Import/ClipperzImportComponent.js new file mode 100644 index 0000000..50dcb93 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/ClipperzImportComponent.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 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.Import.ClipperzImportComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.Import.ClipperzImportComponent.superclass.constructor.call(this, anElement, args); | ||
40 | |||
41 | this.render(); | ||
42 | |||
43 | return this; | ||
44 | } | ||
45 | |||
46 | //============================================================================= | ||
47 | |||
48 | YAHOO.extendX(Clipperz.PM.Components.Import.ClipperzImportComponent, Clipperz.PM.Components.Import.GenericImportComponent, { | ||
49 | |||
50 | 'toString': function() { | ||
51 | return "Clipperz.PM.Components.Import.ClipperzImportComponent component"; | ||
52 | }, | ||
53 | |||
54 | //------------------------------------------------------------------------- | ||
55 | |||
56 | 'render': function() { | ||
57 | //MochiKit.Logging.logDebug(">>> Import.ClipperzImportComponent.render"); | ||
58 | this.domHelper().append(this.element(), {tag:'div', cls:'clipperzImportWizard', children:[ | ||
59 | {tag:'h3', htmlString:Clipperz.PM.Strings['Clipperz_ImportWizard_Title']}, | ||
60 | {tag:'div', cls:'importSteps', id:this.getId('importSteps')}, | ||
61 | {tag:'div', cls:'importStepBlocks', children:[ | ||
62 | {tag:'div', cls:'step_0', id:this.getId('step_0'), children:[ | ||
63 | {tag:'div', children:[ | ||
64 | {tag:'div', cls:'importOptionsDescription', htmlString:Clipperz.PM.Strings['importOptions_clipperz_description']}, | ||
65 | {tag:'div', cls:'importOptionsParameters', children:[]}, | ||
66 | this.textAreaConfig() | ||
67 | ]} | ||
68 | ]}, | ||
69 | {tag:'div', cls:'step_1', id:this.getId('step_1'), children:[ | ||
70 | {tag:'div', children:[ | ||
71 | {tag:'div', id:this.getId('previewDiv'), html:"preview"} | ||
72 | ]} | ||
73 | ]}, | ||
74 | {tag:'div', cls:'step_2', id:this.getId('step_2'), children:[ | ||
75 | {tag:'div', children:[ | ||
76 | {tag:'h4', html:"done"} | ||
77 | ]} | ||
78 | ]} | ||
79 | ]}, | ||
80 | {tag:'div', cls:'importOptionsButtons', children:[ | ||
81 | {tag:'table', children:[ | ||
82 | {tag:'tbody', children:[ | ||
83 | {tag:'tr', children:[ | ||
84 | {tag:'td', html:' '}, | ||
85 | {tag:'td', children:[ | ||
86 | {tag:'div', id:this.getId('backActionButton')} | ||
87 | ]}, | ||
88 | {tag:'td', html:' '}, | ||
89 | {tag:'td', children:[ | ||
90 | {tag:'div', id:this.getId('nextActionButton')} | ||
91 | ]}, | ||
92 | {tag:'td', html:' '} | ||
93 | ]} | ||
94 | ]} | ||
95 | ]} | ||
96 | ]} | ||
97 | ]}); | ||
98 | |||
99 | this.updateSteps(); | ||
100 | |||
101 | this.setBackButton(new YAHOO.ext.Button(this.getDom('backActionButton'), {text:"back", handler:this.backAction, scope:this})); | ||
102 | this.setNextButton(new YAHOO.ext.Button(this.getDom('nextActionButton'), {text:"next", handler:this.nextAction, scope:this})); | ||
103 | |||
104 | this.getElement('step_0').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show() | ||
105 | this.getElement('step_1').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
106 | this.getElement('step_2').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
107 | //MochiKit.Logging.logDebug("<<< Import.ClipperzImportComponent.render"); | ||
108 | }, | ||
109 | |||
110 | //------------------------------------------------------------------------- | ||
111 | |||
112 | 'nextAction': function() { | ||
113 | switch (this.currentStep()) { | ||
114 | case 0: //-> 1 | ||
115 | this.previewValues(); | ||
116 | break; | ||
117 | case 1: //-> 2 | ||
118 | this.importValues(); | ||
119 | break; | ||
120 | } | ||
121 | }, | ||
122 | |||
123 | //------------------------------------------------------------------------- | ||
124 | |||
125 | 'deferredPreviewValues': function() { | ||
126 | var deferredResult; | ||
127 | |||
128 | deferredResult = new MochiKit.Async.Deferred(); | ||
129 | deferredResult.addCallback(MochiKit.Base.bind(function(res) { | ||
130 | this.startProcessing(); | ||
131 | |||
132 | return res; | ||
133 | }, this)); | ||
134 | deferredResult.addCallback(MochiKit.Base.method(this, 'processClipperzValues')); | ||
135 | deferredResult.addCallback(MochiKit.Base.method(this, 'setProcessedValues')); | ||
136 | deferredResult.addCallback(MochiKit.Base.method(this, 'previewRecordValues')); | ||
137 | deferredResult.addCallback(MochiKit.Base.bind(function(res) { | ||
138 | this.processingDone(); | ||
139 | this.getElement('step_0').hide(); | ||
140 | this.getElement('step_1').show(); | ||
141 | this.backButton().enable(); | ||
142 | |||
143 | return res; | ||
144 | }, this)); | ||
145 | // deferredResult.addErrback(MochiKit.Base.bind(function() { | ||
146 | // this.processingAborted(); | ||
147 | // }, this)) | ||
148 | deferredResult.callback(this.textAreaContent()); | ||
149 | |||
150 | return deferredResult; | ||
151 | }, | ||
152 | |||
153 | //------------------------------------------------------------------------- | ||
154 | |||
155 | 'processClipperzValues': function(someData) { | ||
156 | var deferredResult; | ||
157 | |||
158 | deferredResult = new MochiKit.Async.Deferred(); | ||
159 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.processClipperzValues - 1: " + res); return res;}); | ||
160 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'parseImportData'); | ||
161 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.processClipperzValues - 2: " + res); return res;}); | ||
162 | deferredResult.addCallback(Clipperz.Base.evalJSON); | ||
163 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.processClipperzValues - 3: " + res); return res;}); | ||
164 | deferredResult.addCallback(function(res) { | ||
165 | return Clipperz.NotificationCenter.deferredNotification(this, 'updatedProgressState', {steps:(res.length)}, res); | ||
166 | }) | ||
167 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.processClipperzValues - 4: " + res); return res;}); | ||
168 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'previewImportData'); | ||
169 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.processClipperzValues - 5: " + res); return res;}); | ||
170 | deferredResult.addCallback(MochiKit.Base.bind(function(someClipperzValues) { | ||
171 | var innerDeferredResult; | ||
172 | var records; | ||
173 | var i,c; | ||
174 | |||
175 | innerDeferredResult = new MochiKit.Async.Deferred(); | ||
176 | records = []; | ||
177 | |||
178 | c = someClipperzValues.length; | ||
179 | for(i=0; i<c; i++) { | ||
180 | innerDeferredResult.addCallback(MochiKit.Async.wait, 0.2); | ||
181 | innerDeferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {}); | ||
182 | innerDeferredResult.addCallback(MochiKit.Base.bind(function(someRecords, someData) { | ||
183 | var record; | ||
184 | var recordVersion; | ||
185 | |||
186 | //MochiKit.Logging.logDebug("=== someData: " + Clipperz.Base.serializeJSON(someData)); | ||
187 | record = new Clipperz.PM.DataModel.Record({user:this.user()}); | ||
188 | record.setLabel(someData['label']); | ||
189 | record.setShouldProcessData(true); | ||
190 | record.processData(someData); | ||
191 | |||
192 | someRecords.push(record); | ||
193 | |||
194 | return someRecords; | ||
195 | }, this), records, someClipperzValues[i]); | ||
196 | } | ||
197 | innerDeferredResult.addCallback(MochiKit.Async.succeed, records); | ||
198 | innerDeferredResult.callback(); | ||
199 | |||
200 | return innerDeferredResult; | ||
201 | }, this)); | ||
202 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.processClipperzValues - 6: " + res); return res;}); | ||
203 | deferredResult.callback(someData); | ||
204 | |||
205 | return deferredResult; | ||
206 | }, | ||
207 | |||
208 | |||
209 | //------------------------------------------------------------------------- | ||
210 | __syntaxFix__: "syntax fix" | ||
211 | }); | ||
212 | |||