N°8031 - Make all portal bricks use custom templates for all templates

add missing templates
This commit is contained in:
Benjamin Dalsass
2025-01-13 11:36:19 +01:00
parent a4490e2b5f
commit f1d448fd78
15 changed files with 51 additions and 18 deletions

View File

@@ -63,6 +63,8 @@ class UserProfileBrick extends PortalBrick
parent::RegisterTemplates($oTemplatesRegister);
$oTemplatesRegister->RegisterTemplates(self::class,
TemplateDefinitionDto::Create('page', static::TEMPLATES_BASE_PATH . 'user-profile/layout.html.twig'),
TemplateDefinitionDto::Create('user_info', static::TEMPLATES_BASE_PATH.'user-profile/user_info.html.twig'),
TemplateDefinitionDto::Create('user_info_ready_js', static::TEMPLATES_BASE_PATH.'user-profile/user_info.ready.js.twig'),
);
}

View File

@@ -45,6 +45,10 @@ abstract class AbstractController extends SymfonyAbstractController implements T
$oTemplatesRegister->RegisterTemplates(self::class,
TemplateDefinitionDto::Create('page', static::TEMPLATES_BASE_PATH . 'layout.html.twig'),
TemplateDefinitionDto::Create('modal', static::TEMPLATES_BASE_PATH . 'modal/layout.html.twig'),
TemplateDefinitionDto::Create('loader', static::TEMPLATES_BASE_PATH.'helpers/loader.html.twig'),
TemplateDefinitionDto::Create('tagset_clic_handler_js', static::TEMPLATES_BASE_PATH.'helpers/tagset_clic_handler.js.twig'),
TemplateDefinitionDto::Create('session_message', static::TEMPLATES_BASE_PATH.'helpers/session_messages/session_message.html.twig'),
TemplateDefinitionDto::Create('session_messages', static::TEMPLATES_BASE_PATH.'helpers/session_messages/session_messages.html.twig'),
);
}

View File

@@ -84,7 +84,13 @@ class ObjectController extends BrickController
TemplateDefinitionDto::Create('page', static::TEMPLATES_BASE_PATH. 'bricks/object/layout.html.twig'),
TemplateDefinitionDto::Create('modal', static::TEMPLATES_BASE_PATH. 'bricks/object/modal.html.twig'),
TemplateDefinitionDto::Create('mode_create', static::TEMPLATES_BASE_PATH.'bricks/object/mode_create.html.twig', true, 'create'),
TemplateDefinitionDto::Create('mode_loader', static::TEMPLATES_BASE_PATH.'modal/mode_loader.html.twig', true, 'loader'),
TemplateDefinitionDto::Create('mode_edit', static::TEMPLATES_BASE_PATH.'bricks/object/mode_edit.html.twig', true, 'edit'),
TemplateDefinitionDto::Create('mode_search_hierarchy', static::TEMPLATES_BASE_PATH.'bricks/object/mode_search_hierarchy.html.twig', true, 'search_hierarchy'),
TemplateDefinitionDto::Create('mode_search_regular', static::TEMPLATES_BASE_PATH.'bricks/object/mode_search_regular.html.twig', true, 'search_regular'),
TemplateDefinitionDto::Create('mode_view', static::TEMPLATES_BASE_PATH.'bricks/object/mode_view.html.twig', true, 'view'),
TemplateDefinitionDto::Create('mode_apply_stimulus', static::TEMPLATES_BASE_PATH.'bricks/object/mode_apply_stimulus.html.twig', true, 'apply_stimulus'),
TemplateDefinitionDto::Create('mode_loader', static::TEMPLATES_BASE_PATH.'modal/mode_loader.html.twig'),
TemplateDefinitionDto::Create('plugins_buttons', static::TEMPLATES_BASE_PATH.'bricks/object/plugins_buttons.html.twig'),
);
}

View File

@@ -180,6 +180,7 @@ class TemplatesProviderService
*
* @return string|null
* @throws \ReflectionException
* @throws \Exception
*/
public function GetTemplatePath(string $sProviderClass, string $sTemplateId, bool $bIsInitial = false): ?string
{
@@ -193,8 +194,17 @@ class TemplatesProviderService
// search for the template definition
$oTemplateDefinition = $this->oTemplateRegister->GetTemplateDefinition($sProviderClass, $sTemplateId);
// return the template path
return $oTemplateDefinition?->GetPath($bIsInitial);
if ($oTemplateDefinition !== null)
{
// return the template path
return $oTemplateDefinition->GetPath($bIsInitial);
}
else
{
throw new Exception("Template definition not found for provider class `$sProviderClass` and template id `$sTemplateId` (provider is known by the service)");
}
} else {
@@ -203,7 +213,18 @@ class TemplatesProviderService
// the provider class is unknown by service
// the class register its templates with legacy constants
return $this->GetLegacyTemplatePath($sProviderClass, $sTemplateId);
$sTemplatePath = $this->GetLegacyTemplatePath($sProviderClass, $sTemplateId);
if ($sTemplatePath !== null)
{
// return the template path
return $sTemplatePath;
}
else
{
throw new Exception("Template definition not found for provider class `$sProviderClass` and template id `$sTemplateId` (provider is unknown by the service)");
}
}
}

View File

