Author: jfthomps
Date: Tue Dec 20 17:56:14 2016
New Revision: 1775330

URL: http://svn.apache.org/viewvc?rev=1775330&view=rev
Log:
VCL-1003 - drag and drop support for moving privilege nodes

moved loading of nodedropdata global javascript variable to an AJAX call to 
speed up page load time

privilege.php:
-modified viewNodes: removed block of code that prints global variable 
nodedropdata; added div that displays that drag and drop data is loading; set 
Add Child button to be disabled by default (adding a child modifies 
nodedropdata)
-modified AJrefreshNodeDropData: added check for nodedropdata not being 
initialized; if not, call initDropData

privilege.js:
-added declaration of global variable nodedropdata
-modified mouseRelease: added return if nodedropdata not initialized
-added initDropData - enabled Add Node button if it exists, hides loading div
-modified checkCanMove and checkNodeDrop: return false if nodedropdata not 
initialized
-modified refreshNodeDropData: added timeout parameter to call to RPCwrapper

Modified:
    vcl/trunk/web/.ht-inc/privileges.php
    vcl/trunk/web/js/privileges.js

Modified: vcl/trunk/web/.ht-inc/privileges.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/privileges.php?rev=1775330&r1=1775329&r2=1775330&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/privileges.php (original)
+++ vcl/trunk/web/.ht-inc/privileges.php Tue Dec 20 17:56:14 2016
@@ -58,10 +58,6 @@ function viewNodes() {
                print "<div id=\"privtreetab\" 
dojoType=\"dijit.layout.ContentPane\" title=\"Privilege Tree\">\n";
        }
        print "<H2>Privilege Tree</H2>\n";
-       print "<script type=\"text/javascript\">\n";
-       $nodedrop = nodeDropData();
-       print "var $nodedrop";
-       print "</script>\n";
        $cont = addContinuationsEntry('AJrefreshNodeDropData');
        print "<INPUT type=hidden id=refreshnodedropdatacont 
value=\"$cont\"\n>";
        $cont = addContinuationsEntry('JSONprivnodelist');
@@ -123,12 +119,13 @@ function viewNodes() {
        print "</div>\n";
        print "</div>\n"; # privtreeparent
        print "</div>\n";
+       print "<div id=ddloading>Loading Drag and Drop data...</div>\n";
        print "<div id=treebuttons>\n";
        print "<TABLE summary=\"\" cellspacing=\"\" cellpadding=\"\">\n";
        print "  <TR valign=top>\n";
        if($hasNodeAdmin) {
                print "    <TD>\n";
-               print "    <button id=addNodeBtn 
dojoType=\"dijit.form.Button\">\n";
+               print "    <button id=addNodeBtn dojoType=\"dijit.form.Button\" 
disabled=\"true\">\n";
                print "      Add Child\n";
                print "      <script type=\"dojo/method\" event=onClick>\n";
                print "        showPrivPane('addNodePane');\n";
@@ -1131,6 +1128,7 @@ function nodeDropData() {
 ///
 
////////////////////////////////////////////////////////////////////////////////
 function AJrefreshNodeDropData() {
+       print "if(typeof(nodedropdata) == 'number') {initDropData();}";
        print nodeDropData();
 }
 

Modified: vcl/trunk/web/js/privileges.js
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/js/privileges.js?rev=1775330&r1=1775329&r2=1775330&view=diff
==============================================================================
--- vcl/trunk/web/js/privileges.js (original)
+++ vcl/trunk/web/js/privileges.js Tue Dec 20 17:56:14 2016
@@ -21,6 +21,7 @@ var nomove = 0;
 var dragnode = {hoverid: 0, dragid: 0, startX: 0, startY: 0};
 var mouseontree = 0;
 var dragging = 0;
+var nodedropdata = 0;
 
 function moveData() {
        this.oldparentid = '';
@@ -83,6 +84,8 @@ function mouseDown(evt) {
 }
 
 function mouseRelease(evt) {
+       if(typeof nodedropdata == 'number')
+               return;
        if(dragging == 0)
                return;
        dragging = 0;
@@ -92,6 +95,12 @@ function mouseRelease(evt) {
                setSelected(dijit.byId('privtree').lastFocused.item.name[0]);
 }
 
+function initDropData() {
+       if(dijit.byId('addNodeBtn'))
+               dijit.byId('addNodeBtn').set('disabled', false);
+       dojo.addClass('ddloading', 'hidden');
+}
+
 function updateNodeLabels(nodename) {
        dojo.byId('addPaneNodeName').innerHTML = 'Node: <strong>' + nodename + 
'</strong>';
        dojo.byId('addGroupPaneNodeName').innerHTML = 'Node: <strong>' + 
nodename + '</strong>';
@@ -120,6 +129,7 @@ function showPrivPane(name) {
 function focusFirstNode(id) {
        var tree = dijit.byId('privtree');
        if(tree._itemNodesMap && tree._itemNodesMap[id]) {
+               refreshNodeDropData();
                setSelected(id);
                updateNodeLabels(tree._itemNodesMap[id][0].label);
                tree.lastFocused = tree._itemNodesMap[id][0];
@@ -833,6 +843,8 @@ function setSelected(nodeid) {
 }
 
 function checkCanMove(tree, domnodes) {
+       if(typeof nodedropdata == 'number')
+               return false;
        var node = dijit.getEnclosingWidget(domnodes[0]);
        var nodeid = node.item.name[0];
        if(nodedropdata[nodeid] == 0)
@@ -841,6 +853,8 @@ function checkCanMove(tree, domnodes) {
 }
 
 function checkNodeDrop(domnode, tree, position) {
+       if(typeof nodedropdata == 'number')
+               return false;
        var node = dijit.getEnclosingWidget(domnode);
        var nodeid = node.item.name[0];
        if(nodedropdata[nodeid] == 0)
@@ -850,5 +864,5 @@ function checkNodeDrop(domnode, tree, po
 
 function refreshNodeDropData() {
        var data = {continuation: dojo.byId('refreshnodedropdatacont').value};
-       RPCwrapper(data, generalPrivCB, 0);
+       RPCwrapper(data, generalPrivCB, 0, 60000);
 }


Reply via email to