Notes / snooze, update data migration
- WIP on finishing out request list
This commit is contained in:
1 parent
3ebb03d470
commit
2369827033
11 files changed
+189
-24
No files matched your search
@@ -0,0 +1,28 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use MyPrayerJournal\{Auth, Layout, Request};
|
||||
|
||||
require '../../../start.php';
|
||||
if ($_SERVER['REQUEST_METHOD'] <> 'GET') not_found();
|
||||
|
||||
Auth::requireUser(false);
|
||||
|
||||
$req = Request::byId($_GET['id']);
|
||||
if (!$req) not_found();
|
||||
|
||||
Layout::bareHead(); ?>
|
||||
<form hx-post="/request/note?id=<?=$req->id?>">
|
||||
<div class="form-floating pb-3">
|
||||
<textarea id=notes name=notes class=form-control style="min-height: 8rem;" placeholder=Notes autofocus
|
||||
required></textarea>
|
||||
<label for=notes>Notes</label>
|
||||
</div>
|
||||
<p class=text-end><button type=submit class="btn btn-primary">Add Notes</button>
|
||||
</form>
|
||||
<hr style="margin: .5rem -1rem">
|
||||
<div id=priorNotes>
|
||||
<p class="text-center pt-3">
|
||||
<button type=button class="btn btn-secondary" hx-get="/components/request/notes?id=<?=$req->id?>"
|
||||
hx-swap=outerHTML hx-target=#priorNotes>Load Prior Notes</button>
|
||||
</div><?php
|
||||
Layout::bareFoot();
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use MyPrayerJournal\{Auth, Layout, Request, UI};
|
||||
|
||||
require '../../../start.php';
|
||||
if ($_SERVER['REQUEST_METHOD'] <> 'GET') not_found();
|
||||
|
||||
Auth::requireUser(false);
|
||||
|
||||
$req = Request::byId($_GET['id']);
|
||||
if (!$req) not_found();
|
||||
|
||||
Layout::bareHead();?>
|
||||
<p class=text-center><strong>Prior Notes for This Request</strong><?php
|
||||
if (sizeof($req->notes) > 0) {
|
||||
foreach ($req->notes as $note) { ?>
|
||||
<p><small class=text-muted><?php UI::relativeDate($note->asOf); ?></small><br>
|
||||
<?=htmlentities($note->text)?><?php
|
||||
}
|
||||
} else { ?>
|
||||
<p class="text-center text-muted">There are no prior notes for this request<?php
|
||||
}
|
||||
Layout::bareFoot();
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use MyPrayerJournal\{Auth, Layout, Request};
|
||||
|
||||
require '../../../start.php';
|
||||
if ($_SERVER['REQUEST_METHOD'] <> 'GET') not_found();
|
||||
|
||||
Auth::requireUser(false);
|
||||
|
||||
$req = Request::byId($_GET['id']);
|
||||
if (!$req) not_found();
|
||||
|
||||
Layout::bareHead(); ?>
|
||||
<form hx-patch="/request/snooze?id=<?=$req->id?>" hx-target=#journalItems hx-swap=outerHTML>
|
||||
<div class="form-floating pb-3">
|
||||
<input type=date id=until name=until class=form-control
|
||||
min="<?=(new DateTimeImmutable('now'))->format('Y-m-d')?>" required>
|
||||
<label for=until>Until</label>
|
||||
</div>
|
||||
<p class="text-end mb-0"><button type=submit class="btn btn-primary">Snooze</button>
|
||||
</form><?php
|
||||
Layout::bareFoot();
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use MyPrayerJournal\{Auth, Note, Request, Table};
|
||||
use BitBadger\PDODocument\Patch;
|
||||
|
||||
require '../../start.php';
|
||||
if ($_SERVER['REQUEST_METHOD'] <> 'POST') not_found();
|
||||
|
||||
Auth::requireUser(false);
|
||||
|
||||
$req = Request::byId($_GET['id']);
|
||||
if (!$req) not_found();
|
||||
|
||||
array_unshift($req->notes, new Note((new DateTimeImmutable('now'))->format('c'), $_POST['notes']));
|
||||
Patch::byId(Table::REQUEST, $req->id, ['notes' => $req->notes]);
|
||||
|
||||
hide_modal('notes');
|
||||
http_response_code(202);
|
||||
@@ -22,9 +22,7 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
||||
recurrence: $recurrence,
|
||||
history: [new History($now->format('c'), RequestAction::Created, $_POST['requestText'])]));
|
||||
//Messages.pushSuccess ctx "Added prayer request" "/journal"
|
||||
header('Location: /journal');
|
||||
http_response_code(303);
|
||||
exit;
|
||||
see_other('/journal');
|
||||
|
||||
case 'PATCH':
|
||||
$req = Request::byId($_PATCH['requestId']);
|
||||
@@ -44,8 +42,5 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
||||
$patch['history'] = $req->history;
|
||||
Patch::byId(Table::REQUEST, $req->id, $patch);
|
||||
//Messages.pushSuccess ctx "Prayer request updated successfully" nextUrl
|
||||
// TODO: make redirect that filters out non-local URLs
|
||||
header('Location: ' . $_PATCH['returnTo']);
|
||||
http_response_code(303);
|
||||
exit;
|
||||
see_other($_PATCH['returnTo']);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use MyPrayerJournal\{Auth, Request, Table, UI};
|
||||
use BitBadger\PDODocument\Patch;
|
||||
|
||||
require '../../start.php';
|
||||
if ($_SERVER['REQUEST_METHOD'] <> 'PATCH') not_found();
|
||||
|
||||
Auth::requireUser(false);
|
||||
|
||||
$req = Request::byId($_GET['id']);
|
||||
if (!$req) not_found();
|
||||
|
||||
$until = (new DateTimeImmutable($_PATCH['until'] . 'T00:00:00', new DateTimeZone($_REQUEST['time_zone'])))
|
||||
->setTimezone(new DateTimeZone('Etc/UTC'));
|
||||
Patch::byId(Table::REQUEST, $req->id, ['snoozedUntil' => $until->format('c')]);
|
||||
|
||||
// TODO: message
|
||||
|
||||
hide_modal('snooze');
|
||||
UI::journal();
|
||||
Reference in new issue
Block a user