[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
parent afbcb179b2
commit cdf3426567
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
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 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']); unset($form_defs['email']['post_on_status_change']);
return Event::next; return Event::next;
} }

View File

@ -39,7 +39,8 @@ class XMPPNotifications extends Plugin
{ {
public function onAddNotificationTransport(&$form_defs): bool 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; 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]); Event::handle('AddNotificationTransport', [&$form_defs]);
unset($form_defs['placeholder']); unset($form_defs['placeholder']);
$tabbed_forms = []; $tabbed_forms = [];
foreach ($form_defs as $transport_name => $f) { 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) { $tabbed_forms = F\map($tabbed_forms, function ($f) {