mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°2313 - Markup extensibility: Add metadata on admin. console object creation forms
This commit is contained in:
@@ -1,61 +1,20 @@
|
||||
<?php
|
||||
// Copyright (C) 2010-2017 Combodo SARL
|
||||
//
|
||||
// This file is part of iTop.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||
/**
|
||||
* 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_<id> (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_<id> (div)-----------+
|
||||
* + +--- ds_<id> (div)---------------------------+ |
|
||||
* | | +------------- fs_<id> (form)------------+ | |
|
||||
* | | | +--------+---+ | | |
|
||||
* | | | | Class | V | | | |
|
||||
* | | | +--------+---+ | | |
|
||||
* | | | | | |
|
||||
* | | | S e a r c h F o r m | | |
|
||||
* | | | +--------+ | | |
|
||||
* | | | | Search | | | |
|
||||
* | | | +--------+ | | |
|
||||
* | | +----------------------------------------+ | |
|
||||
* | +--------------+-dh_<id>-+--------------------+ |
|
||||
* | \ Search / |
|
||||
* | +------+ |
|
||||
* | +--- fr_<id> (form)--------------------------+ |
|
||||
* | | +------------ dr_<id> (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('<div id="ac_create_'.$this->iId.'"><div class="wizContainer" style="vertical-align:top;"><div id="dcr_'.$this->iId.'">');
|
||||
$oPage->add("<h1>".MetaModel::GetClassIcon($this->sTargetClass)." ".Dict::Format('UI:CreationTitle_Class', MetaModel::GetName($this->sTargetClass))."</h1>\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(<<<HTML
|
||||
<div id="ac_create_{$this->iId}">
|
||||
<!-- Beginning of object-details -->
|
||||
<div class="object-details" data-object-class="$sObjClass" data-object-id="$sObjKey" data-object-mode="create">
|
||||
<!-- Beginning of wizContainer -->
|
||||
<div class="wizContainer" style="vertical-align:top;">
|
||||
<div id="dcr_{$this->iId}">
|
||||
<h1>$sClassIcon $sHeaderTitle</h1>
|
||||
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('</div></div></div>');
|
||||
$oPage->add(<<<HTML
|
||||
</div>
|
||||
</div><!-- End of wizContainer -->
|
||||
</div><!-- End of object-details -->
|
||||
</div>
|
||||
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');");
|
||||
|
||||
75
pages/UI.php
75
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("<h1>".MetaModel::GetClassIcon($sRealClass)." ".Dict::Format('UI:CreationTitle_Class', $sClassLabel)."</h1>\n");
|
||||
$oP->add("<div class=\"wizContainer\">\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
|
||||
<!-- Beginning of object-details -->
|
||||
<div class="object-details" data-object-class="$sRealClass" data-object-id="$sObjectTmpKey" data-object-mode="create">
|
||||
<div class="page_header">
|
||||
<h1>$sClassIcon $sHeaderTitle</h1>
|
||||
</div>
|
||||
<!-- Beginning of wizContainer -->
|
||||
<div class="wizContainer">
|
||||
HTML
|
||||
);
|
||||
cmdbAbstractObject::DisplayCreationForm($oP, $sRealClass, $oObjToClone, array());
|
||||
$oP->add("</div>\n");
|
||||
$oP->add(<<<HTML
|
||||
</div><!-- End of wizContainer -->
|
||||
</div><!-- End of object-details -->
|
||||
HTML
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Select the derived class to create
|
||||
$sClassLabel = MetaModel::GetName($sClass);
|
||||
$oP->add("<h1>".MetaModel::GetClassIcon($sClass)." ".Dict::Format('UI:CreationTitle_Class', $sClassLabel)."</h1>\n");
|
||||
$oP->add("<div class=\"wizContainer\">\n");
|
||||
$sClassIcon = MetaModel::GetClassIcon($sClass);
|
||||
$sHeaderTitle = Dict::Format('UI:CreationTitle_Class', $sClassLabel);
|
||||
$oP->add(<<<HTML
|
||||
<!-- Beginning of object-details -->
|
||||
<div class="object-details" data-object-class="$sClass" data-object-id="" data-object-mode="create">
|
||||
<div class="page_header">
|
||||
<h1>$sClassIcon $sHeaderTitle</h1>
|
||||
</div>
|
||||
<!-- Beginning of wizContainer -->
|
||||
<div class="wizContainer">
|
||||
HTML
|
||||
);
|
||||
$oP->add('<form>');
|
||||
$oP->add('<p>'.Dict::Format('UI:SelectTheTypeOf_Class_ToCreate', $sClassLabel));
|
||||
$aDefaults = utils::ReadParam('default', array(), false, 'raw_data');
|
||||
@@ -868,7 +891,11 @@ EOF
|
||||
$oP->add('</select>');
|
||||
$oP->add(" <input type=\"submit\" value=\"".Dict::S('UI:Button:Apply')."\"></p>");
|
||||
$oP->add('</form>');
|
||||
$oP->add("</div>\n");
|
||||
$oP->add(<<<HTML
|
||||
</div><!-- End of wizContainer -->
|
||||
</div><!-- End of object-details -->
|
||||
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("<h1>".MetaModel::GetClassIcon($sClass)." ".Dict::Format('UI:CreationTitle_Class', $sClassLabel)."</h1>\n");
|
||||
$oP->add("<div class=\"wizContainer\">\n");
|
||||
$oP->add(<<<HTML
|
||||
<!-- Beginning of object-details -->
|
||||
<div class="object-details" data-object-class="$sClass" data-object-id="$sObjKey" data-object-mode="create">
|
||||
<div class="page_header">
|
||||
<h1>$sClassIcon $sHeaderTitle</h1>
|
||||
</div>
|
||||
<!-- Beginning of wizContainer -->
|
||||
<div class="wizContainer">
|
||||
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("</div>\n");
|
||||
$oP->add(<<<HTML
|
||||
</div><!-- End of wizContainer -->
|
||||
</div><!-- End of object-details -->
|
||||
HTML
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user