mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
Added a refresh button (and creation /modification messages) on the details of an object
SVN:trunk[2311]
This commit is contained in:
@@ -97,6 +97,15 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
|
||||
// Standard Header with name, actions menu and history block
|
||||
//
|
||||
|
||||
// Is there a message for this object ??
|
||||
$sMessageKey = get_class($this).'::'.$this->GetKey();
|
||||
if (array_key_exists('obj_messages', $_SESSION) && array_key_exists($sMessageKey, $_SESSION['obj_messages']))
|
||||
{
|
||||
$sMsgClass = 'message_'.$_SESSION['obj_messages'][$sMessageKey]['severity'];
|
||||
$oPage->add("<div class=\"header_message $sMsgClass\">".$_SESSION['obj_messages'][$sMessageKey]['message']."</div>");
|
||||
unset($_SESSION['obj_messages'][$sMessageKey]);
|
||||
}
|
||||
|
||||
// action menu
|
||||
$oSingletonFilter = new DBObjectSearch(get_class($this));
|
||||
$oSingletonFilter->AddCondition('id', $this->GetKey(), '=');
|
||||
@@ -191,7 +200,11 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
|
||||
}
|
||||
|
||||
$oPage->add("<div class=\"page_header\"><h1>".$this->GetIcon()." \n");
|
||||
$oPage->add(MetaModel::GetName(get_class($this)).": <span class=\"hilite\">".$this->GetName()."</span>$sSynchroIcon</h1>\n");
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'GET')
|
||||
{
|
||||
$sRefreshIcon = ' <button type="button" onclick="window.location.reload();">'.Dict::S('UI:Button:Refresh').'</button>';
|
||||
}
|
||||
$oPage->add(MetaModel::GetName(get_class($this)).": <span class=\"hilite\">".$this->GetName()."</span>$sRefreshIcon $sSynchroIcon</h1>\n");
|
||||
$oPage->add("</div>\n");
|
||||
|
||||
}
|
||||
|
||||
@@ -1372,3 +1372,38 @@ a.summary, a.summary:hover {
|
||||
.itop-deleted-object {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
.header_message {
|
||||
padding: 1em;
|
||||
font-size: 10pt;
|
||||
background: #fff;
|
||||
border: 1px solid #999;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.header_message {
|
||||
padding: 1em;
|
||||
font-size: 10pt;
|
||||
background: #fff;
|
||||
border: 1px solid #999;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.message_info {
|
||||
border: 1px solid #993;
|
||||
background: url(../images/info-mini.png) 1em 1em no-repeat #ffc;
|
||||
padding-left: 3em;
|
||||
}
|
||||
.message_ok {
|
||||
border: 1px solid #393;
|
||||
background: url(../images/ok.png) 1em 1em no-repeat #cfc;
|
||||
padding-left: 3em;
|
||||
}
|
||||
.message_error {
|
||||
border: 1px solid #933;
|
||||
background: url(../images/error.png) 1em 1em no-repeat #fcc;
|
||||
padding-left: 3em;
|
||||
}
|
||||
BIN
images/info-mini.png
Normal file
BIN
images/info-mini.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 850 B |
BIN
images/ok.png
Normal file
BIN
images/ok.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 643 B |
75
pages/UI.php
75
pages/UI.php
@@ -376,8 +376,7 @@ function ApplyNextAction(Webpage $oP, CMDBObject $oObj, $sNextAction)
|
||||
{
|
||||
$oObj->DBUpdate();
|
||||
}
|
||||
$oObj->Reload();
|
||||
$oObj->DisplayDetails($oP);
|
||||
ReloadAndDisplay($oP, $oObj);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -388,6 +387,17 @@ function ApplyNextAction(Webpage $oP, CMDBObject $oObj, $sNextAction)
|
||||
$oP->add_header('Location: '.utils::GetAbsoluteUrlAppRoot().'pages/UI.php?operation=stimulus&class='.get_class($oObj).'&stimulus='.$sNextAction.'&id='.$oObj->getKey().'&'.$oAppContext->GetForLink());
|
||||
}
|
||||
}
|
||||
|
||||
function ReloadAndDisplay($oPage, $oObj, $sMessage = '', $sSeverity)
|
||||
{
|
||||
$oAppContext = new ApplicationContext();
|
||||
$sMessageKey = get_class($oObj).'::'.$oObj->GetKey();
|
||||
if ($sMessage != '')
|
||||
{
|
||||
$_SESSION['obj_messages'][$sMessageKey] = array('severity' => $sSeverity, 'message' => $sMessage);
|
||||
}
|
||||
$oPage->add_header('Location: '.utils::GetAbsoluteUrlAppRoot().'pages/UI.php?operation=details&class='.get_class($oObj).'&id='.$oObj->getKey().'&'.$oAppContext->GetForLink());
|
||||
}
|
||||
/**
|
||||
* Displays the details of an object
|
||||
* @param $oP WebPage Page for the output
|
||||
@@ -1204,24 +1214,25 @@ EOF
|
||||
else
|
||||
{
|
||||
$oObj->UpdateObjectFromPostedForm();
|
||||
$sMessage = '';
|
||||
$sSeverity = 'ok';
|
||||
|
||||
if (!$oObj->IsModified())
|
||||
{
|
||||
$oP->set_title(Dict::Format('UI:ModificationPageTitle_Object_Class', $oObj->GetRawName(), $sClassLabel)); // Set title will take care of the encoding
|
||||
$oP->p(Dict::Format('UI:Class_Object_NotUpdated', MetaModel::GetName(get_class($oObj)), $oObj->GetName()));
|
||||
$sMessage = Dict::Format('UI:Class_Object_NotUpdated', MetaModel::GetName(get_class($oObj)), $oObj->GetName());
|
||||
$sSeverity = 'info';
|
||||
}
|
||||
else
|
||||
{
|
||||
list($bRes, $aIssues) = $oObj->CheckToWrite();
|
||||
if ($bRes)
|
||||
{
|
||||
$oP->set_title(Dict::Format('UI:ModificationPageTitle_Object_Class', $oObj->GetRawName(), $sClassLabel)); // Set title will take care of the encoding
|
||||
$oP->add("<h1>".Dict::Format('UI:ModificationTitle_Class_Object', $sClassLabel, $oObj->GetName())."</h1>\n");
|
||||
|
||||
$oObj->DBUpdate();
|
||||
utils::RemoveTransaction($sTransactionId);
|
||||
|
||||
$oP->p(Dict::Format('UI:Class_Object_Updated', MetaModel::GetName(get_class($oObj)), $oObj->GetName()));
|
||||
$sMessage = Dict::Format('UI:Class_Object_Updated', MetaModel::GetName(get_class($oObj)), $oObj->GetName());
|
||||
$sSeverity = 'ok';
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1251,7 +1262,7 @@ EOF
|
||||
else
|
||||
{
|
||||
// Nothing more to do
|
||||
$oObj->DisplayDetails($oP);
|
||||
ReloadAndDisplay($oP, $oObj, $sMessage, $sSeverity);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1362,18 +1373,20 @@ EOF
|
||||
$oObj->DBInsert();
|
||||
utils::RemoveTransaction($sTransactionId);
|
||||
$oP->set_title(Dict::S('UI:PageTitle:ObjectCreated'));
|
||||
$oP->add("<h1>".Dict::Format('UI:Title:Object_Of_Class_Created', $oObj->GetName(), $sClassLabel)."</h1>\n");
|
||||
$sMessage = Dict::Format('UI:Title:Object_Of_Class_Created', $oObj->GetName(), $sClassLabel);
|
||||
|
||||
$oObj = MetaModel::GetObject(get_class($oObj), $oObj->GetKey()); //Workaround: reload the object so that the linkedset are displayed properly
|
||||
|
||||
$sNextAction = utils::ReadPostedParam('next_action', '');
|
||||
if (!empty($sNextAction))
|
||||
{
|
||||
$oP->add("<h1>$sMessage</h1>");
|
||||
ApplyNextAction($oP, $oObj, $sNextAction);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Nothing more to do
|
||||
$oObj->DisplayDetails($oP);
|
||||
ReloadAndDisplay($oP, $oObj, $sMessage, 'ok');
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1393,31 +1406,6 @@ EOF
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
case 'wizard_apply_new': // no more used ???
|
||||
$sJson = utils::ReadPostedParam('json_obj', '', 'raw_data');
|
||||
$oWizardHelper = WizardHelper::FromJSON($sJson);
|
||||
$sTransactionId = utils::ReadPostedParam('transaction_id', '');
|
||||
if (!utils::IsTransactionValid($sTransactionId))
|
||||
{
|
||||
$oP->p(Dict::S('UI:Error:ObjectAlreadyCreated'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$oObj = $oWizardHelper->GetTargetObject(true /* read uploaded files */);
|
||||
if (is_object($oObj))
|
||||
{
|
||||
$sClass = get_class($oObj);
|
||||
$sClassLabel = MetaModel::GetName($sClass);
|
||||
$oObj->DBInsert();
|
||||
$oP->set_title(Dict::S('UI:PageTitle:ObjectCreated'));
|
||||
$oP->add("<h1>".Dict::Format('UI:Title:Object_Of_Class_Created', $oObj->GetName(), $sClassLabel)."</h1>\n");
|
||||
$oObj->DisplayDetails($oP);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
case 'select_bulk_stimulus': // Form displayed when applying a stimulus to many objects
|
||||
$sFilter = utils::ReadParam('filter', '', false, 'raw_data');
|
||||
$sStimulus = utils::ReadParam('stimulus', '');
|
||||
@@ -1900,13 +1888,16 @@ EOF
|
||||
{
|
||||
$aTransitions = $oObj->EnumTransitions();
|
||||
$aStimuli = MetaModel::EnumStimuli($sClass);
|
||||
$sMessage = '';
|
||||
$sSeverity = 'ok';
|
||||
if (!isset($aTransitions[$sStimulus]))
|
||||
{
|
||||
throw new ApplicationException(Dict::Format('UI:Error:Invalid_Stimulus_On_Object_In_State', $sStimulus, $oObj->GetName(), $oObj->GetStateLabel()));
|
||||
}
|
||||
if (!utils::IsTransactionValid($sTransactionId))
|
||||
{
|
||||
$oP->p(Dict::S('UI:Error:ObjectAlreadyUpdated'));
|
||||
$sMessage = Dict::S('UI:Error:ObjectAlreadyUpdated');
|
||||
$sSeverity = 'info';
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1941,20 +1932,22 @@ EOF
|
||||
if ($oObj->ApplyStimulus($sStimulus))
|
||||
{
|
||||
$oObj->DBUpdate();
|
||||
$oP->p(Dict::Format('UI:Class_Object_Updated', MetaModel::GetName(get_class($oObj)), $oObj->GetName()));
|
||||
$sMessage = Dict::Format('UI:Class_Object_Updated', MetaModel::GetName(get_class($oObj)), $oObj->GetName());
|
||||
$sSeverity = 'ok';
|
||||
}
|
||||
else
|
||||
{
|
||||
$oP->p(Dict::S('UI:FailedToApplyStimuli'));
|
||||
$sMessage = Dict::S('UI:FailedToApplyStimuli');
|
||||
$sSeverity = 'error';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$oP->p(implode('</p><p>', $aErrors));
|
||||
$sMessage = implode('</p><p>', $aErrors);
|
||||
$sSeverity = 'error';
|
||||
}
|
||||
}
|
||||
$oObj->Reload();
|
||||
$oObj->DisplayDetails($oP);
|
||||
ReloadAndDisplay($oP, $oObj, $sMessage, $sSeverity);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user