From d16c0ffef9bba9670fa198cf06d359fd1f64767e Mon Sep 17 00:00:00 2001 From: Molkobain Date: Fri, 17 Jan 2020 14:16:31 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B02313=20-=20Markup=20extensibility:=20Add?= =?UTF-8?q?=20metadata=20on=20admin.=20console=20object=20creation=20forms?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/ui.extkeywidget.class.inc.php | 88 +++++++++-------------- pages/UI.php | 75 +++++++++++++++---- 2 files changed, 93 insertions(+), 70 deletions(-) diff --git a/application/ui.extkeywidget.class.inc.php b/application/ui.extkeywidget.class.inc.php index 5ea48a021..e1c49b068 100644 --- a/application/ui.extkeywidget.class.inc.php +++ b/application/ui.extkeywidget.class.inc.php @@ -1,61 +1,20 @@ /** - * Class UIExtKeyWidget - * UI wdiget for displaying and editing external keys when - * A simple drop-down list is not enough... + * Copyright (C) 2013-2020 Combodo SARL * - * The layout is the following + * This file is part of iTop. * - * +-- #label_ (input)-------+ +-----------+ - * | | | Browse... | - * +-----------------------------+ +-----------+ + * iTop is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * And the popup dialog has the following layout: + * iTop is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. * - * +------------------- ac_dlg_ (div)-----------+ - * + +--- ds_ (div)---------------------------+ | - * | | +------------- fs_ (form)------------+ | | - * | | | +--------+---+ | | | - * | | | | Class | V | | | | - * | | | +--------+---+ | | | - * | | | | | | - * | | | S e a r c h F o r m | | | - * | | | +--------+ | | | - * | | | | Search | | | | - * | | | +--------+ | | | - * | | +----------------------------------------+ | | - * | +--------------+-dh_-+--------------------+ | - * | \ Search / | - * | +------+ | - * | +--- fr_ (form)--------------------------+ | - * | | +------------ dr_ (div)--------------+ | | - * | | | | | | - * | | | S e a r c h R e s u l t s | | | - * | | | | | | - * | | +----------------------------------------+ | | - * | | +--------+ +-----+ | | - * | | | Cancel | | Add | | | - * | | +--------+ +-----+ | | - * | +--------------------------------------------+ | - * +------------------------------------------------+ - * @copyright Copyright (C) 2010-2017 Combodo SARL - * @license http://opensource.org/licenses/AGPL-3.0 + * You should have received a copy of the GNU Affero General Public License */ require_once(APPROOT.'/application/webpage.class.inc.php'); @@ -578,8 +537,21 @@ EOF $oNewObj->UpdateObjectFromArg('default'); $sDialogTitle = ''; - $oPage->add('
'); - $oPage->add("

".MetaModel::GetClassIcon($this->sTargetClass)." ".Dict::Format('UI:CreationTitle_Class', MetaModel::GetName($this->sTargetClass))."

\n"); + $sClassLabel = MetaModel::GetName($this->sTargetClass); + $sClassIcon = MetaModel::GetClassIcon($this->sTargetClass); + $sObjClass = get_class($oNewObj); + $sObjKey = $oNewObj->GetKey(); + $sHeaderTitle = Dict::Format('UI:CreationTitle_Class', $sClassLabel); + $oPage->add(<< + +
+ +
+
+

$sClassIcon $sHeaderTitle

+HTML + ); $aFieldsFlags = array(); $aFieldsComments = array(); foreach(MetaModel::ListAttributeDefs($this->sTargetClass) as $sAttCode => $oAttDef) @@ -591,7 +563,13 @@ EOF } } cmdbAbstractObject::DisplayCreationForm($oPage, $this->sTargetClass, $oNewObj, array(), array('formPrefix' => $this->iId, 'noRelations' => true, 'fieldsFlags' => $aFieldsFlags, 'fieldsComments' => $aFieldsComments)); - $oPage->add('
'); + $oPage->add(<< +
+
+
+HTML + ); // $oPage->add_ready_script("\$('#ac_create_$this->iId').dialog({ width: $(window).width()*0.8, height: 'auto', autoOpen: false, modal: true, title: '$sDialogTitle'});\n"); $oPage->add_ready_script("\$('#ac_create_$this->iId').dialog({ width: 'auto', height: 'auto', maxHeight: $(window).height() - 50, autoOpen: false, modal: true, title: '$sDialogTitle'});\n"); $oPage->add_ready_script("$('#dcr_{$this->iId} form').removeAttr('onsubmit');"); diff --git a/pages/UI.php b/pages/UI.php index ef827d492..a6f76a329 100644 --- a/pages/UI.php +++ b/pages/UI.php @@ -793,16 +793,8 @@ EOF if (!empty($sRealClass)) { - // Display the creation form - $sClassLabel = MetaModel::GetName($sRealClass); - // Note: some code has been duplicated to the case 'apply_new' when a data integrity issue has been found - $oP->set_title(Dict::Format('UI:CreationPageTitle_Class', $sClassLabel)); - $oP->add("

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

