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/RecordDetail/MainComponent.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/RecordDetail/MainComponent.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Components/RecordDetail/MainComponent.js | 758 |
1 files changed, 758 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/MainComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/MainComponent.js new file mode 100644 index 0000000..53bf9c5 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/MainComponent.js | |||
@@ -0,0 +1,758 @@ | |||
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.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.RecordDetail.MainComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.RecordDetail.MainComponent.superclass.constructor.call(this, anElement, args); | ||
40 | |||
41 | //this._element = args.element; | ||
42 | this._user = args.user; | ||
43 | this._editMode = args.editMode || 'VIEW'; //[ 'VIEW' | 'EDIT' ] | ||
44 | this._mainPanel = args.mainPanel; | ||
45 | |||
46 | this._record = null; | ||
47 | this._editComponents = []; | ||
48 | this._addFieldButton = null; | ||
49 | |||
50 | this._enableSaveButton = true; | ||
51 | this._shouldShowLoginInfo = (Clipperz.PM.Proxy.defaultProxy.isReadOnly() ? false : true); | ||
52 | |||
53 | //this._mainLayoutManager = null; | ||
54 | //this._layoutRegion = null; | ||
55 | |||
56 | Clipperz.NotificationCenter.register(null, 'loadingRecordData', this, 'render'); | ||
57 | Clipperz.NotificationCenter.register(null, 'decryptingRecordData', this, 'render'); | ||
58 | Clipperz.NotificationCenter.register(null, 'loadingRecordVersionData', this, 'render'); | ||
59 | Clipperz.NotificationCenter.register(null, 'decryptingRecordVersionData', this, 'render'); | ||
60 | Clipperz.NotificationCenter.register(null, 'setupDone', this, 'render'); | ||
61 | Clipperz.NotificationCenter.register(null, 'switchLanguage', this, 'render'); | ||
62 | |||
63 | this.render(); | ||
64 | |||
65 | return this; | ||
66 | } | ||
67 | |||
68 | //============================================================================= | ||
69 | |||
70 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.MainComponent, Clipperz.PM.Components.BaseComponent, { | ||
71 | |||
72 | 'toString': function() { | ||
73 | return "Clipperz.PM.Components.RecordDetail.MainComponent component"; | ||
74 | }, | ||
75 | |||
76 | //------------------------------------------------------------------------- | ||
77 | |||
78 | 'editMode': function() { | ||
79 | return this._editMode; | ||
80 | }, | ||
81 | |||
82 | 'setEditMode': function(aValue, aButtonElement, shouldSkipComponentSynchronization) { | ||
83 | //MochiKit.Logging.logDebug(">>> MainComponent.setEditingMode"); | ||
84 | this.scrollToTop(); | ||
85 | |||
86 | if (aValue == 'VIEW') { | ||
87 | if (shouldSkipComponentSynchronization == true) { | ||
88 | this.exitModalView(); | ||
89 | } else { | ||
90 | this.synchronizeComponentValues(); | ||
91 | if (this.record().hasPendingChanges()) { | ||
92 | if (this.record().isBrandNew()) { | ||
93 | this.record().removeEmptyFields(); | ||
94 | } | ||
95 | this.saveCurrentRecordChanges(aButtonElement); | ||
96 | } else { | ||
97 | if (this.record().isBrandNew()) { | ||
98 | this.record().user().removeRecord(this.record()); | ||
99 | } | ||
100 | this.exitModalView(); | ||
101 | } | ||
102 | } | ||
103 | } else if (aValue == 'EDIT') { | ||
104 | this.enterModalView(); | ||
105 | } else { | ||
106 | //???? | ||
107 | } | ||
108 | |||
109 | this._editMode = aValue; | ||
110 | this.render(); | ||
111 | }, | ||
112 | |||
113 | //------------------------------------------------------------------------- | ||
114 | |||
115 | 'user': function() { | ||
116 | return this._user; | ||
117 | }, | ||
118 | |||
119 | //------------------------------------------------------------------------- | ||
120 | |||
121 | 'mainPanel': function() { | ||
122 | return this._mainPanel; | ||
123 | }, | ||
124 | |||
125 | //------------------------------------------------------------------------- | ||
126 | |||
127 | 'render': function() { | ||
128 | //MochiKit.Logging.logDebug(">>> RecordDetail.MainComponent.render"); | ||
129 | this.setEnableSaveButton(true); | ||
130 | this.element().update(""); | ||
131 | |||
132 | if (this.record() == null) { | ||
133 | if (MochiKit.Base.keys(this.user().records()).length == 0) { | ||
134 | this.renderWithNoRecordAtAll(); | ||
135 | } else { | ||
136 | this.renderWithNoSelectedRecord(); | ||
137 | } | ||
138 | } else { | ||
139 | this.renderWithSelectedRecord(); | ||
140 | } | ||
141 | //MochiKit.Logging.logDebug("<<< RecordDetail.MainComponent.render"); | ||
142 | }, | ||
143 | |||
144 | //------------------------------------------------------------------------- | ||
145 | |||
146 | 'renderWithNoRecordAtAll': function() { | ||
147 | //MochiKit.Logging.logDebug(">>> RecordDetail.MainComponent.renderWithNoRecordAtAll"); | ||
148 | Clipperz.YUI.DomHelper.append(this.element().dom, | ||
149 | {tag:'form', cls:'noRecordAtAllFORM', children:[ | ||
150 | {tag:'div', cls:'recordTitleBlock', children:[ | ||
151 | {tag:'h2', id:'recordTitle', htmlString:Clipperz.PM.Strings['recordDetailNoRecordAtAllTitle']} | ||
152 | ]}, | ||
153 | {tag:'table', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
154 | {tag:'tbody', children:[ | ||
155 | {tag:'tr', children:[ | ||
156 | {tag:'td', colspan:'5', children:[ | ||
157 | {tag:'div', cls:'recordDetailDescriptionBox', htmlString:Clipperz.PM.Strings['recordDetailNoRecordAtAllDescription']} | ||
158 | ]} | ||
159 | ]} | ||
160 | ]} | ||
161 | ]} | ||
162 | ]} | ||
163 | ); | ||
164 | //MochiKit.Logging.logDebug("<<< RecordDetail.MainComponent.renderWithNoRecordAtAll"); | ||
165 | }, | ||
166 | |||
167 | //------------------------------------------------------------------------- | ||
168 | |||
169 | 'renderWithNoSelectedRecord': function() { | ||
170 | //MochiKit.Logging.logDebug(">>> RecordDetail.MainComponent.renderWithNoSelectedRecord"); | ||
171 | Clipperz.YUI.DomHelper.append(this.element().dom, | ||
172 | {tag:'form', cls:'noRecordSelectedFORM', children:[ | ||
173 | {tag:'div', cls:'recordTitleBlock', children:[ | ||
174 | {tag:'h2', id:'recordTitle', htmlString:Clipperz.PM.Strings['recordDetailNoRecordSelectedTitle']} | ||
175 | ]}, | ||
176 | {tag:'table', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
177 | {tag:'tbody', children:[ | ||
178 | {tag:'tr', children:[ | ||
179 | {tag:'td', colspan:'5', children:[ | ||
180 | {tag:'div', cls:'recordDetailDescriptionBox', htmlString:Clipperz.PM.Strings['recordDetailNoRecordSelectedDescription']} | ||
181 | ]} | ||
182 | ]}, | ||
183 | {tag:'tr', colspan:'5', children:[ | ||
184 | {tag:'td', colspan:'5', children:this.loginInfo()} | ||
185 | ]} | ||
186 | ]} | ||
187 | ]} | ||
188 | ]} | ||
189 | ); | ||
190 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithNoSelectedRecord - 1"); | ||
191 | |||
192 | if (MochiKit.DOM.getElement('fullLoginHistoryLink') != null) { | ||
193 | MochiKit.Signal.connect('fullLoginHistoryLink', 'onclick', this, 'showLoginHistoryPanel'); | ||
194 | } | ||
195 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithNoSelectedRecord - 2"); | ||
196 | |||
197 | if (MochiKit.DOM.getElement('offlineCopyDownloadWarningLink') != null) { | ||
198 | MochiKit.Signal.connect('offlineCopyDownloadWarningLink', 'onclick', this, 'showDownloadOfflineCopyPanel'); | ||
199 | } | ||
200 | //MochiKit.Logging.logDebug("<<< RecordDetail.MainComponent.renderWithNoSelectedRecord"); | ||
201 | }, | ||
202 | |||
203 | //------------------------------------------------------------------------- | ||
204 | |||
205 | 'renderWithSelectedRecord': function() { | ||
206 | //MochiKit.Logging.logDebug(">>> RecordDetail.MainComponent.renderWithSelectedRecord"); | ||
207 | if (this.record().shouldLoadData() === true) { | ||
208 | // this.renderWithSelectedRecordLoading(); | ||
209 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecord - 1.1"); | ||
210 | this.renderWhileProcessingWithMessage(Clipperz.PM.Strings['recordDetailLoadingRecordMessage']); | ||
211 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecord - 1.2"); | ||
212 | } else if (this.record().shouldDecryptData() === true) { | ||
213 | // this.renderWithSelectedRecordDecrypting(); | ||
214 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecord - 2.1"); | ||
215 | this.renderWhileProcessingWithMessage(Clipperz.PM.Strings['recordDetailDecryptingRecordMessage']); | ||
216 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecord - 2.2"); | ||
217 | } else if (this.record().currentVersion().shouldLoadData() === true) { | ||
218 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecord - 3.1"); | ||
219 | this.renderWhileProcessingWithMessage(Clipperz.PM.Strings['recordDetailLoadingRecordVersionMessage']); | ||
220 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecord - 3.2"); | ||
221 | } else if (this.record().currentVersion().shouldDecryptData() === true) { | ||
222 | // this.renderWithSelectedRecordCurrentVersionDecrypting(); | ||
223 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecord - 4.1"); | ||
224 | this.renderWhileProcessingWithMessage(Clipperz.PM.Strings['recordDetailDecryptingRecordVersionMessage']); | ||
225 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecord - 4.2"); | ||
226 | } else { | ||
227 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecord - 5.1"); | ||
228 | this.renderWithSelectedRecordData(); | ||
229 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecord - 5.2"); | ||
230 | } | ||
231 | //MochiKit.Logging.logDebug("<<< RecordDetail.MainComponent.renderWithSelectedRecord"); | ||
232 | }, | ||
233 | |||
234 | //......................................................................... | ||
235 | |||
236 | 'renderWhileProcessingWithMessage': function(aMessage) { | ||
237 | //MochiKit.Logging.logDebug(">>> RecordDetail.MainComponent.renderWhileProcessingWithMessage"); | ||
238 | Clipperz.YUI.DomHelper.append(this.element().dom, | ||
239 | {tag:'form', cls:'processingRecordFORM', children:[ | ||
240 | {tag:'div', cls:'recordTitleBlock', children:[ | ||
241 | {tag:'h2', id:'recordTitle', html:this.record().label()} | ||
242 | ]}, | ||
243 | {tag:'table', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
244 | {tag:'tbody', children:[ | ||
245 | {tag:'tr', cls:'recordTR', children:[ | ||
246 | {tag:'td', colspan:'5', children:[ | ||
247 | {tag:'div', cls:'recordDetailDescriptionBox', children:[ | ||
248 | {tag:'h5', cls:'recordLoadingMessage', html:aMessage} | ||
249 | ]} | ||
250 | ]} | ||
251 | ]} | ||
252 | ]} | ||
253 | ]} | ||
254 | ]} | ||
255 | ); | ||
256 | //MochiKit.Logging.logDebug("<<< RecordDetail.MainComponent.renderWhileProcessingWithMessage"); | ||
257 | }, | ||
258 | |||
259 | //......................................................................... | ||
260 | /* | ||
261 | 'renderWithSelectedRecordLoading': function() { | ||
262 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', cls:'', style:'border:1px solid red; padding: 20px;', children:[ | ||
263 | {tag:'div', cls:'Clipprez_RecordDetailTitle', children:[ | ||
264 | {tag:'h3', html:this.record().label()}, | ||
265 | {tag:'h3', html:"loading"} | ||
266 | ]} | ||
267 | ]}); | ||
268 | }, | ||
269 | |||
270 | //......................................................................... | ||
271 | |||
272 | 'renderWithSelectedRecordDecrypting': function() { | ||
273 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', cls:'', style:'border:1px solid red; padding: 20px;', children:[ | ||
274 | {tag:'div', cls:'Clipprez_RecordDetailTitle', children:[ | ||
275 | {tag:'h3', html:this.record().label()}, | ||
276 | {tag:'h3', html:"decrypting ... "} | ||
277 | ]} | ||
278 | ]}); | ||
279 | }, | ||
280 | |||
281 | //......................................................................... | ||
282 | |||
283 | 'renderWithSelectedRecordCurrentVersionDecrypting': function() { | ||
284 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', cls:'', style:'border:1px solid red; padding: 20px;', children:[ | ||
285 | {tag:'div', cls:'Clipprez_RecordDetailTitle', children:[ | ||
286 | {tag:'h3', html:this.record().label()}, | ||
287 | {tag:'h3', html:"decrypting version ... "} | ||
288 | ]} | ||
289 | ]}); | ||
290 | }, | ||
291 | */ | ||
292 | //------------------------------------------------------------------------- | ||
293 | |||
294 | 'renderWithErrorMessage': function(anErrorMessage) { | ||
295 | //MochiKit.Logging.logDebug(">>> RecordDetail.MainComponent.renderWithErrorMessage"); | ||
296 | this.element().update(""); | ||
297 | |||
298 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithErrorMessage - 1"); | ||
299 | Clipperz.YUI.DomHelper.append(this.element().dom, | ||
300 | {tag:'form', cls:'errorMessageFORM', children:[ | ||
301 | {tag:'div', cls:'recordTitleBlock', children:[ | ||
302 | {tag:'h2', id:'recordTitle', html:this.record().label()} | ||
303 | ]}, | ||
304 | {tag:'table', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
305 | {tag:'tbody', children:[ | ||
306 | {tag:'tr', cls:'recordTR', children:[ | ||
307 | {tag:'td', colspan:'5', children:[ | ||
308 | {tag:'div', cls:'recordDetailDescriptionBox loadingError', children:[ | ||
309 | {tag:'h5', htmlString:Clipperz.PM.Strings['recordDetailLoadingErrorMessageTitle']}, | ||
310 | {tag:'p', html:anErrorMessage.message} | ||
311 | ]} | ||
312 | ]} | ||
313 | ]} | ||
314 | ]} | ||
315 | ]} | ||
316 | ]} | ||
317 | ); | ||
318 | //MochiKit.Logging.logDebug("<<< RecordDetail.MainComponent.renderWithErrorMessage"); | ||
319 | }, | ||
320 | |||
321 | //------------------------------------------------------------------------- | ||
322 | |||
323 | 'renderWithSelectedRecordData': function() { | ||
324 | varcolumns; | ||
325 | |||
326 | this.resetEditComponents(); | ||
327 | |||
328 | columns = [ | ||
329 | {tag:'td', width:'25', html:' '}, | ||
330 | {tag:'td', width:'25%', htmlString:Clipperz.PM.Strings['recordDetailLabelFieldColumnLabel']}, | ||
331 | {tag:'td', width:'3', html:' '}, | ||
332 | {tag:'td', /*width:'80%',*/ htmlString:Clipperz.PM.Strings['recordDetailDataFieldColumnLabel']} | ||
333 | ]; | ||
334 | |||
335 | if (this.editMode() == 'EDIT') { | ||
336 | columns.push({tag:'td', /*width:'55',*/ htmlString:Clipperz.PM.Strings['recordDetailTypeFieldColumnLabel']}) | ||
337 | } | ||
338 | |||
339 | //MochiKit.Logging.logDebug(">>> RecordDetail.MainComponent.renderWithSelectedRecordData"); | ||
340 | Clipperz.YUI.DomHelper.append(this.element().dom, | ||
341 | {tag:'form', cls:'recordDataFORM', children:[ | ||
342 | {tag:'div', cls:'recordTitleBlock', id:this.getId('title')}, | ||
343 | {tag:'div', id:'recordDetailDataBox', cls:'recordDetailDataBox', children:[ | ||
344 | |||
345 | {tag:'table', width:'100%', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
346 | {tag:'tbody', children:[ | ||
347 | {tag:'tr', children:[ | ||
348 | {tag:'td', width:'5', html:" "}, | ||
349 | {tag:'td', children:[ | ||
350 | |||
351 | {tag:'table', cls:'recordDetailDataBoxTABLE', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
352 | {tag:'tbody', id:this.getId('tbody'), children:[ | ||
353 | {tag:'tr', /*cls:'recordNoteTR',*/ children:[ | ||
354 | {tag:'td', colspan:'5', id:this.getId('notes')} | ||
355 | ]}, | ||
356 | {tag:'tr', cls:'recordFieldsTR', children:columns /*[ | ||
357 | {tag:'td', width:'25', html:' '}, | ||
358 | {tag:'td', width:'25%', htmlString:Clipperz.PM.Strings['recordDetailLabelFieldColumnLabel']}, | ||
359 | {tag:'td', width:'3', html:' '}, | ||
360 | {tag:'td', / *width:'80%',* / htmlString:Clipperz.PM.Strings['recordDetailDataFieldColumnLabel']}, | ||
361 | {tag:'td', / *width:'55',* / htmlString:Clipperz.PM.Strings['recordDetailTypeFieldColumnLabel']} | ||
362 | ] */} | ||
363 | ]} | ||
364 | ]}, | ||
365 | {tag:'div', cls:'addFieldButton', id:this.getId('addField'), children:[ | ||
366 | {tag:'div', id:this.getId('addFieldButton')} | ||
367 | ]}, | ||
368 | {tag:'div', id:this.getId('directLogins')}, | ||
369 | {tag:'div', id:this.getId('footer')} | ||
370 | |||
371 | ]} | ||
372 | ]} | ||
373 | ]} | ||
374 | ]} | ||
375 | |||
376 | ]} | ||
377 | ]} | ||
378 | ); | ||
379 | |||
380 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecordData - 1"); | ||
381 | |||
382 | new Clipperz.PM.Components.RecordDetail.TitleComponent(this.getElement('title'), {mainComponent:this}); | ||
383 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecordData - 2"); | ||
384 | new Clipperz.PM.Components.RecordDetail.NotesComponent(this.getElement('notes'), {mainComponent:this}); | ||
385 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecordData - 3"); | ||
386 | new Clipperz.PM.Components.RecordDetail.DirectLoginsComponent(this.getElement('directLogins'), {mainComponent:this}); | ||
387 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecordData - 4"); | ||
388 | new Clipperz.PM.Components.RecordDetail.HeaderComponent(this.getElement('footer'), {mainComponent:this}); | ||
389 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecordData - 5"); | ||
390 | MochiKit.Iter.forEach(MochiKit.Base.values(this.record().currentVersion().fields()), this.appendFieldComponent, this); | ||
391 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecordData - 6"); | ||
392 | this.setAddFieldButton(new YAHOO.ext.Button(this.getDom('addFieldButton'), {text:Clipperz.PM.Strings['recordDetailAddFieldButtonLabel'], handler:this.addNewRecordField, scope:this})); | ||
393 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecordData - 7"); | ||
394 | |||
395 | this.update(); | ||
396 | |||
397 | //MochiKit.Logging.logDebug("<<< RecordDetail.MainComponent.renderWithSelectedRecordData"); | ||
398 | }, | ||
399 | |||
400 | //------------------------------------------------------------------------- | ||
401 | |||
402 | 'editComponents': function() { | ||
403 | return this._editComponents; | ||
404 | }, | ||
405 | |||
406 | 'resetEditComponents': function() { | ||
407 | this._editComponents = []; | ||
408 | }, | ||
409 | |||
410 | 'addEditComponent': function(aValue) { | ||
411 | this.editComponents().push(aValue); | ||
412 | }, | ||
413 | |||
414 | 'removeEditComponent': function(aValue) { | ||
415 | Clipperz.Base.removeFromArray(this.editComponents(), aValue); | ||
416 | }, | ||
417 | |||
418 | //------------------------------------------------------------------------- | ||
419 | |||
420 | 'record': function() { | ||
421 | return this._record; | ||
422 | }, | ||
423 | |||
424 | 'setRecord': function(aValue) { | ||
425 | varresult; | ||
426 | |||
427 | //MochiKit.Logging.logDebug(">>> MainComponent.setRecord") | ||
428 | if (this._record != aValue) { | ||
429 | vardeferredResult; | ||
430 | |||
431 | deferredResult = new MochiKit.Async.Deferred(); | ||
432 | |||
433 | if ((this._record != null) && (this.editMode() == 'EDIT')) { | ||
434 | this.synchronizeComponentValues(); | ||
435 | deferredResult.addCallback(MochiKit.Base.method(this._record, 'saveChanges')); | ||
436 | } | ||
437 | |||
438 | this._record = aValue; | ||
439 | |||
440 | if (aValue != null) { | ||
441 | this.setShouldShowLoginInfo(false); | ||
442 | deferredResult.addCallback(MochiKit.Base.method(this._record, 'deferredData')); | ||
443 | } | ||
444 | deferredResult.addCallbacks( | ||
445 | MochiKit.Base.method(this, 'render'), | ||
446 | MochiKit.Base.method(this, 'renderWithErrorMessage') | ||
447 | ); | ||
448 | deferredResult.callback(); | ||
449 | this.scrollToTop(); | ||
450 | |||
451 | result = deferredResult; | ||
452 | } else { | ||
453 | result = MochiKit.Async.success(); | ||
454 | } | ||
455 | //MochiKit.Logging.logDebug("<<< MainComponent.setRecord") | ||
456 | |||
457 | return result; | ||
458 | }, | ||
459 | |||
460 | //------------------------------------------------------------------------- | ||
461 | |||
462 | 'saveCurrentRecordChanges': function(aButtonElement) { | ||
463 | var deferred; | ||
464 | var currentNumberOfRecords; | ||
465 | |||
466 | deferred = new MochiKit.Async.Deferred(); | ||
467 | deferred.addCallback(MochiKit.Base.method(Clipperz.PM.Components.MessageBox(), 'deferredShow'), | ||
468 | { | ||
469 | title:Clipperz.PM.Strings['recordDetailSavingChangesMessagePanelInitialTitle'], | ||
470 | text:Clipperz.PM.Strings['recordDetailSavingChangesMessagePanelInitialText'], | ||
471 | width:240, | ||
472 | showProgressBar:true, | ||
473 | showCloseButton:false, | ||
474 | steps:6 | ||
475 | }, | ||
476 | aButtonElement.dom | ||
477 | ); | ||
478 | deferred.addCallback(MochiKit.Base.method(this, 'exitModalView')); | ||
479 | deferred.addCallback(MochiKit.Base.method(this.record(), 'saveChanges')); | ||
480 | deferred.addCallback(Clipperz.NotificationCenter.deferredNotification, this.record(), 'recordUpdated'); | ||
481 | deferred.addCallback(function(res) { | ||
482 | Clipperz.PM.Components.MessageBox().hide(YAHOO.ext.Element.get('main')); | ||
483 | return res; | ||
484 | }); | ||
485 | |||
486 | currentNumberOfRecords = MochiKit.Base.keys(this.user().records()).length; | ||
487 | if ((this.record().isBrandNew()) && (this.user().preferences().shouldShowDonationPanel()) && (currentNumberOfRecords >= 5)) { | ||
488 | deferred.addCallback(Clipperz.PM.showDonationSplashScreen, this.user(), 'recordListAddRecordButton'); | ||
489 | } | ||
490 | |||
491 | deferred.callback(); | ||
492 | }, | ||
493 | |||
494 | //------------------------------------------------------------------------- | ||
495 | |||
496 | 'update': function(anEvent) { | ||
497 | if (this.editMode() == 'EDIT') { | ||
498 | this.updateEditMode(); | ||
499 | } else if (this.editMode() == 'VIEW') { | ||
500 | this.updateViewMode(); | ||
501 | } | ||
502 | |||
503 | MochiKit.Iter.forEach(this.editComponents(), MochiKit.Base.methodcaller('update')); | ||
504 | }, | ||
505 | |||
506 | //------------------------------------------------------------------------- | ||
507 | |||
508 | 'updateViewMode': function() { | ||
509 | this.addFieldButton().hide(); | ||
510 | }, | ||
511 | |||
512 | //------------------------------------------------------------------------- | ||
513 | |||
514 | 'updateEditMode': function() { | ||
515 | this.addFieldButton().show(); | ||
516 | }, | ||
517 | |||
518 | //------------------------------------------------------------------------- | ||
519 | |||
520 | 'appendFieldComponent': function(aRecordField) { | ||
521 | //MochiKit.Logging.logDebug(">>> MainComponent.appendFieldComponent"); | ||
522 | new Clipperz.PM.Components.RecordDetail.FieldComponent( | ||
523 | Clipperz.YUI.DomHelper.append(this.getDom('tbody'), {tag:'tr'}, true), | ||
524 | {recordField:aRecordField, mainComponent:this} | ||
525 | ); | ||
526 | //MochiKit.Logging.logDebug("<<< MainComponent.appendFieldComponent"); | ||
527 | }, | ||
528 | |||
529 | //------------------------------------------------------------------------- | ||
530 | |||
531 | 'removeField': function(aFieldComponent) { | ||
532 | varrecordField; | ||
533 | |||
534 | //MochiKit.Logging.logDebug(">>> MainComponent.removeField") | ||
535 | recordField = aFieldComponent.recordField(); | ||
536 | this.removeEditComponent(aFieldComponent); | ||
537 | aFieldComponent.destroy(); | ||
538 | this.record().removeField(recordField); | ||
539 | |||
540 | Clipperz.NotificationCenter.notify(this.record(), 'removedField'); | ||
541 | //MochiKit.Logging.logDebug("<<< MainComponent.removeField") | ||
542 | }, | ||
543 | |||
544 | //------------------------------------------------------------------------- | ||
545 | |||
546 | 'synchronizeComponentValues': function() { | ||
547 | MochiKit.Iter.forEach(this.editComponents(), MochiKit.Base.methodcaller('synchronizeComponentValues')); | ||
548 | }, | ||
549 | |||
550 | //========================================================================= | ||
551 | |||
552 | 'addFieldButton': function() { | ||
553 | return this._addFieldButton; | ||
554 | }, | ||
555 | |||
556 | 'setAddFieldButton': function(aValue) { | ||
557 | this._addFieldButton = aValue; | ||
558 | }, | ||
559 | |||
560 | 'addNewRecordField': function() { | ||
561 | varnewField; | ||
562 | |||
563 | newField = this.record().addNewField(); | ||
564 | this.appendFieldComponent(newField); | ||
565 | |||
566 | Clipperz.NotificationCenter.notify(this.record(), 'addNewRecordField'); | ||
567 | }, | ||
568 | |||
569 | //------------------------------------------------------------------------- | ||
570 | |||
571 | 'enterModalView': function() { | ||
572 | /* | ||
573 | if (this.user().preferences().useSafeEditMode()) { | ||
574 | var headerMaskElement; | ||
575 | var verticalMaskElement; | ||
576 | |||
577 | headerMaskElement = YAHOO.ext.Element.get('recordDetailEditModeHeaderMask'); | ||
578 | headerMaskElement.show().mask(); | ||
579 | |||
580 | verticalMaskElement = YAHOO.ext.Element.get('recordDetailEditModeVerticalMask'); | ||
581 | verticalMaskElement.show().mask(); | ||
582 | } | ||
583 | */ | ||
584 | this.mainPanel().enterModalView(); | ||
585 | }, | ||
586 | |||
587 | //------------------------------------------------------------------------- | ||
588 | |||
589 | 'exitModalView': function() { | ||
590 | /* | ||
591 | if (this.user().preferences().useSafeEditMode()) { | ||
592 | var headerMaskElement; | ||
593 | var verticalMaskElement; | ||
594 | |||
595 | headerMaskElement = YAHOO.ext.Element.get('recordDetailEditModeHeaderMask'); | ||
596 | headerMaskElement.unmask(); | ||
597 | headerMaskElement.hide(); | ||
598 | |||
599 | verticalMaskElement = YAHOO.ext.Element.get('recordDetailEditModeVerticalMask'); | ||
600 | verticalMaskElement.unmask(); | ||
601 | verticalMaskElement.hide(); | ||
602 | } | ||
603 | */ | ||
604 | this.mainPanel().exitModalView(); | ||
605 | }, | ||
606 | |||
607 | //------------------------------------------------------------------------- | ||
608 | |||
609 | 'enableSaveButton': function() { | ||
610 | return this._enableSaveButton; | ||
611 | }, | ||
612 | |||
613 | 'setEnableSaveButton': function(aValue) { | ||
614 | this._enableSaveButton = aValue; | ||
615 | }, | ||
616 | |||
617 | //------------------------------------------------------------------------- | ||
618 | |||
619 | 'scrollToTop': function() { | ||
620 | YAHOO.ext.Element.get('recordTitleTopBlock').scrollIntoView(document.body); | ||
621 | }, | ||
622 | |||
623 | //------------------------------------------------------------------------- | ||
624 | |||
625 | 'loginInfo': function() { | ||
626 | varresult; | ||
627 | |||
628 | if (this.shouldShowLoginInfo() == true) { | ||
629 | // && (typeof(this.user().loginInfo()['latest']) != 'undefined')) { | ||
630 | varimageExtension; | ||
631 | var currentConnectionText; | ||
632 | var currentIP; | ||
633 | var contentChildren; | ||
634 | |||
635 | result = []; | ||
636 | contentChildren = []; | ||
637 | |||
638 | imageExtension = (Clipperz_IEisBroken == true) ? 'gif': 'png'; | ||
639 | |||
640 | contentChildren.push({tag:'h4', valign:'top', htmlString:Clipperz.PM.Strings['WELCOME_BACK']}); | ||
641 | |||
642 | currentIP = (this.user().loginInfo()['current']['ip'].match(/^\d{1,3}(.\d{1,3}){3}$/)) ? this.user().loginInfo()['current']['ip'] : Clipperz.PM.Strings['unknown_ip']; | ||
643 | currentConnectionText = Clipperz.PM.Strings['currentConnectionText']; | ||
644 | currentConnectionText = currentConnectionText.replace(/__ip__/, "<b>" + Clipperz.Base.sanitizeString(this.user().loginInfo()['current']['ip']) + "</b>"); | ||
645 | currentConnectionText = currentConnectionText.replace(/__country__/, "<b>" + Clipperz.PM.Strings['countries'][Clipperz.Base.sanitizeString(this.user().loginInfo()['current']['country'])] + "</b>"); | ||
646 | currentConnectionText = currentConnectionText.replace(/__browser__/, "<b>" + Clipperz.PM.Strings['browsers'][Clipperz.Base.sanitizeString(this.user().loginInfo()['current']['browser'])] + "</b>"); | ||
647 | currentConnectionText = currentConnectionText.replace(/__operatingSystem__/, "<b>" + Clipperz.PM.Strings['operatingSystems'][Clipperz.Base.sanitizeString(this.user().loginInfo()['current']['operatingSystem'])] + "</b>"); | ||
648 | |||
649 | contentChildren.push( | ||
650 | {tag:'div', cls:'loginInfo_now', children:[ | ||
651 | {tag:'div', cls:'text', htmlString:currentConnectionText}, | ||
652 | {tag:'div', cls:'icons', children:[ | ||
653 | {tag:'img', title:Clipperz.PM.Strings['countries'][Clipperz.Base.sanitizeString(this.user().loginInfo()['current']['country'])], cls:'flag', src:Clipperz.PM.Strings['icons_baseUrl'] + "/flags/" + Clipperz.Base.sanitizeString(this.user().loginInfo()['current']['country']).toLowerCase() + "." + imageExtension, width:'32', height:'32'}, | ||
654 | {tag:'img', title:Clipperz.PM.Strings['browsers'][Clipperz.Base.sanitizeString(this.user().loginInfo()['current']['browser'])], src:Clipperz.PM.Strings['icons_baseUrl'] + "/browsers/" + Clipperz.Base.sanitizeString(this.user().loginInfo()['current']['browser']).toLowerCase() + "." + imageExtension, width:'32', height:'32'}, | ||
655 | {tag:'img', title:Clipperz.PM.Strings['operatingSystems'][Clipperz.Base.sanitizeString(this.user().loginInfo()['current']['operatingSystem'])], src:Clipperz.PM.Strings['icons_baseUrl'] + "/operatingSystems/" + Clipperz.Base.sanitizeString(this.user().loginInfo()['current']['operatingSystem']).toLowerCase() + "." + imageExtension, width:'32', height:'32'} | ||
656 | ]} | ||
657 | ]} | ||
658 | ); | ||
659 | |||
660 | if (typeof(this.user().loginInfo()['latest']) != 'undefined') { | ||
661 | var latestLoginDate; | ||
662 | var elapsedTimeDescription; | ||
663 | var latestIP; | ||
664 | var latestConnectionText; | ||
665 | |||
666 | latestLoginDate = Clipperz.PM.Date.parseDateWithUTCFormat(Clipperz.Base.sanitizeString(this.user().loginInfo()['latest']['date'])); | ||
667 | |||
668 | elapsedTimeDescription = Clipperz.PM.Date.getElapsedTimeDescription(latestLoginDate); | ||
669 | latestIP = (this.user().loginInfo()['latest']['ip'].match(/^\d{1,3}(.\d{1,3}){3}$/)) ? this.user().loginInfo()['latest']['ip'] : Clipperz.PM.Strings['unknown_ip']; | ||
670 | |||
671 | latestConnectionText = Clipperz.PM.Strings['latestConnectionText']; | ||
672 | latestConnectionText = latestConnectionText.replace(/__elapsedTimeDescription__/, "<b>" + elapsedTimeDescription + "</b>"); | ||
673 | latestConnectionText = latestConnectionText.replace(/__time__/, Clipperz.PM.Date.formatDateWithTemplate(latestLoginDate, Clipperz.PM.Strings['fullDate_format'])); | ||
674 | latestConnectionText = latestConnectionText.replace(/__ip__/, "<b>" + Clipperz.Base.sanitizeString(this.user().loginInfo()['latest']['ip']) + "</b>"); | ||
675 | latestConnectionText = latestConnectionText.replace(/__country__/, "<b>" + Clipperz.PM.Strings['countries'][Clipperz.Base.sanitizeString(this.user().loginInfo()['latest']['country'])] + "</b>"); | ||
676 | latestConnectionText = latestConnectionText.replace(/__browser__/, "<b>" + Clipperz.PM.Strings['browsers'][Clipperz.Base.sanitizeString(this.user().loginInfo()['latest']['browser'])] + "</b>"); | ||
677 | latestConnectionText = latestConnectionText.replace(/__operatingSystem__/, "<b>" + Clipperz.PM.Strings['operatingSystems'][Clipperz.Base.sanitizeString(this.user().loginInfo()['latest']['operatingSystem'])] + "</b>"); | ||
678 | |||
679 | |||
680 | contentChildren.push( | ||
681 | {tag:'div', cls:'loginInfo_latest', children:[ | ||
682 | {tag:'div', cls:'inner_header', html:' '}, | ||
683 | {tag:'div', cls:'content', children:[ | ||
684 | {tag:'div', cls:'text', htmlString:latestConnectionText}, | ||
685 | {tag:'div', cls:'icons', children:[ | ||
686 | {tag:'img', title:Clipperz.PM.Strings['countries'][Clipperz.Base.sanitizeString(this.user().loginInfo()['latest']['country'])], cls:'flag', src:Clipperz.PM.Strings['icons_baseUrl'] + "/flags/" + Clipperz.Base.sanitizeString(this.user().loginInfo()['latest']['country']).toLowerCase() + "." + imageExtension, width:'32', height:'32'}, | ||
687 | {tag:'img', title:Clipperz.PM.Strings['browsers'][Clipperz.Base.sanitizeString(this.user().loginInfo()['latest']['browser'])], src:Clipperz.PM.Strings['icons_baseUrl'] + "/browsers/" + Clipperz.Base.sanitizeString(this.user().loginInfo()['latest']['browser']).toLowerCase() + "." + imageExtension, width:'32', height:'32'}, | ||
688 | {tag:'img', title:Clipperz.PM.Strings['operatingSystems'][Clipperz.Base.sanitizeString(this.user().loginInfo()['latest']['operatingSystem'])], src:Clipperz.PM.Strings['icons_baseUrl'] + "/operatingSystems/" + Clipperz.Base.sanitizeString(this.user().loginInfo()['latest']['operatingSystem']).toLowerCase() + "." + imageExtension, width:'32', height:'32'} | ||
689 | ]} | ||
690 | ]}, | ||
691 | {tag:'div', children:[ | ||
692 | {tag:'a', href:'#', id:'fullLoginHistoryLink', htmlString:Clipperz.PM.Strings['fullLoginHistoryLinkLabel']} | ||
693 | ]}, | ||
694 | {tag:'div', cls:'inner_footer', html:' '} | ||
695 | ]} | ||
696 | ); | ||
697 | } | ||
698 | |||
699 | contentChildren.push( | ||
700 | {tag:'table', id:'shouldDownloadOfflineCopyWarningBox', children:[ | ||
701 | {tag:'tbody', width:'100%', children:[ | ||
702 | {tag:'tr', children:[ | ||
703 | {tag:'td', cls:'offlineCopyDownloadWarningIconTD', valign:'top', align:'center', width:'50', children:(this.user().shouldDownloadOfflineCopy() ? [{tag:'img', src:Clipperz.PM.Strings['icons_baseUrl'] + "/misc/offlineCopyWarning.png" , width:'32', height:'32'}]: [])}, | ||
704 | {tag:'td', children:[ | ||
705 | {tag:'div', cls:'offlineCopyDownloadWarning', htmlString:(this.user().shouldDownloadOfflineCopy() ? Clipperz.PM.Strings['offlineCopyDownloadWarning']: Clipperz.PM.Strings['offlineCopyDownloadOk'])} | ||
706 | ]} | ||
707 | ]} | ||
708 | ]} | ||
709 | ]} | ||
710 | ); | ||
711 | |||
712 | |||
713 | result = [{tag:'div', id:'loginInfoWrapper', children:[{tag:'div', id:'loginInfo', children:[ | ||
714 | {tag:'div', cls:'header', html:' '}, | ||
715 | {tag:'div', cls:'content', children:contentChildren}, | ||
716 | {tag:'div', cls:'footer', html:' '} | ||
717 | ]}]}]; | ||
718 | |||
719 | // this.setShouldShowLoginInfo(false); | ||
720 | } else { | ||
721 | resut = []; | ||
722 | } | ||
723 | |||
724 | return result; | ||
725 | }, | ||
726 | |||
727 | //------------------------------------------------------------------------- | ||
728 | |||
729 | 'shouldShowLoginInfo': function() { | ||
730 | return this._shouldShowLoginInfo; | ||
731 | }, | ||
732 | |||
733 | 'setShouldShowLoginInfo': function(aValue) { | ||
734 | this._shouldShowLoginInfo = aValue; | ||
735 | }, | ||
736 | |||
737 | //------------------------------------------------------------------------- | ||
738 | |||
739 | 'showLoginHistoryPanel': function(anEvent) { | ||
740 | anEvent.stop(); | ||
741 | |||
742 | Clipperz.NotificationCenter.notify(this, 'selectTab', 'mainTabPanel.accountTab', true); | ||
743 | Clipperz.NotificationCenter.notify(this, 'selectTab', 'accountTabPanel.loginHistoryTab', true); | ||
744 | }, | ||
745 | |||
746 | //------------------------------------------------------------------------- | ||
747 | |||
748 | 'showDownloadOfflineCopyPanel': function(anEvent) { | ||
749 | anEvent.stop(); | ||
750 | |||
751 | Clipperz.NotificationCenter.notify(this, 'selectTab', 'mainTabPanel.dataTab', true); | ||
752 | Clipperz.NotificationCenter.notify(this, 'selectTab', 'dataTabPanel.offlineCopyTab', true); | ||
753 | }, | ||
754 | |||
755 | //------------------------------------------------------------------------- | ||
756 | __syntaxFix__: "syntax fix" | ||
757 | }); | ||
758 | |||