New API for SelectObjectField, replaced OQL query by DBSearch

SVN:trunk[3977]
This commit is contained in:
Guillaume Lajarige
2016-04-04 10:22:57 +00:00
parent f01bd61692
commit b741532231
2 changed files with 9 additions and 8 deletions

View File

@@ -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()

View File

@@ -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().'">');