Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Add create folder in copy/move form. Fix #544
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Sep 2, 2016
1 parent a34063a commit 53ad20d
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 7 deletions.
1 change: 1 addition & 0 deletions core/src/plugins/access.fs/fsActions.xml
Expand Up @@ -699,6 +699,7 @@
<div id="treeCopy" style="height:194px; padding: 3px 2px; overflow:auto; text-align:left;" class="treeCopyContainer"></div>
</div>
<input type="text" name="dest" value="/" readonly style="width:248px; border: 1px solid #ccc; margin-top:7px; margin-bottom:2px;background-image:none;"/>
<a id="selector_create_folder"><span class="mdi mdi-folder-plus"></span></a>
</div>
]]></clientForm>
<clientListener name="contextChange"><![CDATA[
Expand Down
Expand Up @@ -22,6 +22,8 @@
* Independant widget for opening a form with a Tree in it
*/
Class.create("TreeSelector", {

_selectedNode: null,
/**
* Constructor
* @param oElement HTMLElement
Expand All @@ -34,6 +36,7 @@ Class.create("TreeSelector", {
targetField : 'input[name="dest"]',
targetNode: 'input[name="dest_node"]',
treeContainer : '.treeCopyContainer',
createFolder:'a#selector_create_folder',
nodeFilter : function(ajxpNode){
return (!ajxpNode.isLeaf());
}
Expand All @@ -47,13 +50,19 @@ Class.create("TreeSelector", {
if(webFXTreeHandler && webFXTreeHandler.selected){
this.__initialWebFXSelection = webFXTreeHandler.selected;
}
this.filterSelector = this.htmlElement.select(this.options.filterSelectorId)[0];
var target = this.targetField = this.htmlElement.select(this.options.targetField)[0];
var targetNode = this.targetNode = this.htmlElement.select(this.options.targetNode)[0];
this.treeContainer = this.htmlElement.select(this.options.treeContainer)[0];
this.filterSelector = this.htmlElement.down(this.options.filterSelectorId);
var target = this.targetField = this.htmlElement.down(this.options.targetField);
var targetNode = this.targetNode = this.htmlElement.down(this.options.targetNode);
var createButton = this.htmlElement.down(this.options.createFolder);
if(createButton){
this.bindFolderCreateButton(createButton);
}
this.treeContainer = this.htmlElement.down(this.options.treeContainer);
this.filterSelector.hide();
var oThis = this;
this._nodeActionCallback = function(e){
// Warning, this is the tree object
oThis._selectedNode = this.ajxpNode;
target.value = this.ajxpNode.getPath();
targetNode.value = this.ajxpNode.getPath();
this.select();
Expand All @@ -71,6 +80,40 @@ Class.create("TreeSelector", {
this.treeCopy.setAjxpRootNode(rootNode);

},

bindFolderCreateButton: function(button){
this._createListener = function(){
var currentNode = this._selectedNode || this.treeCopy.ajxpNode;
currentNode.load();
var currentPath = currentNode.getPath();

var newFolderName = window.prompt(pydio.MessageHash[155], "New Folder");
if(!newFolderName) return;
if(currentNode.getChildren().get(currentPath + "/" + newFolderName)){
pydio.displayMessage("ERROR", pydio.MessageHash[40]);
return;
}

var parameters = {
get_action:'mkdir',
dir:currentPath,
dirname:newFolderName
};
if(this.treeCopy.ajxpNode._iNodeProvider && this.treeCopy.ajxpNode._iNodeProvider.properties.get('tmp_repository_id')){
parameters["tmp_repository_id"] = this.treeCopy.ajxpNode._iNodeProvider.properties.get('tmp_repository_id');
}

PydioApi.getClient().request(parameters, function(){
var newFullPath = currentPath + "/" + newFolderName;
currentNode.addChild(new AjxpNode(newFullPath, false, newFolderName));
window.setTimeout(function(){
this.htmlElement.down('div[data-node-path="'+newFullPath+'"]').click();
}.bind(this), 250);
}.bind(this));
}.bind(this);
button.observe("click", this._createListener);
},

/**
* Clear the widget
*/
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/gui.ajax/res/js/vendor/webfx/xtree.js
Expand Up @@ -823,7 +823,7 @@ WebFXTreeItem.prototype.toString = function (nItem, nItemCount) {
}
}
var label = this.text.replace(/</g, '&lt;').replace(/>/g, '&gt;') + d;
var str = "<div id=\"" + this.id + "\" class=\"webfx-tree-item\" onkeydown=\"return webFXTreeHandler.keydown(this, event)\" data-node-icon=\"" + getBaseName((this.open?this.openIcon:this.icon)) + "\">" +
var str = "<div id=\"" + this.id + "\" class=\"webfx-tree-item\" onkeydown=\"return webFXTreeHandler.keydown(this, event)\" data-node-path=\""+(this.ajxpNode?this.ajxpNode.getPath():"")+"\" data-node-icon=\"" + getBaseName((this.open?this.openIcon:this.icon)) + "\">" +
indent +
"<img width=\"19\" height=\"25\" id=\"" + this.id + "-plus\" src=\"" + ((this.folder)?((this.open)?((this.parentNode._last)?webFXTreeConfig.lMinusIcon:webFXTreeConfig.tMinusIcon):((this.parentNode._last)?webFXTreeConfig.lPlusIcon:webFXTreeConfig.tPlusIcon)):((this.parentNode._last)?webFXTreeConfig.lIcon:webFXTreeConfig.tIcon)) + "\">" +
"<a href=\"" + this.url + "\" id=\"" + this.id + "-anchor\" onkeydown=\"return webFXTreeHandler.linkKeyPress(this, event);\" onfocus=\"webFXTreeHandler.focus(this);\" onblur=\"webFXTreeHandler.blur(this);\"" +
Expand Down
11 changes: 10 additions & 1 deletion core/src/plugins/gui.ajax/res/themes/orbit/css/pydio.css
Expand Up @@ -6067,9 +6067,18 @@ div#copymove_form div#treeCopy {
}
div#copymove_form > input {
box-sizing: border-box;
width: 100% !important;
width: 338px !important;
background-color: #fff;
padding: 5px;
border: 0 !important;
border-bottom: 1px solid #cccccc !important;
}
div#copymove_form a#selector_create_folder {
cursor: pointer;
display: inline-block;
padding: 4px 6px 2px;
border: 0px solid #cccccc;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 1px rgba(0, 0, 0, 0.33);
}
div#external_download > div {
padding: 10px 24px 52px !important;
Expand Down
Expand Up @@ -62,9 +62,18 @@ div#copymove_form{
}
> input{
box-sizing: border-box;
width: 100% !important;
width: 338px !important;
background-color: #fff;
padding: 5px;
border:0 !important;
border-bottom: 1px solid #cccccc !important;
}
a#selector_create_folder{
cursor: pointer;
display: inline-block;
padding: 4px 6px 2px;
border: 0px solid #cccccc;
box-shadow: @reactBoxShadowDepthMini;
}
}

Expand Down

0 comments on commit 53ad20d

Please sign in to comment.