@7365admin1/layer-common 4.97.1-staging.714 → 4.97.1-staging.716
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -614,6 +614,25 @@ button.app-btn--err {
|
|
|
614
614
|
border-color: var(--accent);
|
|
615
615
|
}
|
|
616
616
|
|
|
617
|
+
/* IMP-1440: a field whose value is refused (e.g. a From after its To). Kept
|
|
618
|
+
red while focused too, so the state does not vanish under the cursor. */
|
|
619
|
+
.app-field--error,
|
|
620
|
+
.app-field--error:focus-within {
|
|
621
|
+
border-color: var(--err);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
.app-field--error .app-field__icon {
|
|
625
|
+
color: var(--err);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/* The sentence for a refused field, set beside it in a filter row. */
|
|
629
|
+
.app-field-error {
|
|
630
|
+
color: var(--err);
|
|
631
|
+
font-size: 13px;
|
|
632
|
+
font-weight: 600;
|
|
633
|
+
line-height: 1.4;
|
|
634
|
+
}
|
|
635
|
+
|
|
617
636
|
.app-field__label {
|
|
618
637
|
font-size: 13px;
|
|
619
638
|
font-weight: 600;
|
|
@@ -5,9 +5,18 @@
|
|
|
5
5
|
ends of a filter row. `<input type="date">` - the browser's own picker, which
|
|
6
6
|
is the one a phone user already knows and the one that is localised, keyboard
|
|
7
7
|
accessible and free.
|
|
8
|
+
|
|
9
|
+
`error` (IMP-1440) draws the box in the error colour and marks the input
|
|
10
|
+
invalid. The sentence itself is the caller's to place (a filter row shows it
|
|
11
|
+
beside the dates, `.app-field-error`), so the 40px box never grows a line.
|
|
8
12
|
-->
|
|
9
13
|
<template>
|
|
10
|
-
<label
|
|
14
|
+
<label
|
|
15
|
+
v-bind="rootAttrs"
|
|
16
|
+
class="app-field"
|
|
17
|
+
:class="{ 'app-field--compact': compact, 'app-field--error': !!error }"
|
|
18
|
+
:title="typeof error === 'string' && error ? error : undefined"
|
|
19
|
+
>
|
|
11
20
|
<v-icon class="app-field__icon" icon="mdi-calendar-month-outline" size="17" />
|
|
12
21
|
<span v-if="label" class="app-field__label">{{ label }}</span>
|
|
13
22
|
<input
|
|
@@ -18,6 +27,7 @@
|
|
|
18
27
|
:min="min || undefined"
|
|
19
28
|
:max="max || undefined"
|
|
20
29
|
:disabled="disabled"
|
|
30
|
+
:aria-invalid="error ? 'true' : undefined"
|
|
21
31
|
@input="model = ($event.target as HTMLInputElement).value"
|
|
22
32
|
/>
|
|
23
33
|
</label>
|
|
@@ -45,5 +55,7 @@ defineProps({
|
|
|
45
55
|
max: { type: String, default: "" },
|
|
46
56
|
compact: { type: Boolean, default: false },
|
|
47
57
|
disabled: { type: Boolean, default: false },
|
|
58
|
+
/** true, or the sentence saying what is wrong (also the box's tooltip). */
|
|
59
|
+
error: { type: [Boolean, String], default: false },
|
|
48
60
|
});
|
|
49
61
|
</script>
|
|
@@ -123,16 +123,22 @@
|
|
|
123
123
|
<span class="text-caption">Not Checked Out</span>
|
|
124
124
|
</template>
|
|
125
125
|
</v-checkbox>
|
|
126
|
+
<!-- IMP-1440: a From after its To is not sent - both boxes turn
|
|
127
|
+
red, the To box says why, and the list keeps its rows. -->
|
|
126
128
|
<InputDatePicker
|
|
127
129
|
v-model="dateFrom"
|
|
128
130
|
density="compact"
|
|
129
131
|
hide-details
|
|
132
|
+
aria-label="Date from"
|
|
133
|
+
:error="!!dateRangeProblem"
|
|
130
134
|
:max="todayOnly ? sgToday : undefined"
|
|
131
135
|
/>
|
|
132
136
|
<InputDatePicker
|
|
133
137
|
v-model="dateTo"
|
|
134
138
|
density="compact"
|
|
135
|
-
hide-details
|
|
139
|
+
hide-details="auto"
|
|
140
|
+
aria-label="Date to"
|
|
141
|
+
:error-messages="dateRangeProblem ? [dateRangeProblem] : []"
|
|
136
142
|
:max="todayOnly ? sgToday : undefined"
|
|
137
143
|
/>
|
|
138
144
|
<!-- iSecure: every tab but Unregistered; the Guests tab offers
|
|
@@ -1918,6 +1924,7 @@ import { barrierCameraOf, barrierMessage, barrierOf, VISITOR_ACTION_SUCCESS } fr
|
|
|
1918
1924
|
import useVisitorCameraChoices from "../composables/useVisitorCameraChoices";
|
|
1919
1925
|
import { VISITOR_CAMERA_LABEL } from "../utils/visitor-camera";
|
|
1920
1926
|
import { notAfterToday, sgDateOf, type VisitorDateDefault } from "../utils/visitor-date-default";
|
|
1927
|
+
import { dateRangeError } from "../utils/date-range";
|
|
1921
1928
|
import usePassKey from "../composables/usePassKey";
|
|
1922
1929
|
import {
|
|
1923
1930
|
VISITOR_SEARCH_DEBOUNCE_MS,
|
|
@@ -2299,6 +2306,8 @@ const defaultDateFrom = () =>
|
|
|
2299
2306
|
|
|
2300
2307
|
const dateTo = ref(defaultDateTo());
|
|
2301
2308
|
const dateFrom = ref(defaultDateFrom());
|
|
2309
|
+
/** IMP-1440: "" while the range can be fetched, else the sentence shown under To. */
|
|
2310
|
+
const dateRangeProblem = computed(() => dateRangeError(dateFrom.value, dateTo.value));
|
|
2302
2311
|
|
|
2303
2312
|
function sgDayStart(day: string) {
|
|
2304
2313
|
return day ? new Date(`${day}T00:00:00+08:00`).toISOString() : undefined;
|
|
@@ -3091,6 +3100,9 @@ const {
|
|
|
3091
3100
|
} = await useLazyAsyncData(
|
|
3092
3101
|
"get-all-visitors",
|
|
3093
3102
|
async () => {
|
|
3103
|
+
// IMP-1440: a From after its To is not applied. `null` leaves the rows on
|
|
3104
|
+
// screen as they are (the watcher below only takes a real answer).
|
|
3105
|
+
if (dateRangeProblem.value) return null;
|
|
3094
3106
|
const params: any = {
|
|
3095
3107
|
page: page.value,
|
|
3096
3108
|
site: siteId,
|
|
@@ -4096,6 +4108,7 @@ function buildReportParams(): any {
|
|
|
4096
4108
|
}
|
|
4097
4109
|
|
|
4098
4110
|
async function handleDownloadPDFReport() {
|
|
4111
|
+
if (dateRangeProblem.value) return showMessage(dateRangeProblem.value, "error");
|
|
4099
4112
|
try {
|
|
4100
4113
|
showMessage("Generating PDF report...", "info");
|
|
4101
4114
|
|
|
@@ -4125,6 +4138,7 @@ async function handleDownloadPDFReport() {
|
|
|
4125
4138
|
}
|
|
4126
4139
|
|
|
4127
4140
|
async function handleDownloadCSVReport() {
|
|
4141
|
+
if (dateRangeProblem.value) return showMessage(dateRangeProblem.value, "error");
|
|
4128
4142
|
try {
|
|
4129
4143
|
showMessage("Generating CSV report...", "info");
|
|
4130
4144
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@7365admin1/layer-common",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "4.97.1-staging.
|
|
5
|
+
"version": "4.97.1-staging.716",
|
|
6
6
|
"author": "7365admin1",
|
|
7
7
|
"main": "./nuxt.config.ts",
|
|
8
8
|
"//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A list's From / To date filter (IMP-1440).
|
|
3
|
+
*
|
|
4
|
+
* A From later than its To used to be sent as it was: the server found nothing
|
|
5
|
+
* between them and the list just went empty, with no word why. Every list that
|
|
6
|
+
* filters by a day range asks this first and, when it answers, shows the
|
|
7
|
+
* sentence and keeps the rows it already has instead of fetching.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const DATE_RANGE_ERROR = "The 'To' date must be on or after the 'From' date.";
|
|
11
|
+
|
|
12
|
+
const pad2 = (value: number) => String(value).padStart(2, "0");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The calendar day a filter value names, "YYYY-MM-DD", or "" when it names none.
|
|
16
|
+
* A "YYYY-MM-DD…" string is read as written (no time zone shift); a Date is read
|
|
17
|
+
* as the day it is on this device, as the date pickers show it.
|
|
18
|
+
*/
|
|
19
|
+
export function rangeDay(value: unknown): string {
|
|
20
|
+
if (!value) return "";
|
|
21
|
+
if (typeof value === "string") {
|
|
22
|
+
const match = /^(\d{4}-\d{2}-\d{2})/.exec(value.trim());
|
|
23
|
+
if (match) return match[1];
|
|
24
|
+
}
|
|
25
|
+
const date = value instanceof Date ? value : new Date(value as string | number);
|
|
26
|
+
if (isNaN(date.getTime())) return "";
|
|
27
|
+
return `${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The plain-words problem with a From / To pair, or "" when the list may be
|
|
32
|
+
* fetched. The same day at both ends is a valid one-day range; a missing end is
|
|
33
|
+
* left to the caller's own default.
|
|
34
|
+
*/
|
|
35
|
+
export function dateRangeError(from: unknown, to: unknown): string {
|
|
36
|
+
const start = rangeDay(from);
|
|
37
|
+
const end = rangeDay(to);
|
|
38
|
+
if (!start || !end) return "";
|
|
39
|
+
return start > end ? DATE_RANGE_ERROR : "";
|
|
40
|
+
}
|