[CONTROLLER][UI] Add notification settings form
This commit is contained in:
parent
4ba71426b6
commit
b436a0641d
@ -110,27 +110,29 @@ class UserPanel extends AbstractController
|
|||||||
{
|
{
|
||||||
$schema = DB::getConnection()->getSchemaManager();
|
$schema = DB::getConnection()->getSchemaManager();
|
||||||
$platform = $schema->getDatabasePlatform();
|
$platform = $schema->getDatabasePlatform();
|
||||||
$columns = Common::array_remove_keys($schema->listTableColumns('user_notification_prefs'), ['user_id', 'transport', 'created', 'modified']);
|
$columns = Common::arrayRemoveKeys($schema->listTableColumns('user_notification_prefs'), ['user_id', 'transport', 'created', 'modified']);
|
||||||
$form_defs = ['placeholder' => []];
|
$form_defs = ['placeholder' => []];
|
||||||
foreach ($columns as $name => $col) {
|
foreach ($columns as $name => $col) {
|
||||||
$val = $col->getType()->convertToPHPValue($col->getDefault(), $platform);
|
$type = $col->getType();
|
||||||
switch ($col->getType()) {
|
$val = $type->convertToPHPValue($col->getDefault(), $platform);
|
||||||
|
$type_str = lcfirst(substr((string) $type, 1));
|
||||||
|
$label = str_replace('_', ' ', ucfirst($name));
|
||||||
|
switch ($type_str) {
|
||||||
case Types::BOOLEAN:
|
case Types::BOOLEAN:
|
||||||
$form_defs['placeholder'][] = [$name, CheckboxType::class, ['data' => $val, 'label' => _m($col->getComment())]];
|
$form_defs['placeholder'][] = [$name, CheckboxType::class, ['data' => $val, 'label' => $label, 'help' => _m($col->getComment())]];
|
||||||
break;
|
break;
|
||||||
case Types::INTEGER:
|
case Types::INTEGER:
|
||||||
if ($name == 'target_profile_id') {
|
if ($name == 'target_profile_id') {
|
||||||
$form_defs['placeholder'][] = ['target_profiles', TextType::class, ['data' => $val, 'label' => _m($col->getComment())], 'transformer' => ProfileArrayTransformer::class];
|
$form_defs['placeholder'][] = ['target_profiles', TextType::class, ['data' => $val, 'label' => $label, 'help' => _m($col->getComment())], 'transformer' => ProfileArrayTransformer::class];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// fallthrough
|
|
||||||
// no break
|
// no break
|
||||||
default:
|
default:
|
||||||
throw new Exception("Structure of table user_notification_prefs changed in a way not accounted to in notification settings ({$name})", 500);
|
throw new Exception("Structure of table user_notification_prefs changed in a way not accounted to in notification settings ({$name})", 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Event::handle('AddNotificationTransport', [&$form_defs]);
|
Event::handle('add_notification_transport', [&$form_defs]);
|
||||||
unset($form_defs['placeholder']);
|
unset($form_defs['placeholder']);
|
||||||
|
|
||||||
$tabbed_forms = [];
|
$tabbed_forms = [];
|
||||||
|
@ -3,19 +3,29 @@
|
|||||||
{% block title %}Notification Settings{% endblock %}
|
{% block title %}Notification Settings{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
<div class='content'>
|
||||||
|
{% block primary_nav %}
|
||||||
|
{{ parent() }}
|
||||||
|
{% endblock primary_nav %}
|
||||||
|
|
||||||
<div class='content'>
|
{% block form %}
|
||||||
{% block primary_nav %}
|
<div id='form-tabs'>
|
||||||
{{ parent() }}
|
<ul>
|
||||||
{% endblock primary_nav %}
|
|
||||||
|
|
||||||
{% block form %}
|
|
||||||
{% for transport, form in tabbed_forms %}
|
{% for transport, form in tabbed_forms %}
|
||||||
<div id="form_{{ transport }}" class='form'>
|
<li class='hover-effect'>
|
||||||
{{ form(form) }}
|
{{ transport }}
|
||||||
</div>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endblock form %}
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<div id='form-content'>
|
||||||
|
{% for transport, form in tabbed_forms %}
|
||||||
|
<div id="form_{{ transport }}" class='form'>
|
||||||
|
{{ form(form) }}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endblock form %}
|
||||||
|
</div>
|
||||||
|
|
||||||
{% endblock body %}
|
{% endblock body %}
|
||||||
|
Loading…
Reference in New Issue
Block a user