N°2847 - Dashlet header static and text

This commit is contained in:
Eric
2020-10-29 18:06:04 +01:00
parent 8a1d17551b
commit c43d52277c
10 changed files with 204 additions and 18 deletions

View File

@@ -16,6 +16,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with iTop. If not, see <http://www.gnu.org/licenses/>
use Combodo\iTop\Application\UI\Component\Dashlet\DashletFactory;
use Combodo\iTop\Application\UI\Component\Panel\PanelFactory;
require_once(APPROOT.'application/forms.class.inc.php');
@@ -868,8 +869,10 @@ class DashletPlainText extends Dashlet
$sText = utils::HtmlEntities($this->aProperties['text']);
$sText = str_replace(array("\r\n", "\n", "\r"), "<br/>", $sText);
$sId = 'plaintext_'.($bEditMode? 'edit_' : '').$this->sId;
$oPage->add('<div id="'.$sId.'" class="dashlet-content">'.$sText.'</div>');
$sId = 'plaintext_'.($bEditMode ? 'edit_' : '').$this->sId;
$oBlock = DashletFactory::MakeForDashletText($sId, $sText);
$oPage->AddUiBlock($oBlock);
}
/**
@@ -1923,18 +1926,8 @@ class DashletHeaderStatic extends Dashlet
$oIconSelect = $this->oModelReflection->GetIconSelectionField('icon');
$sIconPath = utils::HtmlEntities($oIconSelect->MakeFileUrl($sIcon));
// $oPage->add('<div class="dashlet-content">');
// $oPage->add('<div class="main_header">');
//
// $oPage->add('<img src="'.$sIconPath.'">');
// $oPage->add('<div class="main_header"><h1>&nbsp;'.$this->oModelReflection->DictString($sTitle).'</h1></div>');
//
// $oPage->add('</div>');
// $oPage->add('</div>');
$oPanel = PanelFactory::MakeEnhancedNeutral($this->oModelReflection->DictString($sTitle), $sIconPath);
$oPage->AddUiBlock($oPanel);
$oBlock = DashletFactory::MakeForDashletHeaderStatic($this->oModelReflection->DictString($sTitle), $sIconPath);
$oPage->AddUiBlock($oBlock);
}
/**

View File

@@ -5,4 +5,5 @@
@import "dashlet";
@import "dashlet-badge";
@import "dashlet-header-static";
@import "dashlet-header-dynamic";

View File

@@ -0,0 +1,61 @@
/*!
* @copyright Copyright (C) 2010-2020 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
/* SCSS variables */
$ibo-dashlet-header-static--padding-x: 16px !default;
$ibo-dashlet-header-static--padding-y: 16px !default;
$ibo-dashlet-header-static--min-width: 200px !default;
$ibo-dashlet-header-static--background-color: $ibo-color-white-100 !default;
$ibo-dashlet-header-static--border: 1px solid $ibo-color-grey-400 !default;
$ibo-dashlet-header-static--border-radius: $ibo-border-radius-500 !default;
$ibo-dashlet-header-static--title--text-color: inherit !default;
$ibo-dashlet-header-static--title--margin-right: 8px !default;
$ibo-dashlet-header-static--text--text-color: inherit !default;
$ibo-dashlet-header-static--icon-container--margin-right: 16px !default;
$ibo-dashlet-header-static--icon--size: 48px !default;
/* Rules */
.ibo-dashlet-header-static {
//min-width: $ibo-dashlet-header-static--min-width;
flex-basis: $ibo-dashlet-header-static--min-width;
flex-grow: 1;
flex-shrink: 1;
padding: $ibo-dashlet-header-static--padding-y $ibo-dashlet-header-static--padding-x;
background-color: $ibo-dashlet-header-static--background-color;
border: $ibo-dashlet-header-static--border;
border-radius: $ibo-dashlet-header-static--border-radius;
}
.ibo-dashlet-header-static--body {
display: flex;
justify-items: left;
align-items: center;
}
.ibo-dashlet-header-static--icon-container {
margin-right: $ibo-dashlet-header-static--icon-container--margin-right;
}
.ibo-dashlet-header-static--icon {
width: $ibo-dashlet-header-static--icon--size;
min-width: $ibo-dashlet-header-static--icon--size; /* To avoid image being shrinked when container is too small */
max-height: $ibo-dashlet-header-static--icon--size;
}
.ibo-dashlet-header-static--title {
@extend %ibo-font-ral-med-250;
color: $ibo-dashlet-header-static--title--text-color;
margin-right: $ibo-dashlet-header-static--title--margin-right;
}
.ibo-dashlet-header-static--text {
@extend %ibo-font-ral-nor-200;
flex-grow: 1;
color: $ibo-dashlet-header-static--text--text-color;
}

