mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 07:12:26 +02:00
N°4260 - Fix display of log attributes in list
This commit is contained in:
@@ -10,6 +10,7 @@ use Combodo\iTop\Application\Search\SearchForm;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Alert\AlertUIBlockFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Button\Button;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Button\ButtonUIBlockFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Component\CollapsibleSection\CollapsibleSection;
|
||||
use Combodo\iTop\Application\UI\Base\Component\DataTable\DataTableSettings;
|
||||
use Combodo\iTop\Application\UI\Base\Component\DataTable\DataTableUIBlockFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Component\DataTable\StaticTable\StaticTable;
|
||||
@@ -3239,6 +3240,12 @@ EOF
|
||||
}
|
||||
} else
|
||||
{
|
||||
if ($oAttDef instanceof \AttributeCaseLog) {
|
||||
// Add JS file for display caselog
|
||||
foreach (CollapsibleSection::DEFAULT_JS_FILES_REL_PATH as $sJSFile) {
|
||||
$oPage->add_linked_script('../'.$sJSFile);
|
||||
}
|
||||
}
|
||||
$aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, $aArgs);
|
||||
if (is_array($aAllowedValues) && count($aAllowedValues) == 1)
|
||||
{
|
||||
|
||||
@@ -16,6 +16,12 @@
|
||||
// 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\Base\Component\CollapsibleSection\CollapsibleSectionUIBlockFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Html\Html;
|
||||
use Combodo\iTop\Application\UI\Base\iUIBlock;
|
||||
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlockUIBlockFactory;
|
||||
use Combodo\iTop\Renderer\BlockRenderer;
|
||||
|
||||
define('CASELOG_VISIBLE_ITEMS', 2);
|
||||
define('CASELOG_SEPARATOR', "\n".'========== %1$s : %2$s (%3$d) ============'."\n\n");
|
||||
|
||||
@@ -397,7 +403,7 @@ class ormCaseLog {
|
||||
{
|
||||
$bPrintableVersion = (utils::ReadParam('printable', '0') == '1');
|
||||
|
||||
$sHtml = '<table style="width:100%;table-layout:fixed"><tr><td>'; // Use table-layout:fixed to force the with to be independent from the actual content
|
||||
$oBlock = UIContentBlockUIBlockFactory::MakeStandard(null, ['ibo-caselog-list']);
|
||||
$iPos = 0;
|
||||
$aIndex = $this->m_aIndex;
|
||||
if (($bEditMode) && (count($aIndex) > 0) && $this->m_bModified)
|
||||
@@ -411,20 +417,16 @@ class ormCaseLog {
|
||||
{
|
||||
if (!$bPrintableVersion && ($index < count($aIndex) - CASELOG_VISIBLE_ITEMS))
|
||||
{
|
||||
$sOpen = '';
|
||||
$sDisplay = 'style="display:none;"';
|
||||
$bIsOpen = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sOpen = ' open';
|
||||
$sDisplay = '';
|
||||
$bIsOpen = true;
|
||||
}
|
||||
$iPos += $aIndex[$index]['separator_length'];
|
||||
$sTextEntry = substr($this->m_sLog, $iPos, $aIndex[$index]['text_length']);
|
||||
$sCSSClass= 'caselog_entry_html';
|
||||
if (!array_key_exists('format', $aIndex[$index]) || ($aIndex[$index]['format'] == 'text'))
|
||||
{
|
||||
$sCSSClass= 'caselog_entry';
|
||||
$sTextEntry = str_replace(array("\r\n", "\n", "\r"), "<br/>", htmlentities($sTextEntry, ENT_QUOTES, 'UTF-8'));
|
||||
if (!is_null($aTransfoHandler))
|
||||
{
|
||||
@@ -441,7 +443,6 @@ class ormCaseLog {
|
||||
}
|
||||
$iPos += $aIndex[$index]['text_length'];
|
||||
|
||||
$sEntry = '<div class="caselog_header'.$sOpen.'">';
|
||||
// Workaround: PHP < 5.3 cannot unserialize correctly DateTime objects,
|
||||
// therefore we have changed the format. To preserve the compatibility with existing
|
||||
// installations of iTop, both format are allowed:
|
||||
@@ -464,14 +465,11 @@ class ormCaseLog {
|
||||
$sDate = '';
|
||||
}
|
||||
}
|
||||
$sEntry .= sprintf(Dict::S('UI:CaseLog:Header_Date_UserName'), $sDate, $aIndex[$index]['user_name']);
|
||||
$sEntry .= '</div>';
|
||||
$sEntry .= '<div class="'.$sCSSClass.'"'.$sDisplay.'>';
|
||||
$sEntry .= $sTextEntry;
|
||||
$sEntry .= '</div>';
|
||||
$sHtml = $sHtml.$sEntry;
|
||||
$oCollapsibleBlock = CollapsibleSectionUIBlockFactory::MakeStandard( sprintf(Dict::S('UI:CaseLog:Header_Date_UserName'), $sDate, $aIndex[$index]['user_name']));
|
||||
$oCollapsibleBlock->AddSubBlock(new Html($sTextEntry));
|
||||
$oCollapsibleBlock->SetOpenedByDefault($bIsOpen);
|
||||
$oBlock->AddSubBlock($oCollapsibleBlock);
|
||||
}
|
||||
|
||||
// Process the case of an eventual remainder (quick migration of AttributeText fields)
|
||||
if ($iPos < (strlen($this->m_sLog) - 1))
|
||||
{
|
||||
@@ -485,32 +483,38 @@ class ormCaseLog {
|
||||
|
||||
if (count($this->m_aIndex) == 0)
|
||||
{
|
||||
$sHtml .= '<div class="caselog_entry open">';
|
||||
$sHtml .= $sTextEntry;
|
||||
$sHtml .= '</div>';
|
||||
$oCollapsibleBlock = CollapsibleSectionUIBlockFactory::MakeStandard( '');
|
||||
$oCollapsibleBlock->AddSubBlock(new Html($sTextEntry));
|
||||
$oCollapsibleBlock->SetOpenedByDefault(true);
|
||||
$oBlock->AddSubBlock($oCollapsibleBlock);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$bPrintableVersion && (count($this->m_aIndex) - CASELOG_VISIBLE_ITEMS > 0))
|
||||
{
|
||||
$sOpen = '';
|
||||
$sDisplay = 'style="display:none;"';
|
||||
$bIsOpen = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sOpen = ' open';
|
||||
$sDisplay = '';
|
||||
$bIsOpen = true;
|
||||
}
|
||||
$sHtml .= '<div class="caselog_header'.$sOpen.'">';
|
||||
$sHtml .= Dict::S('UI:CaseLog:InitialValue');
|
||||
$sHtml .= '</div>';
|
||||
$sHtml .= '<div class="caselog_entry"'.$sDisplay.'>';
|
||||
$sHtml .= $sTextEntry;
|
||||
$sHtml .= '</div>';
|
||||
$oCollapsibleBlock = CollapsibleSectionUIBlockFactory::MakeStandard( Dict::S('UI:CaseLog:InitialValue'));
|
||||
$oCollapsibleBlock->AddSubBlock(new Html($sTextEntry));
|
||||
$oCollapsibleBlock->SetOpenedByDefault($bIsOpen);
|
||||
}
|
||||
}
|
||||
$sHtml .= '</td></tr></table>';
|
||||
return $sHtml;
|
||||
$oBlockRenderer = new BlockRenderer($oBlock);
|
||||
$sHtml = $oBlockRenderer->RenderHtml();
|
||||
$sScript = $oBlockRenderer->RenderJsInlineRecursively($oBlock,iUIBlock::ENUM_JS_TYPE_ON_READY);
|
||||
if ($sScript!=''){
|
||||
if ($oP == null) {
|
||||
$sScript = '<script>'.$sScript.'</script>';
|
||||
$sHtml .= $sScript;
|
||||
} else {
|
||||
$oP->add_ready_script($sScript);
|
||||
}
|
||||
}
|
||||
return $sHtml;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,10 @@ $ibo-caselog-entry--highlight-colors: $ibo-caselog-highlight-colors !default;
|
||||
$ibo-caselog-entry--main-information--padding-y: 12px !default;
|
||||
$ibo-caselog-entry--main-information--decoration--width: 3px !default;
|
||||
|
||||
$ibo-caselog-entry-in-collapsible-section--body--background-color: #F9F9F9AA !default;
|
||||
$ibo-caselog-entry-in-collapsible-section--body--padding: 8px !default;
|
||||
$ibo-caselog-entry-in-collapsible-section--body--color: black !default;
|
||||
|
||||
/* Main information */
|
||||
.ibo-caselog-entry{
|
||||
.ibo-activity-entry--main-information{
|
||||
@@ -73,3 +77,22 @@ $ibo-caselog-entry--main-information--decoration--width: 3px !default;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* - caselog display vio ormcaselog */
|
||||
.ibo-caselog-list {
|
||||
.ibo-collapsible-section {
|
||||
margin: 0;
|
||||
min-width: 22em;
|
||||
|
||||
.ibo-collapsible-section--header .ibo-collapsible-section--title {
|
||||
@extend %ibo-font-size-100;
|
||||
}
|
||||
|
||||
.ibo-collapsible-section--body {
|
||||
@extend %ibo-font-size-100;
|
||||
color: $ibo-caselog-entry-in-collapsible-section--body--color;
|
||||
padding: $ibo-caselog-entry-in-collapsible-section--body--padding;
|
||||
background-color: $ibo-caselog-entry-in-collapsible-section--body--background-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,6 @@ $(function () {
|
||||
if (window.pager_params) {
|
||||
window.pager_params['pager'+me.options.sListId] = undefined;
|
||||
}
|
||||
|
||||
var parentElt = $('#'+me.options.sListId).closest('.dataTables_wrapper').parent();
|
||||
var aOptions = $('#'+me.options.sListId).DataTable().context[0].oInit;
|
||||
window['bSelectAllowed'+me.options.sListId] = false;
|
||||
@@ -88,6 +87,16 @@ $(function () {
|
||||
sThead += "<th></th>";
|
||||
}
|
||||
aOptions = $.extend(aOptions, JSON.parse(data));
|
||||
if (aOptions.js_files) {
|
||||
$.each(aOptions.js_files, function (i, item) {
|
||||
if ($.inArray(item, aListJsFiles) === -1)
|
||||
{
|
||||
sFileUrl = CombodoGlobalToolbox.AddParameterToUrl(item, aOptions.js_files_param, aOptions.js_files_value);
|
||||
$.ajax({url:sFileUrl, dataType: 'script', cache: true });
|
||||
aListJsFiles.push(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
$.each(aOptions['allColumns'], function (i, item) {
|
||||
$.each(item, function (j, champs) {
|
||||
if (champs.checked == 'true') {
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace Combodo\iTop\Renderer;
|
||||
|
||||
use Combodo\iTop\Application\TwigBase\Twig\TwigHelper;
|
||||
use Combodo\iTop\Application\UI\Base\iUIBlock;
|
||||
use Combodo\iTop\Application\UI\Base\UIBlock;
|
||||
use utils;
|
||||
|
||||
/**
|
||||
@@ -157,7 +158,24 @@ class BlockRenderer
|
||||
|
||||
return trim($sOutput);
|
||||
}
|
||||
public function RenderJsInlineRecursively(UIBlock $oBlock, string $sType)
|
||||
{
|
||||
$sOutput = '';
|
||||
if(!empty($oBlock->GetJsTemplatesRelPath($sType)))
|
||||
{
|
||||
$sOutput = trim(TwigHelper::RenderTemplate(
|
||||
static::$oTwigEnv,
|
||||
array_merge(['oUIBlock' => $oBlock], $this->aContextParams, $oBlock->GetParameters()),
|
||||
$oBlock->GetJsTemplatesRelPath($sType),
|
||||
$sType
|
||||
));
|
||||
}
|
||||
foreach ($oBlock->GetSubBlocks() as $oSubBlock){
|
||||
$sOutput = $sOutput . $this->RenderJsInlineRecursively($oSubBlock, $sType);
|
||||
}
|
||||
|
||||
return trim($sOutput);
|
||||
}
|
||||
/**
|
||||
* Return the raw output of the CSS template
|
||||
*
|
||||
|
||||
@@ -12,6 +12,7 @@ use appUserPreferences;
|
||||
use AttributeLinkedSet;
|
||||
use cmdbAbstractObject;
|
||||
use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Component\CollapsibleSection\CollapsibleSection;
|
||||
use Combodo\iTop\Application\UI\Base\Component\DataTable\StaticTable\FormTable\FormTable;
|
||||
use Combodo\iTop\Application\UI\Base\Component\DataTable\StaticTable\FormTableRow\FormTableRow;
|
||||
use Combodo\iTop\Application\UI\Base\Component\DataTable\StaticTable\StaticTable;
|
||||
@@ -369,6 +370,10 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
|
||||
}
|
||||
} else {
|
||||
$oAttDef = MetaModel::GetAttributeDef($sClassName, $sAttCode);
|
||||
if ($oAttDef instanceof \AttributeCaseLog) {
|
||||
// Add JS file for display caselog
|
||||
$oDataTable->AddMultipleJsFilesRelPaths(CollapsibleSection::DEFAULT_JS_FILES_REL_PATH);
|
||||
}
|
||||
$sAttDefClass = get_class($oAttDef);
|
||||
$sAttLabel = $oAttDef->GetLabel();
|
||||
$aColumnDefinition[] = [
|
||||
@@ -612,6 +617,10 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
|
||||
}
|
||||
} else {
|
||||
$oAttDef = MetaModel::GetAttributeDef($sClassName, $sAttCode);
|
||||
if ($oAttDef instanceof \AttributeCaseLog) {
|
||||
// Removed from the display list
|
||||
$oDataTable->AddMultipleJsFilesRelPaths(CollapsibleSection::DEFAULT_JS_FILES_REL_PATH);
|
||||
}
|
||||
$sAttDefClass = get_class($oAttDef);
|
||||
$sAttLabel = MetaModel::GetLabel($sClassName, $sAttCode);
|
||||
$aColumnDefinition[] = [
|
||||
@@ -701,6 +710,7 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
|
||||
$sSortCol = utils::ReadParam('sort_col', '', false, 'raw_data');
|
||||
$sSortOrder = utils::ReadParam('sort_order', '', false, 'raw_data');
|
||||
$sOrder = [];
|
||||
$aJsFiles = [];
|
||||
if ($sSortCol != "") {
|
||||
$sOrder[] = [$sSortCol, $sSortOrder];
|
||||
}
|
||||
@@ -753,9 +763,12 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
|
||||
];
|
||||
} else {
|
||||
$oAttDef = MetaModel::GetAttributeDef($sClassName, $sAttCode);
|
||||
if ($oAttDef instanceof \AttributeCaseLog) {
|
||||
// Get JS files
|
||||
$aJsFiles = array_merge($aJsFiles, CollapsibleSection::DEFAULT_JS_FILES_REL_PATH);
|
||||
}
|
||||
$sAttDefClass = get_class($oAttDef);
|
||||
$sAttLabel = MetaModel::GetLabel($sClassName, $sAttCode);
|
||||
|
||||
$aColumnDefinition["title"] = $sAttLabel;
|
||||
$aColumnDefinition['metadata'] = [
|
||||
'object_class' => $sClassName,
|
||||
@@ -829,7 +842,14 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
|
||||
"pages": 5 // number of pages to cache
|
||||
} )'
|
||||
]);
|
||||
|
||||
if(sizeof($aJsFiles)>0) {
|
||||
foreach ($aJsFiles as $sJsFile) {
|
||||
$aUrlFiles[] = utils::GetAbsoluteUrlAppRoot().$sJsFile;
|
||||
}
|
||||
$aOptions['js_files'] = $aUrlFiles;
|
||||
$aOptions['js_files_param'] = 'itopversion';
|
||||
$aOptions['js_files_value'] = ITOP_VERSION;
|
||||
}
|
||||
return $aOptions;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user