-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
imp: Display new feed errors in the modal
For now, responses to form submits redirect to a new page. However, I’d like the modal forms errors to be displayed directly in the modal, without redirecting to a new page. Since the modal is handled with a Turbo Frame, it should not be too complicated. Except that's impossible. I need to set the frame attribute target="_top" in order to redirect after a success, but I would need the opposite in case of an error. There are some discussions to handle this use case directly with Turbo, but until an official solution appears, I will use this hack which use Turbo Stream to update the modal content. I don’t think it’s a perfect solution, so I’m not going to generalize it in the application. The new feed form is important to handle correctly since errors are common (e.g. a feed cannot be found). Reference: hotwired/turbo#138 (comment)
- Loading branch information
1 parent
1f2d682
commit 7045806
Showing
6 changed files
with
87 additions
and
56 deletions.
There are no files selected for viewing
Submodule Minz
updated
17 files
+1 −1 | .github/workflows/ci.yml | |
+6 −6 | Makefile | |
+2 −2 | autoload.php | |
+502 −0 | lib/PHPMailer/LICENSE | |
+227 −0 | lib/PHPMailer/README.md | |
+37 −0 | lib/PHPMailer/SECURITY.md | |
+1 −0 | lib/PHPMailer/VERSION | |
+3 −2 | lib/PHPMailer/src/Exception.php | |
+3 −2 | lib/PHPMailer/src/OAuth.php | |
+479 −270 | lib/PHPMailer/src/PHPMailer.php | |
+56 −29 | lib/PHPMailer/src/POP3.php | |
+156 −71 | lib/PHPMailer/src/SMTP.php | |
+12 −14 | src/Output/View.php | |
+36 −0 | src/Request.php | |
+20 −13 | tests/DatabaseTest.php | |
+26 −11 | tests/Output/ViewTest.php | |
+42 −0 | tests/RequestTest.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<turbo-frame id="modal-feeds-new" target="_top"> | ||
<div class="section"> | ||
<div class="section__title"> | ||
<h1 id="modal-title"><?= _('New feed') ?></h1> | ||
</div> | ||
|
||
<form method="post" action="<?= url('create feed') ?>"> | ||
<?php if ($error): ?> | ||
<p class="form__error"> | ||
<?= $error ?> | ||
</p> | ||
<?php endif; ?> | ||
|
||
<input type="hidden" name="csrf" value="<?= $csrf_token ?>" /> | ||
<input type="hidden" name="from" value="<?= $from ?>" /> | ||
|
||
<div class="form-group <?= isset($errors['url']) ? 'form-group--invalid' : '' ?>"> | ||
<label for="url"> | ||
<?= _('What’s the address of the website or feed to follow?') ?> | ||
</label> | ||
|
||
<input | ||
id="url" | ||
name="url" | ||
type="url" | ||
required | ||
value="<?= $url ?>" | ||
autocomplete="off" | ||
autofocus | ||
aria-describedby="url-caption" | ||
/> | ||
|
||
<?php if (isset($errors['url'])): ?> | ||
<p class="form-group__error"> | ||
<?= icon('error') ?> | ||
<?= $errors['url'] ?> | ||
</p> | ||
<?php endif; ?> | ||
|
||
<p class="form-group__caption" id="url-caption"> | ||
<?= _('It can be copy-paste from the <abbr>URL</abbr> bar, at the top of your browser.') ?> | ||
</p> | ||
</div> | ||
|
||
<div class="form__actions"> | ||
<button type="submit" class="button--primary"> | ||
<?= _('Add the feed') ?> | ||
</button> | ||
</div> | ||
</form> | ||
</div> | ||
</turbo-frame> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<turbo-stream action="replace" target="modal-feeds-new"> | ||
<template> | ||
<?= $this->include('feeds/_new.phtml', [ | ||
'url' => $url, | ||
'from' => $from, | ||
'errors' => $errors, | ||
'error' => $error, | ||
]); ?> | ||
</template> | ||
</turbo-stream> |