View File

@@ -157,9 +157,10 @@ return array(
'Combodo\\iTop\\Application\\UI\\Component\\Breadcrumbs\\Breadcrumbs' => $baseDir . '/sources/application/UI/Component/Breadcrumbs/Breadcrumbs.php',
'Combodo\\iTop\\Application\\UI\\Component\\Button\\Button' => $baseDir . '/sources/application/UI/Component/Button/Button.php',
'Combodo\\iTop\\Application\\UI\\Component\\Button\\ButtonFactory' => $baseDir . '/sources/application/UI/Component/Button/ButtonFactory.php',
'Combodo\\iTop\\Application\\UI\\Component\\Dashlet\\Dashlet' => $baseDir . '/sources/application/UI/Component/Dashlet/Dashlet.php',
'Combodo\\iTop\\Application\\UI\\Component\\Dashlet\\DashletBadge' => $baseDir . '/sources/application/UI/Component/Dashlet/DashletBadge.php',
'Combodo\\iTop\\Application\\UI\\Component\\Dashlet\\DashletComponent' => $baseDir . '/sources/application/UI/Component/Dashlet/DashletComponent.php',
'Combodo\\iTop\\Application\\UI\\Component\\Dashlet\\DashletFactory' => $baseDir . '/sources/application/UI/Component/Dashlet/DashletFactory.php',
'Combodo\\iTop\\Application\\UI\\Component\\Dashlet\\DashletHeaderStatic' => $baseDir . '/sources/application/UI/Component/Dashlet/DashletHeaderStatic.php',
'Combodo\\iTop\\Application\\UI\\Component\\FieldSet\\FieldSet' => $baseDir . '/sources/application/UI/Component/FieldSet/FieldSet.php',
'Combodo\\iTop\\Application\\UI\\Component\\Field\\Field' => $baseDir . '/sources/application/UI/Component/Field/Field.php',
'Combodo\\iTop\\Application\\UI\\Component\\Form\\Form' => $baseDir . '/sources/application/UI/Component/Form/Form.php',

View File

@@ -387,9 +387,10 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b
'Combodo\\iTop\\Application\\UI\\Component\\Breadcrumbs\\Breadcrumbs' => __DIR__ . '/../..' . '/sources/application/UI/Component/Breadcrumbs/Breadcrumbs.php',
'Combodo\\iTop\\Application\\UI\\Component\\Button\\Button' => __DIR__ . '/../..' . '/sources/application/UI/Component/Button/Button.php',
'Combodo\\iTop\\Application\\UI\\Component\\Button\\ButtonFactory' => __DIR__ . '/../..' . '/sources/application/UI/Component/Button/ButtonFactory.php',
'Combodo\\iTop\\Application\\UI\\Component\\Dashlet\\Dashlet' => __DIR__ . '/../..' . '/sources/application/UI/Component/Dashlet/Dashlet.php',
'Combodo\\iTop\\Application\\UI\\Component\\Dashlet\\DashletBadge' => __DIR__ . '/../..' . '/sources/application/UI/Component/Dashlet/DashletBadge.php',
'Combodo\\iTop\\Application\\UI\\Component\\Dashlet\\DashletComponent' => __DIR__ . '/../..' . '/sources/application/UI/Component/Dashlet/DashletComponent.php',
'Combodo\\iTop\\Application\\UI\\Component\\Dashlet\\DashletFactory' => __DIR__ . '/../..' . '/sources/application/UI/Component/Dashlet/DashletFactory.php',
'Combodo\\iTop\\Application\\UI\\Component\\Dashlet\\DashletHeaderStatic' => __DIR__ . '/../..' . '/sources/application/UI/Component/Dashlet/DashletHeaderStatic.php',
'Combodo\\iTop\\Application\\UI\\Component\\FieldSet\\FieldSet' => __DIR__ . '/../..' . '/sources/application/UI/Component/FieldSet/FieldSet.php',
'Combodo\\iTop\\Application\\UI\\Component\\Field\\Field' => __DIR__ . '/../..' . '/sources/application/UI/Component/Field/Field.php',
'Combodo\\iTop\\Application\\UI\\Component\\Form\\Form' => __DIR__ . '/../..' . '/sources/application/UI/Component/Form/Form.php',

View File

@@ -8,7 +8,7 @@
namespace Combodo\iTop\Application\UI\Component\Dashlet;
class DashletBadge extends Dashlet
class DashletBadge extends DashletComponent
{
public const BLOCK_CODE = 'ibo-dashlet-badge';
public const HTML_TEMPLATE_REL_PATH = 'components/dashlet/dashletbadge';

View File

@@ -10,9 +10,13 @@ namespace Combodo\iTop\Application\UI\Component\Dashlet;
use Combodo\iTop\Application\UI\UIBlock;
class Dashlet extends UIBlock
class DashletComponent extends UIBlock
{
public const BLOCK_CODE = 'ibo-dashlet';
public const HTML_TEMPLATE_REL_PATH = 'components/dashlet/layout';
public function __construct(?string $sId = null)
{
parent::__construct($sId);
}
}

View File

@@ -15,4 +15,14 @@ class DashletFactory
return new DashletBadge($sClassIconUrl, $sHyperlink, $iCount, $sClassLabel, $sCreateActionUrl, $sCreateActionLabel);
}
public static function MakeForDashletHeaderStatic(string $sTitle, string $sIconUrl)
{
return new DashletHeaderStatic(null, $sTitle, $sIconUrl);
}
public static function MakeForDashletText(string $sId, string $sText)
{
return new DashletHeaderStatic($sId, '', '', $sText);
}
}

