Skip to content
Snippets Groups Projects
Commit cde47062 authored by Marko Ivancic's avatar Marko Ivancic
Browse files

Enable action buttons config

parent 059b03f0
No related branches found
No related tags found
1 merge request!13Enable action buttons config
...@@ -249,4 +249,17 @@ $config = [ ...@@ -249,4 +249,17 @@ $config = [
*/ */
ModuleConfiguration::OPTION_CRON_TAG_FOR_TRACKER_DATA_RETENTION_POLICY => ModuleConfiguration::OPTION_CRON_TAG_FOR_TRACKER_DATA_RETENTION_POLICY =>
'accounting_tracker_data_retention_policy', 'accounting_tracker_data_retention_policy',
/**
* Enable or disable 'action buttons'. Action buttons are displayed on 'Personal data' page, and can be used to
* provide links to relevant endpoints, for example to change a password, send email to support, etc.
*
* Note that you can easily override the action buttons Twig template using standard SimpleSAMLphp
* custom theming features: https://simplesamlphp.org/docs/stable/simplesamlphp-theming
*
* The path to the action buttons template file is:
* modules/accounting/templates/user/includes/_action-buttons.twig, so when creating a custom theme file,
* place it in: modules/mymodule/themes/fancytheme/accounting/user/includes/_action-buttons.twig
*/
ModuleConfiguration::OPTION_ACTION_BUTTONS_ENABLED => true,
]; ];
...@@ -485,3 +485,52 @@ ...@@ -485,3 +485,52 @@
.close-btn:hover { .close-btn:hover {
color: black; color: black;
} }
/* ================== */
/* Dropdown */
/* ================== */
.dropbtn {
background-color: #3C4A94;
color: var(--main-bg-c);
font-family: var(--main-font-family);
padding: 0.4em;
font-size: 100%;
border: none;
cursor: pointer;
width: 10em;
text-decoration: none;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #3C4A94;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: var(--main-bg-c);
padding: 12px 16px;
text-decoration: none;
display: block;
font-size: 80%;
font-family: var(--main-font-family);
}
.dropdown-content a:hover {background-color: #4f5c9b}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown:hover .dropbtn {
background-color: #4f5c9b;
}
...@@ -127,8 +127,10 @@ class Profile ...@@ -127,8 +127,10 @@ class Profile
$normalizedAttributes[$name] = implode('; ', $value); $normalizedAttributes[$name] = implode('; ', $value);
} }
$actionButtonsEnabled = $this->moduleConfiguration->getActionButtonsEnabled();
$template = $this->resolveTemplate('accounting:user/personal-data.twig'); $template = $this->resolveTemplate('accounting:user/personal-data.twig');
$template->data += compact('normalizedAttributes'); $template->data += compact('normalizedAttributes', 'actionButtonsEnabled');
return $template; return $template;
} }
......
...@@ -39,6 +39,7 @@ class ModuleConfiguration ...@@ -39,6 +39,7 @@ class ModuleConfiguration
public const OPTION_CRON_TAG_FOR_TRACKER_DATA_RETENTION_POLICY = 'cron_tag_for_tracker_data_retention_policy'; public const OPTION_CRON_TAG_FOR_TRACKER_DATA_RETENTION_POLICY = 'cron_tag_for_tracker_data_retention_policy';
public const OPTION_PROVIDER_FOR_CONNECTED_SERVICES = 'provider_for_connected_services'; public const OPTION_PROVIDER_FOR_CONNECTED_SERVICES = 'provider_for_connected_services';
public const OPTION_PROVIDER_FOR_ACTIVITY = 'provider_for_activity'; public const OPTION_PROVIDER_FOR_ACTIVITY = 'provider_for_activity';
public const OPTION_ACTION_BUTTONS_ENABLED = 'action_buttons_enabled';
/** /**
* Contains configuration from module configuration file. * Contains configuration from module configuration file.
...@@ -483,4 +484,9 @@ class ModuleConfiguration ...@@ -483,4 +484,9 @@ class ModuleConfiguration
{ {
return $this->getConfiguration()->getString(self::OPTION_CRON_TAG_FOR_TRACKER_DATA_RETENTION_POLICY); return $this->getConfiguration()->getString(self::OPTION_CRON_TAG_FOR_TRACKER_DATA_RETENTION_POLICY);
} }
public function getActionButtonsEnabled(): bool
{
return $this->getConfiguration()->getBoolean(self::OPTION_ACTION_BUTTONS_ENABLED);
}
} }
<div class="dropdown">
<button class="dropbtn">{% trans %}TODO Actions{% endtrans %}</button>
<div class="dropdown-content">
<a href="#">{% trans %}Download data{% endtrans %}</a>
<a href="#">{% trans %}Custom action{% endtrans %}</a>
</div>
</div>
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
{% if actionButtonsEnabled %}
{% include "@accounting/user/includes/_action-buttons.twig" %}
{% endif %}
<table> <table>
<!-- fixed table header --> <!-- fixed table header -->
<tr> <tr>
......
...@@ -67,4 +67,6 @@ $config = [ ...@@ -67,4 +67,6 @@ $config = [
'accounting_tracker_data_retention_policy', 'accounting_tracker_data_retention_policy',
ModuleConfiguration::OPTION_CRON_TAG_FOR_JOB_RUNNER => 'accounting_job_runner', ModuleConfiguration::OPTION_CRON_TAG_FOR_JOB_RUNNER => 'accounting_job_runner',
ModuleConfiguration::OPTION_ACTION_BUTTONS_ENABLED => true,
]; ];
...@@ -403,4 +403,18 @@ class ModuleConfigurationTest extends TestCase ...@@ -403,4 +403,18 @@ class ModuleConfigurationTest extends TestCase
] ]
); );
} }
public function testCanGetActionButtonsEnabled(): void
{
$moduleConfiguration = new ModuleConfiguration();
$this->assertTrue($moduleConfiguration->getActionButtonsEnabled());
$moduleConfiguration = new ModuleConfiguration(
null,
[ModuleConfiguration::OPTION_ACTION_BUTTONS_ENABLED => false]
);
$this->assertFalse($moduleConfiguration->getActionButtonsEnabled());
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment