Release of v5.1.1-alpha3

Add edit and create options to the ModalSelect Field (in Joomla 5).
This commit is contained in:
2025-03-30 19:52:28 +00:00
parent 8342c5bb9f
commit b9f38943aa
129 changed files with 3866 additions and 85 deletions

View File

@@ -12,7 +12,6 @@
namespace VDM\Joomla\Componentbuilder\Compiler\Component;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component\SettingsInterface as Settings;
@@ -88,30 +87,29 @@ final class Structuremultiple
protected Structure $structure;
/**
* Constructor
* Constructor.
*
* @param Config|null $config The compiler config object.
* @param Registry|null $registry The compiler registry object.
* @param Settings|null $settings The compiler component Joomla version settings object.
* @param Component|null $component The component class.
* @param Createdate|null $createdate The compiler model to get create date class.
* @param Modifieddate|null $modifieddate The compiler model to get modified date class.
* @param Structure|null $structure The compiler structure to build dynamic folder and files class.
* @param Config $config The Config Class.
* @param Registry $registry The Registry Class.
* @param Settings $settings The SettingsInterface Class.
* @param Component $component The Component Class.
* @param Createdate $createdate The Createdate Class.
* @param Modifieddate $modifieddate The Modifieddate Class.
* @param Structure $structure The Structure Class.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry = null,
?Settings $settings = null, ?Component $component = null,
?Createdate $createdate = null, ?Modifieddate $modifieddate = null,
?Structure $structure = null)
public function __construct(Config $config, Registry $registry, Settings $settings,
Component $component, Createdate $createdate,
Modifieddate $modifieddate, Structure $structure)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->settings = $settings ?: Compiler::_('Component.Settings');
$this->component = $component ?: Compiler::_('Component');
$this->createdate = $createdate ?: Compiler::_('Model.Createdate');
$this->modifieddate = $modifieddate ?: Compiler::_('Model.Modifieddate');
$this->structure = $structure ?: Compiler::_('Utilities.Structure');
$this->config = $config;
$this->registry = $registry;
$this->settings = $settings;
$this->component = $component;
$this->createdate = $createdate;
$this->modifieddate = $modifieddate;
$this->structure = $structure;
}
/**
@@ -274,6 +272,25 @@ final class Structuremultiple
return true;
}
/**
* Check if the view has an Modal
*
* @param array $view
*
* @return int
* @since 5.1.1
*/
private function hasModal(array $view): int
{
// only for Joomla 5 and above
if ($this->config->get('joomla_version', 3) > 4)
{
return 1;
}
return 0;
}
/**
* Check if the view has an API
*
@@ -336,12 +353,19 @@ final class Structuremultiple
*/
private function buildAdminView(array $view, array $config)
{
$addModal = $this->hasModal($view);
// build the admin edit view
if ($view['settings']->name_single != 'null')
{
$target = ['admin' => $view['settings']->name_single];
$this->structure->build($target, 'single', false, $config);
if ($addModal)
{
$this->structure->build($target, 'single_modal', false, $config);
}
// build the site edit view (of this admin view)
if (isset($view['edit_create_site_view'])
&& is_numeric($view['edit_create_site_view'])
@@ -350,6 +374,11 @@ final class Structuremultiple
// setup the front site edit-view files
$target = ['site' => $view['settings']->name_single];
$this->structure->build($target, 'edit', false, $config);
if ($addModal)
{
$this->structure->build($target, 'edit_modal', false, $config);
}
}
}
@@ -358,6 +387,11 @@ final class Structuremultiple
{
$target = ['admin' => $view['settings']->name_list];
$this->structure->build($target, 'list', false, $config);
if ($addModal)
{
$this->structure->build($target, 'list_modal', false, $config);
}
}
}

View File

@@ -551,6 +551,11 @@ final class Attributes
return $this->removeRequired();
}
if ($name === 'sql_title_key' && 'ModalSelect' === $this->typeName)
{
return $this->getSqlTitleKey();
}
if ($this->viewType == 2 && in_array($name, ['readonly', 'disabled']))
{
return $this->setReadonly($name);
@@ -967,7 +972,7 @@ final class Attributes
{
// load the text key
$this->attributes['custom']['text']
= StringHelper::safe(
= FieldHelper::safe(
GetHelper::between(
$this->settings->xml, 'value_field="', '"'
)
@@ -986,7 +991,7 @@ final class Attributes
{
// load the id key
$this->attributes['custom']['id']
= StringHelper::safe(
= FieldHelper::safe(
GetHelper::between(
$this->settings->xml, 'key_field="', '"'
)
@@ -1045,6 +1050,30 @@ final class Attributes
return 'false';
}
/**
* get sql title key value
* and set the [data-key-name] if the key is not an [id]
*
* @return string|null
* @since 5.1.1
*/
private function getSqlTitleKey(): ?string
{
// load the id key
$key = FieldHelper::safe(
GetHelper::between(
$this->settings->xml, 'sql_title_key="', '"'
)
);
if ($key !== 'id')
{
$this->attributes['data-key-name'] = $key;
}
return $key;
}
/**
* set the readonly switch
*

View File

@@ -112,6 +112,7 @@ final class ModalSelect
}
$sql_title_key = $fieldAttributes['sql_title_key'] ?? 'id';
$sql_title_column = $fieldAttributes['sql_title_column'] ?? 'id';
// if one field is not id, we add an override to the ModalSelectField as a FIX
if (!$this->addedFix && $sql_title_key !== 'id')
@@ -130,6 +131,15 @@ final class ModalSelect
$this->addedFix = true;
}
// make sure we have the target view code name
$view ??= 'error';
// add the Title Key for the Modal
$this->contentmulti->set($view . '|SQL_TITLE_KEY', $sql_title_key);
// add the Title Column for the Modal
$this->contentmulti->set($view . '|SQL_TITLE_COLUMN', $sql_title_column);
return [
'modal_select' => true,
'urlSelect' => $fieldAttributes['urlSelect'] ?? '',
@@ -138,9 +148,9 @@ final class ModalSelect
'iconSelect' => $fieldAttributes['iconSelect'] ?? '',
'table' => $field_target_table,
'id' => $sql_title_key,
'text' => $fieldAttributes['sql_title_column'] ?? '',
'text' => $sql_title_column,
'component' => $component ?? 'error',
'view' => $view ?? 'error',
'view' => $view,
'views' => $views ?? 'error',
'button' => false,
'extends' => ''

View File

@@ -420,6 +420,15 @@ class Infusion extends Interpretation
'jcb_ce_onBeforeBuildAdminEditViewContent', [&$view, &$nameSingleCode, &$nameListCode]
);
// Here we set defaults
// The real values are set in ModalSelect(4fc020dc-3137-478d-8d42-0571a75b77b5)
// add the Title Key for the Modal
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|SQL_TITLE_KEY', 'id');
// add the Title Column for the Modal
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|SQL_TITLE_COLUMN', 'name');
// FIELDSETS <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|FIELDSETS',
CFactory::_('Compiler.Creator.Fieldset')->get(

View File

@@ -200,7 +200,7 @@ final class Header implements HeaderInterface
$headers = $this->getHeaders($context);
// add to all except the helper classes
if ('admin.helper' !== $context && 'site.helper' !== $context)
if ('admin.helper' !== $context && 'site.helper' !== $context && 'plugin.extension.header' !== $context && 'plugin.provider.header' !== $context)
{
$target = 'Administrator';
if ($this->config->get('build_target', 'admin') === 'site')