瀏覽代碼

Bug fix: the result of CheckToWrite() was not taken into account (action failed silently) when creating an object using the [+] button inside a form.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4056 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 9 年之前
父節點
當前提交
a0ab741637
共有 2 個文件被更改,包括 21 次插入8 次删除
  1. 14 7
      application/ui.extkeywidget.class.inc.php
  2. 7 1
      js/extkeywidget.js

+ 14 - 7
application/ui.extkeywidget.class.inc.php

@@ -505,16 +505,23 @@ EOF
 	 */
 	public function DoCreateObject($oPage)
 	{
-		$oObj = MetaModel::NewObject($this->sTargetClass);
-		$aErrors = $oObj->UpdateObjectFromPostedForm($this->iId);
-		if (count($aErrors) == 0)
+		try
 		{
-			$oObj->DBInsert();
-			return array('name' => $oObj->GetName(), 'id' => $oObj->GetKey());
+			$oObj = MetaModel::NewObject($this->sTargetClass);
+			$aErrors = $oObj->UpdateObjectFromPostedForm($this->iId);
+			if (count($aErrors) == 0)
+			{
+				$oObj->DBInsert();
+				return array('name' => $oObj->GetName(), 'id' => $oObj->GetKey());
+			}
+			else
+			{
+				return array('error' => implode(' ', $aErrors), 'id' => 0);		
+			}
 		}
-		else
+		catch(Exception $e)
 		{
-			return array('name' => implode(' ', $aErrors), 'id' => 0);		
+			return array('error' => $e->getMessage(), 'id' => 0);
 		}
 	}
 

+ 7 - 1
js/extkeywidget.js

@@ -381,7 +381,13 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper
 			me.ajax_request = $.post( AddAppContext(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php'), theMap, 
 				function(data)
 				{
-					if (me.bSelectMode)
+					$('#fstatus_'+me.id).html('');
+					if (data.id == 0)
+					{
+						$('#label_'+me.id).removeClass('ac_dlg_loading');
+						alert(data.error);
+					}
+					else if (me.bSelectMode)
 					{
 						// Add the newly created object to the drop-down list and select it
 						$('<option/>', { value : data.id }).html(data.name).appendTo('#'+me.id);