diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index b390a8c65..2eb51f155 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -728,7 +728,7 @@ HTML $oClassIcon = new MedallionIcon(MetaModel::GetClassIcon($sTargetClass, false)); $oClassIcon->SetDescription($oAttDef->GetDescription())->AddCSSClass('ibo-block-list--medallion'); $oPage->AddUiBlock($oClassIcon); - + $sDisplayValue = ''; // not used $sHTMLValue = "".self::GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $oLinkSet, $sDisplayValue, $sInputId, '', $iFlags, $aArgs).''; @@ -5195,10 +5195,13 @@ EOF $sStatus = $bResult ? Dict::S('UI:BulkModifyStatusModified') : Dict::S('UI:BulkModifyStatusSkipped'); } + $aErrorsToDisplay = array_map(function($sError) { + return utils::HtmlEntities($sError); + }, $aErrors); $aRows[] = array( 'object' => $oObj->GetHyperlink(), 'status' => $sStatus, - 'errors' => '

'.($bResult ? '' : implode('

', $aErrors)).'

', + 'errors' => '

'.($bResult ? '' : implode('

', $aErrorsToDisplay)).'

', ); if ($bResult && (!$bPreview)) { $oObj->DBUpdate(); @@ -5207,7 +5210,7 @@ EOF set_time_limit(intval($iPreviousTimeLimit)); $oTable = DataTableUIBlockFactory::MakeForForm('BulkModify', $aHeaders, $aRows); $oTable->AddOption("bFullscreen", true); - + $oPanel = PanelUIBlockFactory::MakeForClass($sClass, ''); $oPanel->SetIcon($sClassIcon); $oPanel->SetTitle($sHeaderTitle); @@ -5413,13 +5416,13 @@ EOF $oFailAlertBlock = AlertUIBlockFactory::MakeForDanger('', Dict::S('UI:Delete:SorryDeletionNotAllowed')); $oFailAlertBlock->SetIsClosable(false); $oP->AddUiBlock($oFailAlertBlock); - } + } else { $oWarningAlertBlock = AlertUIBlockFactory::MakeForWarning('', Dict::S('UI:Delete:PleaseDoTheManualOperations')); $oWarningAlertBlock->SetIsClosable(false); $oP->AddUiBlock($oWarningAlertBlock); } - + $oForm = FormUIBlockFactory::MakeStandard(''); $oP->AddSubBlock($oForm); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden('transaction_id', utils::ReadParam('transaction_id', '', false, 'transaction_id'))); diff --git a/core/dbobject.class.php b/core/dbobject.class.php index ce7e74775..d71485a09 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -1930,7 +1930,7 @@ abstract class DBObject implements iDisplay /** @var \AttributeExternalKey $oAtt */ $sTargetClass = $oAtt->GetTargetClass(); if (false === MetaModel::IsObjectInDB($sTargetClass, $toCheck)) { - return "Target object not found (".utils::HtmlEntities($sTargetClass).".::".utils::HtmlEntities($toCheck).")"; + return "Target object not found (".$sTargetClass.".::".$toCheck.")"; } } if ($oAtt->IsHierarchicalKey()) @@ -1939,7 +1939,7 @@ abstract class DBObject implements iDisplay $aValues = $oAtt->GetAllowedValues(array('this' => $this)); if (!array_key_exists($toCheck, $aValues)) { - return "Value not allowed [". utils::HtmlEntities($toCheck)."]"; + return "Value not allowed [$toCheck]"; } } } @@ -1953,7 +1953,7 @@ abstract class DBObject implements iDisplay $oTag->SetValues(explode(' ', $toCheck)); } catch (Exception $e) { - return "Tag value [". utils::HtmlEntities($toCheck)."] is not a valid tag list"; + return "Tag value '$toCheck' is not a valid tag list"; } return true; @@ -1981,7 +1981,7 @@ abstract class DBObject implements iDisplay $oTag->SetValues($aValues); } catch (Exception $e) { - return "Set value[". utils::HtmlEntities($toCheck)."] is not a valid set"; + return "Set value '$toCheck' is not a valid set"; } return true; @@ -2001,7 +2001,7 @@ abstract class DBObject implements iDisplay { if (!array_key_exists($toCheck, $aValues)) { - return "Value not allowed [". utils::HtmlEntities($toCheck)."]"; + return "Value not allowed [$toCheck]"; } } if (!is_null($iMaxSize = $oAtt->GetMaxSize())) @@ -2014,7 +2014,7 @@ abstract class DBObject implements iDisplay } if (!$oAtt->CheckFormat($toCheck)) { - return "Wrong format [". utils::HtmlEntities($toCheck)."]"; + return "Wrong format [$toCheck]"; } } else diff --git a/js/console_form_handler.js b/js/console_form_handler.js index 194a78629..24e428cc2 100644 --- a/js/console_form_handler.js +++ b/js/console_form_handler.js @@ -35,8 +35,7 @@ $(function() { var me = this; - this.element - .append('
') + this.element.append('
') .addClass('console_form_handler'); this.options.oWizardHelper = window[this.options.wizard_helper_var_name]; @@ -48,13 +47,13 @@ $(function() // revert other modifications here _destroy: function() { - this.element - .removeClass('console_form_handler'); + this.element.removeClass('console_form_handler'); this._super(); }, _onUpdateFields: function(event, data) { var me = this; + me._updatePreviousValues(); var sFormPath = data.form_path; var sUpdateUrl = GetAbsoluteUrlAppRoot()+'pages/ajax.render.php'; @@ -64,7 +63,6 @@ $(function() { operation: 'custom_fields_update', attcode: this.options.custom_field_attcode, - //current_values: this.getCurrentValues(), requested_fields: data.requested_fields, form_path: sFormPath, json_obj: this.options.oWizardHelper.UpdateWizardToJSON() @@ -85,6 +83,7 @@ $(function() me.element.find('.last-error').text(data.error); } me._onUpdateAlways(data, sFormPath); + me.element.find('[data-field-id="previous_values"]').find('input[type="hidden"]').val('{}'); }); }, // On initialization or update diff --git a/js/form_handler.js b/js/form_handler.js index c709c5e43..64f761c07 100644 --- a/js/form_handler.js +++ b/js/form_handler.js @@ -92,12 +92,24 @@ $(function() { return this.options.field_set.triggerHandler('get_current_values'); }, - + //since 3.0.2 3.1.0 + _updatePreviousValues: function() + { + let me = this; + if(this.element.find('[data-attribute-previous-value]').length>0) { + let aPreviousValues = {}; + $(this.element.find('[data-attribute-previous-value]')).each(function (idx, elt) { + aPreviousValues[$(elt).data('field-id')] = $(elt).data('attribute-previous-value'); + }); + me.element.find('[data-field-id="previous_values"]').find('input[type="hidden"]').val(JSON.stringify(aPreviousValues)); + } + }, // Events callback // - Update fields depending on the update ones _onUpdateFields: function(oEvent, oData) { var me = this; + me._updatePreviousValues(); var sFormPath = oData.form_path; // Data checks diff --git a/pages/UI.php b/pages/UI.php index d479ea8bc..7a79afe18 100644 --- a/pages/UI.php +++ b/pages/UI.php @@ -1481,7 +1481,10 @@ EOF } else { - $sError = '

