aboutsummaryrefslogtreecommitdiff
path: root/src/Handlers
diff options
context:
space:
mode:
authorLaria Carolin Chabowski <laria@laria.me>2020-06-05 22:21:09 +0200
committerLaria Carolin Chabowski <laria@laria.me>2020-06-05 22:21:09 +0200
commit3f82b4cc301d27f6a256a76c744bbbbeb4baa5cb (patch)
tree8db5176dd5daf4bdaf8abacd8b6e80247ac155aa /src/Handlers
parenta43b933df12f97c536a31d3d5a73ddda5f90ed94 (diff)
downloadmicropoly-3f82b4cc301d27f6a256a76c744bbbbeb4baa5cb.tar.gz
micropoly-3f82b4cc301d27f6a256a76c744bbbbeb4baa5cb.tar.bz2
micropoly-3f82b4cc301d27f6a256a76c744bbbbeb4baa5cb.zip
Add button to create note and go back to new note form
This improves the experience of quickly adding lots of notes
Diffstat (limited to 'src/Handlers')
-rw-r--r--src/Handlers/NewNote.php14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/Handlers/NewNote.php b/src/Handlers/NewNote.php
index 9d4286d..838c7cb 100644
--- a/src/Handlers/NewNote.php
+++ b/src/Handlers/NewNote.php
@@ -24,6 +24,7 @@ class NewNote implements Handler
public function handle(Env $env, array $variables)
{
$content = self::getPostedContent();
+ $templateData = [];
if ($content !== null) {
$note = new Note();
$note->setContent($content);
@@ -34,11 +35,16 @@ class NewNote implements Handler
Attachment::createFromUploads($env->db(), $env->attachmentsPath(), $note, $_FILES['attachments']);
$url = $env->documentRoot() . "n/" . $note->getId();
- http_response_code(303);
- header("Location: {$url}");
- echo 'Note created: <a href="' . Esc::e($url) . '">';
+ if ($_POST["create_and_new"]) {
+ $templateData["success"] = true;
+ } else {
+ http_response_code(303);
+ header("Location: {$url}");
+ echo 'Note created: <a href="' . Esc::e($url) . '">';
+ return;
+ }
}
- echo $env->twig()->render("/new_note.twig", []);
+ echo $env->twig()->render("/new_note.twig", $templateData);
}
} \ No newline at end of file