Mentions: Show initials when no picture for contact

This commit is contained in:
Molkobain
2021-04-05 21:20:21 +02:00
parent 8b25679df8
commit 5fa2caac29
4 changed files with 24 additions and 15 deletions

View File

@@ -2581,7 +2581,7 @@ class utils
$sMentionItemUrl = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?operation=details&class='.$sMentionClass.'&id={id}';
$sMentionItemPictureTemplate = (empty(MetaModel::GetImageAttributeCode($sMentionClass))) ? '' : <<<HTML
<span class="ibo-vendors-ckeditor--autocomplete-item-image" style="background-image: url('{picture_url}');"></span>
<span class="ibo-vendors-ckeditor--autocomplete-item-image" style="background-image: url('{picture_url}');">{initials}</span>
HTML;
$sMentionItemTemplate = <<<HTML
<li class="ibo-vendors-ckeditor--autocomplete-item" data-id="{id}">{$sMentionItemPictureTemplate}<span class="ibo-vendors-ckeditor--autocomplete-item-title">{friendlyname}</span></li>

View File

@@ -65,15 +65,17 @@ ul.cke_autocomplete_panel{
align-items: center;
}
.ibo-vendors-ckeditor--autocomplete-item-image{
width: $ibo-vendors-ckeditor--autocomplete-item-image--size;
height: $ibo-vendors-ckeditor--autocomplete-item-image--size;
background-position: center center;
background-size: 100%;
border-radius: 100%;
margin-right: $ibo-vendors-ckeditor--autocomplete-item-image--margin-right;
background-color: $ibo-vendors-ckeditor--autocomplete-item-image--background-color;
border: $ibo-vendors-ckeditor--autocomplete-item-image--border;
}
width: $ibo-vendors-ckeditor--autocomplete-item-image--size;
height: $ibo-vendors-ckeditor--autocomplete-item-image--size;
background-position: center center;
background-size: 100%;
border-radius: 100%;
margin-right: $ibo-vendors-ckeditor--autocomplete-item-image--margin-right;
background-color: $ibo-vendors-ckeditor--autocomplete-item-image--background-color;
border: $ibo-vendors-ckeditor--autocomplete-item-image--border;
@extend %ibo-fully-centered-content;
}
.ibo-vendors-ckeditor--autocomplete-item-title{
color: $ibo-vendors-ckeditor--autocomplete-item-title--text-color;
@extend %ibo-font-ral-bol-100;

File diff suppressed because one or more lines are too long

View File

@@ -2723,14 +2723,21 @@ EOF
'class' => $sObjectClass,
'id' => $iObjectId,
'friendlyname' => $oObject->Get('friendlyname'),
'initials' => '',
];
if(!empty($sObjectImageAttCode)) {
// Try to retrieve image for contact
if (!empty($sObjectImageAttCode)) {
/** @var \ormDocument $oImage */
$oImage = $oObject->Get($sObjectImageAttCode);
$aMatch['picture_url'] = $oImage->GetDisplayURL($sTargetClass, $iObjectId, $sObjectImageAttCode);
if (!$oImage->IsEmpty()) {
$aMatch['picture_url'] = $oImage->GetDisplayURL($sTargetClass, $iObjectId, $sObjectImageAttCode);
}
}
// If no image found, fallback on initials
$aMatch['initials'] = array_key_exists('picture_url', $aMatch) ? '' : utils::ToAcronym($oObject->Get('friendlyname'));
$aMatches[] = $aMatch;
}
}