Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 69e9a17

Browse files
author
Barry de Graaff
committed

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

zimlet/tk_barrydegraaff_owncloud_zimlet.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,21 @@ ownCloudZimlet.saveAttachment =
351351
ownCloudZimlet.prototype.targetFolderPicker =
352352
function(method, args) {
353353
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+
354358
zimletInstance._folderPickerDialog = new ZmDialog({
355359
title: ZmMsg.chooseFolder,
356360
parent: zimletInstance.getShell(),
357361
standardButtons: [DwtDialog.OK_BUTTON, DwtDialog.CANCEL_BUTTON],
362+
extraButtons : [newFolderBtn],
358363
disposeOnPopDown: true
359364
});
360365
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>";
361366

362367
zimletInstance._folderPickerDialog.setContent(html);
368+
zimletInstance._folderPickerDialog.setButtonListener(newFolderBtnId, new AjxListener(zimletInstance, zimletInstance.newFolderInFolderPicker));
363369
zimletInstance._folderPickerDialog.setButtonListener(DwtDialog.OK_BUTTON, new AjxListener(zimletInstance, method, args));
364370
zimletInstance._folderPickerDialog.setButtonListener(DwtDialog.CANCEL_BUTTON, new AjxListener(zimletInstance, zimletInstance.cancelFolderPicker));
365371
zimletInstance._folderPickerDialog._tabGroup.addMember(document.getElementById(zimletInstance._folderPickerDialog._button[1].__internalId));
@@ -381,11 +387,78 @@ ownCloudZimlet.prototype.targetFolderPicker =
381387

382388
};
383389

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+
384419
ownCloudZimlet.prototype.cancelFolderPicker = function() {
385420
var zimletInstance = appCtxt._zimletMgr.getZimletByName('tk_barrydegraaff_owncloud_zimlet').handlerObject;
386421
zimletInstance._folderPickerDialog.popdown();
387422
};
388423

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+
389462
/**
390463
* Save an attachment to OwnCloud.
391464
* @param {string} mid The message id

zimlet/tk_barrydegraaff_owncloud_zimlet.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ along with this program. If not, see http://www.gnu.org/licenses/.
2323
2424
-->
2525
<zimlet name="tk_barrydegraaff_owncloud_zimlet"
26-
version="1.1.5"
26+
version="1.1.6"
2727
target="main compose-window view-window"
2828
label="WebDAV"
2929
description="Attach from and save to WebDAV">

0 commit comments

Comments
 (0)