You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by jf...@apache.org on 2014/11/03 21:47:20 UTC

svn commit: r1636438 - in /vcl/trunk/web: .ht-inc/resource.php js/resources.js js/resources/image.js

Author: jfthomps
Date: Mon Nov  3 20:47:20 2014
New Revision: 1636438

URL: http://svn.apache.org/r1636438
Log:
VCL-776 - rework resource code to have a base class for all resources and inheriting classes for each resource type

updated confirm delete of resource to have user friendly field names and values

resource.php: modified AJpromptToggleDeleteResource: send array of field/name/value combinations instead of just html so that javascript function that generates user friendly values can be called on the values

image.js: modified colformatter: added conditional for maxinitialtime

resources.js: modified toggleDeleteResourceCB: generate html table for names/values from array instead of just using passed in html; join with passed in html when displaying so that data passed in via toggleDeleteResourceExtra gets displayed

Modified:
    vcl/trunk/web/.ht-inc/resource.php
    vcl/trunk/web/js/resources.js
    vcl/trunk/web/js/resources/image.js

Modified: vcl/trunk/web/.ht-inc/resource.php
URL: http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/resource.php?rev=1636438&r1=1636437&r2=1636438&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/resource.php (original)
+++ vcl/trunk/web/.ht-inc/resource.php Mon Nov  3 20:47:20 2014
@@ -320,7 +320,6 @@ class Resource {
 		foreach($names as $field => $name) {
 			if($field == $this->namefield ||
 			   $field == 'name' ||
-			   #$field == 'owner' ||
 			   is_array($resdata[$testid][$field]) ||
 			   preg_match('/id$/', $field))
 				continue;
@@ -624,8 +623,7 @@ class Resource {
 			sendJSON($rt);
 			return;
 		}
-		$rt = array('html' => '',
-		            'title' => "Confirm Delete {$this->restypename}",
+		$rt = array('title' => "Confirm Delete {$this->restypename}",
 		            'question' => "Delete the following {$this->restype}?",
 		            'btntxt' => "Delete {$this->restypename}",
 		            'status' => 'success');
@@ -640,9 +638,13 @@ class Resource {
 			$rt['btntxt'] = "Undelete {$this->restypename}";
 		}
 		$fields = array_keys($resdata[$rscid]);
-		$rt['html'] .= "<table>";
-		$rt['html'] .= "<tr><th>Name:</th><td>{$resdata[$rscid][$this->namefield]}</td></tr>";
-		$rt['html'] .= "<tr><th>Owner:</th><td>{$resdata[$rscid]['owner']}</td></tr>";
+		$rt['fields'] = array();
+		$rt['fields'][] = array('field' => 'name',
+		                        'name' => 'Name',
+		                        'value' => $resdata[$rscid][$this->namefield]);
+		$rt['fields'][] = array('field' => 'owner',
+		                        'name' => 'Owner',
+		                        'value' => $resdata[$rscid]['owner']);
 		foreach($fields as $field) {
 			if($field == $this->namefield ||
 			   $field == 'name' ||
@@ -650,12 +652,11 @@ class Resource {
 			   is_array($resdata[$rscid][$field]) ||
 			   preg_match('/id$/', $field))
 				continue;
-			$rt['html'] .= "<tr><th>";
-			$rt['html'] .= ucfirst($field);
-			$rt['html'] .= ":</th><td>{$resdata[$rscid][$field]}</td></tr>";
+			$rt['fields'][] = array('field' => $field,
+			                        'name' => $this->fieldDisplayName($field),
+			                        'value' => $resdata[$rscid][$field]);
 		}
-		$rt['html'] .= "</table>";
-		$rt['html'] .= $this->toggleDeleteResourceExtra();
+		$rt['html'] = $this->toggleDeleteResourceExtra();
 
 		$cdata = getContinuationVar();
 		$cdata['rscid'] = $rscid;

Modified: vcl/trunk/web/js/resources.js
URL: http://svn.apache.org/viewvc/vcl/trunk/web/js/resources.js?rev=1636438&r1=1636437&r2=1636438&view=diff
==============================================================================
--- vcl/trunk/web/js/resources.js (original)
+++ vcl/trunk/web/js/resources.js Mon Nov  3 20:47:20 2014
@@ -244,7 +244,17 @@ function toggleDeleteResourceCB(data, io
 		dojo.byId('toggleDeleteHeading').innerHTML = data.items.title;
 		dojo.byId('toggleDeleteQuestion').innerHTML = data.items.question;
 		dojo.byId('toggleDeleteBtn').innerHTML = data.items.btntxt;
-		dojo.byId('confdelrescontent').innerHTML = data.items.html;
+		var txt = '<table>';
+		for(var i = 0; i < data.items.fields.length; i++) {
+			var item = data.items.fields[i];
+			txt += '<tr><th align="right">'
+			txt += item.name
+			    + ':</th><td>'
+			    + resource.colformatter(item.value, '', item) 
+			    + '</td></tr>';
+		}
+		txt += '</table>';
+		dojo.byId('confdelrescontent').innerHTML = txt + data.items.html;
 		dojo.byId('submitdeletecont').value = data.items.cont;
 		dijit.byId('toggleDeleteDialog').show();
 	}

Modified: vcl/trunk/web/js/resources/image.js
URL: http://svn.apache.org/viewvc/vcl/trunk/web/js/resources/image.js?rev=1636438&r1=1636437&r2=1636438&view=diff
==============================================================================
--- vcl/trunk/web/js/resources/image.js (original)
+++ vcl/trunk/web/js/resources/image.js Mon Nov  3 20:47:20 2014
@@ -34,6 +34,8 @@ Image.prototype.colformatter = function(
 		if(value == "1")
 			return '<span class="ready">true</span>';
 	}
+	if(obj.field == 'maxinitialtime' && value == 0)
+		return '(unset)';
 	return value;
 }