Document quick view reads like the document page: the page's typography, folder, template, Markdown, review and tags above what it says, what it is linked to as counts that open to their lists instead of every record listed, and Open Document, Edit to the edit page, Share and Export along the bottom; linkGroupsHtml compact mode takes how many links open their groups; the old document edit modal is gone; 26.12.3 changelog entries

This commit is contained in:
johnnyq
2026-11-29 14:08:11 -05:00
parent 6f1c759150
commit 85c151eec8
4 changed files with 74 additions and 69 deletions

View File

@@ -1,8 +1,12 @@
<?php
/*
* A document's quick look - its content, where it lives, and what it is linked
* to, without leaving the page. Open goes to the full document page.
* A document's quick look - read it without leaving the page, laid out as on
* its page (agent/document.php): what it says with the same typography
* (.itflow-prose), where it lives, the template it came from, Markdown when
* it's written in it, and its review, then what it's linked to as counts that
* open to their lists. Open goes to its page, Edit to the edit page, and it
* can be shared or exported from here.
*
* Readable by anyone who can open the document page (client access).
*/
@@ -14,10 +18,15 @@ enforceUserPermission('module_client');
$document_id = intval($_GET['id'] ?? 0);
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT document_client_id, document_content, document_name, document_description, document_folder_id,
document_client_visible, document_archived_at, document_created_at, document_updated_at, COALESCE(updater.user_name, creator.user_name) AS user_name
document_client_visible, document_favorite, document_archived_at, document_created_at, document_updated_at, document_reviewed_at,
document_template_name, document_template_review_months, document_template_archived_at,
" . (documentReviewOwnReady() ? 'document_review_months' : 'NULL AS document_review_months') . ",
" . (documentMarkdownReady() ? 'document_markdown IS NOT NULL' : '0') . " AS document_is_markdown,
COALESCE(updater.user_name, creator.user_name) AS user_name
FROM documents
LEFT JOIN users creator ON document_created_by = creator.user_id
LEFT JOIN users updater ON document_updated_by = updater.user_id
LEFT JOIN document_templates USING (document_template_id)
WHERE document_id = $document_id LIMIT 1"));
if (!$row) {
echo json_encode(['error' => 'That document no longer exists.']);
@@ -28,9 +37,17 @@ enforceClientAccess();
$can_edit = lookupUserPermission('module_support') >= 2;
$document_archived = !empty($row['document_archived_at']);
$document_updated_at = $row['document_updated_at'] ?: $row['document_created_at'];
$folder_tree = folderTree($client_id);
$folder_id = isset($folder_tree[intval($row['document_folder_id'])]) ? intval($row['document_folder_id']) : 0;
$folder_label = $folder_id ? implode(' / ', array_column(folderPath($folder_tree, $folder_id), 'folder_name')) : 'Top level';
// Its review, when it has one - its own, or its template's - not for an archived document
$review = !$document_archived ? documentReviewState($row) : null;
$tags = tagsForRecord('document', $document_id);
// Closed to their counts, so a long list doesn't push what it says out of view
$linked_html = linkGroupsHtml('document', $document_id, $client_id, $document_archived, true, $linked_total, 0);
$csrf = $_SESSION['csrf_token'];
$document_url = "document.php?client_id=$client_id&document_id=$document_id";
ob_start();
@@ -42,13 +59,13 @@ ob_start();
<div class="min-w-0">
<h5 class="modal-title d-flex flex-wrap align-items-center column-gap-2">
<span class="fw-semibold text-break"><?= escapeHtml($row['document_name']) ?></span>
<?php if (intval($row['document_favorite'])) { ?><i class="fas fa-star text-warning fs-6" title="Favorite - on the client's overview"></i><?php } ?>
<?php if ($document_archived) { ?><span class="badge rounded-pill text-bg-secondary fw-normal fs-6">Archived</span><?php } ?>
<?php if (intval($row['document_client_visible'])) { ?><span class="badge rounded-pill bg-info-subtle text-info-emphasis fw-normal fs-6">Portal</span><?php } ?>
<?php if (intval($row['document_client_visible'])) { ?><span class="badge rounded-pill bg-info-subtle text-info-emphasis fw-normal fs-6" title="Technical contacts can read this in the client portal">Portal</span><?php } ?>
</h5>
<div class="small text-body-secondary mt-1">
<?php if ($row['document_description']) { ?><?= escapeHtml($row['document_description']) ?> &middot; <?php } ?>
Updated <?= timeAgo($row['document_updated_at'] ?: $row['document_created_at']) ?><?= $row['user_name'] ? ' by ' . escapeHtml($row['user_name']) : '' ?>
&middot; <i class="fas fa-folder me-1"></i><?= escapeHtml($folder_label) ?>
<span title="<?= formatDateTime($document_updated_at) ?>">Updated <?= timeAgo($document_updated_at) ?></span><?= $row['user_name'] ? ' by ' . escapeHtml($row['user_name']) : '' ?>
</div>
</div>
</div>
@@ -56,19 +73,55 @@ ob_start();
</div>
<div class="modal-body">
<div class="prettyContent itflow-document-quick-content"><?= documentHtmlPurify($row['document_content']) ?: '<p class="text-body-secondary mb-0">This document is empty.</p>' ?></div>
<div class="mt-3">
<div class="small fw-semibold text-uppercase text-body-secondary mb-2">Linked</div>
<?= linkGroupsHtml('document', $document_id, $client_id, $document_archived) ?>
<!-- Where it lives, where it came from, when it's next looked over - as under its name on its page -->
<div class="small text-body-secondary d-flex flex-wrap align-items-center column-gap-3 row-gap-1 mb-3 itflow-document-facts">
<a class="text-reset text-truncate" href="files.php?client_id=<?= $client_id ?>&folder_id=<?= $folder_id ?>" title="Folder"><i class="fas fa-fw fa-folder me-1"></i><?= escapeHtml($folder_label) ?></a>
<?php if ($row['document_template_name'] !== null) { ?>
<span title="The template it was made from"><i class="fas fa-fw fa-puzzle-piece me-1"></i><?= escapeHtml($row['document_template_name']) ?></span>
<?php } ?>
<?php if (intval($row['document_is_markdown'])) { ?>
<span title="Written in Markdown - Edit shows the Markdown"><i class="fab fa-fw fa-markdown me-1"></i>Markdown</span>
<?php } ?>
<?php if ($review) { ?>
<span class="<?= $review['due'] ? 'text-warning-emphasis fw-semibold' : '' ?>" title="Reviewed <?= lcfirst(DOCUMENT_TEMPLATE_REVIEW_MONTHS[$review['months']] ?? '') ?>"><i class="fas fa-fw fa-calendar-check me-1"></i><?= $review['due'] ? 'Review due since ' : 'Next review ' ?><?= date('M j, Y', strtotime($review['next'])) ?></span>
<?php } ?>
<?php if ($tags) { ?>
<span><?= tagPills('document', $document_id, $tags, "files.php?client_id=$client_id&", false) ?></span>
<?php } ?>
</div>
<!-- What it says, as it reads on its page -->
<div class="prettyContent itflow-prose itflow-document-quick-content"><?= documentHtmlPurify($row['document_content']) ?: '<p class="text-body-secondary mb-0">This document is empty.</p>' ?></div>
<!-- What it's about - a count of each kind, opening to the list -->
<div class="mt-3">
<div class="d-flex align-items-center mb-2">
<span class="small fw-semibold text-uppercase text-body-secondary me-auto">Linked<?php if ($linked_total) { ?> <span class="badge rounded-pill text-bg-secondary ms-1"><?= $linked_total ?></span><?php } ?></span>
<?php if ($can_edit && !$document_archived) { ?>
<?= linkPickerButton('document', $document_id, '', 'Link', 'btn btn-sm btn-outline-secondary', 'fas fa-plus me-1') ?>
<?php } ?>
</div>
<?= $linked_html ?>
</div>
</div>
<div class="modal-footer">
<a href="document.php?client_id=<?= $client_id ?>&document_id=<?= $document_id ?>" class="btn btn-primary fw-bold"><i class="fas fa-arrow-right me-2"></i>Open Document</a>
<a href="<?= $document_url ?>" class="btn btn-primary fw-bold"><i class="fas fa-arrow-right me-2"></i>Open Document</a>
<?php if ($can_edit && !$document_archived) { ?>
<button type="button" class="btn btn-outline-secondary ajax-modal" data-modal-size="xl" data-modal-url="modals/document/document_edit.php?id=<?= $document_id ?>"><i class="fas fa-edit me-2"></i>Edit</button>
<a class="btn btn-outline-secondary" href="document_edit.php?client_id=<?= $client_id ?>&document_id=<?= $document_id ?>"><i class="fas fa-edit me-2"></i>Edit</a>
<?php } ?>
<?php if (!$document_archived && shareCanMake('Document')) { ?>
<button type="button" class="btn btn-outline-secondary ajax-modal" data-modal-url="modals/share/share_add.php?type=Document&amp;id=<?= $document_id ?>" title="Share a link to it"><i class="fas fa-share-alt me-2"></i>Share</button>
<?php } ?>
<div class="dropup">
<button type="button" class="btn btn-outline-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false" title="Download it"><i class="fas fa-download me-2"></i>Export</button>
<div class="dropdown-menu dropdown-menu-end">
<a class="dropdown-item" href="post.php?export_document=<?= $document_id ?>&csrf_token=<?= $csrf ?>"><i class="fas fa-fw fa-file-pdf me-2"></i>PDF</a>
<a class="dropdown-item" href="post.php?export_document_markdown=<?= $document_id ?>&csrf_token=<?= $csrf ?>"><i class="fab fa-fw fa-markdown me-2"></i>Markdown (.md)</a>
</div>
</div>
<button type="button" class="btn btn-light" data-bs-dismiss="modal"><i class="fas fa-times me-2"></i>Close</button>
</div>