Browse Source

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.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3759 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 9 năm trước cách đây
mục cha
commit
7938e15cb4

+ 1 - 1
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;
 	}

+ 21 - 1
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"), "<br/>", 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 = '<span class="case-log-history-entry">'.$sBefore.'<span class="case-log-history-entry-end">'.$sAfter.'<span class="case-log-history-entry-toggle ui-icon ui-icon-circle-minus"></span></span><span class="case-log-history-entry-more">...<span class="case-log-history-entry-toggle ui-icon ui-icon-circle-plus"></span></span></span>';
+			}
+			$sResult = Dict::Format('Change:AttName_EntryAdded', $sAttName, $sTextEntry);
 		}
 		return $sResult;
 	}

+ 9 - 0
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.',

+ 21 - 0
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;
+	}
 }
 ?>

+ 43 - 0
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;
+}
+
+

+ 28 - 1
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;
-}
+}
+.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;
+}

+ 1 - 1
dictionaries/da.dictionary.itop.core.php

@@ -1492,7 +1492,7 @@ Operators:<br/>
 	'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',

+ 1 - 1
dictionaries/de.dictionary.itop.core.php

@@ -416,7 +416,7 @@ Operatoren:<br/>
 	'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',

+ 1 - 1
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',

+ 1 - 1
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',

+ 1 - 1
dictionaries/fr.dictionary.itop.core.php

@@ -526,7 +526,7 @@ Opérateurs :<br/>
 	'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',

+ 1 - 1
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',
 ));
 
 //

+ 1 - 1
dictionaries/ja.dictionary.itop.core.php

@@ -420,7 +420,7 @@ Operators:<br/>
 	'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',

+ 1 - 1
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',

+ 1 - 1
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',

+ 1 - 1
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~~',