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/12/11 17:01:45 UTC

svn commit: r1644688 - in /vcl/trunk/web: .ht-inc/requests.php js/requests.js

Author: jfthomps
Date: Thu Dec 11 16:01:45 2014
New Revision: 1644688

URL: http://svn.apache.org/r1644688
Log:
VCL-780 - combine new reservation and current reservations pages

requests.php:
-modified viewRequests: added 'notbyowner' variable to AJconfirmDeleteRequest continuation so it will prompt with the owner of the reservation instead of assuming the user is the owner; added dijit Dialog for prompting users when attempting to delete a server reservation owned by another user to make it clear that someone else owns it
-modified AJconfirmDeleteRequest: if user is not owner, return status to have user prompted that someone else owns the reservation

requests.js:
-modified endReservation: save passed in continuation in hidden form element so it can be reused when prompting user about deleting server reservation owned by another user
-added endServerReservation
-modified endReservationCB: if status is 'serverconfirm', prompt user that someone else owns the reservation; if prompt is open, hide it and enable the Confirm Delete button

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

Modified: vcl/trunk/web/.ht-inc/requests.php
URL: http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/requests.php?rev=1644688&r1=1644687&r2=1644688&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/requests.php (original)
+++ vcl/trunk/web/.ht-inc/requests.php Thu Dec 11 16:01:45 2014
@@ -121,7 +121,11 @@ function viewRequests() {
 				$cont = addContinuationsEntry('AJconnectRequest', $cdata, SECINDAY);
 				$text .= getViewRequestHTMLitem('connectbtn', $cont);
 				if($requests[$i]['serveradmin']) {
-					$cont = addContinuationsEntry('AJconfirmDeleteRequest', $cdata, SECINDAY);
+					$cdata2 = $cdata;
+					$cdata2['notbyowner'] = 0;
+					if($user['id'] != $requests[$i]['userid'])
+						$cdata2['notbyowner'] = 1;
+					$cont = addContinuationsEntry('AJconfirmDeleteRequest', $cdata2, SECINDAY);
 					$text .= getViewRequestHTMLitem('deletebtn', $cont);
 				}
 				else
@@ -192,7 +196,11 @@ function viewRequests() {
 					$text .= getViewRequestHTMLitem('pendingblock', $requests[$i]['id'], $data);
 					$refresh = 1;
 					if($requests[$i]['serveradmin'] && $requests[$i]['laststateid'] != 24) {
-						$cont = addContinuationsEntry('AJconfirmDeleteRequest', $cdata, SECINDAY);
+						$cdata2 = $cdata;
+						$cdata2['notbyowner'] = 0;
+						if($user['id'] != $requests[$i]['userid'])
+							$cdata2['notbyowner'] = 1;
+						$cont = addContinuationsEntry('AJconfirmDeleteRequest', $cdata2, SECINDAY);
 						$text .= getViewRequestHTMLitem('deletebtn', $cont);
 					}
 					else
@@ -203,7 +211,11 @@ function viewRequests() {
 				# reservation is in the future
 				$text .= "    <TD></TD>\n";
 				if($requests[$i]['serveradmin']) {
-					$cont = addContinuationsEntry('AJconfirmDeleteRequest', $cdata, SECINDAY);
+					$cdata2 = $cdata;
+					$cdata2['notbyowner'] = 0;
+					if($user['id'] != $requests[$i]['userid'])
+						$cdata2['notbyowner'] = 1;
+					$cont = addContinuationsEntry('AJconfirmDeleteRequest', $cdata2, SECINDAY);
 					$text .= getViewRequestHTMLitem('deletebtn', $cont);
 				}
 				else
@@ -868,6 +880,34 @@ function viewRequests() {
 		$text .= "   </div>\n";
 		$text .= "</div>\n";
 
+		$text .= "<div dojoType=dijit.Dialog\n";
+		$text .= "      id=\"serverdeletedlg\"\n";
+		$text .= "      duration=250\n";
+		$text .= "      draggable=true>\n";
+		$text .= "   <div id=\"serverDeleteDlgContent\">\n";
+		$text .= "   <h2>Confirm Server Delete</h2>\n";
+		$text .= "   <span class=\"rederrormsg\"><big>\n";
+		$warn = _("WARNING: You are not the owner of this reservation. You have been granted access to manage this reservation by another user. Hover over the details icon to see who the owner is. You should not delete this reservation unless the owner is aware that you are deleting it.");
+		$text .= preg_replace("/(.{1,80}([ \n]|$))/", '\1<br>', $warn);
+		$text .= "   </big></span>\n";
+		$text .= "   </div><br>\n";
+		$text .= "   <div align=\"center\">\n";
+		$text .= "   <input type=\"hidden\" id=\"deletecontholder\">\n";
+		$text .= "   <button id=\"serverDeleteDlgBtn\" dojoType=\"dijit.form.Button\">\n";
+		$text .= "     " . _("Confirm Delete Reservation") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       endServerReservation();\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   <button dojoType=\"dijit.form.Button\">\n";
+		$text .= "     " . _("Cancel") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       dijit.byId('serverdeletedlg').hide();\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   </div>\n";
+		$text .= "</div>\n";
+
 		print $text;
 	}
 	else {
@@ -3727,9 +3767,13 @@ function AJsubmitEditRequest() {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function AJconfirmDeleteRequest() {
+	global $user;
 	$requestid = getContinuationVar('requestid', 0);
 	$notbyowner = getContinuationVar('notbyowner', 0);
 	$fromtimetable = getContinuationVar('fromtimetable', 0);
+	$skipconfirm = processInputVar('skipconfirm', ARG_NUMERIC, 0);
+	if($skipconfirm != 0 && $skipconfirm != 1)
+		$skipconfirm = 0;
 	$request = getRequestInfo($requestid, 1);
 	if(is_null($request)) {
 		$data = array('error' => 1,
@@ -3757,6 +3801,11 @@ function AJconfirmDeleteRequest() {
 			}
 		}
 	}
+	if(! $skipconfirm && $user['id'] != $request['userid']) {
+		$data = array('status' => 'serverconfirm');
+		sendJSON($data);
+		return;
+	}
 	if(datetimeToUnix($request["start"]) > time()) {
 		$text = _("Delete reservation for <b>") . $reservation["prettyimage"]
 		      . _("</b> starting ") . prettyDatetime($request["start"]) . _("?<br>\n");
@@ -3795,6 +3844,7 @@ function AJconfirmDeleteRequest() {
 	$data = array('content' => $text,
 	              'cont' => $cont,
 	              'requestid' => $requestid,
+	              'status' => 'success',
 	              'btntxt' => _('Delete Reservation'));
 	sendJSON($data);
 }
@@ -4813,7 +4863,6 @@ function addConnectTimeout($resid, $comp
 	doQuery($query);
 }
 
-
 ////////////////////////////////////////////////////////////////////////////////
 ///
 /// \fn getReserveDayData()

Modified: vcl/trunk/web/js/requests.js
URL: http://svn.apache.org/viewvc/vcl/trunk/web/js/requests.js?rev=1644688&r1=1644687&r2=1644688&view=diff
==============================================================================
--- vcl/trunk/web/js/requests.js (original)
+++ vcl/trunk/web/js/requests.js Thu Dec 11 16:01:45 2014
@@ -1332,9 +1332,17 @@ function connectRequestCB(data, ioArgs)
 }
 
 function endReservation(cont) {
+	dojo.byId('deletecontholder').value = cont;
 	RPCwrapper({continuation: cont}, endReservationCB, 1, 30000);
 }
 
+function endServerReservation() {
+	dijit.byId('serverDeleteDlgBtn').set('disabled', true);
+	var data = {continuation: dojo.byId('deletecontholder').value,
+	            skipconfirm: 1};
+	RPCwrapper(data, endReservationCB, 1, 30000);
+}
+
 function endReservationCB(data, ioArgs) {
 	if(data.items.error) {
 		alert(data.items.msg);
@@ -1342,6 +1350,15 @@ function endReservationCB(data, ioArgs)
 			setTimeout(resRefresh, 800);
 		return;
 	}
+	if(data.items.status == 'serverconfirm') {
+		dijit.byId('serverDeleteDlgBtn').set('disabled', false);
+		dijit.byId('serverdeletedlg').show();
+		return;
+	}
+	if(dijit.byId('serverdeletedlg').open) {
+		dijit.byId('serverdeletedlg').hide();
+		dijit.byId('serverDeleteDlgBtn').set('disabled', false);
+	}
 	dojo.byId('endrescont').value = data.items.cont;
 	dojo.byId('endresid').value = data.items.requestid;
 	dojo.byId('endResDlgContent').innerHTML = data.items.content;