mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-21 08:12:26 +02:00
N°7326 - JS error in editing object when a tab with list is deleted
This commit is contained in:
@@ -2044,6 +2044,41 @@ HTML
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $value = '', $sDisplayValue = '', $iId = '', $sNameSuffix = '', $iFlags = 0, $aArgs = array(), $bPreserveCurrentValue = true, &$sInputType = '')
|
||||
{
|
||||
$oBlock = self::GetBlockFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $value, $sDisplayValue, $iId, $sNameSuffix, $iFlags, $aArgs, $bPreserveCurrentValue, $sInputType);
|
||||
return ConsoleBlockRenderer::RenderBlockTemplateInPage($oPage, $oBlock);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \WebPage $oPage
|
||||
* @param string $sClass
|
||||
* @param string $sAttCode
|
||||
* @param \AttributeDefinition $oAttDef
|
||||
* @param string $value
|
||||
* @param string $sDisplayValue
|
||||
* @param string $iId
|
||||
* @param string $sNameSuffix
|
||||
* @param int $iFlags
|
||||
* @param array{this: \DBObject, formPrefix: string} $aArgs
|
||||
* @param bool $bPreserveCurrentValue Preserve the current value even if not allowed
|
||||
* @param string $sInputType type of rendering used, see ENUM_INPUT_TYPE_* const
|
||||
*
|
||||
* @return UIContentBlock
|
||||
*
|
||||
* @throws \ArchivedObjectException
|
||||
* @throws \ConfigException
|
||||
* @throws \CoreException
|
||||
* @throws \CoreUnexpectedValue
|
||||
* @throws \DictExceptionMissingString
|
||||
* @throws \MySQLException
|
||||
* @throws \OQLException
|
||||
* @throws \ReflectionException
|
||||
* @throws \Twig\Error\LoaderError
|
||||
* @throws \Twig\Error\RuntimeError
|
||||
* @throws \Twig\Error\SyntaxError
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function GetBlockFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $value = '', $sDisplayValue = '', $iId = '', $sNameSuffix = '', $iFlags = 0, $aArgs = array(), $bPreserveCurrentValue = true, &$sInputType = ''):UIContentBlock
|
||||
{
|
||||
$sFormPrefix = isset($aArgs['formPrefix']) ? $aArgs['formPrefix'] : '';
|
||||
$sFieldPrefix = isset($aArgs['prefix']) ? $sFormPrefix.$aArgs['prefix'] : $sFormPrefix;
|
||||
@@ -2062,13 +2097,13 @@ HTML
|
||||
$iInputId = utils::GetUniqueId();
|
||||
}
|
||||
|
||||
$oBlockValue = null;
|
||||
$sHTMLValue = '';
|
||||
|
||||
// attributes not compatible with bulk modify
|
||||
$bAttNotCompatibleWithBulk = array_key_exists('bulk_context', $aArgs) && !$oAttDef->IsBulkModifyCompatible();
|
||||
if ($bAttNotCompatibleWithBulk) {
|
||||
$oTagSetBlock = new Html('<span class="ibo-bulk--bulk-modify--incompatible-attribute">'.Dict::S('UI:Bulk:modify:IncompatibleAttribute').'</span>');
|
||||
$sHTMLValue = ConsoleBlockRenderer::RenderBlockTemplateInPage($oPage, $oTagSetBlock);
|
||||
$oBlockValue= new Html('<span class="ibo-bulk--bulk-modify--incompatible-attribute">'.Dict::S('UI:Bulk:modify:IncompatibleAttribute').'</span>');
|
||||
}
|
||||
|
||||
if (!$oAttDef->IsExternalField() && !$bAttNotCompatibleWithBulk) {
|
||||
@@ -2105,6 +2140,7 @@ HTML
|
||||
<input title="$sHelpText" class="date-pick ibo-input ibo-input-date" type="text" {$sPlaceholderValue} name="attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}" value="{$sDisplayValueForHtml}" id="{$iId}" autocomplete="off" />
|
||||
</div>{$sValidationSpan}{$sReloadSpan}
|
||||
HTML;
|
||||
$oBlockValue= new Html($sHTMLValue);
|
||||
break;
|
||||
|
||||
case 'DateTime':
|
||||
@@ -2120,6 +2156,7 @@ HTML;
|
||||
<input title="{$sHelpText}" class="datetime-pick ibo-input ibo-input-datetime" type="text" size="19" {$sPlaceholderValue} name="attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}" value="{$sDisplayValueForHtml}" id="{$iId}" autocomplete="off" />
|
||||
</div>{$sValidationSpan}{$sReloadSpan}
|
||||
HTML;
|
||||
$oBlockValue= new Html($sHTMLValue);
|
||||
break;
|
||||
|
||||
case 'Duration':
|
||||
@@ -2138,6 +2175,7 @@ HTML;
|
||||
$sHidden = "<input type=\"hidden\" id=\"{$iId}\" value=\"".utils::EscapeHtml($value)."\"/>";
|
||||
$sHTMLValue = Dict::Format('UI:DurationForm_Days_Hours_Minutes_Seconds', $sDays, $sHours, $sMinutes, $sSeconds).$sHidden." ".$sValidationSpan.$sReloadSpan;
|
||||
$oPage->add_ready_script("$('#{$iId}').on('update', function(evt, sFormId) { return ToggleDurationField('$iId'); });");
|
||||
$oBlockValue= new Html($sHTMLValue);
|
||||
break;
|
||||
|
||||
case 'Password':
|
||||
@@ -2146,6 +2184,7 @@ HTML;
|
||||
$aEventsList[] = 'keyup';
|
||||
$aEventsList[] = 'change';
|
||||
$sHTMLValue = "<div class=\"field_input_zone field_input_password ibo-input-wrapper ibo-input-password-wrapper\" data-validation=\"untouched\"><input class=\"ibo-input ibo-input-password\" title=\"$sHelpText\" type=\"password\" name=\"attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}\" value=\"".utils::EscapeHtml($value)."\" id=\"$iId\"/></div>{$sValidationSpan}{$sReloadSpan}";
|
||||
$oBlockValue= new Html($sHTMLValue);
|
||||
break;
|
||||
|
||||
case 'OQLExpression':
|
||||
@@ -2283,6 +2322,7 @@ HTML;
|
||||
});
|
||||
JS
|
||||
);
|
||||
$oBlockValue= new Html($sHTMLValue);
|
||||
break;
|
||||
|
||||
// Since 3.0 not used for activity panel but kept for bulk modify and bulk-event extension
|
||||
@@ -2325,6 +2365,7 @@ JS
|
||||
CKEditorHelper::ConfigureCKEditorElementForWebPage($oPage, $iId, $sOriginalValue, true, [
|
||||
'placeholder' => Dict::S('UI:CaseLogTypeYourTextHere'),
|
||||
]);
|
||||
$oBlockValue= new Html($sHTMLValue);
|
||||
break;
|
||||
|
||||
case 'HTML':
|
||||
@@ -2333,20 +2374,20 @@ JS
|
||||
$oWidget = new UIHTMLEditorWidget($iId, $oAttDef, $sNameSuffix, $sFieldPrefix, $sHelpText,
|
||||
$sValidationSpan.$sReloadSpan, $sEditValue, $bMandatory);
|
||||
$sHTMLValue = $oWidget->Display($oPage, $aArgs);
|
||||
$oBlockValue= new Html($sHTMLValue);
|
||||
break;
|
||||
|
||||
case 'LinkedSet':
|
||||
if ($oAttDef->GetDisplayStyle() === LINKSET_DISPLAY_STYLE_PROPERTY) {
|
||||
$sInputType = self::ENUM_INPUT_TYPE_TAGSET_LINKEDSET;
|
||||
if (array_key_exists('bulk_context', $aArgs)) {
|
||||
$oTagSetBlock = LinkSetUIBlockFactory::MakeForBulkLinkSet($iId, $oAttDef, $value, $sWizardHelperJsVarName, $aArgs['bulk_context']);
|
||||
$oBlockValue = LinkSetUIBlockFactory::MakeForBulkLinkSet($iId, $oAttDef, $value, $sWizardHelperJsVarName, $aArgs['bulk_context']);
|
||||
} else {
|
||||
$oTagSetBlock = LinkSetUIBlockFactory::MakeForLinkSet($iId, $oAttDef, $value, $sWizardHelperJsVarName, $aArgs['this']);
|
||||
$oBlockValue = LinkSetUIBlockFactory::MakeForLinkSet($iId, $oAttDef, $value, $sWizardHelperJsVarName, $aArgs['this']);
|
||||
}
|
||||
$oTagSetBlock->SetName("attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}");
|
||||
$oBlockValue->SetName("attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}");
|
||||
$aEventsList[] = 'validate';
|
||||
$aEventsList[] = 'change';
|
||||
$sHTMLValue = ConsoleBlockRenderer::RenderBlockTemplateInPage($oPage, $oTagSetBlock);
|
||||
} else {
|
||||
$sInputType = self::ENUM_INPUT_TYPE_LINKEDSET;
|
||||
$oObj = $aArgs['this'] ?? null;
|
||||
@@ -2358,7 +2399,7 @@ JS
|
||||
}
|
||||
$aEventsList[] = 'validate';
|
||||
$aEventsList[] = 'change';
|
||||
$sHTMLValue = $oWidget->Display($oPage, $value, array(), $sFormPrefix, $oObj);
|
||||
$oBlockValue = $oWidget->GetBlock($oPage, $value, array(), $sFormPrefix, $oObj);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -2396,6 +2437,7 @@ HTML;
|
||||
if ($sFileName == '') {
|
||||
$oPage->add_ready_script("$('#remove_attr_{$iId}').addClass('ibo-is-hidden');");
|
||||
}
|
||||
$oBlockValue= new Html($sHTMLValue);
|
||||
break;
|
||||
|
||||
case 'Image':
|
||||
@@ -2429,15 +2471,18 @@ HTML;
|
||||
);
|
||||
$sEditImageOptions = json_encode($aEditImage);
|
||||
$oPage->add_ready_script("$('#edit_$iInputId').edit_image($sEditImageOptions);");
|
||||
$oBlockValue= new Html($sHTMLValue);
|
||||
break;
|
||||
|
||||
case 'StopWatch':
|
||||
$sHTMLValue = "The edition of a stopwatch is not allowed!!!";
|
||||
$oBlockValue= new Html($sHTMLValue);
|
||||
break;
|
||||
|
||||
case 'List':
|
||||
// Not editable for now...
|
||||
$sHTMLValue = '';
|
||||
$oBlockValue= new Html($sHTMLValue);
|
||||
break;
|
||||
|
||||
case 'One Way Password':
|
||||
@@ -2446,6 +2491,7 @@ HTML;
|
||||
$oWidget = new UIPasswordWidget($sAttCode, $iId, $sNameSuffix);
|
||||
$sHTMLValue = $oWidget->Display($oPage, $aArgs);
|
||||
// Event list & validation is handled directly by the widget
|
||||
$oBlockValue= new Html($sHTMLValue);
|
||||
break;
|
||||
|
||||
case 'ExtKey':
|
||||
@@ -2476,6 +2522,7 @@ HTML;
|
||||
$sWizardHelperJsVarName = $aArgs['wizHelperRemote'];
|
||||
$aDependencies = $aArgs['remoteCodes'];
|
||||
}
|
||||
$oBlockValue= new Html($sHTMLValue);
|
||||
|
||||
break;
|
||||
|
||||
@@ -2485,6 +2532,7 @@ HTML;
|
||||
$sHTMLValue .= '</div>';
|
||||
$sHTMLValue .= '<div>'.$sValidationSpan.$sReloadSpan.'</div>';
|
||||
$oPage->add_ready_script("$('#$iId :input').on('keyup change validate', function(evt, sFormId) { return ValidateRedundancySettings('$iId',sFormId); } );"); // Custom validation function
|
||||
$oBlockValue= new Html($sHTMLValue);
|
||||
break;
|
||||
|
||||
case 'CustomFields':
|
||||
@@ -2542,6 +2590,7 @@ $('#{$iId}').on('validate', function(evt, sFormId) {
|
||||
});
|
||||
JS
|
||||
);
|
||||
$oBlockValue= new Html($sHTMLValue);
|
||||
|
||||
break;
|
||||
|
||||
@@ -2570,6 +2619,7 @@ JS
|
||||
$sHTMLValue = '<div class="field_input_zone field_input_set ibo-input-wrapper ibo-input-tagset-wrapper" data-validation="untouched"><input id="'.$iId.'" name="'.$sSetInputName.'" type="hidden" value="'.$sEscapedJson.'"></div>'.$sValidationSpan.$sReloadSpan;
|
||||
$sScript = "$('#$iId').set_widget({inputWidgetIdSuffix: '".AttributeSet::EDITABLE_INPUT_ID_SUFFIX."'});";
|
||||
$oPage->add_ready_script($sScript);
|
||||
$oBlockValue= new Html($sHTMLValue);
|
||||
|
||||
break;
|
||||
|
||||
@@ -2670,6 +2720,7 @@ HTML;
|
||||
$aEventsList[] = 'change';
|
||||
|
||||
}
|
||||
$oBlockValue= new Html($sHTMLValue);
|
||||
break;
|
||||
}
|
||||
$sPattern = addslashes($oAttDef->GetValidationPattern()); //'^([0-9]+)$';
|
||||
@@ -2728,7 +2779,14 @@ JS
|
||||
$oPage->add_init_script('$("[data-input-id=\''.$iId.'\']").attr("data-input-type", "'.$sInputType.'");');
|
||||
}
|
||||
//TODO 3.0 remove the data-attcode attribute (either because it's has been moved to .field_container in 2.7 or even better because the admin. console has been reworked)
|
||||
return "<div id=\"field_{$iId}\" class=\"field_value_container\"><div class=\"attribute-edit\" data-attcode=\"$sAttCode\">{$sHTMLValue}</div></div>";
|
||||
$oBlockEditContainer = UIContentBlockUIBlockFactory::MakeStandard(null, ['attribute-edit']);
|
||||
$oBlockEditContainer->AddSubBlock($oBlockValue);
|
||||
|
||||
$oBlockContainer = UIContentBlockUIBlockFactory::MakeStandard('field_'.$iId, ['field_value_container']);
|
||||
$oBlockContainer->AddSubBlock($oBlockEditContainer);
|
||||
|
||||
return $oBlockContainer;//// "<div id=\"field_{$iId}\" class=\"field_value_container\"><div class=\"attribute-edit\" >{$sHTMLValue}</div></div>";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -92,6 +92,27 @@ class UILinksWidgetDirect
|
||||
|
||||
/**
|
||||
* @param WebPage $oPage
|
||||
* @param $oValue
|
||||
* @param $aArgs
|
||||
* @param $sFormPrefix
|
||||
* @param $oCurrentObj
|
||||
* @return BlockIndirectLinkSetEditTable
|
||||
* @throws ArchivedObjectException
|
||||
* @throws ConfigException
|
||||
* @throws CoreException
|
||||
* @throws CoreUnexpectedValue
|
||||
* @since 3.2
|
||||
*/
|
||||
public function GetBlock(WebPage $oPage, $oValue, $aArgs, $sFormPrefix, $oCurrentObj)
|
||||
{
|
||||
$oBlock = new BlockDirectLinkSetEditTable($this, $this->sInputid);
|
||||
$oBlock->InitTable($oPage, $oValue, $sFormPrefix, $oCurrentObj);
|
||||
|
||||
return $oBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WebPage $oPage
|
||||
* @param string $sProposedRealClass
|
||||
*/
|
||||
public function GetObjectCreationDlg(WebPage $oPage, $sProposedRealClass = '', $oSourceObj = null)
|
||||
|
||||
@@ -148,6 +148,27 @@ class UILinksWidget
|
||||
return ConsoleBlockRenderer::RenderBlockTemplateInPage($oPage, $oBlock);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WebPage $oPage
|
||||
* @param $oValue
|
||||
* @param $aArgs
|
||||
* @param $sFormPrefix
|
||||
* @param $oCurrentObj
|
||||
* @return BlockIndirectLinkSetEditTable
|
||||
* @throws ArchivedObjectException
|
||||
* @throws ConfigException
|
||||
* @throws CoreException
|
||||
* @throws CoreUnexpectedValue
|
||||
* @since 3.2
|
||||
*/
|
||||
public function GetBlock(WebPage $oPage, $oValue, $aArgs, $sFormPrefix, $oCurrentObj): BlockIndirectLinkSetEditTable
|
||||
{
|
||||
$oBlock = new BlockIndirectLinkSetEditTable($this);
|
||||
$oBlock->InitTable($oPage, $oValue, $aArgs, $sFormPrefix, $oCurrentObj, $this->m_aTableConfig);
|
||||
|
||||
return $oBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WebPage $oPage
|
||||
* @param DBObject $oCurrentObj
|
||||
|
||||
Reference in New Issue
Block a user