Compare commits

...

2 Commits

Author SHA1 Message Date
Anne-Cath
891a7bcbdd N°7326 - JS error in editing object when a tab with list is deleted 2025-03-17 11:17:25 +01:00
Anne-Cath
60e54e6160 N°7326 - JS error in editing object when a tab with list is deleted 2025-03-17 11:17:20 +01:00
3 changed files with 574 additions and 473 deletions

View File

@@ -760,10 +760,11 @@ HTML
if ($bEditMode && (!$bReadOnly)) { if ($bEditMode && (!$bReadOnly)) {
$sInputId = $this->m_iFormId.'_'.$sAttCode; $sInputId = $this->m_iFormId.'_'.$sAttCode;
$sDisplayValue = ''; // not used $sDisplayValue = ''; // not used
$sHTMLValue = "<span id=\"field_{$sInputId}\">".self::GetFormElementForField($oPage, $sClass, $sAttCode, $oDiv=UIContentBlockUIBlockFactory::MakeStandard('field_'.$sInputId);
$oAttDef, $oLinkSet, $sDisplayValue, $sInputId, '', $iFlags, $aArgs).'</span>'; $oLinkBlock = self::GetBlockFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $oLinkSet, $sDisplayValue, $sInputId, '', $iFlags, $aArgs);
$oDiv->AddSubBlock($oLinkBlock);
$this->AddToFieldsMap($sAttCode, $sInputId); $this->AddToFieldsMap($sAttCode, $sInputId);
$oPage->add($sHTMLValue); $oPage->AddUiBlock($oDiv);
} else { } else {
if ($oAttDef->IsIndirect()) { if ($oAttDef->IsIndirect()) {
$oBlockLinkSetViewTable = new BlockIndirectLinkSetViewTable($oPage, $this, $sClass, $sAttCode, $oAttDef, $bReadOnly); $oBlockLinkSetViewTable = new BlockIndirectLinkSetViewTable($oPage, $this, $sClass, $sAttCode, $oAttDef, $bReadOnly);
@@ -2044,6 +2045,41 @@ HTML
* @throws \Exception * @throws \Exception
*/ */
public static function GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $value = '', $sDisplayValue = '', $iId = '', $sNameSuffix = '', $iFlags = 0, $aArgs = array(), $bPreserveCurrentValue = true, &$sInputType = '') 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'] : ''; $sFormPrefix = isset($aArgs['formPrefix']) ? $aArgs['formPrefix'] : '';
$sFieldPrefix = isset($aArgs['prefix']) ? $sFormPrefix.$aArgs['prefix'] : $sFormPrefix; $sFieldPrefix = isset($aArgs['prefix']) ? $sFormPrefix.$aArgs['prefix'] : $sFormPrefix;
@@ -2062,13 +2098,13 @@ HTML
$iInputId = utils::GetUniqueId(); $iInputId = utils::GetUniqueId();
} }
$oBlockValue = null;
$sHTMLValue = ''; $sHTMLValue = '';
// attributes not compatible with bulk modify // attributes not compatible with bulk modify
$bAttNotCompatibleWithBulk = array_key_exists('bulk_context', $aArgs) && !$oAttDef->IsBulkModifyCompatible(); $bAttNotCompatibleWithBulk = array_key_exists('bulk_context', $aArgs) && !$oAttDef->IsBulkModifyCompatible();
if ($bAttNotCompatibleWithBulk) { if ($bAttNotCompatibleWithBulk) {
$oTagSetBlock = new Html('<span class="ibo-bulk--bulk-modify--incompatible-attribute">'.Dict::S('UI:Bulk:modify:IncompatibleAttribute').'</span>'); $oBlockValue= new Html('<span class="ibo-bulk--bulk-modify--incompatible-attribute">'.Dict::S('UI:Bulk:modify:IncompatibleAttribute').'</span>');
$sHTMLValue = ConsoleBlockRenderer::RenderBlockTemplateInPage($oPage, $oTagSetBlock);
} }
if (!$oAttDef->IsExternalField() && !$bAttNotCompatibleWithBulk) { if (!$oAttDef->IsExternalField() && !$bAttNotCompatibleWithBulk) {
@@ -2105,6 +2141,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" /> <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} </div>{$sValidationSpan}{$sReloadSpan}
HTML; HTML;
$oBlockValue= new Html($sHTMLValue);
break; break;
case 'DateTime': case 'DateTime':
@@ -2120,6 +2157,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" /> <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} </div>{$sValidationSpan}{$sReloadSpan}
HTML; HTML;
$oBlockValue= new Html($sHTMLValue);
break; break;
case 'Duration': case 'Duration':
@@ -2138,6 +2176,7 @@ HTML;
$sHidden = "<input type=\"hidden\" id=\"{$iId}\" value=\"".utils::EscapeHtml($value)."\"/>"; $sHidden = "<input type=\"hidden\" id=\"{$iId}\" value=\"".utils::EscapeHtml($value)."\"/>";
$sHTMLValue = Dict::Format('UI:DurationForm_Days_Hours_Minutes_Seconds', $sDays, $sHours, $sMinutes, $sSeconds).$sHidden."&nbsp;".$sValidationSpan.$sReloadSpan; $sHTMLValue = Dict::Format('UI:DurationForm_Days_Hours_Minutes_Seconds', $sDays, $sHours, $sMinutes, $sSeconds).$sHidden."&nbsp;".$sValidationSpan.$sReloadSpan;
$oPage->add_ready_script("$('#{$iId}').on('update', function(evt, sFormId) { return ToggleDurationField('$iId'); });"); $oPage->add_ready_script("$('#{$iId}').on('update', function(evt, sFormId) { return ToggleDurationField('$iId'); });");
$oBlockValue= new Html($sHTMLValue);
break; break;
case 'Password': case 'Password':
@@ -2146,6 +2185,7 @@ HTML;
$aEventsList[] = 'keyup'; $aEventsList[] = 'keyup';
$aEventsList[] = 'change'; $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}"; $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; break;
case 'OQLExpression': case 'OQLExpression':
@@ -2283,6 +2323,7 @@ HTML;
}); });
JS JS
); );
$oBlockValue= new Html($sHTMLValue);
break; break;
// Since 3.0 not used for activity panel but kept for bulk modify and bulk-event extension // Since 3.0 not used for activity panel but kept for bulk modify and bulk-event extension
@@ -2325,6 +2366,7 @@ JS
CKEditorHelper::ConfigureCKEditorElementForWebPage($oPage, $iId, $sOriginalValue, true, [ CKEditorHelper::ConfigureCKEditorElementForWebPage($oPage, $iId, $sOriginalValue, true, [
'placeholder' => Dict::S('UI:CaseLogTypeYourTextHere'), 'placeholder' => Dict::S('UI:CaseLogTypeYourTextHere'),
]); ]);
$oBlockValue= new Html($sHTMLValue);
break; break;
case 'HTML': case 'HTML':
@@ -2333,20 +2375,20 @@ JS
$oWidget = new UIHTMLEditorWidget($iId, $oAttDef, $sNameSuffix, $sFieldPrefix, $sHelpText, $oWidget = new UIHTMLEditorWidget($iId, $oAttDef, $sNameSuffix, $sFieldPrefix, $sHelpText,
$sValidationSpan.$sReloadSpan, $sEditValue, $bMandatory); $sValidationSpan.$sReloadSpan, $sEditValue, $bMandatory);
$sHTMLValue = $oWidget->Display($oPage, $aArgs); $sHTMLValue = $oWidget->Display($oPage, $aArgs);
$oBlockValue= new Html($sHTMLValue);
break; break;
case 'LinkedSet': case 'LinkedSet':
if ($oAttDef->GetDisplayStyle() === LINKSET_DISPLAY_STYLE_PROPERTY) { if ($oAttDef->GetDisplayStyle() === LINKSET_DISPLAY_STYLE_PROPERTY) {
$sInputType = self::ENUM_INPUT_TYPE_TAGSET_LINKEDSET; $sInputType = self::ENUM_INPUT_TYPE_TAGSET_LINKEDSET;
if (array_key_exists('bulk_context', $aArgs)) { 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 { } 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[] = 'validate';
$aEventsList[] = 'change'; $aEventsList[] = 'change';
$sHTMLValue = ConsoleBlockRenderer::RenderBlockTemplateInPage($oPage, $oTagSetBlock);
} else { } else {
$sInputType = self::ENUM_INPUT_TYPE_LINKEDSET; $sInputType = self::ENUM_INPUT_TYPE_LINKEDSET;
$oObj = $aArgs['this'] ?? null; $oObj = $aArgs['this'] ?? null;
@@ -2358,7 +2400,7 @@ JS
} }
$aEventsList[] = 'validate'; $aEventsList[] = 'validate';
$aEventsList[] = 'change'; $aEventsList[] = 'change';
$sHTMLValue = $oWidget->Display($oPage, $value, array(), $sFormPrefix, $oObj); $oBlockValue = $oWidget->GetBlock($oPage, $value, array(), $sFormPrefix, $oObj);
} }
break; break;
@@ -2396,6 +2438,7 @@ HTML;
if ($sFileName == '') { if ($sFileName == '') {
$oPage->add_ready_script("$('#remove_attr_{$iId}').addClass('ibo-is-hidden');"); $oPage->add_ready_script("$('#remove_attr_{$iId}').addClass('ibo-is-hidden');");
} }
$oBlockValue= new Html($sHTMLValue);
break; break;
case 'Image': case 'Image':
@@ -2429,15 +2472,18 @@ HTML;
); );
$sEditImageOptions = json_encode($aEditImage); $sEditImageOptions = json_encode($aEditImage);
$oPage->add_ready_script("$('#edit_$iInputId').edit_image($sEditImageOptions);"); $oPage->add_ready_script("$('#edit_$iInputId').edit_image($sEditImageOptions);");
$oBlockValue= new Html($sHTMLValue);
break; break;
case 'StopWatch': case 'StopWatch':
$sHTMLValue = "The edition of a stopwatch is not allowed!!!"; $sHTMLValue = "The edition of a stopwatch is not allowed!!!";
$oBlockValue= new Html($sHTMLValue);
break; break;
case 'List': case 'List':
// Not editable for now... // Not editable for now...
$sHTMLValue = ''; $sHTMLValue = '';
$oBlockValue= new Html($sHTMLValue);
break; break;
case 'One Way Password': case 'One Way Password':
@@ -2446,6 +2492,7 @@ HTML;
$oWidget = new UIPasswordWidget($sAttCode, $iId, $sNameSuffix); $oWidget = new UIPasswordWidget($sAttCode, $iId, $sNameSuffix);
$sHTMLValue = $oWidget->Display($oPage, $aArgs); $sHTMLValue = $oWidget->Display($oPage, $aArgs);
// Event list & validation is handled directly by the widget // Event list & validation is handled directly by the widget
$oBlockValue= new Html($sHTMLValue);
break; break;
case 'ExtKey': case 'ExtKey':
@@ -2476,6 +2523,7 @@ HTML;
$sWizardHelperJsVarName = $aArgs['wizHelperRemote']; $sWizardHelperJsVarName = $aArgs['wizHelperRemote'];
$aDependencies = $aArgs['remoteCodes']; $aDependencies = $aArgs['remoteCodes'];
} }
$oBlockValue= new Html($sHTMLValue);
break; break;
@@ -2485,6 +2533,7 @@ HTML;
$sHTMLValue .= '</div>'; $sHTMLValue .= '</div>';
$sHTMLValue .= '<div>'.$sValidationSpan.$sReloadSpan.'</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 $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; break;
case 'CustomFields': case 'CustomFields':
@@ -2542,6 +2591,7 @@ $('#{$iId}').on('validate', function(evt, sFormId) {
}); });
JS JS
); );
$oBlockValue= new Html($sHTMLValue);
break; break;
@@ -2570,6 +2620,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; $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."'});"; $sScript = "$('#$iId').set_widget({inputWidgetIdSuffix: '".AttributeSet::EDITABLE_INPUT_ID_SUFFIX."'});";
$oPage->add_ready_script($sScript); $oPage->add_ready_script($sScript);
$oBlockValue= new Html($sHTMLValue);
break; break;
@@ -2670,6 +2721,7 @@ HTML;
$aEventsList[] = 'change'; $aEventsList[] = 'change';
} }
$oBlockValue= new Html($sHTMLValue);
break; break;
} }
$sPattern = addslashes($oAttDef->GetValidationPattern()); //'^([0-9]+)$'; $sPattern = addslashes($oAttDef->GetValidationPattern()); //'^([0-9]+)$';
@@ -2728,7 +2780,14 @@ JS
$oPage->add_init_script('$("[data-input-id=\''.$iId.'\']").attr("data-input-type", "'.$sInputType.'");'); $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) //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>";
} }
/** /**

View File

@@ -92,6 +92,27 @@ class UILinksWidgetDirect
/** /**
* @param WebPage $oPage * @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 * @param string $sProposedRealClass
*/ */
public function GetObjectCreationDlg(WebPage $oPage, $sProposedRealClass = '', $oSourceObj = null) public function GetObjectCreationDlg(WebPage $oPage, $sProposedRealClass = '', $oSourceObj = null)

View File

@@ -148,6 +148,27 @@ class UILinksWidget
return ConsoleBlockRenderer::RenderBlockTemplateInPage($oPage, $oBlock); 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 WebPage $oPage
* @param DBObject $oCurrentObj * @param DBObject $oCurrentObj