View File

@@ -0,0 +1,98 @@
<?php
/**
* @copyright Copyright (C) 2010-2020 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
namespace Combodo\iTop\Application\UI\Component\Dashlet;
class DashletHeaderStatic extends DashletComponent
{
public const BLOCK_CODE = 'ibo-dashlet-header-static';
public const HTML_TEMPLATE_REL_PATH = 'components/dashlet/dashletheaderstatic';
/** @var string */
protected $sTitle;
/** @var string */
protected $sIconUrl;
/** @var string */
protected $sText;
/**
* DashletHeaderStatic constructor.
*
* @param string $sTitle
* @param string $sIconUrl
* @param string $sText
*/
public function __construct(string $sId = null, string $sTitle, string $sIconUrl, string $sText = '')
{
parent::__construct($sId);
$this->sTitle = $sTitle;
$this->sIconUrl = $sIconUrl;
$this->sText = $sText;
}
/**
* @return string
*/
public function GetTitle(): string
{
return $this->sTitle;
}
/**
* @param string $sTitle
*
* @return DashletHeaderStatic
*/
public function SetTitle(string $sTitle): DashletHeaderStatic
{
$this->sTitle = $sTitle;
return $this;
}
/**
* @return string
*/
public function GetIconUrl(): string
{
return $this->sIconUrl;
}
/**
* @param string $sIconUrl
*
* @return DashletHeaderStatic
*/
public function SetIconUrl(string $sIconUrl): DashletHeaderStatic
{
$this->sIconUrl = $sIconUrl;
return $this;
}
/**
* @return string
*/
public function GetText(): string
{
return $this->sText;
}
/**
* @param string $sText
*
* @return DashletHeaderStatic
*/
public function SetText(string $sText): DashletHeaderStatic
{
$this->sText = $sText;
return $this;
}
}

View File

@@ -0,0 +1,17 @@
{# @copyright Copyright (C) 2010-2020 Combodo SARL #}
{# @license http://opensource.org/licenses/AGPL-3.0 #}
{% apply spaceless %}
<div class="ibo-dashlet-header-static">
<div class="ibo-dashlet-header-static--body">
{% if oUIBlock.GetIconUrl() is not empty %}
<div class="ibo-dashlet-header-static--icon-container">
<img class="ibo-dashlet-header-static--icon" src="{{ oUIBlock.GetIconUrl() }}" alt="{{ oUIBlock.GetTitle() }}"/>
</div>
{% endif %}
{% if oUIBlock.GetTitle() is not empty %}
<div class="ibo-dashlet-header-static--title">{{ oUIBlock.GetTitle() }}</div>
{% endif %}
<div class="ibo-dashlet-header-static--text">{{ oUIBlock.GetText() }}</div>
</div>
</div>
{% endapply %}