Преглед изворни кода

- Better management of (truncated) list of linked objects (Trac #219)
- New type of display block to display some "actions" (New/Search) for a given class of objects.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@709 a333f486-631f-4898-b8df-5754b55c2be0

dflaven пре 14 година
родитељ
комит
c7b529d42d
2 измењених фајлова са 30 додато и 3 уклоњено
  1. 4 0
      application/cmdbabstract.class.inc.php
  2. 26 3
      application/displayblock.class.inc.php

+ 4 - 0
application/cmdbabstract.class.inc.php

@@ -483,6 +483,10 @@ abstract class cmdbAbstractObject extends CMDBObject
 			$divId = $aExtraParams['block_id'];
 			$sFilter = $oSet->GetFilter()->serialize();
 			$aExtraParams['display_limit'] = false; // To expand the full list
+			foreach($oSet->GetFilter()->GetInternalParams() as $sName => $sValue)
+			{
+				$aExtraParams['query_params'][$sName] = $sValue;
+			}
 			$sExtraParams = addslashes(str_replace('"', "'", json_encode($aExtraParams))); // JSON encode, change the style of the quotes and escape them
 			$sHtml .= '<tr class="containerHeader"><td>'.Dict::Format('UI:TruncatedResults', utils::GetConfig()->GetMinDisplayLimit(), $oSet->Count()).'&nbsp;&nbsp;<a href="#open_'.$divId.'" onClick="Javascript:ReloadTruncatedList(\''.$divId.'\', \''.$sFilter.'\', \''.$sExtraParams.'\');">'.Dict::S('UI:DisplayAll').'</a></td><td>';
 			$oPage->add_ready_script("$('#{$divId} table.listResults').addClass('truncated');");

+ 26 - 3
application/displayblock.class.inc.php

@@ -290,6 +290,11 @@ class DisplayBlock
 		$bDoSearch = utils::ReadParam('dosearch', false);
 		if ($this->m_oSet == null)
 		{
+			$aQueryParams = array();
+			if (isset($aExtraParams['query_params']))
+			{
+				$aQueryParams = $aExtraParams['query_params'];
+			}
 			if ($this->m_sStyle != 'links')
 			{
 				$aFilterCodes = array_keys(MetaModel::GetClassFilterDefs($this->m_oFilter->GetClass()));
@@ -306,7 +311,7 @@ class DisplayBlock
 					}
 				}
 			}
-			$this->m_oSet = new CMDBObjectSet($this->m_oFilter);
+			$this->m_oSet = new CMDBObjectSet($this->m_oFilter, array(), $aQueryParams);
 		}
 		switch($this->m_sStyle)
 		{
@@ -340,8 +345,13 @@ class DisplayBlock
 			else
 			{
 				// Simply count the number of elements in the set
-				$iCount = $oSet->Count();
-				$sHtml .= $oPage->GetP(Dict::Format('UI:CountOfObjects', $iCount));
+				$iCount = $this->m_oSet->Count();
+				$sFormat = 'UI:CountOfObjects';
+				if (isset($aExtraParams['format']))
+				{
+					$sFormat = $aExtraParams['format'];
+				}
+				$sHtml .= $oPage->GetP(Dict::Format($sFormat, $iCount));
 			}
 			
 			break;
@@ -542,6 +552,19 @@ class DisplayBlock
 			}
 			break;
 			
+			case 'actions':
+			$sClass = $this->m_oFilter->GetClass();
+			$oAppContext = new ApplicationContext();
+			$sParams = $oAppContext->GetForLink();
+			$sHtml .= '<p>';
+			if (UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY))
+			{
+				$sHtml .= "<a href=\"../pages/UI.php?operation=new&class={$sClass}&$sParams\">".Dict::Format('UI:ClickToCreateNew', MetaModel::GetName($sClass))."</a><br/>\n";
+			}
+			$sHtml .= "<a href=\"../pages/UI.php?operation=search_form&class={$sClass}&$sParams\">".Dict::Format('UI:SearchFor_Class', MetaModel::GetName($sClass))."</a>\n";
+			$sHtml .= '</p>';
+			break;
+			
 			case 'bare_details':
 			while($oObj = $this->m_oSet->Fetch())
 			{