[UI][TWIG][CONTROLLER][UserPanell] Add way to expand details with a GET parameter. Implement it in UserPanel

This commit is contained in:
Hugo Sales 2021-11-15 13:34:34 +00:00
parent c509692102
commit 1abd28c949
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
4 changed files with 15 additions and 7 deletions

View File

@ -37,6 +37,7 @@ namespace App\Controller;
// {{{ Imports // {{{ Imports
use App\Core\Controller;
use App\Core\DB\DB; use App\Core\DB\DB;
use App\Core\Event; use App\Core\Event;
use App\Core\Form; use App\Core\Form;
@ -64,7 +65,7 @@ use Symfony\Component\HttpFoundation\Request;
// }}} Imports // }}} Imports
class UserPanel extends AbstractController class UserPanel extends Controller
{ {
/** /**
* Return main settings page forms * Return main settings page forms
@ -82,6 +83,7 @@ class UserPanel extends AbstractController
'prof' => $personal_form->createView(), 'prof' => $personal_form->createView(),
'acc' => $account_form->createView(), 'acc' => $account_form->createView(),
'tabbed_forms_notify' => $notifications_form_array, 'tabbed_forms_notify' => $notifications_form_array,
'open_details_query' => $this->string('open')
]; ];
} }

View File

@ -70,6 +70,7 @@ class Extension extends AbstractExtension
new TwigFunction('icon', [Runtime::class, 'embedSvgIcon'], ['needs_environment' => true]), new TwigFunction('icon', [Runtime::class, 'embedSvgIcon'], ['needs_environment' => true]),
new TwigFunction('is_firefox', [Runtime::class, 'isFirefox']), new TwigFunction('is_firefox', [Runtime::class, 'isFirefox']),
new TwigFunction('handle_override_template_import', [Runtime::class, 'handleOverrideTemplateImport']), new TwigFunction('handle_override_template_import', [Runtime::class, 'handleOverrideTemplateImport']),
new TwigFunction('open_details', [Runtime::class, 'openDetails']),
]; ];
} }
} }

View File

@ -134,6 +134,11 @@ class Runtime implements RuntimeExtensionInterface, EventSubscriberInterface
return $result; return $result;
} }
public function openDetails(?string $query, array $ids)
{
return in_array($query, $ids) ? 'open=""' : '';
}
// ---------------------------------------------------------- // ----------------------------------------------------------
/** /**

View File

@ -13,7 +13,7 @@
<h2>Settings</h2> <h2>Settings</h2>
<ul> <ul>
<li> <li>
<details class="section-title-settings"> <details class="section-title-settings" {{ open_details(open_details_query, ['profile', 'personal_info']) }} id="profile-details">
<summary> <summary>
<h3>Profile {{ icon('arrow-down', 'icon icon-details-open') | raw }}</h3> <h3>Profile {{ icon('arrow-down', 'icon icon-details-open') | raw }}</h3>
<em>Personal Information, Avatar and Profile</em> <em>Personal Information, Avatar and Profile</em>
@ -23,7 +23,7 @@
<nav class='section-settings-nav'> <nav class='section-settings-nav'>
<ul> <ul>
<li> <li>
<details class="section-title-settings"> <details class="section-title-settings" {{ open_details(open_details_query, ['personal_info']) }} id="perosnal-info-details">
<summary> <summary>
<h3>Personal Info{{ icon('arrow-down', 'icon icon-details-open') | raw }}</h3> <h3>Personal Info{{ icon('arrow-down', 'icon icon-details-open') | raw }}</h3>
<em>Nickname, Homepage, Bio, Self Tags and more.</em> <em>Nickname, Homepage, Bio, Self Tags and more.</em>
@ -38,7 +38,7 @@
{% set profile_tabs = handle_event('PopulateProfileSettingsTabs', app.request) %} {% set profile_tabs = handle_event('PopulateProfileSettingsTabs', app.request) %}
{% for tab in profile_tabs %} {% for tab in profile_tabs %}
<li> <li>
<details class="section-title-settings"> <details class="section-title-settings"> {# TODO add ID and open_details and to parent #}
<summary> <summary>
<h3>{{ tab['title'] }}{{ icon('arrow-down', 'icon icon-details-open') | raw }}</h3> <h3>{{ tab['title'] }}{{ icon('arrow-down', 'icon icon-details-open') | raw }}</h3>
<em>{{ tab['desc'] }}</em> <em>{{ tab['desc'] }}</em>
@ -63,7 +63,7 @@
<hr> <hr>
<li> <li>
<details class="section-title-settings"> <details class="section-title-settings" {{ open_details(open_details_query, ['account']) }} id="account-details">
<summary> <summary>
<h3>Account{{ icon('arrow-down', 'icon icon-details-open') | raw }}</h3> <h3>Account{{ icon('arrow-down', 'icon icon-details-open') | raw }}</h3>
<em>Email, Password and Language</em> <em>Email, Password and Language</em>
@ -80,7 +80,7 @@
<hr> <hr>
<li> <li>
<details class="section-title-settings"> <details class="section-title-settings" {{ open_details(open_details_query, ['notifications']) }} id="notifications-details">
<summary> <summary>
<h3>Notifications{{ icon('arrow-down', 'icon icon-details-open') | raw }}</h3> <h3>Notifications{{ icon('arrow-down', 'icon icon-details-open') | raw }}</h3>
<em>Enable/disable notifications (Email, XMPP, Replies...)</em> <em>Enable/disable notifications (Email, XMPP, Replies...)</em>
@ -97,4 +97,4 @@
</nav> </nav>
{% endblock body %} {% endblock body %}
{% block javascripts %}{% endblock %} {% block javascripts %}{% endblock %}