mirror of
https://github.com/itflow-org/itflow
synced 2026-11-21 11:57:25 +00:00
View tabs that do not fit across the screen fold into a More menu at the end of the row on every list instead of running off the edge, keeping the open tab out and showing the count of an alerting tab in it in red or amber, with the counts kept live
This commit is contained in:
@@ -211,6 +211,7 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u
|
||||
- Starter Content and the demo data are in US spelling - license, authorized, organization, fiber and the like. Where you loaded them before, nothing is added twice: the Authorised Contacts Only vendor tag and the Licence assigned canned response you have count as loaded, and bringing the starter canned responses up to date gives the response its new name. Bringing the starter ticket templates up to date has New Hire Onboarding ask for the License. Loading the demo data again, or removing it, still finds what an earlier load made.
|
||||
- Maintenance > Starter Content is laid out like Backup and Update: how much of the library you don't have yet, with Add all, at the top; each pack with how many it would add and how many of it you have, Pick which, its Add and its Update; the demo data under them; and the totals, how adding works and what to know about the demo data at the side. Update and Remove demo data ask first in the usual window.
|
||||
- Maintenance > Starter Content: Clear out unused, beside a pack's counts, archives what you have from the pack that nothing uses yet - a category no ticket, invoice, expense or product has, a tag on nothing, a template nothing was made from, a canned response never put in a reply, a product on no invoice, quote or asset. A window lists them, all ticked, and says how many are in use and stay; Undo puts them back, and Add doesn't make them again.
|
||||
- Lists: tabs that don't fit across the screen go into More at the end of the row, instead of running off the edge out of sight - on the tickets list at most screen sizes, and on any list on a phone. The tab you're on always stays out, and More shows a red or amber count when a tab in it needs attention, such as Overdue or Unassigned.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
@@ -417,6 +418,7 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u
|
||||
- Starter content: `starterRenamed()` in `admin/post/starter_content_model.php` maps a starter item's old name, keyed as `starterExistingNames()` keys it, to its new one. Tags and canned responses here under the old name count as present (`starterExistingRenamed()`, `starterCannedResponseNames()`), `starterUpdateCannedResponses()` renames one before replacing it, and `demoAttachTags()` falls back to the old tag name. `demoDataRenamed()` holds the demo products' old name and description and the errand trip's old purpose; `demoProductId()` finds a demo product either way for load and removal, and a load renames an old one in place.
|
||||
- `admin/starter_content.php` is rebuilt on the Maintenance page layout (a hero card, then the packs as a `list-group` sharing Get started's `.itflow-gs-pack-icon` and `.itflow-gs-pack-about`, and an At a glance card); `.itflow-starter-pack-cell` is gone. Update and Remove demo data are `confirm-link` buttons in place of `onsubmit` confirms.
|
||||
- Starter content: `starterPackRecords()`, `starterPackHere()`, `starterPackUsed()`, `starterContentUnused()` and `starterClearUnused()` in `admin/post/starter_content_model.php`, `clear_starter_unused` in `admin/post/starter_content.php` (rechecked on post, with an Undo of the archive) and `admin/modals/starter_content/starter_clear.php`. A tag counts as used by any table with a `tag_id` or `*_tag_id` column (read from information_schema) or a seat count, a project template by its tickets' history line, and a category by `categoryUsage()` plus ticket templates, settings, RMM alerts, AI triage and child categories. `starterPickHtml()` takes `$open`; `js/starter_content.js` counts `data-starter-format="clear"` and sets up a pack in a window as it opens.
|
||||
- Tab bars: `js/tab_fold.js` (loaded by `includes/footer.php`) folds the tabs of an `.itflow-asset-tabs` bar that scrolls (`.nav.flex-nowrap.overflow-auto`, or one inside an `.itflow-asset-tabs` card header) that don't fit into a More dropdown, from the end, never the `.active` one. Folded tabs stay in place with `.itflow-tab-folded`, so page scripts keep working on them; More's items are built on `show.bs.dropdown` - a link for a tab with an href, otherwise a button that clicks the tab - and More and its items aren't `.nav-link`. The bar gets `.itflow-tabs-fold` (overflow visible, min-width 0), and fits again on resize, font load and any change to its tabs (a MutationObserver - the counts `agent/js/tickets_live.js` updates).
|
||||
|
||||
## [26.11.8]
|
||||
|
||||
|
||||
@@ -4319,6 +4319,35 @@ img.itflow-asset-icon {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
/* Tabs that don't fit fold into More at the end of the bar (js/tab_fold.js).
|
||||
The bar stops scrolling, so More's menu isn't cut off by it - min-width 0
|
||||
keeps it as narrow as it was as a scroller, so it still knows it's full. */
|
||||
.nav.itflow-tabs-fold.overflow-auto {
|
||||
overflow: visible !important;
|
||||
min-width: 0;
|
||||
}
|
||||
.itflow-tab-folded {
|
||||
display: none !important;
|
||||
}
|
||||
.itflow-tabs-more-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: .3rem .75rem;
|
||||
border: 0;
|
||||
border-radius: var(--bs-nav-pills-border-radius);
|
||||
background: none;
|
||||
color: var(--bs-secondary-color);
|
||||
}
|
||||
.itflow-tabs-more-toggle:hover,
|
||||
.itflow-tabs-more-toggle[aria-expanded="true"] {
|
||||
color: var(--bs-nav-link-hover-color);
|
||||
}
|
||||
.itflow-tabs-more .badge:not([class*="text-bg-"]) {
|
||||
background-color: var(--bs-secondary-bg);
|
||||
color: var(--bs-secondary-color);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* List rows */
|
||||
.itflow-asset-table td {
|
||||
padding-top: .6rem;
|
||||
|
||||
@@ -90,6 +90,7 @@ try {
|
||||
<script src="<?= staticFileUrl('/js/picture_field.js') ?>"></script>
|
||||
<script src="<?= staticFileUrl('/js/credentials.js') ?>"></script>
|
||||
<script src="<?= staticFileUrl('/js/tag_picker.js') ?>"></script>
|
||||
<script src="<?= staticFileUrl('/js/tab_fold.js') ?>"></script>
|
||||
<script src="<?= staticFileUrl('/js/quick_pick.js') ?>"></script>
|
||||
<script src="<?= staticFileUrl('/js/ajax_modal.js') ?>"></script>
|
||||
<script src="<?= staticFileUrl('/js/confirm_modal.js') ?>"></script>
|
||||
|
||||
194
js/tab_fold.js
Normal file
194
js/tab_fold.js
Normal file
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
* ITFlow - view tabs that don't fit fold into More.
|
||||
*
|
||||
* The tab bars over the lists (.itflow-asset-tabs, the ones that scroll sideways:
|
||||
* flex-nowrap overflow-auto) used to run off the edge of the card, with the last
|
||||
* tabs out of sight behind a scroll nobody noticed. Now the tabs that don't fit
|
||||
* go, from the end, into a More menu at the end of the bar, and come back as the
|
||||
* bar gets wider. The tab that is open never goes into it. More wears the alarm
|
||||
* of a tab in it that has one (Overdue in red, Unassigned in amber), with that
|
||||
* tab's count.
|
||||
*
|
||||
* The tabs themselves stay where they are, only hidden (.itflow-tab-folded), so
|
||||
* whatever a page does with them still works - the tickets list updating their
|
||||
* counts (agent/js/tickets_live.js), reconcile's tabs that filter in place.
|
||||
* More's items are built as the menu opens, from the tabs as they are then: a
|
||||
* link for a tab that is a link, otherwise a button that clicks the tab. More
|
||||
* and its items aren't .nav-link, so nothing counting the tabs counts them.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
if (window.itflowTabFold) {
|
||||
return;
|
||||
}
|
||||
window.itflowTabFold = true;
|
||||
|
||||
var FOLDED = 'itflow-tab-folded';
|
||||
|
||||
function tabsOf(bar) {
|
||||
return Array.prototype.filter.call(bar.children, function (el) {
|
||||
return el.classList.contains('nav-link');
|
||||
});
|
||||
}
|
||||
|
||||
// A tab the page itself hides isn't ours to show or fold
|
||||
function pageHidden(el) {
|
||||
return !el.classList.contains(FOLDED) && getComputedStyle(el).display === 'none';
|
||||
}
|
||||
|
||||
function setup(bar) {
|
||||
bar.classList.add('itflow-tabs-fold');
|
||||
|
||||
var more = document.createElement('div');
|
||||
more.className = 'dropdown itflow-tabs-more ' + FOLDED;
|
||||
more.innerHTML = '<button type="button" class="itflow-tabs-more-toggle text-nowrap" data-bs-toggle="dropdown" aria-expanded="false" aria-haspopup="true">'
|
||||
+ 'More<span class="badge rounded-pill ms-1 d-none"></span><i class="fas fa-caret-down ms-1" aria-hidden="true"></i></button>'
|
||||
+ '<div class="dropdown-menu dropdown-menu-end"></div>';
|
||||
bar.appendChild(more);
|
||||
var badge = more.querySelector('.badge');
|
||||
var menu = more.querySelector('.dropdown-menu');
|
||||
|
||||
function folded() {
|
||||
return tabsOf(bar).filter(function (tab) {
|
||||
return tab.classList.contains(FOLDED);
|
||||
});
|
||||
}
|
||||
|
||||
// More shows the most pressing alarm in it - red before amber - with that tab's count
|
||||
function markMore() {
|
||||
var alarm = null;
|
||||
['text-bg-danger', 'text-bg-warning'].some(function (cls) {
|
||||
return folded().some(function (tab) {
|
||||
var b = tab.querySelector('.badge.' + cls);
|
||||
if (b) {
|
||||
alarm = [cls, b.textContent.trim(), tab];
|
||||
}
|
||||
return !!b;
|
||||
});
|
||||
});
|
||||
badge.className = 'badge rounded-pill ms-1' + (alarm ? ' ' + alarm[0] : ' d-none');
|
||||
badge.textContent = alarm ? alarm[1] : '';
|
||||
more.firstChild.title = alarm ? alarm[2].textContent.replace(/\s+/g, ' ').trim() + ' is in here' : '';
|
||||
}
|
||||
|
||||
function fit() {
|
||||
observer.disconnect();
|
||||
var tabs = tabsOf(bar);
|
||||
var rules = Array.prototype.filter.call(bar.children, function (el) {
|
||||
return el.classList.contains('vr');
|
||||
});
|
||||
tabs.concat(rules).forEach(function (el) {
|
||||
el.classList.remove(FOLDED);
|
||||
});
|
||||
more.classList.add(FOLDED);
|
||||
|
||||
if (bar.scrollWidth > bar.clientWidth + 1) {
|
||||
more.classList.remove(FOLDED);
|
||||
for (var i = tabs.length - 1; i >= 0 && bar.scrollWidth > bar.clientWidth + 1; i--) {
|
||||
if (!tabs[i].classList.contains('active') && !pageHidden(tabs[i])) {
|
||||
tabs[i].classList.add(FOLDED);
|
||||
}
|
||||
}
|
||||
// A line between groups only between tabs that are still out
|
||||
rules.forEach(function (rule) {
|
||||
var before = false;
|
||||
var after = false;
|
||||
for (var el = rule.previousElementSibling; el; el = el.previousElementSibling) {
|
||||
before = before || (el.classList.contains('nav-link') && !el.classList.contains(FOLDED) && !pageHidden(el));
|
||||
}
|
||||
for (el = rule.nextElementSibling; el; el = el.nextElementSibling) {
|
||||
after = after || (el.classList.contains('nav-link') && !el.classList.contains(FOLDED) && !pageHidden(el));
|
||||
}
|
||||
rule.classList.toggle(FOLDED, !(before && after));
|
||||
});
|
||||
}
|
||||
markMore();
|
||||
observer.observe(bar, { subtree: true, childList: true, characterData: true, attributes: true, attributeFilter: ['class'] });
|
||||
}
|
||||
|
||||
// The menu, from the folded tabs as they are now - a line where a group starts
|
||||
more.addEventListener('show.bs.dropdown', function () {
|
||||
menu.textContent = '';
|
||||
var tabs = folded();
|
||||
tabs.forEach(function (tab, n) {
|
||||
var prev = tab.previousElementSibling;
|
||||
if (n && prev && prev.classList.contains('vr')) {
|
||||
menu.appendChild(Object.assign(document.createElement('div'), { className: 'dropdown-divider' }));
|
||||
}
|
||||
var href = tab.getAttribute('href') || '';
|
||||
var item = document.createElement(href && href.charAt(0) !== '#' ? 'a' : 'button');
|
||||
item.className = 'dropdown-item d-flex align-items-center gap-2';
|
||||
if (item.tagName === 'A') {
|
||||
item.href = tab.href;
|
||||
} else {
|
||||
item.type = 'button';
|
||||
item.addEventListener('click', function () {
|
||||
tab.click();
|
||||
});
|
||||
}
|
||||
if (tab.title) {
|
||||
item.title = tab.title;
|
||||
}
|
||||
Array.prototype.forEach.call(tab.childNodes, function (node) {
|
||||
item.appendChild(node.cloneNode(true));
|
||||
});
|
||||
// The gap spaces them out here, and the count goes to the right
|
||||
item.querySelectorAll('.me-1, .ms-1').forEach(function (el) {
|
||||
el.classList.remove('me-1', 'ms-1');
|
||||
});
|
||||
var count = item.querySelector('.badge');
|
||||
if (count) {
|
||||
count.classList.add('ms-auto');
|
||||
item.appendChild(count);
|
||||
}
|
||||
menu.appendChild(item);
|
||||
});
|
||||
});
|
||||
|
||||
var queued = false;
|
||||
function refit() {
|
||||
if (queued) {
|
||||
return;
|
||||
}
|
||||
queued = true;
|
||||
requestAnimationFrame(function () {
|
||||
queued = false;
|
||||
fit();
|
||||
});
|
||||
}
|
||||
|
||||
// A count or the open tab changed (tickets_live.js, reconcile) - fit again
|
||||
var observer = new MutationObserver(function (records) {
|
||||
if (records.some(function (r) {
|
||||
return !more.contains(r.target);
|
||||
})) {
|
||||
refit();
|
||||
}
|
||||
});
|
||||
|
||||
if (window.ResizeObserver) {
|
||||
new ResizeObserver(refit).observe(bar);
|
||||
} else {
|
||||
window.addEventListener('resize', refit);
|
||||
}
|
||||
if (document.fonts && document.fonts.ready) {
|
||||
document.fonts.ready.then(refit);
|
||||
}
|
||||
fit();
|
||||
}
|
||||
|
||||
function init() {
|
||||
document.querySelectorAll('.itflow-asset-tabs.nav.flex-nowrap.overflow-auto, .itflow-asset-tabs > .nav.flex-nowrap.overflow-auto').forEach(function (bar) {
|
||||
if (!bar.classList.contains('itflow-tabs-fold') && tabsOf(bar).length > 1) {
|
||||
setup(bar);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user