mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
New API for SelectObjectField, replaced OQL query by DBSearch
SVN:trunk[3977]
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
namespace Combodo\iTop\Form\Field;
|
||||
|
||||
use \Closure;
|
||||
use \DBSearch;
|
||||
use Combodo\iTop\Form\Validator\NotEmptyExtKeyValidator;
|
||||
|
||||
/**
|
||||
@@ -28,21 +29,21 @@ use Combodo\iTop\Form\Validator\NotEmptyExtKeyValidator;
|
||||
*/
|
||||
class SelectObjectField extends Field
|
||||
{
|
||||
protected $sOqlQuery;
|
||||
protected $oSearch;
|
||||
protected $iMaximumComboLength;
|
||||
protected $iMinAutoCompleteChars;
|
||||
|
||||
public function __construct($sId, Closure $onFinalizeCallback = null)
|
||||
{
|
||||
parent::__construct($sId, $onFinalizeCallback);
|
||||
$this->sOqlQuery = null;
|
||||
$this->oSearch = null;
|
||||
$this->iMaximumComboLength = null;
|
||||
$this->iMinAutoCompleteChars = 3;
|
||||
}
|
||||
|
||||
public function SetOqlQuery($sOqlQuery)
|
||||
public function SetSearch(DBSearch $oSearch)
|
||||
{
|
||||
$this->sOqlQuery = $sOqlQuery;
|
||||
$this->oSearch = $oSearch;
|
||||
}
|
||||
|
||||
public function SetMaximumComboLength($iMaximumComboLength)
|
||||
@@ -85,9 +86,9 @@ class SelectObjectField extends Field
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function GetOqlQuery()
|
||||
public function GetSearch()
|
||||
{
|
||||
return $this->sOqlQuery;
|
||||
return $this->oSearch;
|
||||
}
|
||||
|
||||
public function GetMaximumComboLength()
|
||||
|
||||
@@ -87,7 +87,7 @@ class ConsoleSimpleFieldRenderer extends FieldRenderer
|
||||
$oOutput->AddHtml('<td class="form-field-content">');
|
||||
if ($this->oField->GetReadOnly())
|
||||
{
|
||||
$oSearch = \DBSearch::FromOQL($this->oField->GetOqlQuery());
|
||||
$oSearch = $this->oField->GetSearch()->DeepClone();
|
||||
$oSearch->AddCondition('id', $this->oField->GetCurrentValue());
|
||||
$oSet = new DBObjectSet($oSearch);
|
||||
$oObject = $oSet->Fetch();
|
||||
@@ -104,7 +104,7 @@ class ConsoleSimpleFieldRenderer extends FieldRenderer
|
||||
}
|
||||
else
|
||||
{
|
||||
$oSearch = \DBSearch::FromOQL($this->oField->GetOqlQuery());
|
||||
$oSearch = $this->oField->GetSearch()->DeepClone();
|
||||
$oSet = new \DBObjectSet($oSearch);
|
||||
$oSet->OptimizeColumnLoad(array($oSearch->GetClassAlias() => array('friendlyname')));
|
||||
$oOutput->AddHtml('<select class="form-field-data" id="'.$this->oField->GetGlobalId().'">');
|
||||
|
||||
Reference in New Issue
Block a user