N°3712 - Activity panel: Fix origin indicator being displayed on all type of entries

This commit is contained in:
Molkobain
2021-08-24 10:17:56 +02:00
parent dbf8475883
commit 808c1fa571
5 changed files with 52 additions and 50 deletions

View File

@@ -22,6 +22,7 @@ namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry;
use AttributeDateTime;
use Combodo\iTop\Application\UI\Base\UIBlock;
use Combodo\iTop\Core\CMDBChange\CMDBChangeOrigin;
use DateTime;
use UserRights;
use utils;
@@ -41,7 +42,7 @@ class ActivityEntry extends UIBlock
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/layouts/activity-panel/activity-entry/layout';
/** @var string DEFAULT_ORIGIN */
public const DEFAULT_ORIGIN = 'unknown';
public const DEFAULT_ORIGIN = CMDBChangeOrigin::INTERACTIVE;
/** @var string DEFAULT_TYPE */
public const DEFAULT_TYPE = 'generic';
/** @var string DEFAULT_DECORATION_CLASSES */
@@ -67,7 +68,10 @@ class ActivityEntry extends UIBlock
protected $sAuthorPictureAbsUrl;
/** @var bool $bIsFromCurrentUser Flag to know if the user who made the activity was the current user */
protected $bIsFromCurrentUser;
/** @var string $sOrigin Origin of the entry (case log, cron, lifecycle, user edit, ...) */
/**
* @var string $sOrigin Origin of the entry (interactive, CSV import, ...)
* @see \Combodo\iTop\Core\CMDBChange\CMDBChangeOrigin
*/
protected $sOrigin;
/**
@@ -301,4 +305,43 @@ class ActivityEntry extends UIBlock
{
return $this->sOrigin;
}
/**
* @return string|null The CSS decoration classes for the origin of the entry
* @see \CMDBChangeOrigin
*/
public function GetOriginDecorationClasses(): ?string
{
$sDecorationClasses = null;
// Note: We put fa-fw on all cases instead of just in the template as one of the cases could (in the future) not use FA icons. This will ensure that any use of the FA icons are always the same width.
switch($this->GetOrigin()) {
case CMDBChangeOrigin::CSV_INTERACTIVE:
case CMDBChangeOrigin::CSV_IMPORT:
$sDecorationClasses = 'fas fa-fw fa-file-import';
break;
case CMDBChangeOrigin::EMAIL_PROCESSING:
$sDecorationClasses = 'fas fa-fw fa-envelope-open';
break;
case CMDBChangeOrigin::SYNCHRO_DATA_SOURCE:
$sDecorationClasses = 'fas fa-fw fa-lock';
break;
case CMDBChangeOrigin::WEBSERVICE_REST:
case CMDBChangeOrigin::WEBSERVICE_SOAP:
$sDecorationClasses = 'fas fa-fw fa-cloud';
break;
case CMDBChangeOrigin::CUSTOM_EXTENSION:
$sDecorationClasses = 'fas fa-fw fa-parachute-box';
break;
default:
break;
}
return $sDecorationClasses;
}
}

View File

@@ -69,7 +69,6 @@ class CaseLogEntry extends ActivityEntry
$this->sAttCode = $sAttCode;
$this->SetCaseLogRank(static::DEFAULT_CASELOG_RANK);
$this->SetOrigin('caselog:'.$this->sAttCode);
}
/*

View File

@@ -20,7 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry;
use Combodo\iTop\Core\CMDBChange\CMDBChangeOrigin;
use DateTime;
use Dict;
use Exception;
@@ -52,7 +51,7 @@ class EditsEntry extends ActivityEntry
* EditsEntry constructor.
*
* @param \DateTime $oDateTime
* @param \User $sAuthorLogin
* @param string $sAuthorLogin
* @param string $sObjectClass Class of the object concerned by the edits
* @param string|null $sId
*
@@ -223,40 +222,4 @@ class EditsEntry extends ActivityEntry
return $sDescriptionAsHtml;
}
/**
* @return string|null The CSS decoration classes for the origin of the entry
* @see \CMDBChangeOrigin
*/
public function GetOriginDecorationClasses(): ?string
{
$sDecorationClasses = null;
// Note: We put fa-fw on all cases instead of just in the template as one of the cases could (in the future) not use FA icons. This will ensure that any use of the FA icons are always the same width.
switch($this->GetOrigin()) {
case CMDBChangeOrigin::CSV_INTERACTIVE:
case CMDBChangeOrigin::CSV_IMPORT:
$sDecorationClasses = 'fas fa-fw fa-file-import';
break;
case CMDBChangeOrigin::EMAIL_PROCESSING:
$sDecorationClasses = 'fas fa-fw fa-envelope-open';
break;
case CMDBChangeOrigin::SYNCHRO_DATA_SOURCE:
$sDecorationClasses = 'fas fa-fw fa-lock';
break;
case CMDBChangeOrigin::WEBSERVICE_REST:
case CMDBChangeOrigin::WEBSERVICE_SOAP:
$sDecorationClasses = 'fas fa-fw fa-cloud';
break;
case CMDBChangeOrigin::CUSTOM_EXTENSION:
$sDecorationClasses = 'fas fa-fw fa-parachute-box';
break;
}
return $sDecorationClasses;
}
}

View File

@@ -19,13 +19,4 @@
{% endfor %}
</ul>
{% endif %}
{% endblock %}
{% block iboActivityEntrySubInformation %}
{% if oUIBlock.GetOrigin() is not null and oUIBlock.GetOrigin != constant('Combodo\\iTop\\Core\\CMDBChange\\CMDBChangeOrigin::INTERACTIVE') %}
<span class="ibo-activity-entry--origin" data-role="ibo-activity-entry--origin" data-tooltip-content="{{ ('Class:CMDBChange/Attribute:origin/Value:' ~ oUIBlock.GetOrigin())|dict_s }}">
<span class="{{ oUIBlock.GetOriginDecorationClasses() }}"></span>
</span>
{% endif %}
{{ parent() }}
{% endblock %}

View File

@@ -34,11 +34,17 @@
</div>
<div class="ibo-activity-entry--sub-information" data-role="ibo-activity-entry--sub-information">
{% block iboActivityEntrySubInformation %}
{% if oUIBlock.GetOrigin() is not null and oUIBlock.GetOrigin != constant('Combodo\\iTop\\Core\\CMDBChange\\CMDBChangeOrigin::INTERACTIVE') %}
<span class="ibo-activity-entry--origin" data-role="ibo-activity-entry--origin" data-tooltip-content="{{ ('Class:CMDBChange/Attribute:origin/Value:' ~ oUIBlock.GetOrigin())|dict_s }}" data-tooltip-placement="bottom">
<span class="{{ oUIBlock.GetOriginDecorationClasses() }}"></span>
</span>
{% endif %}
{% if get_config_parameter('activity_panel.show_author_name_below_entries') %}
<span class="ibo-activity-entry--author-name ibo-is-hidden" data-role="ibo-activity-entry--author-name">{{ oUIBlock.GetAuthorFriendlyname() }}</span>
{% endif %}
<span class="ibo-activity-entry--datetime" data-role="ibo-activity-entry--datetime"
data-tooltip-content="{{ oUIBlock.GetFormattedDateTime() }}"
data-tooltip-placement="bottom"
data-raw-datetime="{{ oUIBlock.GetRawDateTime() }}"
data-formatted-datetime="{{ oUIBlock.GetFormattedDateTime() }}">{{ oUIBlock.GetFormattedDateTime() }}</span>
{% endblock %}