\n"); - $oP->add("
\n"); - // Set all the default values in an object and clone this "default" object $oObjToClone = MetaModel::NewObject($sRealClass); - // 1st - set context values $oAppContext->InitObjectFromContext($oObjToClone); // 2nd - set values from the page argument 'default' @@ -815,15 +807,46 @@ EOF // 3rd - prefill API $oObjToClone->PrefillForm('creation_from_0',$aPrefillFormParam); + // Display the creation form + $sClassLabel = MetaModel::GetName($sRealClass); + $sClassIcon = MetaModel::GetClassIcon($sRealClass); + $sObjectTmpKey = $oObjToClone->GetKey(); + $sHeaderTitle = Dict::Format('UI:CreationTitle_Class', $sClassLabel); + // Note: some code has been duplicated to the case 'apply_new' when a data integrity issue has been found + $oP->set_title(Dict::Format('UI:CreationPageTitle_Class', $sClassLabel)); + $oP->add(<< +
+ + +
+HTML + ); cmdbAbstractObject::DisplayCreationForm($oP, $sRealClass, $oObjToClone, array()); - $oP->add("
\n"); + $oP->add(<< +
+HTML + ); } else { // Select the derived class to create $sClassLabel = MetaModel::GetName($sClass); - $oP->add("

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

\n"); - $oP->add("
\n"); + $sClassIcon = MetaModel::GetClassIcon($sClass); + $sHeaderTitle = Dict::Format('UI:CreationTitle_Class', $sClassLabel); + $oP->add(<< +
+ + +
+HTML + ); $oP->add('
'); $oP->add('

'.Dict::Format('UI:SelectTheTypeOf_Class_ToCreate', $sClassLabel)); $aDefaults = utils::ReadParam('default', array(), false, 'raw_data'); @@ -868,7 +891,11 @@ EOF $oP->add(''); $oP->add(" 

"); $oP->add('
'); - $oP->add("
\n"); + $oP->add(<< +
+HTML + ); } break; @@ -1143,9 +1170,23 @@ EOF // $aIssues = $e->getIssues(); + $sObjKey = $oObj->GetKey(); + $sClassIcon = MetaModel::GetClassIcon($sClass); + $sHeaderTitle = Dict::Format('UI:CreationTitle_Class', $sClassLabel); + $oP->set_title(Dict::Format('UI:CreationPageTitle_Class', $sClassLabel)); - $oP->add("

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

\n"); - $oP->add("
\n"); + $oP->add(<< +
+ + +
+HTML + ); + + if (!empty($aIssues)) { $oP->AddHeaderMessage($e->getHtmlMessage(), 'message_error'); @@ -1156,7 +1197,11 @@ EOF $oP->AddHeaderMessage($sWarnings, 'message_info'); } cmdbAbstractObject::DisplayCreationForm($oP, $sClass, $oObj); - $oP->add("
\n"); + $oP->add(<< +
+HTML + ); } } break;