summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js
Unidiff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js652
1 files changed, 652 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js
new file mode 100644
index 0000000..2340aeb
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js
@@ -0,0 +1,652 @@
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
29Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers');
30
31Clipperz.PM.UI.Web.Controllers.CardDialogController = function(args) {
32 args = args || {};
33
34 Clipperz.PM.UI.Web.Controllers.CardDialogController.superclass.constructor.call(this, args);
35
36 this._record = args.record || Clipperz.Base.exception.raise('MandatoryParameter');
37 this._delegate = args.delegate || Clipperz.Base.exception.raise('MandatoryParameter');
38
39 this._referenceElement = null;
40 this._cardDialogComponent = null;
41
42 this._fieldsReferences = {};
43 this._directLoginReferences = {};
44
45 this._directLoginWizardController = null;
46 this._directLoginEditingComponent = null;
47 this._isDirectLoginEditingComponentVisible = false;
48
49 return this;
50};
51
52Clipperz.Base.extend(Clipperz.PM.UI.Web.Controllers.CardDialogController, Object, {
53
54 'toString': function() {
55 return "Clipperz.PM.UI.Web.Controllers.CardDialogController";
56 },
57
58 //-------------------------------------------------------------------------
59
60 'record': function () {
61 return this._record;
62 },
63
64 'delegate': function () {
65 return this._delegate;
66 },
67
68 //-------------------------------------------------------------------------
69
70 'fieldsReferences': function () {
71 return this._fieldsReferences;
72 },
73
74 'directLoginReferences': function () {
75 return this._directLoginReferences;
76 },
77
78 //-------------------------------------------------------------------------
79
80 'referenceElement': function () {
81 return this._referenceElement;
82 },
83
84 'setReferenceElement': function (anElement) {
85 this._referenceElement = anElement;
86 },
87
88 //-------------------------------------------------------------------------
89
90 'cardDialogComponent': function () {
91 if (this._cardDialogComponent == null) {
92 this._cardDialogComponent = new Clipperz.PM.UI.Web.Components.CardDialogComponent();
93
94 MochiKit.Signal.connect(this._cardDialogComponent, 'cancel', this, 'handleCancel');
95 MochiKit.Signal.connect(this._cardDialogComponent, 'save', this, 'handleSave');
96
97 MochiKit.Signal.connect(this._cardDialogComponent, 'addField', this, 'handleAddField');
98 MochiKit.Signal.connect(this._cardDialogComponent, 'changedValue',this, 'handleChangedValue');
99
100 MochiKit.Signal.connect(this._cardDialogComponent, 'addDirectLogin',this, 'handleAddDirectLogin');
101 MochiKit.Signal.connect(this._cardDialogComponent, 'keyPressed',this, 'handleCardDialogComponentKeyPressed');
102 }
103
104 return this._cardDialogComponent;
105 },
106
107 //=========================================================================
108
109 'directLoginWizardController': function () {
110 if (this._directLoginWizardController == null) {
111 this._directLoginWizardController = new Clipperz.PM.UI.Web.Controllers.DirectLoginWizardController({
112 'cardLabel': this.cardDialogComponent().title(),
113 'directLoginEditingComponent': this.directLoginEditingComponent()
114 })
115
116 MochiKit.Signal.connect(this._directLoginWizardController, 'exit',this, 'handleHideDirectLoginEditingComponent');
117 MochiKit.Signal.connect(this._directLoginWizardController, 'done',this, 'handleCompleteDirectLoginEditingComponent');
118 }
119
120 return this._directLoginWizardController;
121 },
122
123 //-------------------------------------------------------------------------
124
125 'directLoginEditingComponent': function () {
126 if (this._directLoginEditingComponent == null) {
127 this._directLoginEditingComponent = new Clipperz.PM.UI.Web.Components.DirectLoginEditingComponent();
128
129 this.cardDialogComponent().renderDirectLoginEditingComponent(this._directLoginEditingComponent);
130
131 // MochiKit.Signal.connect(this._directLoginEditingComponent, 'back', this, 'handleHideDirectLoginEditingComponent')
132 // MochiKit.Signal.connect(this._directLoginEditingComponent, 'changedValue',this, 'handleChangedValue');
133 // MochiKit.Signal.connect(this.__directLoginEditingComponent, 'keyPressed',this, 'handleDirectLoginEditingComponentKeyPressed');
134 }
135
136 return this._directLoginEditingComponent;
137 },
138
139 //-------------------------------------------------------------------------
140
141 'isDirectLoginEditingComponentVisible': function () {
142 return this._isDirectLoginEditingComponentVisible;
143 },
144
145 'setIsDirectLoginEditingComponentVisible': function (aValue) {
146 this._isDirectLoginEditingComponentVisible = aValue;
147 },
148
149 //=========================================================================
150
151 'run': function (anElement) {
152 var deferredResult;
153
154 this.setReferenceElement(anElement);
155
156 deferredResult = new Clipperz.Async.Deferred("CardDialogController.run", {trace:false});
157 deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress', {'steps':11});
158
159 deferredResult.addMethod(this.cardDialogComponent(), 'deferredShowModal', {openFromElement:this.referenceElement()});
160 deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress');
161
162 deferredResult.addMethod(this.record(), 'label');
163 deferredResult.addMethod(this.cardDialogComponent(), 'setTitle');
164 deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress');
165
166 deferredResult.addMethod(this, 'updateComponentState');
167 deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress');
168 deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'progressDone');
169
170 deferredResult.addMethod(this.cardDialogComponent(), 'fixRendering');
171 deferredResult.addMethod(this.cardDialogComponent(), 'hideProgressMask');
172
173 if (this.record().isBrandNew()) {
174 deferredResult.addMethod(this.cardDialogComponent(), 'setHintMode', 'ON');
175 deferredResult.addMethod(this.cardDialogComponent(), 'setFocusOnTitleField');
176 }
177
178 deferredResult.addErrback(MochiKit.Base.method(this.cardDialogComponent(), 'showError'));
179 deferredResult.callback();
180
181 return deferredResult;
182 },
183
184 //=========================================================================
185
186 'updateComponentState': function () {
187 return Clipperz.Async.callbacks("CardDialogController.updateComponentState", [
188 MochiKit.Base.method(this.record(), 'hasPendingChanges'),
189 MochiKit.Base.method(this.cardDialogComponent(), 'setShouldEnableSaving'),
190
191 MochiKit.Base.method(this.record(), 'label'),
192 MochiKit.Base.method(this.cardDialogComponent(), 'setTitle'),
193 MochiKit.Base.method(this.record(), 'notes'),
194 MochiKit.Base.method(this.cardDialogComponent(), 'setNotes'),
195
196 MochiKit.Base.method(this.record(), 'fields'),
197 MochiKit.Base.values,
198 MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'addCardDialogComponentWithField')),
199
200 MochiKit.Base.method(this.record(), 'directLogins'),
201 MochiKit.Base.values,
202 MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'addCardDialogComponentWithDirectLogin')),
203
204 MochiKit.Base.method(this.cardDialogComponent(), 'resetNewFieldInputs'),
205 MochiKit.Base.noop
206 ], {trace:false});
207 },
208
209 //-------------------------------------------------------------------------
210
211 'addCardDialogComponentWithField': function (aField) {
212 varfieldComponent;
213
214 fieldComponent = new Clipperz.PM.UI.Web.Components.CardDialogRecordFieldComponent({reference: aField.reference()});
215 MochiKit.Signal.connect(fieldComponent, 'changedValue',this, 'handleChangedValue');
216 MochiKit.Signal.connect(fieldComponent, 'performAction',this, 'handlePerformFieldAction');
217 MochiKit.Signal.connect(fieldComponent, 'deleteField',this, 'handleDeleteField');
218
219 // this.fieldsReferences().push({'field':aField, 'component':fieldComponent});
220 this.fieldsReferences()[aField.reference()] = {'field':aField, 'component':fieldComponent};
221
222 return Clipperz.Async.callbacks("CardDialogController.addCardDialogComponentWithField", [
223 MochiKit.Base.method(this.cardDialogComponent(), 'addFieldRowComponent', fieldComponent),
224
225 MochiKit.Base.method(aField, 'label'),
226 MochiKit.Base.method(fieldComponent, 'setLabel'),
227 MochiKit.Base.method(aField, 'value'),
228 MochiKit.Base.method(fieldComponent, 'setValue'),
229 MochiKit.Base.method(aField, 'actionType'),
230 MochiKit.Base.method(fieldComponent, 'setActionType'),
231 MochiKit.Base.method(aField, 'isHidden'),
232 MochiKit.Base.method(fieldComponent, 'setIsHidden')
233 ], {trace:false});
234 },
235
236 //-------------------------------------------------------------------------
237
238 'addCardDialogComponentWithDirectLogin': function (aDirectLogin) {
239 var directLoginComponent;
240
241 directLoginComponent = new Clipperz.PM.UI.Web.Components.CardDialogRecordDirectLoginComponent({reference: aDirectLogin.reference()});
242 MochiKit.Signal.connect(directLoginComponent, 'changedValue', this, 'handleChangedValue');
243 MochiKit.Signal.connect(directLoginComponent, 'deleteDirectLogin',this, 'handleDeleteDirectLogin');
244 MochiKit.Signal.connect(directLoginComponent, 'editDirectLogin',this, 'handleEditDirectLogin');
245 MochiKit.Signal.connect(directLoginComponent, 'openDirectLogin',this, 'handleOpenDirectLogin');
246
247 this.directLoginReferences()[aDirectLogin.reference()] = {'directLogin':aDirectLogin, 'component':directLoginComponent};
248
249 return Clipperz.Async.callbacks("CardDialogController.addCardDialogComponentWithDirectLogin", [
250 MochiKit.Base.method(this.cardDialogComponent(), 'addDirectLoginComponent', directLoginComponent),
251 MochiKit.Base.method(this, 'refreshDirectLoginComponent', this.directLoginReferences()[aDirectLogin.reference()])
252 ], {trace:false});
253 },
254
255 //-------------------------------------------------------------------------
256
257 'refreshDirectLoginComponent': function (aDirectLoginReference) {
258 return Clipperz.Async.callbacks("CardDialogController.refreshDirectLoginComponent", [
259 MochiKit.Base.method(aDirectLoginReference['directLogin'],'favicon'),
260 // MochiKit.Base.method(aDirectLoginReference['directLogin'],'faviconData'),
261 MochiKit.Base.method(aDirectLoginReference['component'],'setFavicon'),
262 MochiKit.Base.method(aDirectLoginReference['directLogin'],'label'),
263 MochiKit.Base.method(aDirectLoginReference['component'],'setLabel')
264 ], {trace:false});
265 },
266
267 'refreshDirectLoginComponents': function () {
268 return Clipperz.Async.callbacks("CardDialogController.refreshDirectLoginComponents", [
269 MochiKit.Base.method(this, 'directLoginReferences'),
270 MochiKit.Base.values,
271 MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'refreshDirectLoginComponent')),
272 Clipperz.Async.collectAll
273 ])
274 },
275
276 //-------------------------------------------------------------------------
277
278 'updateRecordValues': function () {
279 return Clipperz.Async.callbacks('CardDialogController.updateRecordValues', [
280 MochiKit.Base.method(this.cardDialogComponent(), 'title'),
281 MochiKit.Base.method(this.record(), 'setLabel'),
282 MochiKit.Base.method(this.cardDialogComponent(), 'notes'),
283 MochiKit.Base.method(this.record(), 'setNotes'),
284
285 MochiKit.Base.method(this, 'fieldsReferences'),
286 MochiKit.Base.values,
287 MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'updateRecordFieldValues')),
288
289 MochiKit.Base.method(this, 'directLoginReferences'),
290 MochiKit.Base.values,
291 MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'updateRecordDirectLoginValues')),
292
293 MochiKit.Base.method(this.directLoginEditingComponent(), 'directLoginReference'),
294 MochiKit.Base.method(this.record(), 'directLoginWithReference'),
295 MochiKit.Base.method(this, 'updateRecordDirectLoginDetails'),
296
297 MochiKit.Base.noop
298 ], {trace:false});
299 },
300
301 //-------------------------------------------------------------------------
302
303 'updateRecordFieldValues': function (aFieldReference) {
304 var deferredResult;
305
306 deferredResult = Clipperz.Async.callbacks('CardDialogController.updateRecordFieldValues', [
307 MochiKit.Base.method(aFieldReference['component'],'label'),
308 MochiKit.Base.method(aFieldReference['field'], 'setLabel'),
309
310 MochiKit.Base.method(aFieldReference['component'],'value'),
311 MochiKit.Base.method(aFieldReference['field'], 'setValue'),
312
313 MochiKit.Base.method(aFieldReference['component'],'isHidden'),
314 MochiKit.Base.method(aFieldReference['field'], 'setIsHidden'),
315
316 MochiKit.Base.method(aFieldReference['field'], 'actionType'),
317 MochiKit.Base.method(aFieldReference['component'],'setActionType')
318 ], {trace:false});
319
320 return deferredResult;
321 },
322
323 //-------------------------------------------------------------------------
324
325 'updateRecordDirectLoginValues': function (aDirectLoginReference) {
326 var deferredResult;
327
328 deferredResult = Clipperz.Async.callbacks('CardDialogController.updateRecordDirectLoginValues', [
329 MochiKit.Base.method(aDirectLoginReference['component'], 'label'),
330 MochiKit.Base.method(aDirectLoginReference['directLogin'], 'setLabel')
331 ], {trace:false});
332
333 return deferredResult;
334 },
335
336 //-------------------------------------------------------------------------
337
338 'updateRecordDirectLoginDetails': function (aDirectLogin) {
339 var result;
340
341 if (MochiKit.Base.isUndefinedOrNull(aDirectLogin)) {
342 result = MochiKit.Async.succeed();
343 } else {
344 result = Clipperz.Async.callbacks("CardDialogController.updateRecordDirectLoginDetails", [
345 MochiKit.Base.method(this.directLoginEditingComponent(), 'label'),
346 MochiKit.Base.method(aDirectLogin, 'setLabel'),
347 MochiKit.Base.method(this.directLoginEditingComponent(), 'favicon'),
348 MochiKit.Base.method(aDirectLogin, 'setFavicon')
349 ], {trace:false});
350 }
351
352 return result;
353 },
354
355 //=========================================================================
356
357 'addField': function () {
358 return this.record().addField({
359 'label':this.cardDialogComponent().newFieldLabel(),
360 'value':this.cardDialogComponent().newFieldValue(),
361 'isHidden':this.cardDialogComponent().newFieldIsHidden()
362 });
363 },
364
365 'handleAddField': function () {
366 return Clipperz.Async.callbacks("CardDialogController.handleAddField", [
367 MochiKit.Base.method(this, 'addField'),
368
369 MochiKit.Base.method(this, 'addCardDialogComponentWithField'),
370 MochiKit.Base.method(this.cardDialogComponent(), 'resetNewFieldInputs'),
371
372 MochiKit.Base.method(this.cardDialogComponent(), 'fixRendering'),
373 MochiKit.Base.method(this, 'handleChangedValue')
374 ], {trace:false})
375 },
376
377 //-------------------------------------------------------------------------
378
379 'handlePerformFieldAction': function (aFieldID, aTargetElement) {
380//console.log("### targetElement", aTargetElement);
381 return Clipperz.Async.callbacks("CardDialogController.handleDeleteField", [
382 MochiKit.Base.method(this.record(), 'fields'),
383 MochiKit.Base.itemgetter(aFieldID),
384 Clipperz.Async.collectResults("CardDialogController.handleDeleteField <collect results>", {
385 'value':MochiKit.Base.methodcaller('value'),
386 'type': MochiKit.Base.methodcaller('actionType')
387 }, {trace:false}),
388 MochiKit.Base.bind(function (someValues) {
389 switch (someValues['type']) {
390 case 'NONE':
391 throw "this event handler should not be triggered for fields with type 'NONE'";
392 break;
393 case 'URL':
394 var url;
395
396 url = someValues['value'];
397 if (/^https?\:\/\//.test(url) == false) {
398 url = 'http://' + url;
399 }
400
401 window.open(url);
402 break;
403 case 'EMAIL':
404 var url;
405
406 url = 'mailto:' + someValues['value'];
407
408 MochiKit.DOM.currentWindow().location = url;
409 break;
410 case 'PASSWORD':
411//Clipperz.log("SHOW PASSWORD " + someValues['value']);
412 this.showPasswordTooltip(someValues['value'], aTargetElement);
413 break;
414 }
415 }, this)
416 ], {trace:false});
417 },
418
419 //-------------------------------------------------------------------------
420
421 'handleDeleteField': function (aFieldID) {
422 return Clipperz.Async.callbacks("CardDialogController.handleDeleteField", [
423 MochiKit.Base.method(this.record(), 'fields'),
424 MochiKit.Base.itemgetter(aFieldID),
425 MochiKit.Base.method(this.record(), 'removeField'),
426
427 MochiKit.Base.method(this, 'fieldsReferences'),
428 MochiKit.Base.itemgetter(aFieldID),
429 MochiKit.Base.itemgetter('component'),
430
431 function (aComponent) {
432 return Clipperz.Async.callbacks("CardDialogController.handleDeleteField [fade and remove]", [
433 MochiKit.Base.partial(Clipperz.Visual.deferredAnimation, MochiKit.Visual.fade, aComponent.element(), {from:1.0, to:0.0, duration:0.5}),
434 // Clipperz.Visual.deferredAnimation(MochiKit.Visual.fade, aComponent.element(), {from:1.0, to:0.0, duration:0.5}),
435 MochiKit.Base.method(aComponent, 'remove')
436 ], {trace:false});
437 },
438
439 MochiKit.Base.bind(function () {
440 delete this.fieldsReferences()[aFieldID];
441 }, this),
442
443 MochiKit.Base.method(this.cardDialogComponent(), 'fixRendering'),
444 MochiKit.Base.method(this, 'handleChangedValue')
445 ], {trace:false});
446 },
447
448 //=========================================================================
449
450 'handleDeleteDirectLogin': function(aDirectLoginReference) {
451 var cardDialogComponent;
452
453 cardDialogComponent = this.cardDialogComponent();
454
455 return Clipperz.Async.callbacks("CardDialogController.handleDeleteDirectLogin", [
456 MochiKit.Base.method(this.record(), 'directLogins'),
457 MochiKit.Base.itemgetter(aDirectLoginReference),
458 MochiKit.Base.methodcaller('remove'),
459
460 MochiKit.Base.method(this, 'directLoginReferences'),
461 MochiKit.Base.itemgetter(aDirectLoginReference),
462 MochiKit.Base.itemgetter('component'),
463
464 function (aComponent) {
465 return Clipperz.Async.callbacks("CardDialogController.handleDeleteDirectLogin [fade and remove]", [
466 MochiKit.Base.partial(Clipperz.Visual.deferredAnimation, MochiKit.Visual.fade, aComponent.element(), {from:1.0, to:0.0, duration:0.5}),// Clipperz.Visual.deferredAnimation(MochiKit.Visual.fade, aComponent.element(), {from:1.0, to:0.0, duration:0.5}),
467 /// MochiKit.Base.method(aComponent, 'remove')
468 MochiKit.Base.method(cardDialogComponent, 'removeDirectLoginComponent', aComponent)
469 ], {trace:false});
470 },
471
472 MochiKit.Base.bind(function () {
473 delete this.directLoginReferences()[aDirectLoginReference];
474 }, this),
475
476 MochiKit.Base.method(this.cardDialogComponent(), 'fixRendering'),
477 MochiKit.Base.method(this, 'handleChangedValue')
478 ], {trace:false});
479 },
480
481 //-------------------------------------------------------------------------
482
483 'handleOpenDirectLogin': function (aDirectLoginReference) {
484 return Clipperz.Async.callbacks("CardDialogController.handleOpenDirectLogin", [
485 MochiKit.Base.method(this.record(), 'directLoginWithReference', aDirectLoginReference),
486 Clipperz.PM.UI.Common.Controllers.DirectLoginRunner.openDirectLogin
487 ], {trace:false});
488 },
489
490 //-------------------------------------------------------------------------
491
492 'handleEditDirectLogin': function (aDirectLoginReference) {
493 return Clipperz.Async.callbacks("CardDialogController.handleEditDirectLogin", [
494 MochiKit.Base.method(this, 'setIsDirectLoginEditingComponentVisible', true),
495 MochiKit.Base.method(this.directLoginEditingComponent(), 'setDirectLoginReference', aDirectLoginReference),
496 MochiKit.Base.method(this.cardDialogComponent(), 'placeDirectLoginEditingComponent'),
497 MochiKit.Base.method(this.record(), 'directLoginWithReference', aDirectLoginReference),
498 MochiKit.Base.method(this.directLoginWizardController(), 'runWithDirectLogin'),
499 MochiKit.Base.method(this.directLoginWizardController(), 'fixRulerRendering', this.cardDialogComponent().displayMode()),
500 MochiKit.Base.method(this.cardDialogComponent(), 'showDirectLoginEditingComponent')
501 ], {trace:false});
502 },
503
504 //-------------------------------------------------------------------------
505
506 'handleHideDirectLoginEditingComponent': function () {
507 return Clipperz.Async.callbacks("CardDialogController.handleHideDirectLoginEditingComponent", [
508 MochiKit.Base.method(this, 'setIsDirectLoginEditingComponentVisible', false),
509 MochiKit.Base.method(this.directLoginWizardController(), 'hideRuler'),
510 MochiKit.Base.method(this.directLoginEditingComponent(), 'setDirectLoginReference', null),
511 MochiKit.Base.method(this, 'refreshDirectLoginComponents'),
512 MochiKit.Base.method(this.cardDialogComponent(), 'hideDirectLoginEditingComponent')
513 ], {trace:false})
514 },
515
516 'handleCompleteDirectLoginEditingComponent': function (someParameters) {
517 return Clipperz.Async.callbacks("CardDialogController.handleCompleteDirectLoginEditingComponent", [
518 MochiKit.Base.method(this, 'setIsDirectLoginEditingComponentVisible', false),
519 MochiKit.Base.method(this.directLoginEditingComponent(), 'setDirectLoginReference', null),
520 MochiKit.Base.partial(MochiKit.Async.succeed, someParameters['hasJustBeenAdded']),
521 Clipperz.Async.deferredIf("CardDialogController.handleCompleteDirectLoginEditingComponent - should addTheEditedDirectLogin", [
522 MochiKit.Base.method(this, 'addCardDialogComponentWithDirectLogin', someParameters['directLogin'])
523 ], []),
524 MochiKit.Base.method(this, 'refreshDirectLoginComponents'),
525 MochiKit.Base.method(this, 'handleChangedValue'),
526 MochiKit.Base.method(this.cardDialogComponent(), 'hideDirectLoginEditingComponent')
527 ], {trace:false})
528 },
529
530 //=========================================================================
531
532 'handleChangedValue': function () {
533 return Clipperz.Async.callbacks("CardDialogController.handleChangedValue", [
534 MochiKit.Base.method(this, 'updateRecordValues'),
535 MochiKit.Base.method(this.record(), 'hasPendingChanges'),
536 MochiKit.Base.method(this.cardDialogComponent(), 'setShouldEnableSaving')
537 ], {trace:false});
538 },
539
540 //-------------------------------------------------------------------------
541
542 'handleSave': function () {
543 var deferredResult;
544
545 deferredResult = new Clipperz.Async.Deferred("CardDialogController.handleSave", {trace:false});
546 deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress', {'steps':8});
547 deferredResult.addMethod(this.cardDialogComponent(), 'showProgressMask');
548 deferredResult.addMethod(this.cardDialogComponent(), 'newFieldHasPendingChanges');
549 deferredResult.addIf([
550 MochiKit.Base.method(this, 'addField')
551 ], [])
552 deferredResult.addMethod(this, 'saveChanges');
553 deferredResult.addMethod(this.cardDialogComponent(), 'deferredHideModal', {closeToElement:null});
554 deferredResult.addMethod(this.cardDialogComponent(), 'remove');
555 deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'cardDialogComponentClosed');
556
557 deferredResult.callback();
558
559 return deferredResult;
560 },
561
562 //.........................................................................
563
564 'saveChanges': function () {
565 var deferredResult;
566
567 deferredResult = new Clipperz.Async.Deferred("CardDialogController.handleSave", {trace:false});
568 deferredResult.addMethod(this.delegate(), 'saveChanges');
569deferredResult.addErrback(function (aValue) { Clipperz.log("SHIT HAPPENS!!"); return aValue; });
570
571 deferredResult.callback();
572
573 return deferredResult;
574 },
575
576 //-------------------------------------------------------------------------
577
578 'handleCancel': function () {
579 var deferredResult;
580
581 if (this.isDirectLoginEditingComponentVisible()) {
582 deferredResult = this.handleHideDirectLoginEditingComponent();
583 } else {
584 deferredResult = new Clipperz.Async.Deferred("CardDialogController.handleCancel", {trace:false});
585 // deferredResult.addMethod(this.record(), 'hasPendingChanges'),
586 deferredResult.addMethod(this.delegate(), 'hasPendingChanges'),
587 deferredResult.addIf([
588 MochiKit.Base.method(this.cardDialogComponent(), 'askConfirmationForLoosingPendingChanges')
589 ], [])
590 deferredResult.addMethod(this.delegate(), 'revertChanges');
591 deferredResult.addMethod(this.cardDialogComponent(), 'deferredHideModal', {closeToElement:this.referenceElement()});
592 deferredResult.addMethod(this.cardDialogComponent(), 'remove');
593 deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'cardDialogComponentClosed');
594
595 deferredResult.callback();
596 }
597
598 return deferredResult;
599 },
600
601 //-------------------------------------------------------------------------
602
603 'handleAddDirectLogin': function () {
604 return Clipperz.Async.callbacks("CardDialogController.handleAddDirectLogin", [
605 MochiKit.Base.method(this.record(), 'createNewDirectLogin'),
606 MochiKit.Base.bind(function (aDirectLogin) {
607 return Clipperz.Async.callbacks("CardDialogController.handleAddDirectLogin - directLogin", [
608 MochiKit.Base.method(this.cardDialogComponent(), 'newFieldHasPendingChanges'),
609 Clipperz.Async.deferredIf("cardDialogComponent.newFieldHasPendingChanges", [
610 MochiKit.Base.method(this, 'handleAddField')
611 ], []),
612
613 MochiKit.Base.method(this.directLoginEditingComponent(), 'setDirectLoginReference', aDirectLogin.reference()),
614 MochiKit.Base.method(this.cardDialogComponent(), 'placeDirectLoginEditingComponent'),
615 MochiKit.Base.method(this.directLoginWizardController(), 'runWithDirectLogin', aDirectLogin, true),
616 MochiKit.Base.method(this.directLoginWizardController(), 'fixRulerRendering', this.cardDialogComponent().displayMode()),
617 MochiKit.Base.method(this.cardDialogComponent(), 'showDirectLoginEditingComponent')
618 ], {trace:false});
619 }, this)
620 ], {trace:false});
621 },
622
623 //=========================================================================
624
625 'handleCardDialogComponentKeyPressed': function (anEvent) {
626 if ((anEvent.key().string == 'KEY_TAB') && this.cardDialogComponent().newFieldHasPendingChanges()) {
627 anEvent.preventDefault();
628
629 // MochiKit.Signal.signal(this.cardDialogComponent(), 'addField');
630 this.handleAddField()
631 this.cardDialogComponent().focusOnNewFieldLabel();
632 }
633 },
634
635 //=========================================================================
636
637 'showPasswordTooltip': function (aValue, anElement) {
638 varpasswordTooltip;
639
640 passwordTooltip = new Clipperz.PM.UI.Web.Components.PasswordTooltip({
641 'referebceElement': anElement,
642 'text': aValue
643 });
644
645 passwordTooltip.show();
646
647
648 },
649
650 //=========================================================================
651 __syntaxFix__: "syntax fix"
652});