mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
N°931: TagSet Fix Bulk update
This commit is contained in:
@@ -2176,14 +2176,17 @@ EOF
|
||||
}
|
||||
$aJson['possible_values'] = $aTagSetKeyValData;
|
||||
|
||||
$aJson['partial_values'] = is_null($oValue) ? array() : $oValue->GetModifiedTags();
|
||||
|
||||
// orig_values
|
||||
$aJson['orig_value'] = is_null($oValue) ? array() : $oValue->GetValue();
|
||||
|
||||
// added
|
||||
if (is_null($oValue))
|
||||
{
|
||||
$aJson['partial_values'] = array();
|
||||
$aJson['orig_value'] = array();
|
||||
}
|
||||
else
|
||||
{
|
||||
$aJson['partial_values'] = $oValue->GetModifiedTags();
|
||||
$aJson['orig_value'] = array_merge($oValue->GetValue(), $oValue->GetModifiedTags());
|
||||
}
|
||||
$aJson['added'] = array();
|
||||
// removed
|
||||
$aJson['removed'] = array();
|
||||
|
||||
return json_encode($aJson);
|
||||
|
||||
@@ -5966,8 +5966,15 @@ class AttributeTagSet extends AttributeDBFieldVoid
|
||||
|
||||
public function GetAllowedValues($aArgs = array(), $sContains = '')
|
||||
{
|
||||
// The check is done when adding / removing tags, no need to have also this check here
|
||||
return array();
|
||||
$sAttCode = $this->GetCode();
|
||||
$sClass = MetaModel::GetAttributeOrigin($this->GetHostClass(), $sAttCode);
|
||||
$aAllowedTags = TagSetFieldData::GetAllowedValues($sClass, $sAttCode);
|
||||
$aAllowedValues = array();
|
||||
foreach($aAllowedTags as $oAllowedTag)
|
||||
{
|
||||
$aAllowedValues[$oAllowedTag->Get('tag_code')] = $oAllowedTag->Get('tag_label');
|
||||
}
|
||||
return $aAllowedValues;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1184,6 +1184,15 @@ abstract class DBObject implements iDisplay
|
||||
// check if the given (or current) value is suitable for the attribute
|
||||
// return true if successfull
|
||||
// return the error desciption otherwise
|
||||
/**
|
||||
* @param $sAttCode
|
||||
* @param null $value
|
||||
*
|
||||
* @return bool|string
|
||||
* @throws \ArchivedObjectException
|
||||
* @throws \CoreException
|
||||
* @throws \OQLException
|
||||
*/
|
||||
public function CheckValue($sAttCode, $value = null)
|
||||
{
|
||||
if (!is_null($value))
|
||||
@@ -1232,6 +1241,29 @@ abstract class DBObject implements iDisplay
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($oAtt instanceof AttributeTagSet)
|
||||
{
|
||||
if (is_string($toCheck))
|
||||
{
|
||||
$oTag = new ormTagSet(get_class($this), $sAttCode);
|
||||
try
|
||||
{
|
||||
$oTag->SetValue(explode(' ', $toCheck));
|
||||
} catch (Exception $e)
|
||||
{
|
||||
return "Tag value '$toCheck' is not a valid tag list";
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($toCheck instanceof ormTagSet)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return "Bad type";
|
||||
}
|
||||
elseif ($oAtt->IsScalar())
|
||||
{
|
||||
$aValues = $oAtt->GetAllowedValues($this->ToArgsForQuery());
|
||||
|
||||
Reference in New Issue
Block a user