[CONTROLLR][UserPanel][PLUGINS] Add submit button to notification settings for each transport

This commit is contained in:
Hugo Sales 2021-08-07 18:24:11 +00:00 committed by Diogo Peralta Cordeiro
parent 06b9bd9910
commit 9a6fddb004
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
3 changed files with 17 additions and 3 deletions

View File

@ -39,7 +39,8 @@ class EmailNotifications extends Plugin
{
public function onAddNotificationTransport(&$form_defs): bool
{
$form_defs['email'] = $form_defs['placeholder'];
$form_defs['email'] = $form_defs['placeholder'];
$form_defs['email'][] = $form_defs['placeholder']['save']('Email', 'save_email');
unset($form_defs['email']['post_on_status_change']);
return Event::next;
}

View File

@ -39,7 +39,8 @@ class XMPPNotifications extends Plugin
{
public function onAddNotificationTransport(&$form_defs): bool
{
$form_defs['xmpp'] = $form_defs['placeholder'];
$form_defs['xmpp'] = $form_defs['placeholder'];
$form_defs['xmpp'][] = $form_defs['placeholder']['save']('XMMP', 'save_xmpp');
return Event::next;
}
}

View File

@ -177,12 +177,24 @@ class UserPanel extends AbstractController
}
}
$form_defs['placeholder']['save'] = fn(string $transport, string $form_name) =>
[$form_name, SubmitType::class,
['label' => _m('Save notification settings for {transport}', ['transport' => $transport])]];
Event::handle('AddNotificationTransport', [&$form_defs]);
unset($form_defs['placeholder']);
$tabbed_forms = [];
foreach ($form_defs as $transport_name => $f) {
$tabbed_forms[$transport_name] = Form::create($f);
unset($f['save']);
$form = Form::create($f);
$tabbed_forms[$transport_name] = $form;
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
dd($data, $transport_name);
}
}
$tabbed_forms = F\map($tabbed_forms, function ($f) {