mirror of
https://github.com/itflow-org/itflow
synced 2026-12-02 00:59:03 +00:00
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:
@@ -21,6 +21,7 @@ Update from Maintenance > Update as usual - this release has three database chan
|
||||
- Markdown pasted into a document's rich text editor - copied from GitHub, VS Code, Obsidian or an AI chat - goes in as formatting. Ctrl+Shift+V pastes it as it is.
|
||||
- A document's page is easier to read: headings in proportion to the text with room between sections, and tables, code and quotes that look part of it. Under its name are its folder, its template, Markdown when it's written in it, and its review - due, or when it's next due - whose menu has Mark Reviewed and how often. The buttons are Edit, Share and Export (PDF, Markdown or Print), with the rest in the ⋮ menu, now including Template. Beside it, Contents marks the section you're reading, and Linked, Versions and History are tabs of one card: Linked shows each kind of record with its count, opening to the list.
|
||||
- Lists on a phone: Tickets, Credentials, Assets and Contacts (and Contacts' portal invites) show each row as a card instead of a table cut off at the edge of the screen - its name with the tick box and ⋮ menu across the top, then every other column with its label: a ticket's client, status, priority, agent, due date and last activity, a credential's login and what it's for, an asset's type, model, IP, location and status, a contact's phone and email. Status, priority, agent and location still change with a tap, and the column names above the cards sort the list.
|
||||
- A document's quick view (Quick view in Files, and the view button on an asset or contact) reads like its page: headings in proportion to the text with tables, code and quotes that look part of it, its folder, template, Markdown and review above it, and what it's linked to as a count of each kind that opens to the list, instead of every linked record listed under it. Along the bottom are Open Document, Edit (now the edit page, as from the document), Share and Export (PDF or Markdown).
|
||||
- Documents and articles read outside ITFlow look like a document's page: in the client portal (a document, and a Help article), on a shared link and on the public help center, headings are in proportion to the text, tables, code and quotes look part of it, and a picture shown smaller than it is opens full size when clicked. A long one - three headings or more - has its Contents beside it, in view as you scroll and marking the section being read, or above it on a phone. Picking a heading in Contents marks that one, not the one just under it - on a document's page in ITFlow too.
|
||||
- A document's PDF, and a Knowledge Base article's, look like your invoices and the documentation PDF: your logo and company details at the top, then its name with the client, its folder (an article's category) and when it was last updated and by whom, and its summary. Each later page has the client and the name at the top, and every page your company, Confidential (Knowledge Base for an article) and the date at the foot, with the page number. Tables have lines, code is shaded, a checklist shows its boxes, symbols such as ✓ and → show, and a document with headings has them as bookmarks beside the PDF.
|
||||
- Pictures in tickets are kept as files: a screenshot pasted or dropped into a ticket, a reply or a note - by your team, in the client portal or through the API - and the pictures in a client's email are kept with the ticket as files instead of inside its text. A ticket full of screenshots opens quickly, and so do the tickets list and the client portal. Pictures show where they were put and stay out of the ticket's list of files, and emails carry them as before.
|
||||
@@ -55,6 +56,7 @@ Update from Maintenance > Update as usual - this release has three database chan
|
||||
- functions/document_pdf.php: DocumentPdf (TCPDF) and documentPdfRender() draw the document and Knowledge Base article PDFs (export_document in agent/post/document.php, export_kb_article in agent/post/kb.php), from documentPdfDocument() / documentPdfKbArticle(), and are sent with billingPdfSend(). documentPdfParts() splits the purified HTML at its top-level headings (inside a Markdown document's wrapper) for the bookmarks, and puts table lines, header cells and code shading in inline styles, which TCPDF reads where it ignores the style block. clientExportPdfImages() is clientExportPdfDocumentHtml()'s image step on its own, for uploads/documents or uploads/kb, and now turns a WebP picture into a PNG.
|
||||
- documentReadHtml() (functions/files.php) lays out a document or article outside the agent app - client/document.php, client/kb_article.php, guest/kb.php and guest/share.php - with .itflow-prose, and the Contents beside it in an .itflow-document-read grid (css/itflow_custom.css). js/document_contents.js reads [data-document-body] as well as .itflow-document-body, runs again from window.itflowDocumentContents() (js/guest_share.js, once a shared document is in), leaves the address alone with data-document-contents-keep-address (a shared link's secret is after its #), and keeps a section picked from the list marked while the page scrolls to it. The portal footer loads it when a page sets $portal_document_contents.
|
||||
- A list table with .itflow-list-stack (css/itflow_custom.css) stacks below 768px: each row a grid card with the tick box, first cell and last (the menu) across the top and every other cell under them labelled from its data-label, and the head a wrapping row of its sort links. Used on agent/ticket_list.php, agent/credentials.php, agent/assets.php and agent/contacts.php (contacts and invites); the ticket row's phone-only line of status, priority and client is gone, as the card shows them.
|
||||
- agent/modals/document/document_view.php uses .itflow-prose and linkGroupsHtml()'s compact mode, which takes $open_up_to (5 by default, 0 for the quick view: always closed). Its Edit goes to agent/document_edit.php, so agent/modals/document/document_edit.php, which only it opened, is gone.
|
||||
|
||||
## [26.12.2]
|
||||
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Edit a document. Saving keeps what it said before as a version.
|
||||
*/
|
||||
|
||||
require_once '../../../includes/modal_header.php';
|
||||
|
||||
enforceUserPermission('module_support', 2);
|
||||
|
||||
$document_id = intval($_GET['id'] ?? 0);
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT document_client_id, document_client_visible, document_content, document_description,
|
||||
document_folder_id, document_name, document_archived_at, " . documentMarkdownSql() . " FROM documents WHERE document_id = $document_id LIMIT 1"));
|
||||
if (!$row) {
|
||||
echo json_encode(['error' => 'That document no longer exists.']);
|
||||
exit;
|
||||
}
|
||||
$client_id = intval($row['document_client_id']);
|
||||
enforceClientAccess();
|
||||
|
||||
$document_form_mode = 'edit';
|
||||
$document_name = escapeHtml($row['document_name']);
|
||||
$document_description = escapeHtml($row['document_description']);
|
||||
$document_content = escapeHtml($row['document_content']);
|
||||
$document_markdown = $row['document_markdown']; // raw - null for a document in the rich text editor
|
||||
$document_folder_id = intval($row['document_folder_id']);
|
||||
$document_client_visible = intval($row['document_client_visible']);
|
||||
|
||||
ob_start();
|
||||
|
||||
?>
|
||||
|
||||
<div class="modal-header bg-dark">
|
||||
<h5 class="modal-title text-truncate"><i class="fas fa-fw fa-edit me-2"></i>Edit Document <span class="fw-normal text-white-50 ms-1"><?= $document_name ?></span></h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
||||
<input type="hidden" name="document_id" value="<?= $document_id ?>">
|
||||
<div class="modal-body">
|
||||
<?php require 'document_form.php'; ?>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" name="edit_document" class="btn btn-primary fw-bold"><i class="fas fa-check me-2"></i>Save</button>
|
||||
<button type="button" class="btn btn-light" data-bs-dismiss="modal"><i class="fas fa-times me-2"></i>Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
require_once '../../../includes/modal_footer.php';
|
||||
@@ -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']) ?> · <?php } ?>
|
||||
Updated <?= timeAgo($row['document_updated_at'] ?: $row['document_created_at']) ?><?= $row['user_name'] ? ' by ' . escapeHtml($row['user_name']) : '' ?>
|
||||
· <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&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>
|
||||
|
||||
|
||||
@@ -421,12 +421,13 @@ function linkRowHtml($to, $row, $client_id) {
|
||||
* buttons). Empty groups collapse to a single "Link a ..." line, so the card
|
||||
* says what can be linked without a wall of empty headings.
|
||||
*
|
||||
* $compact (the document page): a group is its heading and count, opening to
|
||||
* its rows - open already when there are five links or fewer in all. Linking
|
||||
* is the one Link button above them, so groups have none of their own and
|
||||
* empty ones aren't offered. $total is how many links there are.
|
||||
* $compact (the document page and its quick look): a group is its heading and
|
||||
* count, opening to its rows - open already when there are $open_up_to links
|
||||
* or fewer in all (0, the quick look: always closed). Linking is the one Link
|
||||
* button above them, so groups have none of their own and empty ones aren't
|
||||
* offered. $total is how many links there are.
|
||||
*/
|
||||
function linkGroupsHtml($from, $id, $client_id, $archived = false, $compact = false, &$total = null) {
|
||||
function linkGroupsHtml($from, $id, $client_id, $archived = false, $compact = false, &$total = null, $open_up_to = 5) {
|
||||
$id = intval($id);
|
||||
$groups = '';
|
||||
$empty = [];
|
||||
@@ -454,7 +455,7 @@ function linkGroupsHtml($from, $id, $client_id, $archived = false, $compact = fa
|
||||
}
|
||||
$add = $can_edit ? linkPickerButton($from, $id, $to, 'Link', 'ms-auto small', 'fas fa-plus me-1', "Link {$entity['label']}") : '';
|
||||
if ($compact) {
|
||||
$open = $total <= 5;
|
||||
$open = $total <= $open_up_to;
|
||||
$collapse_id = 'linked-' . preg_replace('/[^a-z0-9_-]/i', '', "$from-$id-$to");
|
||||
$groups .= '<div class="itflow-link-group is-compact"><div class="itflow-link-group-head">'
|
||||
. '<button type="button" class="itflow-link-group-toggle' . ($open ? '' : ' collapsed') . '" data-bs-toggle="collapse" data-bs-target="#' . $collapse_id . '" aria-expanded="' . ($open ? 'true' : 'false') . '" aria-controls="' . $collapse_id . '">'
|
||||
|
||||
Reference in New Issue
Block a user