@@ -4,7 +4,7 @@
{% block pPageReadyScripts %}
{{ parent() }}
{% include 'itop-portal-base/portal/templates/helpers/tagset_clic_handler.js.twig' %}
{% include template('tagset_clic_handler_js') %}
{% endblock %}

View File

@@ -19,7 +19,7 @@
<div id="brick_mosaic_overlay">
{% block bBrowseMosaicOverlay %}
<div class="overlay_content">
{% include 'itop-portal-base/portal/templates/helpers/loader.html.twig' %}
{% include template('loader') %}
</div>
{% endblock %}
</div>

View File

@@ -34,7 +34,7 @@
</div>
<div id="brick_tree_overlay">
<div class="overlay_content">
{% include 'itop-portal-base/portal/templates/helpers/loader.html.twig' %}
{% include template('loader') %}
</div>
</div>
{% endblock %}

View File

@@ -18,5 +18,5 @@
{% block pPageReadyScripts %}
{{ parent() }}
{% include 'itop-portal-base/portal/templates/helpers/tagset_clic_handler.js.twig' %}
{% include template('tagset_clic_handler_js') %}
{% endblock %}

View File

@@ -30,7 +30,7 @@
{# Misc. buttons #}
{% if form.buttons is defined and (form.buttons.actions is defined or form.buttons.links is defined) %}
<div class="form_btn_misc">
{% include 'itop-portal-base/portal/templates/bricks/object/plugins_buttons.html.twig' with {'aButtons': form.buttons} %}
{% include template('plugins_buttons', 'Combodo\\iTop\\Portal\\Controller\\ObjectController') with {'aButtons': form.buttons} %}
</div>
{% endif %}
{# Transition buttons #}

View File

@@ -6,7 +6,7 @@
{# Misc. buttons #}
{% if form.buttons is defined and (form.buttons.actions is defined or form.buttons.links is defined) %}
<div class="form_btn_misc">
{% include 'itop-portal-base/portal/templates/bricks/object/plugins_buttons.html.twig' with {'aButtons': form.buttons} %}
{% include template('plugins_buttons', 'Combodo\\iTop\\Portal\\Controller\\ObjectController') with {'aButtons': form.buttons} %}
</div>
{% endif %}

View File

@@ -55,7 +55,7 @@
{% set oContactForm = forms.contact %}
{% set oPreferencesForm = forms.preferences %}
{% set oPasswordForm = forms.password %}
{% include 'itop-portal-base/portal/templates/bricks/user-profile/user_info.html.twig' %}
{% include template('user_info', 'Combodo\\iTop\\Portal\\Brick\\UserProfileBrick') %}
{% else %}
<div id="user-profile-wrapper">
<div class="row">
@@ -80,7 +80,7 @@
{% set oContactForm = forms.contact %}
{% set oPreferencesForm = forms.preferences %}
{% set oPasswordForm = forms.password %}
{% include 'itop-portal-base/portal/templates/bricks/user-profile/user_info.ready.js.twig' %}
{% include template('user_info_ready_js', 'Combodo\\iTop\\Portal\\Brick\\UserProfileBrick') %}
{% endif %}
{% endblock %}

View File

@@ -1,5 +1,5 @@
<div id="session-messages">
{% for aSessionMessage in app['session_message_helper'] %}
{% include 'itop-portal-base/portal/templates/helpers/session_messages/session_message.html.twig' with {aSessionMessage: aSessionMessage} %}
{% include template('session_message') with {aSessionMessage: aSessionMessage} %}
{% endfor %}
</div>

View File

@@ -11,7 +11,7 @@
<div class="col-xs-12 col-sm-9 col-md-10 col-sm-offset-3 col-md-offset-2">
<section class="row">
<div class="col-xs-12">
{% include 'itop-portal-base/portal/templates/helpers/session_messages/session_messages.html.twig' %}
{% include template('session_messages') %}
</div>
</section>
<section class="row tiles_wrapper">

View File

@@ -335,7 +335,7 @@
<div class="col-xs-12 col-sm-9 col-md-10 col-sm-offset-3 col-md-offset-2">
<section class="row">
<div class="col-xs-12">
{% include 'itop-portal-base/portal/templates/helpers/session_messages/session_messages.html.twig' %}
{% include template('session_messages') %}
</div>
</section>
<section class="row" id="main-header">
@@ -367,7 +367,7 @@
<div class="modal fade" id="modal-for-all" role="dialog" tabindex="-1">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
{% include 'itop-portal-base/portal/templates/helpers/loader.html.twig' %}
{% include template('loader') %}
</div>
</div>
</div>
@@ -395,7 +395,7 @@
{% block pPageOverlay %}
<div id="page_overlay" class="global_overlay">
<div class="overlay_content">
{% include 'itop-portal-base/portal/templates/helpers/loader.html.twig' %}
{% include template('loader') %}
</div>
</div>
{% endblock %}

View File

@@ -3,7 +3,7 @@
{% extends 'itop-portal-base/portal/templates/modal/layout.html.twig' %}
{% block pModalContent %}
{% include 'itop-portal-base/portal/templates/helpers/loader.html.twig' %}
{% include template('loader') %}
{% if redirection is defined and redirection.url is defined %}
<script type="text/javascript">