Permalink
Browse files

Add pagination controllers in folders tree (when in Selector mode onl…

…y) to allow copying/moving data around even if inside another page. Fix #1179

(cherry picked from commit efeb573)
  • Loading branch information...
1 parent 6c78656 commit 52bae2d81cc0d0a4cb35d0d943a61d097cf207e4 @cdujeu cdujeu committed Jul 6, 2016
@@ -70,7 +70,7 @@ Class.create("FoldersTree", AjxpPane, {
var filter = this.createFilter();
var fakeRootNode = new AjxpNode("/", true, MessageHash[391], "folder.png");
fakeRootNode._isLoaded = true;
- this.tree = new AJXPTree(fakeRootNode, action, filter);
+ this.tree = new AJXPTree(fakeRootNode, action, filter, false);
this.treeContainer.update(this.tree.toString());
$(this.tree.id).ajxpNode = this.tree.ajxpNode;
@@ -61,7 +61,7 @@ Class.create("TreeSelector", {
if(!rootNode){
rootNode = new AjxpNode("/", false, MessageHash[373], "folder.png");
}
- this.treeCopy = new AJXPTree(rootNode, this._nodeActionCallback, this.options.nodeFilter);
+ this.treeCopy = new AJXPTree(rootNode, this._nodeActionCallback, this.options.nodeFilter, true);
this.treeContainer.update(this.treeCopy.toString());
$(this.treeCopy.id).observe("click", function(e){
this.action();
@@ -34,10 +34,11 @@ function splitOverlayClasses(ajxpNode){
return ajxpNode.getMetadata().get("overlay_class").split(",");
}
-function AJXPTree(rootNode, sAction, filter) {
+function AJXPTree(rootNode, sAction, filter, showPagination) {
this.WebFXTree = WebFXTree;
this.loaded = true;
this.ajxpNode = rootNode;
+ this.showPagination = showPagination;
var icon = rootNode.getIcon();
if(icon.indexOf(ajxpResourcesFolder+"/") != 0){
icon = resolveImageSource(icon, "/images/mimes/ICON_SIZE", 16);
@@ -109,20 +110,44 @@ AJXPTree.prototype.setAjxpRootNode = function(rootNode){
};
AJXPTree.prototype.attachListeners = function(jsNode, ajxpNode){
+ var showPagination = this.showPagination;
ajxpNode.observe("child_added", function(childPath){
if(ajxpNode.getMetadata().get('paginationData') && parseInt(ajxpNode.getMetadata().get('paginationData').get('total')) > 1){
var pData = ajxpNode.getMetadata().get('paginationData');
- if(!this.paginated){
- this.paginated = true;
- if(pData.get('dirsCount')!="0"){
- var message = pData.get('overflowMessage');
- if(MessageHash[message]) message = MessageHash[message];
- this.updateLabel(this.text + " (" + message+ ")");
- }
- }
- //return;
+ this.paginated = true;
+ if(pData.get('dirsCount')!="0"){
+ var message = pData.get('overflowMessage');
+ if(!this.overflowMessage || this.overflowMessage !== message){
+ this.overflowMessage = message;
+ var label;
+ if(showPagination){
+ label = new Element('span', {className:'treeLabelPaginationWrapper'}).update(this.text + '<span class="treeLabelPaginationPadding"></span>');
+ var total = parseInt(pData.get("total"));
+ var current = parseInt(pData.get("current"));
+ if(current > 1){
+ var prev = new Element('a', {className:'treeLabelPagination prev icon-chevron-sign-left'}).observe('click', function(){
+ ajxpNode.getMetadata().get("paginationData").set("current", current-1);
+ ajxpNode.reload();
+ });
+ label.insert(prev);
+ }
+ label.insert(message);
+ if(current < total){
+ var prev = new Element('a', {className:'treeLabelPagination next icon-chevron-sign-right'}).observe('click', function(){
+ ajxpNode.getMetadata().get("paginationData").set("current", current+1);
+ ajxpNode.reload();
+ });
+ label.insert(prev);
+ }
+ }else{
+ label = this.text + " (" + message+ ")";
+ }
+ this.updateLabel(label);
+ }
+ }
}else if(this.paginated){
this.paginated = false;
+ this.overflowMessage = false;
this.updateLabel(this.text);
}
var child = ajxpNode.findChildByPath(childPath);
@@ -186,6 +211,7 @@ function AJXPTreeItem(ajxpNode, sAction, eParent) {
}
this.folder = true;
+ this.showPagination = eParent.showPagination;
this.WebFXTreeItem(
ajxpNode.getLabel(),
sAction,
Oops, something went wrong.
@@ -39,6 +39,22 @@
background-repeat: no-repeat;
font-size: 13px;
background-size: 16px;
+ span.treeLabelPaginationWrapper{
+ display: inline;
+ padding: 0;
+ margin: 0;
+ span.treeLabelPaginationPadding{
+ display: inline-block;
+ margin-right: 8px;
+ padding: 0;
+ }
+ a.treeLabelPagination{
+ display: inline-block;
+ margin: 0 3px;
+ cursor: pointer;
+ }
+ }
+
}
&.selected-focus{
color: white;
@@ -386,6 +386,30 @@ div.dialogBox div#element_overlay {
font-size: 13px;
background-size: 16px;
}
+.webfx-tree-item a span span.treeLabelPaginationWrapper,
+.webfx-tree-item a:active span span.treeLabelPaginationWrapper,
+.webfx-tree-item a:hover span span.treeLabelPaginationWrapper,
+.webfx-tree-item a:link span span.treeLabelPaginationWrapper {
+ display: inline;
+ padding: 0;
+ margin: 0;
+}
+.webfx-tree-item a span span.treeLabelPaginationWrapper span.treeLabelPaginationPadding,
+.webfx-tree-item a:active span span.treeLabelPaginationWrapper span.treeLabelPaginationPadding,
+.webfx-tree-item a:hover span span.treeLabelPaginationWrapper span.treeLabelPaginationPadding,
+.webfx-tree-item a:link span span.treeLabelPaginationWrapper span.treeLabelPaginationPadding {
+ display: inline-block;
+ margin-right: 8px;
+ padding: 0;
+}
+.webfx-tree-item a span span.treeLabelPaginationWrapper a.treeLabelPagination,
+.webfx-tree-item a:active span span.treeLabelPaginationWrapper a.treeLabelPagination,
+.webfx-tree-item a:hover span span.treeLabelPaginationWrapper a.treeLabelPagination,
+.webfx-tree-item a:link span span.treeLabelPaginationWrapper a.treeLabelPagination {
+ display: inline-block;
+ margin: 0 3px;
+ cursor: pointer;
+}
.webfx-tree-item a.selected-focus,
.webfx-tree-item a:active.selected-focus,
.webfx-tree-item a:hover.selected-focus,

0 comments on commit 52bae2d

Please sign in to comment.