From acf26754effb7075d0a7373cc209ef6fb7232e83 Mon Sep 17 00:00:00 2001 From: Benjamin Dalsass Date: Tue, 18 Apr 2023 15:28:45 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B05958=20-=201:n=20-=20edit=5Fmode=3DADD?= =?UTF-8?q?=5FONLY=20-=20Location=20->=20Person?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/ui.extkeywidget.class.inc.php | 21 ++++---- .../ui.linksdirectwidget.class.inc.php | 17 +++++-- lib/composer/autoload_classmap.php | 1 + lib/composer/autoload_static.php | 1 + lib/composer/installed.php | 4 +- .../Application/Helper/LegacyFormHelper.php | 48 +++++++++++++++++++ .../Base/Layout/ObjectController.php | 8 ++++ .../Controller/Links/LinkSetController.php | 5 ++ 8 files changed, 89 insertions(+), 16 deletions(-) create mode 100644 sources/Application/Helper/LegacyFormHelper.php diff --git a/application/ui.extkeywidget.class.inc.php b/application/ui.extkeywidget.class.inc.php index bebaa9d54..24af82c9e 100644 --- a/application/ui.extkeywidget.class.inc.php +++ b/application/ui.extkeywidget.class.inc.php @@ -4,8 +4,8 @@ * @license http://opensource.org/licenses/AGPL-3.0 */ +use Combodo\iTop\Application\Helper\LegacyFormHelper; use Combodo\iTop\Application\UI\Base\Component\Form\FormUIBlockFactory; -use Combodo\iTop\Application\UI\Base\Component\Input\InputUIBlockFactory; use Combodo\iTop\Application\UI\Base\Layout\UIContentBlockUIBlockFactory; use Combodo\iTop\Core\MetaModel\FriendlyNameType; @@ -968,15 +968,16 @@ JS
HTML ); - $aFieldsFlags = array(); - $aFieldsComments = array(); - foreach (MetaModel::ListAttributeDefs($this->sTargetClass) as $sAttCode => $oAttDef) { - if (($oAttDef instanceof AttributeBlob) || (false)) { - $aFieldsFlags[$sAttCode] = OPT_ATT_READONLY; - $aFieldsComments[$sAttCode] = ' '; - } - } - cmdbAbstractObject::DisplayCreationForm($oPage, $this->sTargetClass, $oNewObj, array(), array('formPrefix' => $this->iId, 'noRelations' => true, 'fieldsFlags' => $aFieldsFlags, 'fieldsComments' => $aFieldsComments)); + + $aFormExtraParams = array( + 'formPrefix' => $this->iId, + 'noRelations' => true, + ); + + // Remove blob edition from creation form @see N°5863 to allow blob edition in modal context + LegacyFormHelper::DisableAttributeBlobInputs($this->sTargetClass, $aFormExtraParams); + + cmdbAbstractObject::DisplayCreationForm($oPage, $this->sTargetClass, $oNewObj, array(), $aFormExtraParams); $oPage->add(<<
diff --git a/application/ui.linksdirectwidget.class.inc.php b/application/ui.linksdirectwidget.class.inc.php index 8c19bba3d..a4bdac803 100644 --- a/application/ui.linksdirectwidget.class.inc.php +++ b/application/ui.linksdirectwidget.class.inc.php @@ -4,6 +4,7 @@ * @license http://opensource.org/licenses/AGPL-3.0 */ +use Combodo\iTop\Application\Helper\LegacyFormHelper; use Combodo\iTop\Application\UI\Links\Direct\BlockDirectLinkSetEditTable; use Combodo\iTop\Renderer\Console\ConsoleBlockRenderer; @@ -118,15 +119,23 @@ class UILinksWidgetDirect $sRealClass = $aKeys[0]; } - if ($sRealClass != '') - { + if ($sRealClass != '') { $oLinksetDef = MetaModel::GetAttributeDef($this->sClass, $this->sAttCode); $sExtKeyToMe = $oLinksetDef->GetExtKeyToMe(); - $aFieldFlags = array( $sExtKeyToMe => OPT_ATT_HIDDEN); + $aFieldsFlags = array($sExtKeyToMe => OPT_ATT_HIDDEN); $oObj = DBObject::MakeDefaultInstance($sRealClass); $aPrefillParam = array('source_obj' => $oSourceObj); $oObj->PrefillForm('creation_from_editinplace', $aPrefillParam); - cmdbAbstractObject::DisplayCreationForm($oPage, $sRealClass, $oObj, array(), array('formPrefix' => $this->sInputid, 'noRelations' => true, 'fieldsFlags' => $aFieldFlags)); + $aFormExtraParams = array( + 'formPrefix' => $this->sInputid, + 'noRelations' => true, + 'fieldsFlags' => $aFieldsFlags, + ); + + // Remove blob edition from creation form @see N°5863 to allow blob edition in modal context + LegacyFormHelper::DisableAttributeBlobInputs($sRealClass, $aFormExtraParams); + + cmdbAbstractObject::DisplayCreationForm($oPage, $sRealClass, $oObj, array(), $aFormExtraParams); } else { diff --git a/lib/composer/autoload_classmap.php b/lib/composer/autoload_classmap.php index f8cb68c7f..01e712091 100644 --- a/lib/composer/autoload_classmap.php +++ b/lib/composer/autoload_classmap.php @@ -190,6 +190,7 @@ return array( 'CheckableExpression' => $baseDir . '/core/oql/oqlquery.class.inc.php', 'Combodo\\iTop\\Application\\Branding' => $baseDir . '/sources/Application/Branding.php', 'Combodo\\iTop\\Application\\EventRegister\\ApplicationEvents' => $baseDir . '/sources/Application/EventRegister/ApplicationEvents.php', + 'Combodo\\iTop\\Application\\Helper\\LegacyFormHelper' => $baseDir . '/sources/Application/Helper/LegacyFormHelper.php', 'Combodo\\iTop\\Application\\Helper\\Session' => $baseDir . '/sources/Application/Helper/Session.php', 'Combodo\\iTop\\Application\\Helper\\WebResourcesHelper' => $baseDir . '/sources/Application/Helper/WebResourcesHelper.php', 'Combodo\\iTop\\Application\\Search\\AjaxSearchException' => $baseDir . '/sources/Application/Search/ajaxsearchexception.class.inc.php', diff --git a/lib/composer/autoload_static.php b/lib/composer/autoload_static.php index c53d441a5..7faea4328 100644 --- a/lib/composer/autoload_static.php +++ b/lib/composer/autoload_static.php @@ -555,6 +555,7 @@ class ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f 'CheckableExpression' => __DIR__ . '/../..' . '/core/oql/oqlquery.class.inc.php', 'Combodo\\iTop\\Application\\Branding' => __DIR__ . '/../..' . '/sources/Application/Branding.php', 'Combodo\\iTop\\Application\\EventRegister\\ApplicationEvents' => __DIR__ . '/../..' . '/sources/Application/EventRegister/ApplicationEvents.php', + 'Combodo\\iTop\\Application\\Helper\\LegacyFormHelper' => __DIR__ . '/../..' . '/sources/Application/Helper/LegacyFormHelper.php', 'Combodo\\iTop\\Application\\Helper\\Session' => __DIR__ . '/../..' . '/sources/Application/Helper/Session.php', 'Combodo\\iTop\\Application\\Helper\\WebResourcesHelper' => __DIR__ . '/../..' . '/sources/Application/Helper/WebResourcesHelper.php', 'Combodo\\iTop\\Application\\Search\\AjaxSearchException' => __DIR__ . '/../..' . '/sources/Application/Search/ajaxsearchexception.class.inc.php', diff --git a/lib/composer/installed.php b/lib/composer/installed.php index 1b7ceb17b..2c8578068 100644 --- a/lib/composer/installed.php +++ b/lib/composer/installed.php @@ -5,7 +5,7 @@ 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '4af0b9ab30a243b26bbebddcf190363ea6f28c83', + 'reference' => 'e645e9b00625680af30db024d4f2ef652179407c', 'name' => 'combodo/itop', 'dev' => true, ), @@ -25,7 +25,7 @@ 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '4af0b9ab30a243b26bbebddcf190363ea6f28c83', + 'reference' => 'e645e9b00625680af30db024d4f2ef652179407c', 'dev_requirement' => false, ), 'combodo/tcpdf' => array( diff --git a/sources/Application/Helper/LegacyFormHelper.php b/sources/Application/Helper/LegacyFormHelper.php new file mode 100644 index 000000000..08aadf741 --- /dev/null +++ b/sources/Application/Helper/LegacyFormHelper.php @@ -0,0 +1,48 @@ + $oAttDef) { + + // Set attribute blobs in read only + if ($oAttDef instanceof AttributeBlob) { + $aExtraParams['fieldsFlags'][$sAttCode] = OPT_ATT_READONLY; + $aExtraParams['fieldsComments'][$sAttCode] = ' '; + } + } + } +} \ No newline at end of file diff --git a/sources/Controller/Base/Layout/ObjectController.php b/sources/Controller/Base/Layout/ObjectController.php index e68aff1e0..8a2ca12d7 100644 --- a/sources/Controller/Base/Layout/ObjectController.php +++ b/sources/Controller/Base/Layout/ObjectController.php @@ -11,6 +11,7 @@ use ApplicationContext; use ApplicationException; use cmdbAbstractObject; use CMDBObjectSet; +use Combodo\iTop\Application\Helper\LegacyFormHelper; use Combodo\iTop\Application\Helper\Session; use Combodo\iTop\Application\UI\Base\Component\Alert\AlertUIBlockFactory; use Combodo\iTop\Application\UI\Base\Component\QuickCreate\QuickCreateHelper; @@ -172,6 +173,10 @@ JS; $oPage->set_title(Dict::Format('UI:CreationPageTitle_Class', $sClassLabel)); $oPage->SetContentLayout(PageContentFactory::MakeForObjectDetails($oObjToClone, cmdbAbstractObject::ENUM_DISPLAY_MODE_CREATE)); } + + // Remove blob edition from creation form @see N°5863 to allow blob edition in modal context + LegacyFormHelper::DisableAttributeBlobInputs($sRealClass, $aFormExtraParams); + cmdbAbstractObject::DisplayCreationForm($oPage, $sRealClass, $oObjToClone, array(), $aFormExtraParams); } else { if ($this->IsHandlingXmlHttpRequest()) { @@ -283,6 +288,9 @@ JS; $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().$sJsFileRelPath); } + // Remove blob edition from creation form @see N°5863 to allow blob edition in modal context + LegacyFormHelper::DisableAttributeBlobInputs($sClass, $aFormExtraParams); + // Note: Code duplicated to the case 'apply_modify' in UI.php when a data integrity issue has been found $oObj->DisplayModifyForm($oPage, $aFormExtraParams); // wizard_container: Display the title above the form diff --git a/sources/Controller/Links/LinkSetController.php b/sources/Controller/Links/LinkSetController.php index f1040c352..70b642353 100644 --- a/sources/Controller/Links/LinkSetController.php +++ b/sources/Controller/Links/LinkSetController.php @@ -8,6 +8,7 @@ namespace Combodo\iTop\Controller\Links; use AjaxPage; use cmdbAbstractObject; +use Combodo\iTop\Application\Helper\LegacyFormHelper; use Combodo\iTop\Application\UI\Base\Component\Form\FormUIBlockFactory; use Combodo\iTop\Controller\AbstractController; use Combodo\iTop\Service\Base\ObjectRepository; @@ -213,6 +214,10 @@ JS , ], ]; + + // Remove blob edition from creation form @see N°5863 to allow blob edition in modal context + LegacyFormHelper::DisableAttributeBlobInputs($sRealClass, $aExtraParams); + cmdbAbstractObject::DisplayCreationForm($oPage, $sRealClass, $oObj, array(), $aExtraParams); } else