소스 검색

Dashboard: continuing...

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2007 a333f486-631f-4898-b8df-5754b55c2be0
romainq 13 년 전
부모
커밋
f0c5d8fab6
1개의 변경된 파일24개의 추가작업 그리고 13개의 파일을 삭제
  1. 24 13
      application/dashlet.class.inc.php

+ 24 - 13
application/dashlet.class.inc.php

@@ -26,7 +26,6 @@ abstract class Dashlet
 	protected $bRedrawNeeded;
 	protected $bFormRedrawNeeded;
 	protected $aProperties; // array of {property => value}
-	protected $aChanges; // array of {property => old value}
 	
 	public function __construct($sId)
 	{
@@ -34,7 +33,6 @@ abstract class Dashlet
 		$this->bRedrawNeeded = true; // By default: redraw each time a property changes
 		$this->bFormRedrawNeeded = false; // By default: no need to redraw the form (independent fields)
 		$this->aProperties = array(); // By default: there is no property
-		$this->aChanges = array();
 	}
 
 	// Assuming that a property has the type of its default value, set in the constructor
@@ -104,12 +102,7 @@ abstract class Dashlet
 		{
 			if (array_key_exists($sProperty, $aParams))
 			{
-				$newvalue = $aParams[$sProperty];
-				if ($newvalue != $value)
-				{
-					$this->aChanges[$sProperty] = $value;
-				}
-				$this->aProperties[$sProperty] = $newvalue;
+				$this->aProperties[$sProperty] = $aParams[$sProperty];
 			}
 		}
 	}
@@ -401,6 +394,12 @@ class DashletGroupBy extends Dashlet
 			$oBlock = DisplayBlock::FromTemplate($sXML);
 			$oBlock->Display($oPage, $sBlockId, $aParams);
 			$oPage->add('</div>');
+
+			// TEST Group By as SQL!
+			//$oSearch = DBObjectSearch::FromOQL($this->aProperties['query']);
+			//$sSql = MetaModel::MakeSelectQuery($oSearch);
+			//$sHtmlSql = htmlentities($sSql, ENT_QUOTES, 'UTF-8');
+			//$oPage->p($sHtmlSql);
 		}
 	}
 
@@ -421,7 +420,17 @@ class DashletGroupBy extends Dashlet
 			if (!$oAttDef->IsScalar()) continue; // skip link sets
 			if ($oAttDef->IsExternalKey(EXTKEY_ABSOLUTE)) continue; // skip external keys
 			$aGroupBy[$sAttCode] = $oAttDef->GetLabel();
+
+			if ($oAttDef instanceof AttributeDateTime)
+			{
+				//date_format(start_date, '%d')
+				$aGroupBy['date_of_'.$sAttCode] = 'Day of '.$oAttDef->GetLabel();
+			}
+
 		}
+
+		
+
 		$oField = new DesignerComboField('group_by', 'Group by', $this->aProperties['group_by']);
 		$oField->SetAllowedValues($aGroupBy);
 		$oForm->AddField($oField);
@@ -438,25 +447,27 @@ class DashletGroupBy extends Dashlet
 		$oForm->AddField($oField);
 	}
 	
-	public function FromParams($aParams)
+	public function Update($aValues, $aUpdatedFields)
 	{
-		parent::FromParams($aParams);
-		if (array_key_exists('query', $this->aChanges))
+		if (in_array('query', $aUpdatedFields))
 		{
-			$sCurrQuery = $this->aProperties['query'];
+			$sCurrQuery = $aValues['query'];
 			$oCurrSearch = DBObjectSearch::FromOQL($sCurrQuery);
 			$sCurrClass = $oCurrSearch->GetClass();
 
-			$sPrevQuery = $this->aChanges['query'];
+			$sPrevQuery = $this->aProperties['query'];
 			$oPrevSearch = DBObjectSearch::FromOQL($sPrevQuery);
 			$sPrevClass = $oPrevSearch->GetClass();
 
 			if ($sCurrClass != $sPrevClass)
 			{
 				$this->bFormRedrawNeeded = true;
+				// wrong but not necessary - unset($aUpdatedFields['group_by']);
 				$this->aProperties['group_by'] = '';
 			}
 		}
+
+		parent::Update($aValues, $aUpdatedFields);
 	}
 
 	static public function GetInfo()