HTML
);
/** @var \iTopWebPage $oPage */
$this->DisplayBareHeader($oPage, $bEditMode);
// Object's details
- // TODO 3.0.0: Complete the factory
+ // TODO 3.0.0: Complete the factory and use it in the different methods (DisplayModifyForm, DisplayTransitionForm), see N°3518
$oObjectDetails = ObjectFactory::MakeDetails($this);
$oPage->AddUiBlock($oObjectDetails);
diff --git a/css/backoffice/components/_panel.scss b/css/backoffice/components/_panel.scss
index 119d0f300..b77e9a8e0 100644
--- a/css/backoffice/components/_panel.scss
+++ b/css/backoffice/components/_panel.scss
@@ -77,6 +77,7 @@ $ibo-panel-colors: (
.ibo-panel--header {
display: flex;
+ justify-content: space-between;
align-items: stretch;
}
diff --git a/sources/application/UI/Base/Layout/Object/ObjectDetails.php b/sources/application/UI/Base/Layout/Object/ObjectDetails.php
index 45b595219..f6cbe0fba 100644
--- a/sources/application/UI/Base/Layout/Object/ObjectDetails.php
+++ b/sources/application/UI/Base/Layout/Object/ObjectDetails.php
@@ -7,6 +7,7 @@
namespace Combodo\iTop\Application\UI\Base\Layout\Object;
+use cmdbAbstractObject;
use Combodo\iTop\Application\UI\Base\Component\Panel\Panel;
use Combodo\iTop\Application\UI\Helper\UIHelper;
use DBObject;
@@ -18,12 +19,19 @@ class ObjectDetails extends Panel
public const BLOCK_CODE = 'ibo-object-details';
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/layouts/object/object-details/layout';
- /** @var string */
+ /** @var string Class name of the object (eg. "UserRequest") */
protected $sClassName;
- /** @var string */
+ /** @var string Class label of the object (eg. "User request") */
protected $sClassLabel;
+ /** @var string ID of the object */
+ protected $sObjectId;
/** @var string */
- protected $sName;
+ protected $sObjectName;
+ /**
+ * @var string The mode in which the object should be displayed (read, edit, create, ...)
+ * @see \cmdbAbstractObject::ENUM_OBJECT_MODE_XXX
+ */
+ protected $sObjectMode;
/** @var string */
protected $sIconUrl;
/** @var string */
@@ -36,16 +44,21 @@ class ObjectDetails extends Panel
/**
* ObjectDetails constructor.
*
- * @param \DBObject $oObject
- * @param string|null $sId
+ * @param \DBObject $oObject The object for which we display the details
+ * @param string $sMode See \cmdbAbstractObject::ENUM_OBJECT_MODE_XXX
+ * @param string|null $sId ID of the block itself, not the $oObject ID
*
+ * @throws \ArchivedObjectException
* @throws \CoreException
+ * @throws \DictExceptionMissingString
*/
- public function __construct(DBObject $oObject, ?string $sId = null) {
+ public function __construct(DBObject $oObject, string $sMode = cmdbAbstractObject::DEFAULT_OBJECT_MODE, ?string $sId = null) {
$this->sClassName = get_class($oObject);
$this->sClassLabel = MetaModel::GetName($this->GetClassName());
+ $this->sObjectId = $oObject->GetKey();
// Note: We get the raw name as only the front-end consumer knows when and how to encode it.
- $this->sName = $oObject->GetRawName();
+ $this->sObjectName = $oObject->GetRawName();
+ $this->sObjectMode = $sMode;
$this->sIconUrl = $oObject->GetIcon(false);
if(MetaModel::HasStateAttributeCode($this->sClassName)) {
@@ -55,11 +68,10 @@ class ObjectDetails extends Panel
}
parent::__construct('', [], static::DEFAULT_COLOR, $sId);
-
}
-
/**
+ * @see self::$sClassName
* @return string
*/
public function GetClassName(): string
@@ -68,14 +80,51 @@ class ObjectDetails extends Panel
}
/**
+ * @see self::$sClassLabel
+ * @return string
+ */
+ public function GetClassLabel(): string
+ {
+ return $this->sClassLabel;
+ }
+
+ /**
+ * @see self::$sObjectName
* @return string
*/
public function GetObjectName(): string
{
- return $this->sName;
+ return $this->sObjectName;
}
- public function SetStatus($sCode, $sLabel, $sColor)
+ /**
+ * @see self::$sObjectId
+ * @return string
+ */
+ public function GetObjectId(): string
+ {
+ return $this->sObjectId;
+ }
+
+ /**
+ * @see self::$sObjectMode
+ * @return string
+ */
+ public function GetObjectMode(): string
+ {
+ return $this->sObjectMode;
+ }
+
+ /**
+ * Set the status to display for the object
+ *
+ * @param string $sCode
+ * @param string $sLabel
+ * @param string $sColor
+ *
+ * @return $this
+ */
+ public function SetStatus(string $sCode, string $sLabel, string $sColor)
{
$this->sStatusCode = $sColor;
$this->sStatusLabel = $sLabel;
@@ -84,16 +133,28 @@ class ObjectDetails extends Panel
return $this;
}
+ /**
+ * @see self::$sStatusCode
+ * @return string
+ */
public function GetStatusCode(): string
{
return $this->sStatusCode;
}
+ /**
+ * @see self::$sStatusLabel
+ * @return string
+ */
public function GetStatusLabel(): string
{
return $this->sStatusLabel;
}
+ /**
+ * @see self::$sStatusColor
+ * @return string
+ */
public function GetStatusColor(): string
{
return $this->sStatusColor;
diff --git a/sources/application/UI/Base/Layout/Object/ObjectFactory.php b/sources/application/UI/Base/Layout/Object/ObjectFactory.php
index 17a8685ca..ab177b3b4 100644
--- a/sources/application/UI/Base/Layout/Object/ObjectFactory.php
+++ b/sources/application/UI/Base/Layout/Object/ObjectFactory.php
@@ -7,6 +7,7 @@
namespace Combodo\iTop\Application\UI\Base\Layout\Object;
+use cmdbAbstractObject;
use DBObject;
/**
@@ -17,13 +18,19 @@ use DBObject;
* @package Combodo\iTop\Application\UI\Base\Layout\Object
* @since 3.0.0
*/
-class ObjectFactory {
+class ObjectFactory
+{
/**
* Make a standard object details layout.
*
+ * @param \DBObject $oObject
+ * @param string|null $sMode
+ *
* @return \Combodo\iTop\Application\UI\Base\Layout\Object\ObjectDetails
+ * @throws \CoreException
*/
- public static function MakeDetails(DBObject $oObject) {
- return new ObjectDetails($oObject);
+ public static function MakeDetails(DBObject $oObject, ?string $sMode = cmdbAbstractObject::DEFAULT_OBJECT_MODE)
+ {
+ return new ObjectDetails($oObject, $sMode);
}
}
\ No newline at end of file
diff --git a/sources/application/UI/Base/Layout/PageContent/PageContentFactory.php b/sources/application/UI/Base/Layout/PageContent/PageContentFactory.php
index b44800dce..5c0b5c184 100644
--- a/sources/application/UI/Base/Layout/PageContent/PageContentFactory.php
+++ b/sources/application/UI/Base/Layout/PageContent/PageContentFactory.php
@@ -22,6 +22,7 @@ namespace Combodo\iTop\Application\UI\Base\Layout\PageContent;
use cmdbAbstractObject;
use Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityPanelFactory;
+use Combodo\iTop\Application\UI\Base\Layout\Object\ObjectFactory;
use DBObject;
/**
@@ -60,7 +61,9 @@ class PageContentFactory
$oLayout = new PageContentWithSideContent();
// Add object details layout
- // TODO 3.0.0
+ // TODO 3.0.0 see N°3518
+ //$oObjectDetails = ObjectFactory::MakeDetails($oObject, $sMode);
+ //$oLayout->AddMainBlock($oObjectDetails);
// Add object activity layout
$oActivityPanel = ActivityPanelFactory::MakeForObjectDetails($oObject, $sMode);
diff --git a/templates/base/components/panel/layout.html.twig b/templates/base/components/panel/layout.html.twig
index cf2071ddb..5a05987ff 100644
--- a/templates/base/components/panel/layout.html.twig
+++ b/templates/base/components/panel/layout.html.twig
@@ -1,15 +1,23 @@
{# @copyright Copyright (C) 2010-2020 Combodo SARL #}
{# @license http://opensource.org/licenses/AGPL-3.0 #}
{% apply spaceless %}
-