mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
N°2334 n:n relations : same fields displayed in EDIT and VIEW modes
Before we were only showing lnk fields in VIEW, and lnk+remote in EDIT (excluding some fields, see below). Now by default (as this is customizable in VIEW mode) we have the same ! Rules to choose fields are moved from \UILinksWidget::__construct to : * \MetaModel::GetZListAttDefsFilteredForIndirectRemoteClass * \MetaModel::GetZListAttDefsFilteredForIndirectLinkClass
This commit is contained in:
@@ -30,6 +30,9 @@ require_once('dbobjectiterator.php');
|
||||
|
||||
class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator
|
||||
{
|
||||
public const LINK_ALIAS = 'Link';
|
||||
public const REMOTE_ALIAS = 'Remote';
|
||||
|
||||
protected $sHostClass; // subclass of DBObject
|
||||
protected $sAttCode; // xxxxxx_list
|
||||
protected $sClass; // class of the links
|
||||
@@ -786,11 +789,13 @@ class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator
|
||||
/**
|
||||
* @param bool $bShowObsolete
|
||||
*
|
||||
* @return \DBObjectSet
|
||||
* @return \DBObjectSet indirect relations will get `SELECT L,R ...` (l = lnk class, R = remote)
|
||||
* @throws \CoreException
|
||||
* @throws \CoreWarning
|
||||
* @throws \MySQLException
|
||||
* @throws \Exception
|
||||
*
|
||||
* @since 2.8.0 N°2334 returns both lnk and remote classes for indirect relations
|
||||
*/
|
||||
public function ToDBObjectSet($bShowObsolete = true)
|
||||
{
|
||||
@@ -802,7 +807,11 @@ class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator
|
||||
$sExtKeyToRemote = $oAttDef->GetExtKeyToRemote();
|
||||
/** @var \AttributeExternalKey $oLinkingAttDef */
|
||||
$oLinkingAttDef = MetaModel::GetAttributeDef($this->sClass, $sExtKeyToRemote);
|
||||
|
||||
// N°2334 add pointed class (SELECT L,R) to have all fields (lnk + remote) in display
|
||||
// the pointed class is always present in the search, as generated by \AttributeLinkedSet::GetDefaultValue
|
||||
$sTargetClass = $oLinkingAttDef->GetTargetClass();
|
||||
$oRemoteClassSearch = new DBObjectSearch($sTargetClass);
|
||||
if (!$bShowObsolete && MetaModel::IsObsoletable($sTargetClass))
|
||||
{
|
||||
$oNotObsolete = new BinaryExpression(
|
||||
@@ -810,10 +819,12 @@ class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator
|
||||
'=',
|
||||
new ScalarExpression(0)
|
||||
);
|
||||
$oNotObsoleteRemote = new DBObjectSearch($sTargetClass);
|
||||
$oNotObsoleteRemote->AddConditionExpression($oNotObsolete);
|
||||
$oLinkSearch->AddCondition_PointingTo($oNotObsoleteRemote, $sExtKeyToRemote);
|
||||
$oRemoteClassSearch->AddConditionExpression($oNotObsolete);
|
||||
}
|
||||
$oLinkSearch->AddCondition_PointingTo($oRemoteClassSearch, $sExtKeyToRemote);
|
||||
$oLinkSearch->RenameAlias($oLinkSearch->GetClassAlias(), self::LINK_ALIAS);
|
||||
$oLinkSearch->RenameAlias($sTargetClass, self::REMOTE_ALIAS);
|
||||
$oLinkSearch->SetSelectedClasses([self::LINK_ALIAS, self::REMOTE_ALIAS]);
|
||||
}
|
||||
$oLinkSet = new DBObjectSet($oLinkSearch);
|
||||
$oLinkSet->SetShowObsoleteData($bShowObsolete);
|
||||
|
||||
Reference in New Issue
Block a user