'.implode('

',$aErrors)."

\n"; + $aErrorsToDisplay = array_map(function($sError) { + return utils::HtmlEntities($sError); + }, $aErrors); + $sError = '

'.implode('

',$aErrorsToDisplay)."

\n"; } } else diff --git a/sources/Renderer/Console/FieldRenderer/ConsoleSimpleFieldRenderer.php b/sources/Renderer/Console/FieldRenderer/ConsoleSimpleFieldRenderer.php index 985a2ee88..a8469a20c 100644 --- a/sources/Renderer/Console/FieldRenderer/ConsoleSimpleFieldRenderer.php +++ b/sources/Renderer/Console/FieldRenderer/ConsoleSimpleFieldRenderer.php @@ -25,6 +25,7 @@ use AttributeDuration; use Combodo\iTop\Application\Helper\WebResourcesHelper; use Combodo\iTop\Application\UI\Base\Component\Field\FieldUIBlockFactory; use Combodo\iTop\Application\UI\Base\Component\Html\Html; +use Combodo\iTop\Application\UI\Base\Component\Html\HtmlFactory; use Combodo\iTop\Application\UI\Base\Component\Input\InputUIBlockFactory; use Combodo\iTop\Application\UI\Base\Component\Input\Select\SelectOptionUIBlockFactory; use Combodo\iTop\Application\UI\Base\Component\Input\SelectUIBlockFactory; @@ -110,15 +111,17 @@ class ConsoleSimpleFieldRenderer extends FieldRenderer $bRichEditor = ($this->oField->GetFormat() === TextAreaField::ENUM_FORMAT_HTML); - $oText = new TextArea("",$this->oField->GetCurrentValue(),$this->oField->GetGlobalId(),40,8); - $oText->AddCSSClass('ibo-input-field-wrapper ibo-input'); - $oValue->AddSubBlock($oText); + if ($this->oField->GetReadOnly()) { - $oText->SetIsDisabled(true); + $oValue->AddSubBlock(UIContentBlockUIBlockFactory::MakeStandard())->AddSubBlock(HtmlFactory::MakeHtmlContent($this->oField->GetCurrentValue())); + $oValue->AddSubBlock(InputUIBlockFactory::MakeForHidden("",$this->oField->GetCurrentValue(), $this->oField->GetGlobalId())); } else { + $oText = new TextArea("",$this->oField->GetCurrentValue(),$this->oField->GetGlobalId(),40,8); + $oText->AddCSSClasses(['ibo-input-field-wrapper', 'ibo-input']); + $oValue->AddSubBlock($oText); // Some additional stuff if we are displaying it with a rich editor if ($bRichEditor) {