@@ -351,15 +351,21 @@ ownCloudZimlet.saveAttachment =
351
351
ownCloudZimlet . prototype . targetFolderPicker =
352
352
function ( method , args ) {
353
353
var zimletInstance = appCtxt . _zimletMgr . getZimletByName ( 'tk_barrydegraaff_owncloud_zimlet' ) . handlerObject ;
354
+
355
+ var newFolderBtnId = Dwt . getNextId ( ) ;
356
+ var newFolderBtn = new DwtDialog_ButtonDescriptor ( newFolderBtnId , ZmMsg . newFolder , DwtDialog . ALIGN_LEFT ) ;
357
+
354
358
zimletInstance . _folderPickerDialog = new ZmDialog ( {
355
359
title : ZmMsg . chooseFolder ,
356
360
parent : zimletInstance . getShell ( ) ,
357
361
standardButtons : [ DwtDialog . OK_BUTTON , DwtDialog . CANCEL_BUTTON ] ,
362
+ extraButtons : [ newFolderBtn ] ,
358
363
disposeOnPopDown : true
359
364
} ) ;
360
365
var html = "<div id=\"moveFolderRoot\" onclick=\"OwnCloudListView.prototype.selectRoot();OwnCloudListView.prototype.displayRootSelect()\" class=\"DwtTreeItem-Control\" role=\"treeitem\" style=\"position: static; overflow: visible; margin-left:-15px !important\"><div class=\"DwtTreeItem\"><table role=\"presentation\" style=\"width:100%\"><tbody><tr><td style=\"width: 16px; height: 16px; min-width: 16px;\" align=\"center\" nowrap=\"\" ></td><td style=\"width:20px\" nowrap=\"\" class=\"imageCell\"><div class=\"ImgFolder\"></div></td><td nowrap=\"\" class=\"DwtTreeItem-Text\" >" + ZmMsg . rootFolder + "</td><td class=\"DwtTreeItem-ExtraImg\"><div class=\"ImgBlank_16\"></div></td></tr></tbody></table></div></div><div onclick='OwnCloudListView.prototype.unDisplayRootSelect()' id='ownCloudZimletFolderPicker'></div>" ;
361
366
362
367
zimletInstance . _folderPickerDialog . setContent ( html ) ;
368
+ zimletInstance . _folderPickerDialog . setButtonListener ( newFolderBtnId , new AjxListener ( zimletInstance , zimletInstance . newFolderInFolderPicker ) ) ;
363
369
zimletInstance . _folderPickerDialog . setButtonListener ( DwtDialog . OK_BUTTON , new AjxListener ( zimletInstance , method , args ) ) ;
364
370
zimletInstance . _folderPickerDialog . setButtonListener ( DwtDialog . CANCEL_BUTTON , new AjxListener ( zimletInstance , zimletInstance . cancelFolderPicker ) ) ;
365
371
zimletInstance . _folderPickerDialog . _tabGroup . addMember ( document . getElementById ( zimletInstance . _folderPickerDialog . _button [ 1 ] . __internalId ) ) ;
@@ -381,11 +387,78 @@ ownCloudZimlet.prototype.targetFolderPicker =
381
387
382
388
} ;
383
389
390
+ ownCloudZimlet . prototype . newFolderInFolderPicker = function ( ) {
391
+ var zimletInstance = appCtxt . _zimletMgr . getZimletByName ( 'tk_barrydegraaff_owncloud_zimlet' ) . handlerObject ;
392
+
393
+ var newFolderDialog = new DwtDialog ( { parent : appCtxt . getShell ( ) } ) ,
394
+ folder = zimletInstance . OwnCloudFolderPicker . selectedDavResource ,
395
+ composite = new DwtComposite ( { parent : newFolderDialog } ) ,
396
+ label ,
397
+ input ;
398
+
399
+ newFolderDialog . setView ( composite ) ;
400
+
401
+ label = new DwtLabel ( {
402
+ parent : composite
403
+ } ) ;
404
+ label . setText ( ZmMsg . newFolder + ":" ) ;
405
+
406
+ input = new DwtInputField ( {
407
+ parent : composite
408
+ } ) ;
409
+ newFolderDialog . setTitle ( ZmMsg . newFolder ) ;
410
+ newFolderDialog . setButtonListener ( DwtDialog . OK_BUTTON , new AjxListener ( this , this . _newFolderCallback , [ folder , input , newFolderDialog ] ) ) ;
411
+ newFolderDialog . addEnterListener ( new AjxListener ( this , this . _newFolderCallback , [ folder , input , newFolderDialog ] ) ) ;
412
+
413
+ //add tab group and focus on the input field
414
+ newFolderDialog . _tabGroup . addMemberBefore ( input , newFolderDialog . _tabGroup . getFirstMember ( ) ) ;
415
+ newFolderDialog . _tabGroup . setFocusMember ( input ) ;
416
+ newFolderDialog . popup ( ) ;
417
+ } ;
418
+
384
419
ownCloudZimlet . prototype . cancelFolderPicker = function ( ) {
385
420
var zimletInstance = appCtxt . _zimletMgr . getZimletByName ( 'tk_barrydegraaff_owncloud_zimlet' ) . handlerObject ;
386
421
zimletInstance . _folderPickerDialog . popdown ( ) ;
387
422
} ;
388
423
424
+
425
+ ownCloudZimlet . prototype . _newFolderCallback = function ( folder , input , dialog , ev ) {
426
+ var zimletInstance = appCtxt . _zimletMgr . getZimletByName ( 'tk_barrydegraaff_owncloud_zimlet' ) . handlerObject ;
427
+ var inputValue = ownCloudZimlet . prototype . sanitizeFileName ( input . getValue ( ) ) ;
428
+
429
+ var folderHref ;
430
+ if ( typeof folder === 'string' )
431
+ {
432
+ folderHref = folder
433
+ }
434
+ else
435
+ {
436
+ folderHref = folder . getHref ( ) ;
437
+ }
438
+
439
+
440
+ dialog . getButton ( DwtDialog . OK_BUTTON ) . setEnabled ( false ) ;
441
+ dialog . getButton ( DwtDialog . CANCEL_BUTTON ) . setEnabled ( false ) ;
442
+
443
+ this . _davConnector . mkcol (
444
+ "/" + ( folderHref + inputValue ) . replace ( tk_barrydegraaff_owncloud_zimlet_HandlerObject . settings [ 'owncloud_zimlet_server_path' ] , "" ) ,
445
+ new AjxCallback ( this , function ( dialog , result ) {
446
+ dialog . popdown ( ) ;
447
+
448
+ zimletInstance . OwnCloudFolderPicker = new OwnCloudFolderPicker (
449
+ zimletInstance . _folderPickerDialog ,
450
+ zimletInstance ,
451
+ zimletInstance . _davConnector ,
452
+ zimletInstance . _ownCloudConnector ,
453
+ new OwnCloudCommons ( zimletInstance . _davConnector , zimletInstance . _ownCloudConnector )
454
+ ) ;
455
+ document . getElementById ( 'ownCloudZimletFolderPicker' ) . innerHTML = "" ;
456
+ zimletInstance . OwnCloudFolderPicker . reparentHtmlElement ( document . getElementById ( 'ownCloudZimletFolderPicker' ) ) ;
457
+ } , [ dialog ] )
458
+ ) ;
459
+ } ;
460
+
461
+
389
462
/**
390
463
* Save an attachment to OwnCloud.
391
464
* @param {string } mid The message id
0 commit comments