mirror of
https://github.com/itflow-org/itflow
synced 2026-11-23 21:07:22 +00:00
QoL 79: the date filter box on list pages shows All Time or its date range from the first paint instead of filling in after the page loads
This commit is contained in:
@@ -25,6 +25,8 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u
|
||||
- RMM Providers: a device moved to another linked client in Tactical stayed with its asset at the first client, and that asset took the new client's location. It is now matched or made at the client it moved to. The first client's asset stays there, no longer kept up, and its history says where the device went. Devices that moved before this update are put right at the next sync.
|
||||
- RMM Providers: one server with many disks - more than 255 characters of them - stopped every sync of its provider with "Data too long for column 'asset_spec_value'", and as that client was always tried first, no client's devices were brought in again. A device's CPU and storage are now cut to fit, and a device that can't be saved for any other reason no longer stops the sync: the rest come in, and the provider's row names it.
|
||||
- RMM Providers: an answer from the RMM that wasn't a list - an error page sent as a success, or a change to its API - was read as a client with no devices, or an RMM with no clients, and everything in it would have been marked gone. It is now an error, and nothing is changed.
|
||||
- Pickers: as a page loaded, a picker's "nothing" choice showed as "- Anyone -" for a moment before it became "Anyone" - on the tickets list's filters and in pickers across the app and the client portal. It is "Anyone", in its quieter grey, from the start.
|
||||
- Lists: the date filter box - on tickets, invoices, quotes, expenses, the audit log and the rest - was empty as the page loaded, then filled in with All Time or its dates a moment later. It says so from the start.
|
||||
|
||||
### Developer Updates
|
||||
|
||||
@@ -40,6 +42,8 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u
|
||||
- `rmmIsList()` - the Tactical kind's clients, devices and alerts answers must be JSON lists, or the call is an error. Another kind should do the same.
|
||||
- The sync's unlisted devices are held when at least `RMM_GONE_AT_ONCE` (3) of a client's live devices, and at least half, are missing from a whole list, until their `rmm_device_synced_at` - when they were last listed - is `RMM_GONE_HOLD_HOURS` (24) old. Held ids go to `rmmDeviceSave()` and `rmmAssetMatch()` as `$free`, so a reinstalled agent can still take an asset one of them has, deleting its row. Clients the RMM no longer lists stay in that clean-up while they have live devices, not only when first marked. The sync is `ok` false while any are held.
|
||||
- `rmmAlertsCleanup()`, from `cron/nightly_tasks.php`, deletes alerts cleared more than `RMM_ALERTS_KEEP_DAYS` (180) ago. Only open ones are read, so the minute's poll no longer scans every alert there has been.
|
||||
- `js/itflow_select_early.js`, loaded in the `<head>` of `includes/header.php`, `client/includes/header.php`, `agent/client_onboarding.php`, `admin/getting_started.php` and `setup/index.php` (a file, as the portal allows no inline scripts), watches the page as it is parsed and takes the dashes off a `- None -` option of a `select.select2`, marking it `data-none="1"` - before the first paint, so the raw `<select>` shown until `js/itflow_select.js` runs in the footer already reads the same. It stops at `DOMContentLoaded`. `js/itflow_select.js` treats `data-none="1"` as the "nothing" choice alongside an empty value and the dashed label, and `css/itflow_custom.css` greys a single select showing it until the picker takes over (`:has(option:checked[data-none="1"])`).
|
||||
- `dateFilterLabel($dtf, $dtt)` in `functions/format.php` gives what `js/date_filter.js` shows for a range - `All Time` for 1970-01-01 to 2099-12-31 or no dates, otherwise `Y-m-d — Y-m-d`, a date that isn't one taken as no bound. The 18 pages with a `#dateFilter` write it as the box's `value`, from the same expressions as their hidden `dtf` and `dtt`. `js/date_filter.js` empties the box before it starts Flatpickr, which would otherwise try to read those words as dates, and `setDisplay()` writes them back in the same step.
|
||||
|
||||
## [26.12]
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ $ms_text = function ($ms) {
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-6">
|
||||
<input type="text" id="dateFilter" class="form-control" autocomplete="off" title="When" aria-label="When">
|
||||
<input type="text" id="dateFilter" value="<?= escapeHtml(dateFilterLabel($dtf ?? '', $dtt ?? '')) ?>" class="form-control" autocomplete="off" title="When" aria-label="When">
|
||||
<input type="hidden" name="canned_date" id="canned_date" value="<?= escapeHtml(is_string($_GET['canned_date'] ?? null) ? $_GET['canned_date'] : '') ?>">
|
||||
<input type="hidden" name="dtf" id="dtf" value="<?= escapeHtml($dtf ?? '') ?>">
|
||||
<input type="hidden" name="dtt" id="dtt" value="<?= escapeHtml($dtt ?? '') ?>">
|
||||
|
||||
@@ -118,7 +118,7 @@ $filters_url = function ($modal) use ($dtf, $dtt, $view, $category_filter) {
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-6">
|
||||
<input type="text" id="dateFilter" class="form-control" autocomplete="off" title="When" aria-label="When">
|
||||
<input type="text" id="dateFilter" value="<?= escapeHtml(dateFilterLabel($dtf ?? '', $dtt ?? '')) ?>" class="form-control" autocomplete="off" title="When" aria-label="When">
|
||||
<input type="hidden" name="canned_date" id="canned_date" value="<?= escapeHtml(is_string($_GET['canned_date'] ?? null) ? $_GET['canned_date'] : '') ?>">
|
||||
<input type="hidden" name="dtf" id="dtf" value="<?= escapeHtml($dtf ?? '') ?>">
|
||||
<input type="hidden" name="dtt" id="dtt" value="<?= escapeHtml($dtt ?? '') ?>">
|
||||
|
||||
@@ -130,7 +130,7 @@ $view_empty = [
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-6">
|
||||
<input type="text" id="dateFilter" class="form-control" autocomplete="off" title="When" aria-label="When">
|
||||
<input type="text" id="dateFilter" value="<?= escapeHtml(dateFilterLabel($dtf ?? '', $dtt ?? '')) ?>" class="form-control" autocomplete="off" title="When" aria-label="When">
|
||||
<input type="hidden" name="canned_date" id="canned_date" value="<?= escapeHtml(is_string($_GET['canned_date'] ?? null) ? $_GET['canned_date'] : '') ?>">
|
||||
<input type="hidden" name="dtf" id="dtf" value="<?= escapeHtml($dtf ?? '') ?>">
|
||||
<input type="hidden" name="dtt" id="dtt" value="<?= escapeHtml($dtt ?? '') ?>">
|
||||
|
||||
@@ -85,6 +85,8 @@ define('FROM_GETTING_STARTED', true);
|
||||
<link rel="stylesheet" href="<?= staticFileUrl('/libs/adminlte/css/adminlte.min.css') ?>">
|
||||
<link rel="stylesheet" href="<?= staticFileUrl('/libs/sweetalert2/css/sweetalert2.min.css') ?>">
|
||||
<link rel="stylesheet" href="<?= staticFileUrl('/css/itflow_custom.css') ?>">
|
||||
<!-- "- Anyone -" choices without their dashes from the first paint (js/itflow_select_early.js) -->
|
||||
<script src="<?= staticFileUrl('/js/itflow_select_early.js') ?>"></script>
|
||||
</head>
|
||||
|
||||
<body class="itflow-setup itflow-gs bg-body-tertiary">
|
||||
|
||||
@@ -131,7 +131,7 @@ $filtered_dates = isset($_GET['dtf']) && $_GET['dtf'] !== '' && $_GET['dtf'] !==
|
||||
<label class="form-label" for="dateFilter">Queued</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-calendar-alt"></i></span>
|
||||
<input type="text" id="dateFilter" class="form-control" autocomplete="off">
|
||||
<input type="text" id="dateFilter" value="<?= escapeHtml(dateFilterLabel($dtf ?? '', $dtt ?? '')) ?>" class="form-control" autocomplete="off">
|
||||
</div>
|
||||
<input type="hidden" name="canned_date" id="canned_date" value="<?= escapeHtml($_GET['canned_date'] ?? '') ?>">
|
||||
<input type="hidden" name="dtf" id="dtf" value="<?= escapeHtml($dtf ?? '') ?>">
|
||||
|
||||
@@ -182,7 +182,7 @@ $audit_url = function (array $query) use ($dates_query) {
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-5">
|
||||
<input type="text" id="dateFilter" class="form-control" autocomplete="off" title="When" aria-label="When">
|
||||
<input type="text" id="dateFilter" value="<?= escapeHtml(dateFilterLabel($dtf ?? '', $dtt ?? '')) ?>" class="form-control" autocomplete="off" title="When" aria-label="When">
|
||||
<input type="hidden" name="canned_date" id="canned_date" value="<?= escapeHtml(is_string($_GET['canned_date'] ?? null) ? $_GET['canned_date'] : '') ?>">
|
||||
<input type="hidden" name="dtf" id="dtf" value="<?= escapeHtml($dtf ?? '') ?>">
|
||||
<input type="hidden" name="dtt" id="dtt" value="<?= escapeHtml($dtt ?? '') ?>">
|
||||
|
||||
@@ -129,7 +129,7 @@ $ready = smsReady();
|
||||
<label class="form-label" for="dateFilter">When</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-calendar-alt"></i></span>
|
||||
<input type="text" id="dateFilter" class="form-control" autocomplete="off">
|
||||
<input type="text" id="dateFilter" value="<?= escapeHtml(dateFilterLabel($dtf ?? '', $dtt ?? '')) ?>" class="form-control" autocomplete="off">
|
||||
</div>
|
||||
<input type="hidden" name="canned_date" id="canned_date" value="<?= escapeHtml($_GET['canned_date'] ?? '') ?>">
|
||||
<input type="hidden" name="dtf" id="dtf" value="<?= escapeHtml($dtf ?? '') ?>">
|
||||
|
||||
@@ -122,7 +122,7 @@ $view_empty = [
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-6">
|
||||
<input type="text" id="dateFilter" class="form-control" autocomplete="off" title="When" aria-label="When">
|
||||
<input type="text" id="dateFilter" value="<?= escapeHtml(dateFilterLabel($dtf ?? '', $dtt ?? '')) ?>" class="form-control" autocomplete="off" title="When" aria-label="When">
|
||||
<input type="hidden" name="canned_date" id="canned_date" value="<?= escapeHtml(is_string($_GET['canned_date'] ?? null) ? $_GET['canned_date'] : '') ?>">
|
||||
<input type="hidden" name="dtf" id="dtf" value="<?= escapeHtml($dtf ?? '') ?>">
|
||||
<input type="hidden" name="dtt" id="dtt" value="<?= escapeHtml($dtt ?? '') ?>">
|
||||
|
||||
@@ -98,6 +98,8 @@ define('FROM_CLIENT_ONBOARDING', true);
|
||||
<link rel="stylesheet" href="<?= staticFileUrl('/libs/sweetalert2/css/sweetalert2.min.css') ?>">
|
||||
<link rel="stylesheet" href="<?= staticFileUrl('/libs/intl-tel-input/css/intlTelInput.min.css') ?>">
|
||||
<link rel="stylesheet" href="<?= staticFileUrl('/css/itflow_custom.css') ?>">
|
||||
<!-- "- Anyone -" choices without their dashes from the first paint (js/itflow_select_early.js) -->
|
||||
<script src="<?= staticFileUrl('/js/itflow_select_early.js') ?>"></script>
|
||||
</head>
|
||||
|
||||
<body class="itflow-setup itflow-gs itflow-co bg-body-tertiary" data-itflow-phone-country="<?= escapeHtml($country_iso2_array[$session_company_country] ?? '') ?>">
|
||||
|
||||
@@ -500,7 +500,7 @@ $total_leads = intval($row['leads']);
|
||||
<?php } ?>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Created</label>
|
||||
<input type="text" id="dateFilter" class="form-control" autocomplete="off">
|
||||
<input type="text" id="dateFilter" value="<?= escapeHtml(dateFilterLabel($dtf ?? '', $dtt ?? '')) ?>" class="form-control" autocomplete="off">
|
||||
<input type="hidden" name="canned_date" id="canned_date" value="<?= escapeHtml($_GET['canned_date'] ?? '') ?>">
|
||||
<input type="hidden" name="dtf" id="dtf" value="<?= escapeHtml($dtf ?? '') ?>">
|
||||
<input type="hidden" name="dtt" id="dtt" value="<?= escapeHtml($dtt ?? '') ?>">
|
||||
|
||||
@@ -193,7 +193,7 @@ $month_change = $stats['last_to_date'] > 0 ? round(($stats['month'] - $stats['la
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-6">
|
||||
<input type="text" id="dateFilter" class="form-control" autocomplete="off" title="Date paid" aria-label="Date paid">
|
||||
<input type="text" id="dateFilter" value="<?= escapeHtml(dateFilterLabel($dtf ?? '', $dtt ?? '')) ?>" class="form-control" autocomplete="off" title="Date paid" aria-label="Date paid">
|
||||
<input type="hidden" name="canned_date" id="canned_date" value="<?= escapeHtml($_GET['canned_date'] ?? '') ?>">
|
||||
<input type="hidden" name="dtf" id="dtf" value="<?= escapeHtml($dtf ?? '') ?>">
|
||||
<input type="hidden" name="dtt" id="dtt" value="<?= escapeHtml($dtt ?? '') ?>">
|
||||
|
||||
@@ -192,7 +192,7 @@ $invoices_url = 'invoices.php?' . ($client_page ? "client_id=$client_id&" : '')
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-6">
|
||||
<input type="text" id="dateFilter" class="form-control" autocomplete="off" title="Date it came in" aria-label="Date it came in">
|
||||
<input type="text" id="dateFilter" value="<?= escapeHtml(dateFilterLabel($dtf ?? '', $dtt ?? '')) ?>" class="form-control" autocomplete="off" title="Date it came in" aria-label="Date it came in">
|
||||
<input type="hidden" name="canned_date" id="canned_date" value="<?= escapeHtml($_GET['canned_date'] ?? '') ?>">
|
||||
<input type="hidden" name="dtf" id="dtf" value="<?= escapeHtml($dtf ?? '') ?>">
|
||||
<input type="hidden" name="dtt" id="dtt" value="<?= escapeHtml($dtt ?? '') ?>">
|
||||
|
||||
@@ -247,7 +247,7 @@ $stat_money = function ($amount) use ($session_company_currency) {
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-6">
|
||||
<input type="text" id="dateFilter" class="form-control" autocomplete="off" title="Invoice date" aria-label="Invoice date">
|
||||
<input type="text" id="dateFilter" value="<?= escapeHtml(dateFilterLabel($dtf ?? '', $dtt ?? '')) ?>" class="form-control" autocomplete="off" title="Invoice date" aria-label="Invoice date">
|
||||
<input type="hidden" name="canned_date" id="canned_date" value="<?= escapeHtml($_GET['canned_date'] ?? '') ?>">
|
||||
<input type="hidden" name="dtf" id="dtf" value="<?= escapeHtml($dtf ?? '') ?>">
|
||||
<input type="hidden" name="dtt" id="dtt" value="<?= escapeHtml($dtt ?? '') ?>">
|
||||
|
||||
@@ -115,7 +115,7 @@ $empty_state_skip = true;
|
||||
<div class="row g-3">
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Date range</label>
|
||||
<input type="text" id="dateFilter" class="form-control" autocomplete="off">
|
||||
<input type="text" id="dateFilter" value="<?= escapeHtml(dateFilterLabel($dtf ?? '', $dtt ?? '')) ?>" class="form-control" autocomplete="off">
|
||||
<input type="hidden" name="canned_date" id="canned_date" value="<?= escapeHtml($_GET['canned_date'] ?? '') ?>">
|
||||
<input type="hidden" name="dtf" id="dtf" value="<?= escapeHtml($dtf ?? '') ?>">
|
||||
<input type="hidden" name="dtt" id="dtt" value="<?= escapeHtml($dtt ?? '') ?>">
|
||||
|
||||
@@ -260,7 +260,7 @@ $hidden_filter_count = $date_filter_active ? 1 : 0;
|
||||
<div class="row g-2 mt-1">
|
||||
<div class="col-lg-3 col-md-6">
|
||||
<label class="form-label small text-body-secondary mb-1">Created</label>
|
||||
<input type="text" id="dateFilter" class="form-control" autocomplete="off" placeholder="Any time">
|
||||
<input type="text" id="dateFilter" value="<?= escapeHtml(dateFilterLabel($date_filter_active ? $dtf : '', $date_filter_active ? $dtt : '')) ?>" class="form-control" autocomplete="off" placeholder="Any time">
|
||||
<input type="hidden" name="canned_date" id="canned_date" value="<?= escapeHtml($_GET['canned_date'] ?? '') ?>">
|
||||
<input type="hidden" name="dtf" id="dtf" value="<?= escapeHtml($date_filter_active ? $dtf : '') ?>">
|
||||
<input type="hidden" name="dtt" id="dtt" value="<?= escapeHtml($date_filter_active ? $dtt : '') ?>">
|
||||
|
||||
@@ -189,7 +189,7 @@ $stat_monthly = function ($amount) use ($stat_money) {
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-6">
|
||||
<input type="text" id="dateFilter" class="form-control" autocomplete="off" title="Quote date" aria-label="Quote date">
|
||||
<input type="text" id="dateFilter" value="<?= escapeHtml(dateFilterLabel($dtf ?? '', $dtt ?? '')) ?>" class="form-control" autocomplete="off" title="Quote date" aria-label="Quote date">
|
||||
<input type="hidden" name="canned_date" id="canned_date" value="<?= escapeHtml($_GET['canned_date'] ?? '') ?>">
|
||||
<input type="hidden" name="dtf" id="dtf" value="<?= escapeHtml($dtf ?? '') ?>">
|
||||
<input type="hidden" name="dtt" id="dtt" value="<?= escapeHtml($dtt ?? '') ?>">
|
||||
|
||||
@@ -502,7 +502,7 @@ $export_extra = [
|
||||
<?php } ?>
|
||||
<div class="col-lg-3 col-md-6">
|
||||
<label class="form-label small text-body-secondary mb-1">Created</label>
|
||||
<input type="text" id="dateFilter" class="form-control" autocomplete="off" placeholder="Any time">
|
||||
<input type="text" id="dateFilter" value="<?= escapeHtml(dateFilterLabel($dtf ?? '', $dtt ?? '')) ?>" class="form-control" autocomplete="off" placeholder="Any time">
|
||||
<input type="hidden" name="canned_date" id="canned_date" value="<?= escapeHtml($_GET['canned_date'] ?? '') ?>">
|
||||
<input type="hidden" name="dtf" id="dtf" value="<?= escapeHtml($dtf ?? '') ?>">
|
||||
<input type="hidden" name="dtt" id="dtt" value="<?= escapeHtml($dtt ?? '') ?>">
|
||||
|
||||
@@ -291,7 +291,7 @@ $is_card = $account && $account['type'] === 3;
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-4">
|
||||
<input type="text" id="dateFilter" class="form-control" autocomplete="off" title="Date" aria-label="Date">
|
||||
<input type="text" id="dateFilter" value="<?= escapeHtml(dateFilterLabel($dtf ?? '', $dtt ?? '')) ?>" class="form-control" autocomplete="off" title="Date" aria-label="Date">
|
||||
<input type="hidden" name="canned_date" id="canned_date" value="<?= escapeHtml($_GET['canned_date'] ?? '') ?>">
|
||||
<input type="hidden" name="dtf" id="dtf" value="<?= escapeHtml($dtf ?? '') ?>">
|
||||
<input type="hidden" name="dtt" id="dtt" value="<?= escapeHtml($dtt ?? '') ?>">
|
||||
|
||||
@@ -214,7 +214,7 @@ $add_url = 'modals/trip/trip_add.php' . ($client_page ? "?client_id=$client_id"
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-6">
|
||||
<input type="text" id="dateFilter" class="form-control" autocomplete="off" title="Date of the trip" aria-label="Date of the trip">
|
||||
<input type="text" id="dateFilter" value="<?= escapeHtml(dateFilterLabel($dtf ?? '', $dtt ?? '')) ?>" class="form-control" autocomplete="off" title="Date of the trip" aria-label="Date of the trip">
|
||||
<input type="hidden" name="canned_date" id="canned_date" value="<?= escapeHtml($_GET['canned_date'] ?? '') ?>">
|
||||
<input type="hidden" name="dtf" id="dtf" value="<?= escapeHtml($dtf ?? '') ?>">
|
||||
<input type="hidden" name="dtt" id="dtt" value="<?= escapeHtml($dtt ?? '') ?>">
|
||||
|
||||
@@ -110,7 +110,7 @@ $view_empty = [
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-5">
|
||||
<input type="text" id="dateFilter" class="form-control" autocomplete="off" title="When" aria-label="When">
|
||||
<input type="text" id="dateFilter" value="<?= escapeHtml(dateFilterLabel($dtf ?? '', $dtt ?? '')) ?>" class="form-control" autocomplete="off" title="When" aria-label="When">
|
||||
<input type="hidden" name="canned_date" id="canned_date" value="<?= escapeHtml(is_string($_GET['canned_date'] ?? null) ? $_GET['canned_date'] : '') ?>">
|
||||
<input type="hidden" name="dtf" id="dtf" value="<?= escapeHtml($dtf ?? '') ?>">
|
||||
<input type="hidden" name="dtt" id="dtt" value="<?= escapeHtml($dtt ?? '') ?>">
|
||||
|
||||
@@ -92,6 +92,8 @@ $portal_contact_name = (string) ($contact['contact_name'] ?? '');
|
||||
<link rel="stylesheet" href="<?= staticFileUrl('/libs/intl-tel-input/css/intlTelInput.min.css') ?>">
|
||||
<?php } ?>
|
||||
|
||||
<!-- "- Anyone -" choices without their dashes from the first paint (js/itflow_select_early.js) -->
|
||||
<script src="<?= staticFileUrl('/js/itflow_select_early.js') ?>"></script>
|
||||
</head>
|
||||
|
||||
<?php /* Same country bridge as the agent header: intl-tel-input wants an ISO2
|
||||
|
||||
@@ -1119,6 +1119,13 @@ select.select2[multiple]:not(.itflow-select-native) {
|
||||
@keyframes itflowRevealUninitSelect {
|
||||
to { visibility: visible; }
|
||||
}
|
||||
/* A single one showing its "nothing" choice - "Anyone", its dashes already taken off by
|
||||
js/itflow_select_early.js - is in the quieter colour the picker gives it, so nothing about
|
||||
it changes when the picker takes over */
|
||||
select.select2:not([multiple]):not(.itflow-select-native):has(option:checked[data-none="1"]),
|
||||
select.select2:not([multiple]):not(.itflow-select-native):has(option:checked[value=""]) {
|
||||
color: var(--bs-secondary-color);
|
||||
}
|
||||
|
||||
.itflow-select {
|
||||
position: relative;
|
||||
|
||||
@@ -509,6 +509,24 @@ function validateDate($date) {
|
||||
return date('Y-m-d'); // Fallback
|
||||
}
|
||||
|
||||
/**
|
||||
* What a list's date filter box (#dateFilter, js/date_filter.js) says for the range in its
|
||||
* hidden dtf and dtt fields - "All Time", or "2026-11-01 — 2026-11-21". Written into the box by
|
||||
* the page, so it isn't empty until the script fills in the same words. Worked out the way the
|
||||
* script does: a date that isn't one is no bound, and 1970-01-01 to 2099-12-31 is All Time.
|
||||
*/
|
||||
function dateFilterLabel($dtf, $dtt) {
|
||||
$day = function ($value, $fallback) {
|
||||
if (!preg_match('/^(\d+)-(\d+)-(\d+)$/', trim((string) $value), $m)) {
|
||||
return $fallback;
|
||||
}
|
||||
return date('Y-m-d', mktime(0, 0, 0, intval($m[2]), intval($m[3]), intval($m[1])));
|
||||
};
|
||||
$from = $day($dtf, '1970-01-01');
|
||||
$to = $day($dtt, '2099-12-31');
|
||||
return $from === '1970-01-01' && $to === '2099-12-31' ? 'All Time' : "$from \u{2014} $to";
|
||||
}
|
||||
|
||||
/*
|
||||
* Validates a recurring invoice frequency against the values the UI offers -
|
||||
* month, quarter and year, each also a MySQL interval unit. A whitelist is the
|
||||
|
||||
@@ -48,6 +48,10 @@ header("X-Frame-Options: DENY");
|
||||
footer.php is what actually loads it. */ ?>
|
||||
<link rel="preload" as="script" href="<?= staticFileUrl('/js/itflow_select.js') ?>">
|
||||
|
||||
<?php /* Takes the dashes off "- Anyone -" choices as the page is read, so the plain <select>
|
||||
painted before the picker runs already says "Anyone" (js/itflow_select_early.js) */ ?>
|
||||
<script src="<?= staticFileUrl('/js/itflow_select_early.js') ?>"></script>
|
||||
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="<?= staticFileUrl('/libs/fontawesome-free/css/all.min.css') ?>">
|
||||
|
||||
|
||||
@@ -137,6 +137,12 @@
|
||||
// first click starts a fresh selection.
|
||||
var allTimeActive = initialKey === ALL_TIME_START + '|' + ALL_TIME_END;
|
||||
|
||||
// The page wrote the words in the box already (dateFilterLabel() in functions/format.php),
|
||||
// so it isn't empty until this runs. Flatpickr would try to read them as dates, so the box
|
||||
// is emptied for it here - setDisplay() at the end puts the same words back in this same
|
||||
// step, before the browser draws again, so nothing is seen to change.
|
||||
input.value = '';
|
||||
|
||||
flatpickr(input, {
|
||||
mode: 'range',
|
||||
dateFormat: 'Y-m-d',
|
||||
|
||||
@@ -46,7 +46,10 @@
|
||||
*
|
||||
* functions/format.php has PHP helpers that write these for clients, users,
|
||||
* contacts, tags and categories. Labels written as "- Unassigned -" show
|
||||
* without the dashes, in a quieter colour, as the "nothing" choice.
|
||||
* without the dashes, in a quieter colour, as the "nothing" choice. On the
|
||||
* page as it first loads, js/itflow_select_early.js has already taken the
|
||||
* dashes off and marked the option data-none="1", so the plain <select> the
|
||||
* browser paints before this runs shows the same label.
|
||||
*
|
||||
* ON THE <select>:
|
||||
*
|
||||
@@ -191,7 +194,7 @@
|
||||
option: option,
|
||||
value: option.value,
|
||||
label: none ? none[1] : raw,
|
||||
none: !!none || option.value === '',
|
||||
none: !!none || option.value === '' || data.none === '1',
|
||||
description: data.description || '',
|
||||
icon: icon && icon.indexOf('fa-') === -1 ? 'fas fa-' + icon : icon,
|
||||
image: data.image || '',
|
||||
@@ -398,11 +401,12 @@
|
||||
return this.multiple ? 'Choose' : 'Select';
|
||||
};
|
||||
|
||||
/* The option that means "nothing" - an empty value, or a "- None -" label. */
|
||||
/* The option that means "nothing" - an empty value, or a "- None -" label (data-none="1" once
|
||||
js/itflow_select_early.js has taken its dashes off). */
|
||||
Picker.prototype.noneOption = function () {
|
||||
var options = this.select.options;
|
||||
for (var i = 0; i < options.length; i++) {
|
||||
if (options[i].value === '' || NONE_LABEL.test(options[i].label || options[i].textContent || '')) {
|
||||
if (options[i].value === '' || options[i].dataset.none === '1' || NONE_LABEL.test(options[i].label || options[i].textContent || '')) {
|
||||
return options[i];
|
||||
}
|
||||
}
|
||||
@@ -418,7 +422,7 @@
|
||||
}
|
||||
var none = this.noneOption();
|
||||
var chosen = this.select.selectedOptions[0];
|
||||
return !!(none && chosen && chosen !== none && !NONE_LABEL.test(chosen.label || ''));
|
||||
return !!(none && chosen && chosen !== none && chosen.dataset.none !== '1' && !NONE_LABEL.test(chosen.label || ''));
|
||||
};
|
||||
|
||||
Picker.prototype.chosen = function () {
|
||||
|
||||
62
js/itflow_select_early.js
Normal file
62
js/itflow_select_early.js
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* ITFlow select, before it runs - loaded in the <head>, ahead of everything on the page.
|
||||
*
|
||||
* js/itflow_select.js draws every <select class="select2">, but it loads at the end of the page,
|
||||
* so the browser first paints the plain <select> it has read so far. A "nothing" choice written
|
||||
* "- Anyone -" showed with its dashes for that moment, then as "Anyone" once the picker drew it.
|
||||
* This takes the dashes off those labels as the page is read, before anything is painted, and
|
||||
* marks the option (data-none="1") so the picker still knows it is the "nothing" choice. Its
|
||||
* quieter colour comes from css/itflow_custom.css. It stops once the page has been read - a
|
||||
* select added later is drawn by the picker straight away, so it never shows the dashes.
|
||||
*
|
||||
* A file rather than an inline script: the client portal's pages allow no inline scripts.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var NONE_LABEL = /^\s*-\s*(.*?)\s*-\s*$/;
|
||||
|
||||
function tidy(option) {
|
||||
if (!option || option.tagName !== 'OPTION' || option.dataset.none === '1' || option.hasAttribute('label')) {
|
||||
return;
|
||||
}
|
||||
var select = option.closest('select');
|
||||
if (!select || !select.classList.contains('select2')) {
|
||||
return;
|
||||
}
|
||||
var none = NONE_LABEL.exec(option.textContent || '');
|
||||
if (none && none[1] !== '') {
|
||||
option.dataset.none = '1';
|
||||
option.textContent = none[1];
|
||||
}
|
||||
}
|
||||
|
||||
// As the parser adds each option, and the text inside it - in one piece or several
|
||||
var watcher = new MutationObserver(function (records) {
|
||||
records.forEach(function (record) {
|
||||
if (record.type === 'characterData') {
|
||||
tidy(record.target.parentNode);
|
||||
return;
|
||||
}
|
||||
tidy(record.target);
|
||||
record.addedNodes.forEach(function (node) {
|
||||
if (node.nodeType !== 1) {
|
||||
return;
|
||||
}
|
||||
if (node.tagName === 'OPTION') {
|
||||
tidy(node);
|
||||
} else if (node.firstElementChild) {
|
||||
// Added with its insides already there - by a script, not the parser
|
||||
node.querySelectorAll('select.select2 option').forEach(tidy);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
watcher.observe(document.documentElement, { childList: true, subtree: true, characterData: true });
|
||||
|
||||
// Once the page has been read: one last look, then stop
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
watcher.disconnect();
|
||||
document.querySelectorAll('select.select2 option').forEach(tidy);
|
||||
});
|
||||
})();
|
||||
@@ -545,6 +545,8 @@ $setup_title = ['restore' => 'Restore a backup', 'restored' => 'Backup restored'
|
||||
<link rel="stylesheet" href="<?= staticFileUrl('/libs/intl-tel-input/css/intlTelInput.min.css') ?>">
|
||||
<?php } ?>
|
||||
<link rel="stylesheet" href="<?= staticFileUrl('/css/itflow_custom.css') ?>">
|
||||
<!-- "- Anyone -" choices without their dashes from the first paint (js/itflow_select_early.js) -->
|
||||
<script src="<?= staticFileUrl('/js/itflow_select_early.js') ?>"></script>
|
||||
</head>
|
||||
|
||||
<body class="itflow-setup bg-body-tertiary">
|
||||
|
||||
Reference in New Issue
Block a user