mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
N°580 - Jean Dupont - Jean Dupont, auto-complete avec homonyme
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
use Combodo\iTop\Core\MetaModel\FriendlyNameType;
|
||||
|
||||
require_once(APPROOT.'/application/displayblock.class.inc.php');
|
||||
|
||||
/**
|
||||
@@ -200,42 +202,33 @@ class UIExtKeyWidget
|
||||
$sHelpText = ''; //$this->oAttDef->GetHelpOnEdition();
|
||||
//$sHTMLValue .= "<div class=\"field_select_wrapper\">\n";
|
||||
$aOptions = [];
|
||||
$sDisplayValue = "";
|
||||
|
||||
$aOption = [];
|
||||
$aOption['value'] = "";
|
||||
$aOption['label'] = Dict::S('UI:SelectOne');
|
||||
array_push($aOptions,$aOption);
|
||||
array_push($aOptions, $aOption);
|
||||
|
||||
$oAllowedValues->Rewind();
|
||||
$bAddingValue=false;
|
||||
$sClassAllowed = $oAllowedValues->GetClass();
|
||||
$bAddingValue = false;
|
||||
|
||||
$aComplementAttributeSpec = MetaModel::GetComplementAttributeSpec($oAllowedValues->GetClass());
|
||||
$aComplementAttributeSpec = MetaModel::GetNameSpec($oAllowedValues->GetClass(), FriendlyNameType::COMPLEMENTARY);
|
||||
$sFormatAdditionalField = $aComplementAttributeSpec[0];
|
||||
$aAdditionalField = $aComplementAttributeSpec[1];
|
||||
|
||||
if (count($aAdditionalField)>0)
|
||||
{
|
||||
$bAddingValue=true;
|
||||
if (count($aAdditionalField) > 0) {
|
||||
$bAddingValue = true;
|
||||
}
|
||||
while($oObj = $oAllowedValues->Fetch())
|
||||
{
|
||||
$aOption=[];
|
||||
$sObjectImageAttCode = MetaModel::GetImageAttributeCode($sClassAllowed);
|
||||
while ($oObj = $oAllowedValues->Fetch()) {
|
||||
$aOption = [];
|
||||
$aOption['value'] = $oObj->GetKey();
|
||||
$aOption['label'] = $oObj->GetName();//.'<span class=\"object-ref-icon fas fa-eye-slash object-obsolete fa-1x fa-fw\"></span>';
|
||||
|
||||
if (($oAllowedValues->Count() == 1) && ($bMandatory == 'true') )
|
||||
{
|
||||
if (($oAllowedValues->Count() == 1) && ($bMandatory == 'true')) {
|
||||
// When there is only once choice, select it by default
|
||||
$sDisplayValue=$oObj->GetName();
|
||||
if($value != $oObj->GetKey())
|
||||
{
|
||||
$value=$oObj->GetKey();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((is_array($value) && in_array($oObj->GetKey(), $value)) || ($value == $oObj->GetKey())) {
|
||||
$sDisplayValue = $oObj->GetName();
|
||||
if ($value != $oObj->GetKey()) {
|
||||
$value = $oObj->GetKey();
|
||||
}
|
||||
}
|
||||
if ($oObj->IsObsolete()) {
|
||||
@@ -248,6 +241,17 @@ class UIExtKeyWidget
|
||||
}
|
||||
$aOption['additional_field'] = vsprintf($sFormatAdditionalField, $aArguments);
|
||||
}
|
||||
if (!empty($sObjectImageAttCode)) {
|
||||
// Try to retrieve image for contact
|
||||
/** @var \ormDocument $oImage */
|
||||
$oImage = $oObj->Get($sObjectImageAttCode);
|
||||
if (!$oImage->IsEmpty()) {
|
||||
$aOption['picture_url'] = $oImage->GetDisplayURL($sClassAllowed, $oObj->GetKey(), $sObjectImageAttCode);
|
||||
$aOption['initials'] = '';
|
||||
} else {
|
||||
$aOption['initials'] = utils::ToAcronym($oObj->Get('friendlyname'));
|
||||
}
|
||||
}
|
||||
array_push($aOptions, $aOption);
|
||||
}
|
||||
$sInputType = CmdbAbstractObject::ENUM_INPUT_TYPE_DROPDOWN_DECORATED;
|
||||
@@ -811,21 +815,24 @@ JS
|
||||
{
|
||||
case static::ENUM_OUTPUT_FORMAT_JSON:
|
||||
|
||||
$aJsonMap = array();
|
||||
foreach ($aValues as $sKey => $aValue)
|
||||
{
|
||||
if ($aValue['additional_field'] != '')
|
||||
{
|
||||
$aJsonMap[] = array('value' => $sKey, 'label' => $aValue['label'], 'obsolescence_flag' => $aValue['obsolescence_flag'], 'additional_field' => $aValue['additional_field']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$aJsonMap[] = array('value' => $sKey, 'label' => $aValue['label'], 'obsolescence_flag' => $aValue['obsolescence_flag']);
|
||||
}
|
||||
}
|
||||
$aJsonMap = array();
|
||||
foreach ($aValues as $sKey => $aValue) {
|
||||
$aElt = ['value' => $sKey, 'label' => $aValue['label'], 'obsolescence_flag' => $aValue['obsolescence_flag']];
|
||||
if ($aValue['additional_field'] != '') {
|
||||
$aElt['additional_field'] = $aValue['additional_field'];
|
||||
}
|
||||
|
||||
$oP->SetContentType('application/json');
|
||||
$oP->add(json_encode($aJsonMap));
|
||||
if (array_key_exists('initials', $aValue)) {
|
||||
$aElt['initials'] = $aValue['initials'];
|
||||
if (array_key_exists('picture_url', $aValue)) {
|
||||
$aElt['picture_url'] = $aValue['picture_url'];
|
||||
}
|
||||
}
|
||||
$aJsonMap[] = $aElt;
|
||||
}
|
||||
|
||||
$oP->SetContentType('application/json');
|
||||
$oP->add(json_encode($aJsonMap));
|
||||
break;
|
||||
|
||||
case static::ENUM_OUTPUT_FORMAT_CSV:
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
use Combodo\iTop\Core\MetaModel\FriendlyNameType;
|
||||
|
||||
/**
|
||||
* All objects to be displayed in the application (either as a list or as details)
|
||||
* must implement this interface.
|
||||
@@ -1525,14 +1527,14 @@ abstract class DBObject implements iDisplay
|
||||
* Helper to get the friendly name in a safe manner for displaying inside a web page
|
||||
*
|
||||
* @internal
|
||||
* @since 3.0.0 N°4106 This method is now internal. It will be set final in 3.1.0 (N°4107)
|
||||
*
|
||||
* @return string
|
||||
* @throws \CoreException
|
||||
* @since 3.0.0 N°4106 This method is now internal. It will be set final in 3.1.0 (N°4107)
|
||||
*
|
||||
*/
|
||||
public function GetName()
|
||||
public function GetName($sType = FriendlyNameType::SHORT)
|
||||
{
|
||||
return htmlentities($this->GetRawName(), ENT_QUOTES, 'UTF-8');
|
||||
return htmlentities($this->GetRawName($sType), ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1548,9 +1550,14 @@ abstract class DBObject implements iDisplay
|
||||
* @since 3.0.0 N°4106 This method is now internal. It will be set final in 3.1.0 (N°4107)
|
||||
*
|
||||
*/
|
||||
public function GetRawName()
|
||||
public function GetRawName($sType = FriendlyNameType::SHORT)
|
||||
{
|
||||
return $this->Get('friendlyname');
|
||||
if ($sType == FriendlyNameType::SHORT) {
|
||||
return $this->Get('friendlyname');
|
||||
} else {
|
||||
$oExpression = MetaModel::GetNameExpression(get_class($this), $sType);
|
||||
$this->EvaluateExpression($oExpression);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
// along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||
//
|
||||
|
||||
use Combodo\iTop\Core\MetaModel\FriendlyNameType;
|
||||
|
||||
require_once APPROOT.'core/modulehandler.class.inc.php';
|
||||
require_once APPROOT.'core/querymodifier.class.inc.php';
|
||||
require_once APPROOT.'core/metamodelmodifier.inc.php';
|
||||
@@ -24,6 +26,7 @@ require_once APPROOT.'core/computing.inc.php';
|
||||
require_once APPROOT.'core/relationgraph.class.inc.php';
|
||||
require_once APPROOT.'core/apc-compat.php';
|
||||
require_once APPROOT.'core/expressioncache.class.inc.php';
|
||||
require_once APPROOT.'sources/Core/MetaModel/FriendlyNameType.php';
|
||||
|
||||
|
||||
/**
|
||||
@@ -757,12 +760,48 @@ abstract class MetaModel
|
||||
* @throws \CoreException
|
||||
* @throws \DictExceptionMissingString
|
||||
*/
|
||||
final public static function GetNameSpec($sClass)
|
||||
final public static function GetNameSpec($sClass, $sType = FriendlyNameType::SHORT)
|
||||
{
|
||||
self::_check_subclass($sClass);
|
||||
$nameRawSpec = self::$m_aClassParams[$sClass]["name_attcode"];
|
||||
|
||||
switch ($sType) {
|
||||
case FriendlyNameType::COMPLEMENTARY:
|
||||
if (!isset(self::$m_aClassParams[$sClass]["complementary_name_attcode"])) {
|
||||
return [$sClass, []];
|
||||
}
|
||||
$nameRawSpec = self::$m_aClassParams[$sClass]["complementary_name_attcode"];
|
||||
$sDictName = 'ComplementaryName';
|
||||
break;
|
||||
case FriendlyNameType::LONG:
|
||||
$nameRawSpec = self::$m_aClassParams[$sClass]["name_attcode"];
|
||||
if (!isset(self::$m_aClassParams[$sClass]["complementary_name_attcode"])) {
|
||||
return self::GetNameSpec($sClass, FriendlyNameType::SHORT);
|
||||
}
|
||||
$complementaryNameRawSpec = self::$m_aClassParams[$sClass]["complementary_name_attcode"];
|
||||
if (is_array($nameRawSpec)) {
|
||||
if (is_array($complementaryNameRawSpec)) {
|
||||
$nameRawSpec = merge($nameRawSpec, $complementaryNameRawSpec);
|
||||
} elseif (!empty($nameRawSpec)) {
|
||||
$nameRawSpec = merge($nameRawSpec, [$complementaryNameRawSpec]);
|
||||
}
|
||||
} elseif (empty($nameRawSpec)) {
|
||||
$nameRawSpec = $complementaryNameRawSpec;
|
||||
} else {
|
||||
if (is_array($complementaryNameRawSpec)) {
|
||||
$nameRawSpec = merge([$nameRawSpec], $complementaryNameRawSpec);
|
||||
} elseif (!empty($nameRawSpec)) {
|
||||
$nameRawSpec = [$nameRawSpec, $complementaryNameRawSpec];
|
||||
}
|
||||
}
|
||||
$sDictName = 'LongName';
|
||||
break;
|
||||
default:
|
||||
$nameRawSpec = self::$m_aClassParams[$sClass]["name_attcode"];
|
||||
$sDictName = 'Name';
|
||||
}
|
||||
|
||||
if (is_array($nameRawSpec)) {
|
||||
$sFormat = Dict::S("Class:$sClass/Name", '');
|
||||
$sFormat = Dict::S("Class:$sClass/$sDictName", '');
|
||||
if (strlen($sFormat) == 0) {
|
||||
// Default to "%1$s %2$s..."
|
||||
for ($i = 1; $i <= count($nameRawSpec); $i++) {
|
||||
@@ -774,12 +813,12 @@ abstract class MetaModel
|
||||
}
|
||||
}
|
||||
|
||||
return array($sFormat, $nameRawSpec);
|
||||
return [$sFormat, $nameRawSpec];
|
||||
} elseif (empty($nameRawSpec)) {
|
||||
return array($sClass, array());
|
||||
return [$sClass, []];
|
||||
} else {
|
||||
// string -> attcode
|
||||
return array('%1$s', array($nameRawSpec));
|
||||
return ['%1$s', [$nameRawSpec]];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -792,19 +831,32 @@ abstract class MetaModel
|
||||
* @throws \CoreException
|
||||
* @since 3.0.0
|
||||
*/
|
||||
final public static function GetNameAttributes(string $sClass, $bWithAttributeDefinition = false): array
|
||||
final public static function GetNameAttributes(string $sClass, $bWithAttributeDefinition = false, $sType = FriendlyNameType::SHORT): array
|
||||
{
|
||||
self::_check_subclass($sClass);
|
||||
$rawNameAttCodes = self::$m_aClassParams[$sClass]["name_attcode"];
|
||||
$aNameAttCodes = [];
|
||||
if (!is_array($rawNameAttCodes)) {
|
||||
if (self::IsValidAttCode($sClass, $rawNameAttCodes)) {
|
||||
$aNameAttCodes[] = $rawNameAttCodes;
|
||||
if ($sType == FriendlyNameType::SHORT || FriendlyNameType::LONG) {
|
||||
$rawNameAttCodes = self::$m_aClassParams[$sClass]["name_attcode"];
|
||||
if (!is_array($rawNameAttCodes)) {
|
||||
if (self::IsValidAttCode($sClass, $rawNameAttCodes)) {
|
||||
$aNameAttCodes[] = $rawNameAttCodes;
|
||||
}
|
||||
} else {
|
||||
$aNameAttCodes = $rawNameAttCodes;
|
||||
}
|
||||
}
|
||||
if ($sType == FriendlyNameType::COMPLEMENTARY || FriendlyNameType::LONG) {
|
||||
$rawNameAttCodes = self::$m_aClassParams[$sClass]["complementary_name_attcode"];
|
||||
if (!isEmpty($rawNameAttCodes)) {
|
||||
if (!is_array($rawNameAttCodes)) {
|
||||
if (self::IsValidAttCode($sClass, $rawNameAttCodes)) {
|
||||
$aNameAttCodes[] = array_merge($aNameAttCodes, [$rawNameAttCodes]);
|
||||
}
|
||||
} else {
|
||||
$aNameAttCodes = array_merge($rawNameAttCodes, $rawNameAttCodes);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$aNameAttCodes = $rawNameAttCodes;
|
||||
}
|
||||
|
||||
if ($bWithAttributeDefinition) {
|
||||
$aResults = [];
|
||||
foreach ($aNameAttCodes as $sAttCode) {
|
||||
@@ -842,56 +894,6 @@ abstract class MetaModel
|
||||
return $aResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sClass
|
||||
*
|
||||
* @return array
|
||||
* @throws \CoreException
|
||||
* @throws \DictExceptionMissingString
|
||||
*/
|
||||
final static public function GetComplementAttributeSpec($sClass)
|
||||
{
|
||||
self::_check_subclass($sClass);
|
||||
if (!isset(self::$m_aClassParams[$sClass]["name_complement_for_select"]))
|
||||
{
|
||||
$sParentClass = static::GetParentClass($sClass);
|
||||
if (is_null($sParentClass)) {
|
||||
return array($sClass, array());
|
||||
} else {
|
||||
return static::GetComplementAttributeSpec($sParentClass);
|
||||
}
|
||||
}
|
||||
$nameRawSpec = self::$m_aClassParams[$sClass]["name_complement_for_select"];
|
||||
if (is_array($nameRawSpec))
|
||||
{
|
||||
$sFormat = Dict::S("Class:$sClass/ComplementForSelect", '');
|
||||
if (strlen($sFormat) == 0)
|
||||
{
|
||||
// Default to "%1$s %2$s..."
|
||||
for($i = 1; $i <= count($nameRawSpec); $i++)
|
||||
{
|
||||
if (empty($sFormat))
|
||||
{
|
||||
$sFormat .= '%'.$i.'$s';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sFormat .= ' %'.$i.'$s';
|
||||
}
|
||||
}
|
||||
}
|
||||
return array($sFormat, $nameRawSpec);
|
||||
}
|
||||
elseif (empty($nameRawSpec))
|
||||
{
|
||||
return array($sClass, array());
|
||||
}
|
||||
else
|
||||
{
|
||||
// string -> attcode
|
||||
return array('%1$s', array($nameRawSpec));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get the friendly name expression for a given class
|
||||
*
|
||||
@@ -901,9 +903,9 @@ abstract class MetaModel
|
||||
* @throws \CoreException
|
||||
* @throws \DictExceptionMissingString
|
||||
*/
|
||||
final public static function GetNameExpression($sClass)
|
||||
final public static function GetNameExpression($sClass, $sType = FriendlyNameType::SHORT)
|
||||
{
|
||||
$aNameSpec = self::GetNameSpec($sClass);
|
||||
$aNameSpec = self::GetNameSpec($sClass, $sType);
|
||||
$sFormat = $aNameSpec[0];
|
||||
$aAttributes = $aNameSpec[1];
|
||||
|
||||
@@ -940,9 +942,9 @@ abstract class MetaModel
|
||||
* @throws \CoreException
|
||||
* @throws \DictExceptionMissingString
|
||||
*/
|
||||
final public static function GetFriendlyNameAttributeCode($sClass)
|
||||
final public static function GetFriendlyNameAttributeCode($sClass, $sType = FriendlyNameType::SHORT)
|
||||
{
|
||||
$aNameSpec = self::GetNameSpec($sClass);
|
||||
$aNameSpec = self::GetNameSpec($sClass, $sType);
|
||||
$sFormat = trim($aNameSpec[0]);
|
||||
$aAttributes = $aNameSpec[1];
|
||||
if (($sFormat != '') && ($sFormat != '%1$s')) {
|
||||
@@ -962,9 +964,9 @@ abstract class MetaModel
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
final public static function GetFriendlyNameAttributeCodeList($sClass)
|
||||
final public static function GetFriendlyNameAttributeCodeList($sClass, $sType = FriendlyNameType::SHORT)
|
||||
{
|
||||
$aNameSpec = self::GetNameSpec($sClass);
|
||||
$aNameSpec = self::GetNameSpec($sClass, $sType);
|
||||
$aAttributes = $aNameSpec[1];
|
||||
|
||||
return $aAttributes;
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
use Combodo\iTop\Core\MetaModel\FriendlyNameType;
|
||||
|
||||
require_once('MyHelpers.class.inc.php');
|
||||
|
||||
/**
|
||||
@@ -379,41 +381,35 @@ class ValueSetObjects extends ValueSetDefinition
|
||||
|
||||
$this->m_aValues = array();
|
||||
|
||||
if ($this->m_bAllowAllData)
|
||||
{
|
||||
if ($this->m_bAllowAllData) {
|
||||
$oFilter = DBObjectSearch::FromOQL_AllData($this->m_sFilterExpr);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$oFilter = DBObjectSearch::FromOQL($this->m_sFilterExpr);
|
||||
$oFilter->SetShowObsoleteData(utils::ShowObsoleteData());
|
||||
}
|
||||
|
||||
if (!$oFilter) return false;
|
||||
if (!is_null($this->m_oExtraCondition))
|
||||
{
|
||||
if (!$oFilter) {
|
||||
return false;
|
||||
}
|
||||
if (!is_null($this->m_oExtraCondition)) {
|
||||
$oFilter = $oFilter->Intersect($this->m_oExtraCondition);
|
||||
}
|
||||
foreach($this->m_aModifierProperties as $sPluginClass => $aProperties)
|
||||
{
|
||||
foreach ($aProperties as $sProperty => $value)
|
||||
{
|
||||
foreach ($this->m_aModifierProperties as $sPluginClass => $aProperties) {
|
||||
foreach ($aProperties as $sProperty => $value) {
|
||||
$oFilter->SetModifierProperty($sPluginClass, $sProperty, $value);
|
||||
}
|
||||
}
|
||||
|
||||
//$oExpression = DBObjectSearch::GetPolymorphicExpression($oFilter->GetClass(), 'friendlyname');
|
||||
$sClass = $oFilter->GetClass();
|
||||
$sClassAlias = $oFilter->GetClassAlias();
|
||||
|
||||
switch ($sOperation)
|
||||
{
|
||||
switch ($sOperation) {
|
||||
case 'equals':
|
||||
$aAttributes = MetaModel::GetFriendlyNameAttributeCodeList($sClass);
|
||||
$sClassAlias = $oFilter->GetClassAlias();
|
||||
$aFilters = array();
|
||||
$oValueExpr = new ScalarExpression($sContains);
|
||||
foreach($aAttributes as $sAttribute)
|
||||
{
|
||||
foreach ($aAttributes as $sAttribute) {
|
||||
$oNewFilter = $oFilter->DeepClone();
|
||||
$oNameExpr = new FieldExpression($sAttribute, $sClassAlias);
|
||||
$oCondition = new BinaryExpression($oNameExpr, '=', $oValueExpr);
|
||||
@@ -425,7 +421,6 @@ class ValueSetObjects extends ValueSetDefinition
|
||||
break;
|
||||
case 'start_with':
|
||||
$aAttributes = MetaModel::GetFriendlyNameAttributeCodeList($sClass);
|
||||
$sClassAlias = $oFilter->GetClassAlias();
|
||||
$aFilters = array();
|
||||
$oValueExpr = new ScalarExpression($sContains.'%');
|
||||
foreach($aAttributes as $sAttribute)
|
||||
@@ -442,63 +437,67 @@ class ValueSetObjects extends ValueSetDefinition
|
||||
|
||||
default:
|
||||
$oValueExpr = new ScalarExpression('%'.$sContains.'%');
|
||||
$oNameExpr = new FieldExpression('friendlyname', $oFilter->GetClassAlias());
|
||||
$oNameExpr = new FieldExpression('friendlyname', $sClassAlias);
|
||||
$oNewCondition = new BinaryExpression($oNameExpr, 'LIKE', $oValueExpr);
|
||||
$oFilter->AddConditionExpression($oNewCondition);
|
||||
break;
|
||||
}
|
||||
|
||||
$oObjects = new DBObjectSet($oFilter, $this->m_aOrderBy, $aArgs, null, $this->m_iLimit, 0, $this->m_bSort);
|
||||
if (empty($this->m_sValueAttCode))
|
||||
{
|
||||
$aAttToLoad = array($oFilter->GetClassAlias() => array('friendlyname'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$aAttToLoad = array($oFilter->GetClassAlias() => array($this->m_sValueAttCode));
|
||||
if (empty($this->m_sValueAttCode)) {
|
||||
$aAttToLoad = ['friendlyname'];
|
||||
} else {
|
||||
$aAttToLoad = [$this->m_sValueAttCode];
|
||||
}
|
||||
|
||||
$aComplementAttributeSpec = MetaModel::GetComplementAttributeSpec($sClass);
|
||||
$sImageAttr = MetaModel::GetImageAttributeCode($sClass);
|
||||
if (!empty($sImageAttr)) {
|
||||
$aAttToLoad [] = $sImageAttr;
|
||||
}
|
||||
|
||||
$aComplementAttributeSpec = MetaModel::GetNameSpec($sClass, FriendlyNameType::COMPLEMENTARY);
|
||||
$sFormatAdditionalField = $aComplementAttributeSpec[0];
|
||||
$aAdditionalField = $aComplementAttributeSpec[1];
|
||||
$aAdditionalField = $aComplementAttributeSpec[1];
|
||||
|
||||
if (count($aAdditionalField)>0)
|
||||
{
|
||||
$aAttToLoad = array_merge ($aAttToLoad, [$oFilter->GetClassAlias() => $aAdditionalField]);
|
||||
if (count($aAdditionalField) > 0) {
|
||||
if (is_array($aAdditionalField)) {
|
||||
$aAttToLoad = array_merge($aAttToLoad, $aAdditionalField);
|
||||
} else {
|
||||
$aAttToLoad [] = $aAdditionalField;
|
||||
}
|
||||
}
|
||||
|
||||
$oObjects->OptimizeColumnLoad($aAttToLoad);
|
||||
while ($oObject = $oObjects->Fetch())
|
||||
{
|
||||
$aData=[];
|
||||
if (empty($this->m_sValueAttCode))
|
||||
{
|
||||
$oObjects->OptimizeColumnLoad([$sClassAlias => $aAttToLoad]);
|
||||
while ($oObject = $oObjects->Fetch()) {
|
||||
$aData = [];
|
||||
if (empty($this->m_sValueAttCode)) {
|
||||
$aData['label'] = $oObject->GetName();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$aData['label'] = $oObject->Get($this->m_sValueAttCode);
|
||||
}
|
||||
if($oObject->IsObsolete())
|
||||
{
|
||||
$aData['obsolescence_flag']='1';
|
||||
if ($oObject->IsObsolete()) {
|
||||
$aData['obsolescence_flag'] = '1';
|
||||
} else {
|
||||
$aData['obsolescence_flag'] = '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
$aData['obsolescence_flag']='0';
|
||||
}
|
||||
if (count($aAdditionalField)>0)
|
||||
{
|
||||
if (count($aAdditionalField) > 0) {
|
||||
$aArguments = [];
|
||||
foreach ($aAdditionalField as $sAdditionalField)
|
||||
{
|
||||
array_push ($aArguments,$oObject->Get($sAdditionalField));
|
||||
foreach ($aAdditionalField as $sAdditionalField) {
|
||||
array_push($aArguments, $oObject->Get($sAdditionalField));
|
||||
}
|
||||
$aData['additional_field'] = vsprintf($sFormatAdditionalField, $aArguments);
|
||||
} else {
|
||||
$aData['additional_field'] = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$aData['additional_field']='';
|
||||
if (!empty($sImageAttr)) {
|
||||
/** @var \ormDocument $oImage */
|
||||
$oImage = $oObject->Get($sImageAttr);
|
||||
if (!$oImage->IsEmpty()) {
|
||||
$aData['picture_url'] = $oImage->GetDisplayURL($sClass, $oObject->GetKey(), $sImageAttr);
|
||||
$aData['initials'] = '';
|
||||
} else {
|
||||
$aData['initials'] = utils::ToAcronym($aData['label']);
|
||||
}
|
||||
}
|
||||
$this->m_aValues[$oObject->GetKey()] = $aData;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,11 @@ $ibo-input-select--select-wrapper--action-button--margin-right: 20px !default;
|
||||
$ibo-input-select--action-button--padding-left: 6px !default;
|
||||
$ibo-input-select--action-button--padding-right: 2px !default;
|
||||
|
||||
$ibo-select--autocomplete-item-image--size: 25px !default;
|
||||
$ibo-select--autocomplete-item-image--margin-right: 0.5rem !default;
|
||||
$ibo-select--autocomplete-item-image--background-color: $ibo-color-blue-100 !default;
|
||||
$ibo-select--autocomplete-item-image--border: 1px solid $ibo-color-grey-600 !default;
|
||||
|
||||
.ibo-input-select {
|
||||
display: inline-block;
|
||||
min-width: $ibo-input-select--value--min-midth;
|
||||
@@ -164,8 +169,35 @@ $ibo-input-select--action-button--padding-right: 2px !default;
|
||||
max-height: $ibo-input-select-selectize--dropdown--max-height;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.selectize-dropdown.ui-menu .ui-state-active {
|
||||
margin: unset;
|
||||
background-color: #f5fafd;
|
||||
color: #495c68;
|
||||
margin: unset;
|
||||
background-color: #f5fafd;
|
||||
color: #495c68;
|
||||
}
|
||||
|
||||
.ibo-select--autocomplete-item {
|
||||
display: flex;
|
||||
justify-content: left;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.ibo-select--autocomplete-item-image {
|
||||
width: $ibo-select--autocomplete-item-image--size;
|
||||
height: $ibo-select--autocomplete-item-image--size;
|
||||
/* min-xxx are here to avoid medallion to be horizontally compressed when the title is to long */
|
||||
min-width: $ibo-select--autocomplete-item-image--size;
|
||||
min-height: $ibo-select--autocomplete-item-image--size;
|
||||
background-position: center center;
|
||||
background-size: 100%;
|
||||
border-radius: 100%;
|
||||
margin-right: $ibo-select--autocomplete-item-image--margin-right;
|
||||
background-color: $ibo-select--autocomplete-item-image--background-color;
|
||||
border: $ibo-select--autocomplete-item-image--border;
|
||||
|
||||
@extend %ibo-fully-centered-content;
|
||||
}
|
||||
|
||||
.ibo-select--autocomplete-item-txt {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
@@ -137,15 +137,25 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper
|
||||
return $("<div>").append(val);
|
||||
},
|
||||
option: function(item) {
|
||||
val = '';
|
||||
if (item.initials != undefined) {
|
||||
if (item.picture_url != undefined) {
|
||||
val = '<span class="ibo-select--autocomplete-item-image" style="background-image: url('+item.picture_url+');">'+item.initials+'</span>';
|
||||
} else {
|
||||
val = '<span class="ibo-select--autocomplete-item-image">'+item.initials+'</span>';
|
||||
}
|
||||
}
|
||||
val = val+'<span class="ibo-select--autocomplete-item-txt" >';
|
||||
if (item.obsolescence_flag == 1) {
|
||||
val = '<span class="object-ref-icon text_decoration"><span class="fas fa-eye-slash object-obsolete fa-1x fa-fw"></span></span>'+item.label;
|
||||
val = val+'<span class="object-ref-icon text_decoration"><span class="fas fa-eye-slash object-obsolete fa-1x fa-fw"></span></span>'+item.label;
|
||||
} else {
|
||||
val = item.label;
|
||||
val = val+item.label;
|
||||
}
|
||||
if (item.additional_field != undefined) {
|
||||
val = val+'<br><i>'+item.additional_field+'</i>';
|
||||
}
|
||||
return $("<div class=\"option\">").append(val);
|
||||
val = val+'</span>';
|
||||
return $("<div class=\"option ibo-select--autocomplete-item\">").append(val);
|
||||
}
|
||||
},
|
||||
valueField: 'value',
|
||||
@@ -238,19 +248,28 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper
|
||||
})
|
||||
.autocomplete("instance")._renderItem = function (ul, item) {
|
||||
$(ul).addClass('selectize-dropdown');
|
||||
var term = this.term.replace("/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi", "\\$1");
|
||||
var val = $('<div>').text(item.label).html();
|
||||
val = val.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+term+")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
|
||||
if (item.obsolescence_flag == '1') {
|
||||
val = ' <span class="object-ref-icon text_decoration"><span class="fas fa-eye-slash object-obsolete fa-1x fa-fw"></span></span>'+val;
|
||||
let term = this.term.replace("/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi", "\\$1");
|
||||
let val = '';
|
||||
if (item.initials != undefined) {
|
||||
if (item.picture_url != undefined) {
|
||||
val = '<span class="ibo-select--autocomplete-item-image" style="background-image: url('+item.picture_url+');">'+item.initials+'</span>';
|
||||
} else {
|
||||
val = '<span class="ibo-select--autocomplete-item-image");">'+item.initials+'</span>';
|
||||
}
|
||||
}
|
||||
if (item.additional_field != undefined )
|
||||
{
|
||||
val = val+'<div class="ibo-select--autocomplete-item-txt">';
|
||||
if (item.obsolescence_flag == '1') {
|
||||
val = val+' <span class="object-ref-icon text_decoration"><span class="fas fa-eye-slash object-obsolete fa-1x fa-fw"></span></span>';
|
||||
}
|
||||
let labelValue = $('<div>').text(item.label).html();
|
||||
labelValue = labelValue.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+term+")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
|
||||
val = val+labelValue;
|
||||
if (item.additional_field != undefined) {
|
||||
val = val+'<br><i>'+item.additional_field+'</i>';
|
||||
}
|
||||
|
||||
val = val+'</div>';
|
||||
return $("<li>")
|
||||
.append("<div data-selectable=\"\">"+val+"</div>")
|
||||
.append("<div data-selectable=\"\" class=\"ibo-select--autocomplete-item\">"+val+"</div>")
|
||||
.appendTo(ul);
|
||||
};
|
||||
|
||||
|
||||
@@ -1099,41 +1099,47 @@ EOF
|
||||
$oProperties = $oClass->GetUniqueElement('properties');
|
||||
$sPHP = '';
|
||||
$sCss = ''; // Contains dynamic CSS class definitions
|
||||
|
||||
|
||||
// Class caracteristics
|
||||
//
|
||||
$aClassParams = array();
|
||||
$aClassParams['category'] = $this->GetPropString($oProperties, 'category', '');
|
||||
$aClassParams['key_type'] = "'autoincrement'";
|
||||
if ((bool) $this->GetPropNumber($oProperties, 'is_link', 0))
|
||||
{
|
||||
if ((bool)$this->GetPropNumber($oProperties, 'is_link', 0)) {
|
||||
$aClassParams['is_link'] = 'true';
|
||||
}
|
||||
|
||||
// Naming
|
||||
if ($oNaming = $oProperties->GetOptionalElement('naming'))
|
||||
{
|
||||
$sComplementaryNameAttCode = "";
|
||||
if ($oNaming = $oProperties->GetOptionalElement('naming')) {
|
||||
$oNameAttributes = $oNaming->GetUniqueElement('attributes');
|
||||
/** @var \DOMNodeList $oAttributes */
|
||||
$oAttributes = $oNameAttributes->getElementsByTagName('attribute');
|
||||
$aNameAttCodes = array();
|
||||
/** @var \MFElement $oAttribute */
|
||||
foreach($oAttributes as $oAttribute)
|
||||
{
|
||||
foreach ($oAttributes as $oAttribute) {
|
||||
$aNameAttCodes[] = $oAttribute->getAttribute('id');
|
||||
}
|
||||
if (count($aNameAttCodes) > 0)
|
||||
{
|
||||
if (count($aNameAttCodes) > 0) {
|
||||
// New style...
|
||||
$sNameAttCode = "array('".implode("', '", $aNameAttCodes)."')";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$sNameAttCode = "''";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($oComplementaryNameAttributes = $oNaming->GetOptionalElement('complementary_attributes')) {
|
||||
/** @var \DOMNodeList $oAttributes */
|
||||
$oComplementaryAttributes = $oComplementaryNameAttributes->getElementsByTagName('attribute');
|
||||
$aComplementaryNameAttCodes = array();
|
||||
/** @var \MFElement $oAttribute */
|
||||
foreach ($oComplementaryAttributes as $oComplementaryAttribute) {
|
||||
$aComplementaryNameAttCodes[] = $oComplementaryAttribute->getAttribute('id');
|
||||
}
|
||||
if (count($aComplementaryNameAttCodes) > 0) {
|
||||
$sComplementaryNameAttCode = "array('".implode("', '", $aComplementaryNameAttCodes)."')";
|
||||
}
|
||||
$aClassParams['complementary_name_attcode'] = $sComplementaryNameAttCode;
|
||||
}
|
||||
} else {
|
||||
$sNameAttCode = "''";
|
||||
}
|
||||
$aClassParams['name_attcode'] = $sNameAttCode;
|
||||
@@ -1228,76 +1234,39 @@ EOF
|
||||
{
|
||||
$sIndexId = $oIndex->getAttribute('id');
|
||||
$oAttributes = $oIndex->GetUniqueElement('attributes');
|
||||
foreach($oAttributes->getElementsByTagName('attribute') as $oAttribute)
|
||||
{
|
||||
foreach ($oAttributes->getElementsByTagName('attribute') as $oAttribute) {
|
||||
$aIndexes[$sIndexId][] = $oAttribute->getAttribute('id');
|
||||
}
|
||||
}
|
||||
$aClassParams['indexes'] = var_export($aIndexes, true);
|
||||
}
|
||||
|
||||
if ($oArchive = $oProperties->GetOptionalElement('archive'))
|
||||
{
|
||||
if ($oArchive = $oProperties->GetOptionalElement('archive')) {
|
||||
$bEnabled = $this->GetPropBoolean($oArchive, 'enabled', false);
|
||||
$aClassParams['archive'] = $bEnabled;
|
||||
}
|
||||
|
||||
if ($oObsolescence = $oProperties->GetOptionalElement('obsolescence'))
|
||||
{
|
||||
if ($oObsolescence = $oProperties->GetOptionalElement('obsolescence')) {
|
||||
$sCondition = trim($this->GetPropString($oObsolescence, 'condition', ''));
|
||||
if ($sCondition != "''")
|
||||
{
|
||||
if ($sCondition != "''") {
|
||||
$aClassParams['obsolescence_expression'] = $sCondition;
|
||||
}
|
||||
}
|
||||
|
||||
if ($oAdditionalValueForSelect = $oProperties->GetOptionalElement('complement_for_select'))
|
||||
{
|
||||
$oNameAttributes = $oAdditionalValueForSelect->GetUniqueElement('attributes');
|
||||
/** @var \DOMNodeList $oAttributes */
|
||||
$oAttributes = $oNameAttributes->getElementsByTagName('attribute');
|
||||
$aNameAttCodes = array();
|
||||
/** @var \MFElement $oAttribute */
|
||||
foreach($oAttributes as $oAttribute)
|
||||
{
|
||||
$aNameAttCodes[] = $oAttribute->getAttribute('id');
|
||||
}
|
||||
if (count($aNameAttCodes) > 0)
|
||||
{
|
||||
// New style...
|
||||
$sNameAttCode = "array('".implode("', '", $aNameAttCodes)."')";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sNameAttCode = "''";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sNameAttCode = "''";
|
||||
}
|
||||
$aClassParams['name_complement_for_select'] = $sNameAttCode;
|
||||
|
||||
if ($oUniquenessRules = $oProperties->GetOptionalElement('uniqueness_rules'))
|
||||
{
|
||||
if ($oUniquenessRules = $oProperties->GetOptionalElement('uniqueness_rules')) {
|
||||
$aUniquenessRules = array();
|
||||
/** @var \MFElement $oUniquenessSingleRule */
|
||||
foreach ($oUniquenessRules->GetElementsByTagName('rule') as $oUniquenessSingleRule)
|
||||
{
|
||||
foreach ($oUniquenessRules->GetElementsByTagName('rule') as $oUniquenessSingleRule) {
|
||||
$sCurrentRuleId = $oUniquenessSingleRule->getAttribute('id');
|
||||
|
||||
$oAttributes = $oUniquenessSingleRule->GetUniqueElement('attributes', false);
|
||||
if ($oAttributes)
|
||||
{
|
||||
if ($oAttributes) {
|
||||
$aUniquenessAttributes = array();
|
||||
foreach ($oAttributes->getElementsByTagName('attribute') as $oAttribute)
|
||||
{
|
||||
foreach ($oAttributes->getElementsByTagName('attribute') as $oAttribute) {
|
||||
$aUniquenessAttributes[] = $oAttribute->getAttribute('id');
|
||||
}
|
||||
$aUniquenessRules[$sCurrentRuleId]['attributes'] = $aUniquenessAttributes;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$aUniquenessRules[$sCurrentRuleId]['attributes'] = null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user