From 6fd2c8131565493f1d033329280c1513bd6d5e79 Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Mon, 14 Sep 2015 13:46:48 +0000 Subject: [PATCH] History display enhancement: whenever a new case log entry is added, display its content in the history. The display is truncated at a configurable max length. The user can expand/collapse the truncated text, entry per entry. The text is not truncated when printing. SVN:trunk[3759] --- application/displayblock.class.inc.php | 2 +- core/cmdbchangeop.class.inc.php | 22 ++++++++++- core/config.class.inc.php | 9 +++++ core/ormcaselog.class.inc.php | 21 ++++++++++ css/light-grey.css | 43 +++++++++++++++++++++ css/light-grey.scss | 29 +++++++++++++- dictionaries/da.dictionary.itop.core.php | 2 +- dictionaries/de.dictionary.itop.core.php | 2 +- dictionaries/dictionary.itop.core.php | 2 +- dictionaries/es_cr.dictionary.itop.core.php | 2 +- dictionaries/fr.dictionary.itop.core.php | 2 +- dictionaries/it.dictionary.itop.core.php | 2 +- dictionaries/ja.dictionary.itop.core.php | 2 +- dictionaries/nl.dictionary.itop.core.php | 2 +- dictionaries/pt_br.dictionary.itop.core.php | 2 +- dictionaries/ru.dictionary.itop.core.php | 2 +- 16 files changed, 133 insertions(+), 13 deletions(-) diff --git a/application/displayblock.class.inc.php b/application/displayblock.class.inc.php index 9c8b6ad49..aaf599a45 100644 --- a/application/displayblock.class.inc.php +++ b/application/displayblock.class.inc.php @@ -1290,7 +1290,7 @@ class HistoryBlock extends DisplayBlock { $sHtml .= $this->GetHistoryTable($oPage, $oSet); } - + $oPage->add_ready_script("$('.case-log-history-entry-toggle').on('click', function () { $(this).closest('.case-log-history-entry').toggleClass('expanded');});"); } return $sHtml; } diff --git a/core/cmdbchangeop.class.inc.php b/core/cmdbchangeop.class.inc.php index 61359e836..69f335486 100644 --- a/core/cmdbchangeop.class.inc.php +++ b/core/cmdbchangeop.class.inc.php @@ -619,7 +619,27 @@ class CMDBChangeOpSetAttributeCaseLog extends CMDBChangeOpSetAttribute // The attribute was renamed or removed from the object ? $sAttName = $this->Get('attcode'); } - $sResult = Dict::Format('Change:AttName_EntryAdded', $sAttName); + $oObj = $oMonoObjectSet->Fetch(); + $oCaseLog = $oObj->Get($this->Get('attcode')); + $iMaxVisibleLength = MetaModel::getConfig()->Get('max_history_case_log_entry_length', 0); + $sTextEntry = str_replace(array("\r\n", "\n", "\r"), "
", htmlentities($oCaseLog->GetEntryAt($this->Get('lastentry')), ENT_QUOTES, 'UTF-8')); + if (($iMaxVisibleLength > 0) && (strlen($sTextEntry) > $iMaxVisibleLength)) + { + if (function_exists('mb_strcut')) + { + // Safe with multi-byte strings + $sBefore = mb_strcut($sTextEntry, 0, $iMaxVisibleLength); + $sAfter = mb_strcut($sTextEntry, $iMaxVisibleLength); + } + else + { + // Let's hpe we have no multi-byte characters around the cuttting point... + $sBefore = substr($sTextEntry, 0, $iMaxVisibleLength); + $sAfter = substr($sTextEntry, $iMaxVisibleLength); + } + $sTextEntry = ''.$sBefore.''.$sAfter.'...'; + } + $sResult = Dict::Format('Change:AttName_EntryAdded', $sAttName, $sTextEntry); } return $sResult; } diff --git a/core/config.class.inc.php b/core/config.class.inc.php index b75cac5ec..ae853282b 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -736,6 +736,15 @@ class Config 'source_of_value' => '', 'show_in_conf_sample' => false, ), + 'max_history_case_log_entry_length' => array( + 'type' => 'integer', + 'description' => 'The length (in number of characters) at which to truncate the (expandable) display (in the history) of a case log entry. If zero, the display in the history is not truncated.', + // examples... not used + 'default' => 60, + 'value' => 60, + 'source_of_value' => '', + 'show_in_conf_sample' => false, + ), 'full_text_chunk_duration' => array( 'type' => 'integer', 'description' => 'Delay after which the results are displayed.', diff --git a/core/ormcaselog.class.inc.php b/core/ormcaselog.class.inc.php index 7d7cf46e5..5ea44ea3d 100644 --- a/core/ormcaselog.class.inc.php +++ b/core/ormcaselog.class.inc.php @@ -554,5 +554,26 @@ class ormCaseLog { $iLast = end($aKeys); // Strict standards: the parameter passed to 'end' must be a variable since it is passed by reference return $iLast; } + + /** + * Get the text string corresponding to the given entry in the log (zero based index, older entries first) + * @param integer $iIndex + * @return string The text of the entry + */ + public function GetEntryAt($iIndex) + { + $iPos = 0; + $index = count($this->m_aIndex) - 1; + $aIndex = $this->m_aIndex; + while($index > $iIndex) + { + $iPos += $this->m_aIndex[$index]['separator_length']; + $iPos += $this->m_aIndex[$index]['text_length']; + $index--; + } + $iPos += $this->m_aIndex[$index]['separator_length']; + $sText = substr($this->m_sLog, $iPos, $this->m_aIndex[$index]['text_length']); + return $sText; + } } ?> \ No newline at end of file diff --git a/css/light-grey.css b/css/light-grey.css index 12c172c26..aac3b5b19 100644 --- a/css/light-grey.css +++ b/css/light-grey.css @@ -2101,3 +2101,46 @@ span.refresh-button { } +.case-log-history-entry-end { + display: none; +} + + +.expanded .case-log-history-entry-end { + display: inline; +} + + +.case-log-history-entry-more { + display: inline; +} + + +.expanded .case-log-history-entry-more { + display: none; +} + + +.case-log-history-entry .case-log-history-entry-toggle { + display: inline-block; + float: none; + pointer: cursor; + vertical-align: bottom; +} + + +.printable-tab .case-log-history-entry-end { + display: inline; +} + + +.printable-tab .case-log-history-entry-more { + display: none; +} + + +.printable-tab .case-log-history-entry .case-log-history-entry-toggle { + display: none; +} + + diff --git a/css/light-grey.scss b/css/light-grey.scss index 48e51dd4f..ccc73249e 100644 --- a/css/light-grey.scss +++ b/css/light-grey.scss @@ -1549,4 +1549,31 @@ span.refresh-button { height: 18px; cursor: pointer; background: transparent url(../images/refresh-fff.png) left center no-repeat; -} \ No newline at end of file +} +.case-log-history-entry-end { + display: none; +} +.expanded .case-log-history-entry-end { + display: inline; +} +.case-log-history-entry-more { + display: inline; +} +.expanded .case-log-history-entry-more { + display: none; +} +.case-log-history-entry .case-log-history-entry-toggle { + display: inline-block; + float: none; + pointer: cursor; + vertical-align: bottom; +} +.printable-tab .case-log-history-entry-end { + display: inline; +} +.printable-tab .case-log-history-entry-more { + display: none; +} +.printable-tab .case-log-history-entry .case-log-history-entry-toggle { + display: none; +} diff --git a/dictionaries/da.dictionary.itop.core.php b/dictionaries/da.dictionary.itop.core.php index 9e9312fcc..e041b6a93 100644 --- a/dictionaries/da.dictionary.itop.core.php +++ b/dictionaries/da.dictionary.itop.core.php @@ -1492,7 +1492,7 @@ Operators:
'Change:Text_AppendedTo_AttName' => '%1$s tilføjet til %2$s', 'Change:AttName_Changed_PreviousValue_OldValue' => '%1$s ændret, tidligere værdi: %2$s', 'Change:AttName_Changed' => '%1$s ændret', - 'Change:AttName_EntryAdded' => '%1$s ændret, ny entry tilføjet.', + 'Change:AttName_EntryAdded' => '%1$s ændret, ny entry tilføjet: %2$s', 'Change:LinkSet:Added' => 'tilføjet %1$s', 'Change:LinkSet:Removed' => 'fjernet %1$s', 'Change:LinkSet:Modified' => 'ændret %1$s', diff --git a/dictionaries/de.dictionary.itop.core.php b/dictionaries/de.dictionary.itop.core.php index ff7f88f6e..2dd668430 100644 --- a/dictionaries/de.dictionary.itop.core.php +++ b/dictionaries/de.dictionary.itop.core.php @@ -416,7 +416,7 @@ Operatoren:
'Change:Text_AppendedTo_AttName' => '%1$s zugefügt an %2$s', 'Change:AttName_Changed_PreviousValue_OldValue' => '%1$s modifiziert, vorheriger Wert: %2$s', 'Change:AttName_Changed' => '%1$s modifiziert', - 'Change:AttName_EntryAdded' => '%1$s modifiziert, neuer Eintrag hinzugefügt.', + 'Change:AttName_EntryAdded' => '%1$s modifiziert, neuer Eintrag hinzugefügt: %2$s', 'Change:LinkSet:Added' => 'hinzugefügt: %1$s', 'Change:LinkSet:Removed' => 'entfernt: %1$s', 'Change:LinkSet:Modified' => 'modifizert: %1$s', diff --git a/dictionaries/dictionary.itop.core.php b/dictionaries/dictionary.itop.core.php index 26f35be17..8a4acfd7a 100644 --- a/dictionaries/dictionary.itop.core.php +++ b/dictionaries/dictionary.itop.core.php @@ -249,7 +249,7 @@ Dict::Add('EN US', 'English', 'English', array( 'Change:Text_AppendedTo_AttName' => '%1$s appended to %2$s', 'Change:AttName_Changed_PreviousValue_OldValue' => '%1$s modified, previous value: %2$s', 'Change:AttName_Changed' => '%1$s modified', - 'Change:AttName_EntryAdded' => '%1$s modified, new entry added.', + 'Change:AttName_EntryAdded' => '%1$s modified, new entry added: %2$s', 'Change:LinkSet:Added' => 'added %1$s', 'Change:LinkSet:Removed' => 'removed %1$s', 'Change:LinkSet:Modified' => 'modified %1$s', diff --git a/dictionaries/es_cr.dictionary.itop.core.php b/dictionaries/es_cr.dictionary.itop.core.php index d6f08b373..d12b89959 100644 --- a/dictionaries/es_cr.dictionary.itop.core.php +++ b/dictionaries/es_cr.dictionary.itop.core.php @@ -248,7 +248,7 @@ Dict::Add('ES CR', 'Spanish', 'Español, Castellano', array( 'Change:Text_AppendedTo_AttName' => '%1$s agregado a %2$s', 'Change:AttName_Changed_PreviousValue_OldValue' => '%1$s cambiado, valor anterior: %2$s', 'Change:AttName_Changed' => '%1$s cambiado', - 'Change:AttName_EntryAdded' => '%1$s cambiado, nuevo registro agregado.', + 'Change:AttName_EntryAdded' => '%1$s cambiado, nuevo registro agregado: %2$s', 'Change:LinkSet:Added' => 'Agregado %1$s', 'Change:LinkSet:Removed' => 'Removido %1$s', 'Change:LinkSet:Modified' => 'Modificado %1$s', diff --git a/dictionaries/fr.dictionary.itop.core.php b/dictionaries/fr.dictionary.itop.core.php index 8ed2d0aa6..9b0696401 100644 --- a/dictionaries/fr.dictionary.itop.core.php +++ b/dictionaries/fr.dictionary.itop.core.php @@ -526,7 +526,7 @@ Opérateurs :
'Change:Text_AppendedTo_AttName' => '%1$s ajouté à %2$s', 'Change:AttName_Changed_PreviousValue_OldValue' => '%1$s modifié, ancienne valeur: %2$s', 'Change:AttName_Changed' => '%1$s modifié', - 'Change:AttName_EntryAdded' => '%1$s champ modifié, une nouvelle entrée a été ajoutée', + 'Change:AttName_EntryAdded' => '%1$s champ modifié, une nouvelle entrée a été ajoutée: %2$s', 'Change:LinkSet:Added' => 'ajout de %1$s', 'Change:LinkSet:Removed' => 'suppression de %1$s', 'Change:LinkSet:Modified' => 'modification de %1$s', diff --git a/dictionaries/it.dictionary.itop.core.php b/dictionaries/it.dictionary.itop.core.php index 2818dd9fb..41b6ec51c 100644 --- a/dictionaries/it.dictionary.itop.core.php +++ b/dictionaries/it.dictionary.itop.core.php @@ -240,7 +240,7 @@ Dict::Add('IT IT', 'Italian', 'Italiano', array( 'Change:Text_AppendedTo_AttName' => '%1$s allegato a %2$s', 'Change:AttName_Changed_PreviousValue_OldValue' => '%1$s modificato, valore precedente: %2$s', 'Change:AttName_Changed' => '%1$s modificato', - 'Change:AttName_EntryAdded' => '%1$s modificato, nuova voce aggiunta.', + 'Change:AttName_EntryAdded' => '%1$s modificato, nuova voce aggiunta: %2$s', )); // diff --git a/dictionaries/ja.dictionary.itop.core.php b/dictionaries/ja.dictionary.itop.core.php index 3885587b0..44150057c 100644 --- a/dictionaries/ja.dictionary.itop.core.php +++ b/dictionaries/ja.dictionary.itop.core.php @@ -420,7 +420,7 @@ Operators:
'Change:Text_AppendedTo_AttName' => '%1$sを%2$sに追加しました', 'Change:AttName_Changed_PreviousValue_OldValue' => '%1$sを変更しました。更新前の値: %2$s', 'Change:AttName_Changed' => '%1$sを変更しました', - 'Change:AttName_EntryAdded' => '%1$s は、修正されました。新しいエントリーが追加されました。', + 'Change:AttName_EntryAdded' => '%1$s は、修正されました。新しいエントリーが追加されました。: %2$s', 'Change:LinkSet:Added' => '追加されました %1$s', 'Change:LinkSet:Removed' => '削除されました %1$s', 'Change:LinkSet:Modified' => '修正されました %1$s', diff --git a/dictionaries/nl.dictionary.itop.core.php b/dictionaries/nl.dictionary.itop.core.php index 315561dd8..9cffc4e54 100644 --- a/dictionaries/nl.dictionary.itop.core.php +++ b/dictionaries/nl.dictionary.itop.core.php @@ -255,7 +255,7 @@ Dict::Add('NL NL', 'Dutch', 'Nederlands', array( 'Change:Text_AppendedTo_AttName' => '%1$s toegevoegd aan %2$s', 'Change:AttName_Changed_PreviousValue_OldValue' => '%1$s aangepast, vorige waarde: %2$s', 'Change:AttName_Changed' => '%1$s aangepast', - 'Change:AttName_EntryAdded' => '%1$s aangepast, nieuwe entry toegevoegd.', + 'Change:AttName_EntryAdded' => '%1$s aangepast, nieuwe entry toegevoegd: %2$s', 'Change:LinkSet:Added' => 'toegevoegd %1$s', 'Change:LinkSet:Removed' => 'verwijderd %1$s', 'Change:LinkSet:Modified' => 'aangepast %1$s', diff --git a/dictionaries/pt_br.dictionary.itop.core.php b/dictionaries/pt_br.dictionary.itop.core.php index 729c0b393..dc738ce02 100644 --- a/dictionaries/pt_br.dictionary.itop.core.php +++ b/dictionaries/pt_br.dictionary.itop.core.php @@ -249,7 +249,7 @@ Dict::Add('PT BR', 'Brazilian', 'Brazilian', array( 'Change:Text_AppendedTo_AttName' => '%1$s anexado ao %2$s', 'Change:AttName_Changed_PreviousValue_OldValue' => '%1$s modificado, valor anterior: %2$s', 'Change:AttName_Changed' => '%1$s modificado', - 'Change:AttName_EntryAdded' => '%1$s modificado, nova entrada adicionada.', + 'Change:AttName_EntryAdded' => '%1$s modificado, nova entrada adicionada: %2$s', 'Change:LinkSet:Added' => 'adicionado %1$s', 'Change:LinkSet:Removed' => 'excluído %1$s', 'Change:LinkSet:Modified' => 'modificado %1$s', diff --git a/dictionaries/ru.dictionary.itop.core.php b/dictionaries/ru.dictionary.itop.core.php index 2108c883d..8eb3511c1 100644 --- a/dictionaries/ru.dictionary.itop.core.php +++ b/dictionaries/ru.dictionary.itop.core.php @@ -244,7 +244,7 @@ Dict::Add('RU RU', 'Russian', 'Русский', array( 'Change:Text_AppendedTo_AttName' => '%1$s добавлено к %2$s', 'Change:AttName_Changed_PreviousValue_OldValue' => '%1$s изменено, предыдущее значение: %2$s', 'Change:AttName_Changed' => '%1$s изменено', - 'Change:AttName_EntryAdded' => '%1$s изменено, добавлено новое значение.', + 'Change:AttName_EntryAdded' => '%1$s изменено, добавлено новое значение: %2$s', 'Change:LinkSet:Added' => 'добавлен %1$s~~', 'Change:LinkSet:Removed' => 'удален %1$s~~', 'Change:LinkSet:Modified' => 'изменен %1$s~~',