diff --git a/plugins/DeleteNote/Controller/DeleteNote.php b/plugins/DeleteNote/Controller/DeleteNote.php
new file mode 100644
index 0000000000..390392c5b6
--- /dev/null
+++ b/plugins/DeleteNote/Controller/DeleteNote.php
@@ -0,0 +1,36 @@
+.
+
+// }}}
+
+namespace Plugin\DeleteNote\Controller;
+
+use App\Core\Controller;
+use App\Util\Exception\NotImplementedException;
+use Symfony\Component\HttpFoundation\Request;
+
+class DeleteNote extends Controller
+{
+ public function __invoke(Request $request)
+ {
+ throw new NotImplementedException;
+ }
+}
diff --git a/plugins/DeleteNote/DeleteNote.php b/plugins/DeleteNote/DeleteNote.php
index c2b94d7887..b62cf2f110 100644
--- a/plugins/DeleteNote/DeleteNote.php
+++ b/plugins/DeleteNote/DeleteNote.php
@@ -26,6 +26,8 @@ use App\Core\Event;
use App\Core\Form;
use function App\Core\I18n\_m;
use App\Core\Modules\NoteHandlerPlugin;
+use App\Core\Router\RouteLoader;
+use App\Core\Router\Router;
use App\Entity\Note;
use App\Util\Common;
use App\Util\Exception\RedirectException;
@@ -46,14 +48,29 @@ use Symfony\Component\HttpFoundation\Request;
*/
class DeleteNote extends NoteHandlerPlugin
{
- // TODO: Refactoring to link instead of a form
+ public function onAddRoute(RouteLoader $r)
+ {
+ $r->connect(id: 'delete_note', uri_path: '/object/note/{id<\d+>}/delete', target: Controller\DeleteNote::class);
+ return Event::next;
+ }
+
+ public function onAddExtraNoteActions(Request $request, Note $note, array &$actions)
+ {
+ $actions[] = [
+ 'title' => _m('Delete note'),
+ 'classes' => '',
+ 'url' => Router::url('delete_note', ['id' => $note->getId()]),
+ ];
+ }
+
/**
* HTML rendering event that adds the repeat form as a note
* action, if a user is logged in
*
* @throws RedirectException
*/
-/* public function onAddNoteActions(Request $request, Note $note, array &$actions)
+ // TODO: Refactoring to link instead of a form
+ /* public function onAddNoteActions(Request $request, Note $note, array &$actions)
{
if (($user = Common::user()) === null) {
return Event::next;
diff --git a/src/Twig/Extension.php b/src/Twig/Extension.php
index e3b44ecd89..5aaff61bcd 100644
--- a/src/Twig/Extension.php
+++ b/src/Twig/Extension.php
@@ -64,6 +64,7 @@ class Extension extends AbstractExtension
new TwigFunction('active', [Runtime::class, 'isCurrentRouteActive']),
new TwigFunction('is_route', [Runtime::class, 'isCurrentRoute']),
new TwigFunction('get_note_actions', [Runtime::class, 'getNoteActions']),
+ new TwigFunction('get_extra_note_actions', [Runtime::class, 'getExtraNoteActions']),
new TwigFunction('show_stylesheets', [Runtime::class, 'getShowStylesheets']),
new TwigFunction('handle_event', [Runtime::class, 'handleEvent']),
new TwigFunction('config', [Runtime::class, 'getConfig']),
diff --git a/src/Twig/Runtime.php b/src/Twig/Runtime.php
index 9040e40c6e..176a5addc9 100644
--- a/src/Twig/Runtime.php
+++ b/src/Twig/Runtime.php
@@ -72,6 +72,13 @@ class Runtime implements RuntimeExtensionInterface, EventSubscriberInterface
return $actions;
}
+ public function getExtraNoteActions(Note $note)
+ {
+ $extra_actions = [];
+ Event::handle('AddExtraNoteActions', [$this->request, $note, &$extra_actions]);
+ return $extra_actions;
+ }
+
/**
* @codeCoverageIgnore
*/
diff --git a/templates/cards/note/view.html.twig b/templates/cards/note/view.html.twig
index d2f7fa2378..a33519abf5 100644
--- a/templates/cards/note/view.html.twig
+++ b/templates/cards/note/view.html.twig
@@ -4,6 +4,18 @@
{% for current_action in get_note_actions(note) %}
{% endfor %}
+
+
+ {{ icon('kebab', 'icon icon-extra-note-actions') | raw }} {# button-container #}
+
+
+
{% endif %}
{% endblock note_actions %}