mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 15:34:12 +01:00
N°2224 - Portal: Enable tooltips for object's attributes description
This commit is contained in:
@@ -1026,6 +1026,13 @@ abstract class AttributeDefinition
|
||||
$oFormField->AddValidator(new Validator($this->GetValidationPattern()));
|
||||
}
|
||||
|
||||
// Description
|
||||
$sAttDescription = $this->GetDescription();
|
||||
if(!empty($sAttDescription))
|
||||
{
|
||||
$oFormField->SetDescription($this->GetDescription());
|
||||
}
|
||||
|
||||
// Metadata
|
||||
$oFormField->AddMetadata('attribute-code', $this->GetCode());
|
||||
$oFormField->AddMetadata('attribute-type', get_class($this));
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1113,6 +1113,17 @@ table .group-actions .item-action-wrapper .panel-body > p:last-child{
|
||||
/*********/
|
||||
/* Forms */
|
||||
/*********/
|
||||
.form_field_label > .control-label[data-tooltip-instanciated="true"] {
|
||||
&::after {
|
||||
content: "?";
|
||||
padding-left: 3px;
|
||||
vertical-align: top;
|
||||
|
||||
cursor: pointer;
|
||||
color: $gray;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
}
|
||||
.form_field .form_mandatory .control-label:after{
|
||||
content: "\002a";
|
||||
position: relative;
|
||||
|
||||
@@ -37,6 +37,7 @@ abstract class Field
|
||||
const ENUM_DISPLAY_MODE_DENSE = 'dense'; // Label and value side by side, closely
|
||||
|
||||
const DEFAULT_LABEL = '';
|
||||
const DEFAULT_DESCRIPTION = '';
|
||||
const DEFAULT_METADATA = array();
|
||||
const DEFAULT_HIDDEN = false;
|
||||
const DEFAULT_READ_ONLY = false;
|
||||
@@ -48,6 +49,13 @@ abstract class Field
|
||||
protected $sGlobalId;
|
||||
protected $sFormPath;
|
||||
protected $sLabel;
|
||||
/**
|
||||
* Description text of the field, typically to bring more information to the user on the field purpose
|
||||
*
|
||||
* @var string
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected $sDescription;
|
||||
protected $aMetadata;
|
||||
protected $bHidden;
|
||||
protected $bReadOnly;
|
||||
@@ -71,6 +79,7 @@ abstract class Field
|
||||
// No space in such an id, that could be used as a DOM node id
|
||||
$this->sGlobalId = 'field_' . str_replace(' ', '_', $sId) . '_' . uniqid();
|
||||
$this->sLabel = static::DEFAULT_LABEL;
|
||||
$this->sDescription = static::DEFAULT_DESCRIPTION;
|
||||
$this->aMetadata = static::DEFAULT_METADATA;
|
||||
$this->bHidden = static::DEFAULT_HIDDEN;
|
||||
$this->bReadOnly = static::DEFAULT_READ_ONLY;
|
||||
@@ -121,6 +130,28 @@ abstract class Field
|
||||
return $this->sLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the field has a description. Note that an empty string is equivalent to no description.
|
||||
*
|
||||
* @see static::$sDescription
|
||||
* @return bool
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function HasDescription(): bool
|
||||
{
|
||||
return empty($this->sDescription) === false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see static::$sDescription
|
||||
* @return string
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function GetDescription(): string
|
||||
{
|
||||
return $this->sDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of $sName => $sValue metadata.
|
||||
*
|
||||
@@ -248,6 +279,19 @@ abstract class Field
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sDescription
|
||||
* @see static::$sDescription
|
||||
*
|
||||
* @return $this
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function SetDescription(string $sDescription)
|
||||
{
|
||||
$this->sDescription = $sDescription;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Must be an array of $sName => $sValue metadata.
|
||||
*
|
||||
|
||||
@@ -77,6 +77,7 @@ class BsFileUploadFieldRenderer extends BsFieldRenderer
|
||||
$sCollapseTogglerClass = 'form_linkedset_toggler';
|
||||
$sCollapseTogglerId = $sCollapseTogglerClass . '_' . $this->oField->GetGlobalId();
|
||||
$sFieldWrapperId = 'form_upload_wrapper_' . $this->oField->GetGlobalId();
|
||||
$sFieldDescriptionForHTMLTag = ($this->oField->HasDescription()) ? 'data-tooltip-content="'.utils::HtmlEntities($this->oField->GetDescription()).'"' : '';
|
||||
|
||||
// If collapsed
|
||||
$sCollapseTogglerClass .= ' collapsed';
|
||||
@@ -90,7 +91,7 @@ class BsFileUploadFieldRenderer extends BsFieldRenderer
|
||||
{
|
||||
$iAttachmentsCount = $this->oAttachmentsSet->Count();
|
||||
$oOutput
|
||||
->AddHtml('<label for="'.$this->oField->GetGlobalId().'" class="control-label">')
|
||||
->AddHtml('<label for="'.$this->oField->GetGlobalId().'" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')
|
||||
->AddHtml('<a id="' . $sCollapseTogglerId . '" class="' . $sCollapseTogglerClass . '" data-toggle="collapse" href="#' . $sFieldWrapperId . '" aria-expanded="' . $sCollapseTogglerExpanded . '" aria-controls="' . $sFieldWrapperId . '">')
|
||||
->AddHtml($this->oField->GetLabel(),true)
|
||||
->AddHtml(' (<span class="attachments-count">'.$iAttachmentsCount.'</span>)')
|
||||
|
||||
@@ -26,6 +26,7 @@ use Dict;
|
||||
use Exception;
|
||||
use IssueLog;
|
||||
use MetaModel;
|
||||
use utils;
|
||||
|
||||
/**
|
||||
* Description of BsLinkedSetFieldRenderer
|
||||
@@ -45,6 +46,7 @@ class BsLinkedSetFieldRenderer extends BsFieldRenderer
|
||||
$oOutput = parent::Render();
|
||||
|
||||
$sFieldMandatoryClass = ($this->oField->GetMandatory()) ? 'form_mandatory' : '';
|
||||
$sFieldDescriptionForHTMLTag = ($this->oField->HasDescription()) ? 'data-tooltip-content="'.utils::HtmlEntities($this->oField->GetDescription()).'"' : '';
|
||||
// Vars to build the table
|
||||
$sAttributesToDisplayAsJson = json_encode($this->oField->GetAttributesToDisplay());
|
||||
$sAttCodesToDisplayAsJson = json_encode($this->oField->GetAttributesToDisplay(true));
|
||||
@@ -82,7 +84,7 @@ class BsLinkedSetFieldRenderer extends BsFieldRenderer
|
||||
$oOutput->AddHtml('<div class="form-group ' . $sFieldMandatoryClass . '">');
|
||||
if ($this->oField->GetLabel() !== '')
|
||||
{
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')
|
||||
->AddHtml('<a id="' . $sCollapseTogglerId . '" class="' . $sCollapseTogglerClass . '" data-toggle="collapse" href="#' . $sFieldWrapperId . '" aria-expanded="' . $sCollapseTogglerExpanded . '" aria-controls="' . $sFieldWrapperId . '">')
|
||||
->AddHtml($this->oField->GetLabel(), true)
|
||||
->AddHtml('<span class="text">' . count($aItemIds) . '</span>')
|
||||
|
||||
@@ -29,6 +29,7 @@ use Dict;
|
||||
use Exception;
|
||||
use IssueLog;
|
||||
use MetaModel;
|
||||
use utils;
|
||||
|
||||
/**
|
||||
* Description of BsSelectObjectFieldRenderer
|
||||
@@ -50,6 +51,7 @@ class BsSelectObjectFieldRenderer extends BsFieldRenderer
|
||||
$sFieldValueClass = $this->oField->GetSearch()->GetClass();
|
||||
$sFieldMandatoryClass = ($this->oField->GetMandatory()) ? 'form_mandatory' : '';
|
||||
$iFieldControlType = $this->oField->GetControlType();
|
||||
$sFieldDescriptionForHTMLTag = ($this->oField->HasDescription()) ? 'data-tooltip-content="'.utils::HtmlEntities($this->oField->GetDescription()).'"' : '';
|
||||
|
||||
// TODO : Remove this when hierarchical search supported
|
||||
$this->oField->SetHierarchical(false);
|
||||
@@ -71,7 +73,7 @@ class BsSelectObjectFieldRenderer extends BsFieldRenderer
|
||||
$oOutput->AddHtml('<div class="form_field_label">');
|
||||
if ($this->oField->GetLabel() !== '')
|
||||
{
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
|
||||
@@ -341,7 +343,7 @@ EOF
|
||||
$oOutput->AddHtml('<div class="form_field_label">');
|
||||
if ($this->oField->GetLabel() !== '')
|
||||
{
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
namespace Combodo\iTop\Renderer\Bootstrap\FieldRenderer;
|
||||
|
||||
use MetaModel;
|
||||
use utils;
|
||||
|
||||
/**
|
||||
* Description of BsSetFieldRenderer
|
||||
@@ -37,6 +38,7 @@ class BsSetFieldRenderer extends BsFieldRenderer
|
||||
$oOutput = parent::Render();
|
||||
|
||||
$sFieldMandatoryClass = ($this->oField->GetMandatory()) ? 'form_mandatory' : '';
|
||||
$sFieldDescriptionForHTMLTag = ($this->oField->HasDescription()) ? 'data-tooltip-content="'.utils::HtmlEntities($this->oField->GetDescription()).'"' : '';
|
||||
// Vars to build the table
|
||||
// $sAttributesToDisplayAsJson = json_encode($this->oField->GetAttributesToDisplay());
|
||||
// $sAttCodesToDisplayAsJson = json_encode($this->oField->GetAttributesToDisplay(true));
|
||||
@@ -59,7 +61,7 @@ class BsSetFieldRenderer extends BsFieldRenderer
|
||||
$oOutput->AddHtml('<div class="form_field_label">');
|
||||
if ($this->oField->GetLabel() !== '')
|
||||
{
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')
|
||||
->AddHtml($this->oField->GetLabel(), true)
|
||||
->AddHtml('</label>');
|
||||
}
|
||||
|
||||
@@ -47,7 +47,8 @@ class BsSimpleFieldRenderer extends BsFieldRenderer
|
||||
|
||||
$sFieldClass = get_class($this->oField);
|
||||
$sFieldMandatoryClass = ($this->oField->GetMandatory()) ? 'form_mandatory' : '';
|
||||
|
||||
$sFieldDescriptionForHTMLTag = ($this->oField->HasDescription()) ? 'data-tooltip-content="'.utils::HtmlEntities($this->oField->GetDescription()).'"' : '';
|
||||
|
||||
// Rendering field in edition mode
|
||||
if (!$this->oField->GetReadOnly() && !$this->oField->GetHidden())
|
||||
{
|
||||
@@ -69,7 +70,7 @@ class BsSimpleFieldRenderer extends BsFieldRenderer
|
||||
$oOutput->AddHtml('<div class="form_field_label">');
|
||||
if ($this->oField->GetLabel() !== '')
|
||||
{
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
|
||||
@@ -134,7 +135,7 @@ EOF
|
||||
$oOutput->AddHtml('<div class="form_field_label">');
|
||||
if ($this->oField->GetLabel() !== '')
|
||||
{
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
|
||||
@@ -194,7 +195,7 @@ EOF
|
||||
$oOutput->AddHtml('<div class="form_field_label">');
|
||||
if ($this->oField->GetLabel() !== '')
|
||||
{
|
||||
$oOutput->AddHtml('<div><label class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label></div>');
|
||||
$oOutput->AddHtml('<div><label class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label></div>');
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
|
||||
@@ -316,7 +317,7 @@ EOF
|
||||
$oOutput->AddHtml('<div class="form_field_label">');
|
||||
if ($this->oField->GetLabel() !== '')
|
||||
{
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
|
||||
@@ -349,7 +350,7 @@ EOF
|
||||
$oOutput->AddHtml('<div class="form_field_label">');
|
||||
if ($this->oField->GetLabel() !== '')
|
||||
{
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
|
||||
@@ -382,7 +383,7 @@ JS
|
||||
$oOutput->AddHtml('<div class="form_field_label">');
|
||||
if ($this->oField->GetLabel() !== '')
|
||||
{
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
|
||||
@@ -416,7 +417,7 @@ JS
|
||||
$oOutput->AddHtml('<div class="form_field_label">');
|
||||
if ($this->oField->GetLabel() !== '')
|
||||
{
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
|
||||
@@ -456,7 +457,7 @@ JS
|
||||
$oOutput->AddHtml('<div class="form_field_label">');
|
||||
if ($this->oField->GetLabel() !== '')
|
||||
{
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user