From 18041527c5d5c253eefd6b14bf893d9a93c4df01 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Tue, 14 Dec 2021 09:30:54 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B04542=20-=20Restore=20log=20default=20val?= =?UTF-8?q?ue=20being=20set=20through=20"default"=20URL=20param?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Component/Input/RichText/RichText.php | 25 +++++++++++++++++++ .../ActivityPanel/ActivityPanelFactory.php | 11 +++++--- .../input/richtext/layout.html.twig | 2 +- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/sources/application/UI/Base/Component/Input/RichText/RichText.php b/sources/application/UI/Base/Component/Input/RichText/RichText.php index 11502802b..a9cc48cad 100644 --- a/sources/application/UI/Base/Component/Input/RichText/RichText.php +++ b/sources/application/UI/Base/Component/Input/RichText/RichText.php @@ -28,6 +28,8 @@ class RichText extends UIBlock 'js/ckeditor/plugins/codesnippet/lib/highlight/styles/obsidian.css', ]; + /** @var string|null */ + protected $sValue; /** @var array Configuration parameters for the CKEditor instance used with Richtext block */ protected $aConfig; @@ -39,9 +41,32 @@ class RichText extends UIBlock public function __construct(?string $sId = null) { parent::__construct($sId); + $this->sValue = null; $this->aConfig = utils::GetCkeditorPref(); } + /** + * @see static::$sValue + * @return string|null + */ + public function GetValue(): ?string + { + return $this->sValue; + } + + /** + * @param string|null $sValue + * @see static::$sValue + * + * @return $this + */ + public function SetValue(?string $sValue) + { + $this->sValue = $sValue; + + return $this; + } + /** * @param array $aConfig * @see static::$aConfig diff --git a/sources/application/UI/Base/Layout/ActivityPanel/ActivityPanelFactory.php b/sources/application/UI/Base/Layout/ActivityPanel/ActivityPanelFactory.php index 387d2997b..857605f71 100644 --- a/sources/application/UI/Base/Layout/ActivityPanel/ActivityPanelFactory.php +++ b/sources/application/UI/Base/Layout/ActivityPanel/ActivityPanelFactory.php @@ -73,9 +73,17 @@ class ActivityPanelFactory $aCaseLogTabs = $oActivityPanel->GetCaseLogTabs(); foreach($aCaseLogTabs as $sCaseLogAttCode => $aCaseLogData) { + /** @var \ormCaseLog $oCaseLog */ + $oCaseLog = $oObject->Get($sCaseLogAttCode); + // Add new entry block only if the case log is not read only if (false === $aCaseLogData['is_read_only']) { $oActivityPanel->SetCaseLogTabEntryForm($sCaseLogAttCode, CaseLogEntryFormFactory::MakeForCaselogTab($oObject, $sCaseLogAttCode, $sMode)); + + // Prefill input if default value passed for new object + if ($oObject->IsNew() && !$oCaseLog->IsEmpty()) { + $oActivityPanel->GetCaseLogTabEntryForm($sCaseLogAttCode)->GetTextInput()->SetValue($oCaseLog->GetModifiedEntry(\ormCaseLog::ENUM_FORMAT_HTML)); + } } if ($oObject->IsNew()) { @@ -99,9 +107,6 @@ class ActivityPanelFactory $oCaseLogEntriesOriginsSet->OptimizeColumnLoad(['C' => ['origin'], 'CO' => ['lastentry']]); // Retrieve log entries - /** @var \ormCaseLog $oCaseLog */ - $oCaseLog = $oObject->Get($sCaseLogAttCode); - // Debug message to help understand why there could be anomalies on the log entries origins if ($oCaseLog->GetEntryCount() !== $oCaseLogEntriesOriginsSet->Count()) { IssueLog::Debug(static::class.": Number of log entries ({$oCaseLog->GetEntryCount()}) don't match number of corresponding CMDBChanges ({$oCaseLogEntriesOriginsSet->Count()}) for object {$sObjClass}::{$sObjId} / attribute {$sCaseLogAttCode}"); diff --git a/templates/base/components/input/richtext/layout.html.twig b/templates/base/components/input/richtext/layout.html.twig index c176ab11b..fda8cc3bb 100644 --- a/templates/base/components/input/richtext/layout.html.twig +++ b/templates/base/components/input/richtext/layout.html.twig @@ -1,4 +1,4 @@ {% extends "base/components/input/layout.html.twig" %} {% block iboInput %} - + {% endblock %} \ No newline at end of file