From db3f3ff1cdff6a971bda65ab596e297cf15c3357 Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Thu, 1 Jul 2010 20:13:26 +0000 Subject: [PATCH] - The object creation page now offers tha choice to create an instance of the sub-classes - Made some objects abstract in the std config-management model - The creation button is now labelled "Create" instead of "Apply" ! - Better display of long messages (or errors) in SetuWebpage. SVN:trunk[529] --- application/cmdbabstract.class.inc.php | 2 +- dictionaries/dictionary.itop.ui.php | 4 +- dictionaries/fr.dictionary.itop.ui.php | 4 +- .../en.dict.itop-config-mgmt.php | 6 +- .../model.itop-config-mgmt.php | 10 +-- pages/UI.php | 79 ++++++++++++++++--- setup/setuppage.class.inc.php | 8 +- 7 files changed, 88 insertions(+), 25 deletions(-) diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index c5f7365bc..aaf85081d 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -1303,7 +1303,7 @@ EOF $oPage->add("\n"); } $oPage->add("    \n"); - $oPage->add("\n"); + $oPage->add("\n"); $oPage->add("\n"); $aNewFieldsMap = array(); foreach($aFieldsMap as $id => $sFieldCode) diff --git a/dictionaries/dictionary.itop.ui.php b/dictionaries/dictionary.itop.ui.php index 9a7806ed8..ddbca82f1 100644 --- a/dictionaries/dictionary.itop.ui.php +++ b/dictionaries/dictionary.itop.ui.php @@ -356,7 +356,8 @@ Dict::Add('EN US', 'English', 'English', array( 'UI:Button:AddToList' => ' << Add ', 'UI:Button:RemoveFromList' => ' Remove >> ', 'UI:Button:FilterList' => ' Filter... ', - 'UI:Button:Delete' => 'Delete ! ', + 'UI:Button:Create' => ' Create ', + 'UI:Button:Delete' => ' Delete ! ', 'UI:SearchToggle' => 'Search', 'UI:ClickToCreateNew' => 'Click here to create a new %1$s', @@ -636,6 +637,7 @@ Dict::Add('EN US', 'English', 'English', array( 'UI:CloneTitle_Class_Object' => 'Clone of %1$s: %2$s', 'UI:CreationPageTitle_Class' => 'iTop - Creation of a new %1$s ', 'UI:CreationTitle_Class' => 'Creation of a new %1$s', + 'UI:SelectTheTypeOf_Class_ToCreate' => 'Select the type of %1$s to create:', 'UI:Class_Object_NotUpdated' => 'No change detected, %1$s (%2$s) has not been modified.', 'UI:Class_Object_Updated' => '%1$s (%2$s) updated.', 'UI:BulkDeletePageTitle' => 'iTop - Bulk Delete', diff --git a/dictionaries/fr.dictionary.itop.ui.php b/dictionaries/fr.dictionary.itop.ui.php index 70b1641d8..8dd286db8 100644 --- a/dictionaries/fr.dictionary.itop.ui.php +++ b/dictionaries/fr.dictionary.itop.ui.php @@ -349,7 +349,8 @@ Dict::Add('FR FR', 'French', 'Français', array( 'UI:Button:AddToList' => ' << Ajouter ', 'UI:Button:RemoveFromList' => ' Enlever >> ', 'UI:Button:FilterList' => ' Filtrer... ', - 'UI:Button:Delete' => 'Supprimer ! ', + 'UI:Button:Create' => ' Créer ', + 'UI:Button:Delete' => ' Supprimer ! ', 'UI:SearchToggle' => 'Recherche', @@ -630,6 +631,7 @@ Dict::Add('FR FR', 'French', 'Français', array( 'UI:CloneTitle_Class_Object' => ' %1$s - Duplication de %2$s', 'UI:CreationPageTitle_Class' => 'iTop - Création d\'un objet de type %1$s ', 'UI:CreationTitle_Class' => 'Création d\'un objet de type %1$s', + 'UI:SelectTheTypeOf_Class_ToCreate' => 'Sélectionnez le type de %1$s à créer :', 'UI:Class_Object_NotUpdated' => 'Aucun changement détecté, %2$s (type : %2$s) n\'a pas été modifié.', 'UI:Class_Object_Updated' => '%1$s (%2$s) mise à jour.', 'UI:BulkDeletePageTitle' => 'iTop - Suppression massive', diff --git a/modules/itop-config-mgmt-1.0.0/en.dict.itop-config-mgmt.php b/modules/itop-config-mgmt-1.0.0/en.dict.itop-config-mgmt.php index 03037422a..a32d7881a 100644 --- a/modules/itop-config-mgmt-1.0.0/en.dict.itop-config-mgmt.php +++ b/modules/itop-config-mgmt-1.0.0/en.dict.itop-config-mgmt.php @@ -703,7 +703,7 @@ Dict::Add('EN US', 'English', 'English', array( 'Class:Printer/Attribute:type/Value:Mopier+' => '', 'Class:Printer/Attribute:type/Value:Printer' => 'Printer', 'Class:Printer/Attribute:type/Value:Printer+' => '', - 'Class:Printer/Attribute:technology' => 'technology', + 'Class:Printer/Attribute:technology' => 'Technology', 'Class:Printer/Attribute:technology+' => '', 'Class:Printer/Attribute:technology/Value:Inkjet' => 'Inkjet', 'Class:Printer/Attribute:technology/Value:Inkjet+' => '', @@ -841,8 +841,8 @@ Dict::Add('EN US', 'English', 'English', array( 'Menu:Person+' => 'All Persons', 'Menu:Team' => 'Teams', 'Menu:Team+' => 'All Teams', -'Menu:FileDoc' => 'Documents', -'Menu:FileDoc+' => 'All Documents', +'Menu:Document' => 'Documents', +'Menu:Document+' => 'All Documents', 'Menu:Location' => 'Locations', 'Menu:Location+' => 'All Locations', 'Menu:ConfigManagementCI' => 'Configuration Items', diff --git a/modules/itop-config-mgmt-1.0.0/model.itop-config-mgmt.php b/modules/itop-config-mgmt-1.0.0/model.itop-config-mgmt.php index 2fc48fb04..a9220b051 100644 --- a/modules/itop-config-mgmt-1.0.0/model.itop-config-mgmt.php +++ b/modules/itop-config-mgmt-1.0.0/model.itop-config-mgmt.php @@ -778,7 +778,7 @@ class BusinessProcess extends FunctionalCI MetaModel::Init_SetZListItems('list', array('status', 'owner_id', 'importance', 'description')); } } -class ConnectableCI extends FunctionalCI +abstract class ConnectableCI extends FunctionalCI { public static function Init() @@ -848,7 +848,7 @@ class NetworkInterface extends ConnectableCI MetaModel::Init_SetZListItems('list', array('status', 'owner_id', 'importance', 'brand', 'model', 'serial_number', 'asset_ref', 'device_id', 'logical_type', 'physical_type', 'ip_address', 'ip_mask', 'mac_address', 'speed', 'duplex', 'connected_if', 'connected_if_device_id')); } } -class Device extends ConnectableCI +abstract class Device extends ConnectableCI { public static function Init() @@ -908,7 +908,7 @@ class PC extends Device MetaModel::Init_SetZListItems('list', array('status', 'owner_id', 'importance', 'brand', 'model', 'serial_number', 'asset_ref', 'cpu', 'ram', 'hdd', 'os_family', 'os_version')); } } -class MobileCI extends Device +abstract class MobileCI extends Device { public static function Init() @@ -965,7 +965,7 @@ class MobilePhone extends MobileCI MetaModel::Init_SetZListItems('list', array('status', 'owner_id', 'importance', 'brand', 'model', 'serial_number', 'asset_ref', 'number', 'imei', 'hw_pin')); } } -class InfrastructureCI extends Device +abstract class InfrastructureCI extends Device { public static function Init() @@ -1263,7 +1263,7 @@ $oContactNode = new TemplateMenuNode('Contact', '../business/templates/contacts_ new OQLMenuNode('Person', 'SELECT Person', $oContactNode->GetIndex(), 1 /* fRank */); new OQLMenuNode('Team', 'SELECT Team', $oContactNode->GetIndex(), 2 /* fRank */); -new OQLMenuNode('FileDoc', 'SELECT FileDoc', $oConfigManagementGroup->GetIndex(), 2 /* fRank */); +new OQLMenuNode('Document', 'SELECT Document', $oConfigManagementGroup->GetIndex(), 2 /* fRank */); new OQLMenuNode('Location', 'SELECT Location', $oConfigManagementGroup->GetIndex(), 3 /* fRank */); diff --git a/pages/UI.php b/pages/UI.php index 09d1a9a35..c1b0d1941 100644 --- a/pages/UI.php +++ b/pages/UI.php @@ -717,6 +717,7 @@ try case 'new': $sClass = utils::ReadParam('class', ''); $sStateCode = utils::ReadParam('state', ''); + $bCheckSubClass = utils::ReadParam('checkSubclass', true); if ( empty($sClass) ) { throw new ApplicationException(Dict::Format('UI:Error:1ParametersMissing', 'class')); @@ -730,19 +731,77 @@ try $oContext = new UserContext(); $aArgs = array_merge($oAppContext->GetAsHash(), utils::ReadParam('default', array())); - $sClassLabel = MetaModel::GetName($sClass); - $oP->set_title(Dict::Format('UI:CreationPageTitle_Class', $sClassLabel)); - $oP->add("

".Dict::Format('UI:CreationTitle_Class', $sClassLabel)."

\n"); - $oP->add("
\n"); - $aDefaults = utils::ReadParam('default', array()); - $aContext = $oAppContext->GetAsHash(); - foreach($aContext as $key => $value) + // If the specified class has subclasses, ask the user an instance of which class to create + $aSubClasses = MetaModel::EnumChildClasses($sClass, ENUM_CHILD_CLASSES_ALL); // Including the specified class itself + $aPossibleClasses = array(); + $sRealClass = ''; + if ($bCheckSubClass) { - $aDefaults[$key] = $value; + foreach($aSubClasses as $sCandidateClass) + { + if (!MetaModel::IsAbstract($sCandidateClass)) + { + $aPossibleClasses[$sCandidateClass] = MetaModel::GetName($sCandidateClass); + } + } + // Only one of the subclasses can be instantiated... + if (count($aPossibleClasses) == 1) + { + $aKeys = array_keys($aPossibleClasses); + $sRealClass = $aKeys[0]; + } + } + else + { + $sRealClass = $sClass; + } + + if (!empty($sRealClass)) + { + // Display the creation form + $sClassLabel = MetaModel::GetName($sRealClass); + $oP->set_title(Dict::Format('UI:CreationPageTitle_Class', $sClassLabel)); + $oP->add("

".Dict::Format('UI:CreationTitle_Class', $sClassLabel)."

\n"); + $oP->add("
\n"); + $aDefaults = utils::ReadParam('default', array()); + $aContext = $oAppContext->GetAsHash(); + foreach($aContext as $key => $value) + { + $aDefaults[$key] = $value; + } + cmdbAbstractObject::DisplayCreationForm($oP, $sRealClass, null /* $oObjToClone */, array('default' => $aDefaults)); + $oP->add("
\n"); + } + else + { + // Select the derived class to create + $sClassLabel = MetaModel::GetName($sClass); + $oP->add("

".Dict::Format('UI:CreationTitle_Class', $sClassLabel)."

\n"); + $oP->add("
\n"); + $oP->add('
'); + $oP->add('

'.Dict::Format('UI:SelectTheTypeOf_Class_ToCreate', $sClassLabel)); + $aDefaults = utils::ReadParam('default', array()); + $oP->add($oAppContext->GetForForm()); + $oP->add("\n"); + $oP->add("\n"); + foreach($aDefaults as $key => $value) + { + $oP->add("\n"); + $aDefaults[$key] = $value; + } + $oP->add(''); + $oP->add(" 

"); + $oP->add('
'); + $oP->add("
\n"); } - cmdbAbstractObject::DisplayCreationForm($oP, $sClass, null /* $oObjToClone */, array('default' => $aDefaults)); - $oP->add("
\n"); break; case 'apply_modify': diff --git a/setup/setuppage.class.inc.php b/setup/setuppage.class.inc.php index 57f74036a..804d36533 100644 --- a/setup/setuppage.class.inc.php +++ b/setup/setuppage.class.inc.php @@ -101,22 +101,22 @@ button { p.info { padding-left: 50px; background: url(../images/info-mid.png) no-repeat left -5px; - height: 48px; + min-height: 48px; } p.ok { padding-left: 50px; background: url(../images/clean-mid.png) no-repeat left -8px; - height: 48px; + min-height: 48px; } p.warning { padding-left: 50px; background: url(../images/messagebox_warning-mid.png) no-repeat left -5px; - height: 48px; + min-height: 48px; } p.error { padding-left: 50px; background: url(../images/stop-mid.png) no-repeat left -5px; - height: 48px; + min-height: 48px; } td.label { text-align: left;