Author: jfthomps
Date: Mon May 14 18:17:21 2012
New Revision: 1338326

URL: http://svn.apache.org/viewvc?rev=1338326&view=rev
Log:
VCL-311
add more fields to edit computer page

computers.php: modified editOrAddComputer - fixed a few small issues with how 
the options you are allowed to select are controlled

computers.js: modified editComputerSelectType - fixed a few small issues with 
how the options you are allowed to select are controlled

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

Modified: incubator/vcl/trunk/web/.ht-inc/computers.php
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/computers.php?rev=1338326&r1=1338325&r2=1338326&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/computers.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/computers.php Mon May 14 18:17:21 2012
@@ -572,14 +572,10 @@ function editOrAddComputer($state) {
        
        $tmpstates = getStates();
        if($data["stateid"] && array_key_exists($data['stateid'], $tmpstates)) {
-               if($state == 0 && $data['type'] == 'virtualmachine' &&
-                  $computers[$data['compid']]['vmhostid'] == '')
-                       $states = array(10 => "maintenance");
-               else
-                       $states = array($data["stateid"] => 
$tmpstates[$data["stateid"]],
-                                       2 => "available",
-                                       10 => "maintenance",
-                                       20 => "vmhostinuse");
+               $states = array($data["stateid"] => 
$tmpstates[$data["stateid"]],
+                               2 => "available",
+                               10 => "maintenance",
+                               20 => "vmhostinuse");
        }
        else
                $states = array(2 => "available",
@@ -613,6 +609,7 @@ function editOrAddComputer($state) {
        print "var allowedstates = [";
        print implode(',', $tmp);
        print "];\n";
+       print "var provval = {$data['provisioningid']};\n";
        $data2['states'] = $states;
        $platforms = getPlatforms();
        $tmp = getUserResources(array("scheduleAdmin"), array("manageGroup"));
@@ -733,8 +730,13 @@ function editOrAddComputer($state) {
        print "  <TR>\n";
        print "    <TH align=right>State:</TH>\n";
        print "    <TD>\n";
-       if($state == 1 || ($state == 0 && 
$computers[$data['compid']]['provisioning'] == 'None'))
+       if($state == 1 ||
+               ($state == 0 && ($computers[$data['compid']]['provisioning'] == 
'None' ||
+               ($data['type'] == 'virtualmachine' && $data['stateid'] != 2)) ||
+               ($data['type'] == 'virtualmachine' && 
$computers[$data['compid']]['vmhostid'] == '')))
                unset_by_val('available', $states);
+       if($state == 0 && $computers[$data['compid']]['type'] == 
'virtualmachine')
+               unset_by_val('vmhostinuse', $states);
        printSelectInput('stateid', $states, $data['stateid'], 0, 0, 'stateid', 
'dojoType="dijit.form.Select" onChange="editComputerSelectState();"');
        print "    </TD>\n";
        print "    <TD>";

Modified: incubator/vcl/trunk/web/js/computers.js
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/web/js/computers.js?rev=1338326&r1=1338325&r2=1338326&view=diff
==============================================================================
--- incubator/vcl/trunk/web/js/computers.js (original)
+++ incubator/vcl/trunk/web/js/computers.js Mon May 14 18:17:21 2012
@@ -273,7 +273,10 @@ function editComputerSelectType(skipprov
        var type = dijit.byId('type').get('value');
        var prov = dijit.byId('provisioningid').attr('displayedValue');
        for(var i = 0; i < allowedstates.length; i++) {
-               if(type == 'virtualmachine' && allowedstates[i].label != 
'maintenance')
+               if(type == 'virtualmachine' && allowedstates[i].label != 
'maintenance' &&
+                  startstate != 'available')
+                       continue;
+               if(type == 'virtualmachine' && allowedstates[i].label == 
'vmhostinuse')
                        continue;
                if(type == 'lab' && allowedstates[i].label != 'available' &&
                        allowedstates[i].label != 'maintenance')
@@ -286,12 +289,20 @@ function editComputerSelectType(skipprov
        }
        if(restorestate)
                sobj.set('value', savestate);
-       if(! skipprov) {
+       if(skipprov) {
+               for(var i = 0; i < dijit.byId('provisioningid').options.length; 
i++) {
+                       if(provval == 
dijit.byId('provisioningid').options[i].value) {
+                               provval = 
dijit.byId('provisioningid').get('value');
+                       }
+               }
+       }
+       else {
                var pobj = dijit.byId('provisioningid');
                pobj.removeOption(pobj.getOptions());
                for(var i = 0; i < allowedprovs[type].length; i++) {
-                       pobj.addOption({value: allowedprovs[type][i].id, label: 
allowedprovs[type][i].name});
+                       pobj.addOption({value: 
String(allowedprovs[type][i].id), label: allowedprovs[type][i].name});
                }
+               dijit.byId('provisioningid').set('value', String(provval));
        }
 }
 


Reply via email to