@7365admin1/layer-common 4.97.1-staging.705 → 4.97.1-staging.707

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.
@@ -287,11 +287,15 @@
287
287
  "No sticker" adds the vehicle alone. With several plates the
288
288
  sticker goes on the first plate, as Link QR sticker does per plate.
289
289
  -->
290
- <div v-if="prop.qrLink && qrPickItems.length > 1" class="w-100 mt-3">
290
+ <div v-if="prop.qrLink && qrPickerOn" class="w-100 mt-3">
291
291
  <InputLabel title="QR sticker" />
292
292
  <v-autocomplete
293
293
  v-model="qrPick"
294
+ v-model:search="qrPickSearch"
294
295
  :items="qrPickItems"
296
+ no-filter
297
+ placeholder="Type a sticker number, e.g. TLR120 or 120"
298
+ @focus="selectQrPickText"
295
299
  density="comfortable"
296
300
  :hint="newPlateNumbers.filter(Boolean).length > 1 ? 'Linked to the first plate number above.' : 'Type a sticker number to find it.'"
297
301
  persistent-hint
@@ -595,16 +599,53 @@ const {
595
599
  */
596
600
  const qrPicks = ref<BlankPick[]>([]);
597
601
  const qrPick = ref("");
598
- const qrPickItems = computed(() => [
599
- ...qrPicks.value.map((p) => ({ title: blankPickLabel(p), value: p.code })),
600
- { title: "No sticker", value: "" },
601
- ]);
602
+ // the picked sticker stays listed while a search shows other numbers
603
+ const qrPicked = ref<BlankPick | null>(null);
604
+ const qrPickSearch = ref("");
605
+ const qrPickItems = computed(() => {
606
+ const list = qrPicked.value && !qrPicks.value.some((p) => p.code === qrPicked.value!.code)
607
+ ? [qrPicked.value, ...qrPicks.value]
608
+ : qrPicks.value;
609
+ return [...list.map((p) => ({ title: blankPickLabel(p), value: p.code })), { title: "No sticker", value: "" }];
610
+ });
611
+ watch(qrPick, (code) => {
612
+ qrPicked.value = [qrPicked.value, ...qrPicks.value].find((p) => p?.code === code) ?? null;
613
+ });
614
+ // shown when the site has any free sticker - a search with no match keeps it open
615
+ const qrPickerOn = ref(false);
616
+ /*
617
+ * Search the site's whole list on the server as the person types (owner
618
+ * 2026-11-17: a site can hold hundreds of blank stickers; the first 50 alone
619
+ * could not find TLR120).
620
+ */
621
+ // only the latest search may fill the list - a slower earlier answer is dropped
622
+ let qrPickAsked = 0;
623
+ async function loadQrPicks(search = "") {
624
+ const asked = ++qrPickAsked;
625
+ const res = await getBlankStickersBySerial(prop.site, { search, limit: 50 });
626
+ if (asked === qrPickAsked) qrPicks.value = res.items;
627
+ return res;
628
+ }
629
+ // clicking the field selects the picked sticker's text, so typing replaces it
630
+ function selectQrPickText(e: FocusEvent) {
631
+ const input = e.target as HTMLInputElement | null;
632
+ if (input?.select) setTimeout(() => input.select(), 0);
633
+ }
634
+ let qrPickTimer: ReturnType<typeof setTimeout> | undefined;
635
+ watch(qrPickSearch, (v) => {
636
+ clearTimeout(qrPickTimer);
637
+ const text = String(v ?? "");
638
+ // picking a line puts its label in the search text - that is not a search
639
+ if (qrPickItems.value.some((i) => i.title === text)) return;
640
+ qrPickTimer = setTimeout(() => loadQrPicks(text).catch(() => {}), 250);
641
+ });
602
642
  onMounted(async () => {
603
643
  if (!prop.qrLink || prop.mode !== "add") return;
604
644
  try {
605
- const res = await getBlankStickersBySerial(prop.site, { limit: 50 });
606
- qrPicks.value = res.items;
645
+ const res = await loadQrPicks();
646
+ qrPickerOn.value = res.items.length > 0;
607
647
  qrPick.value = res.next?.code ?? "";
648
+ qrPicked.value = res.next ?? null;
608
649
  } catch {
609
650
  qrPicks.value = []; // ponytail: no list, no picker - the vehicle still adds
610
651
  }
@@ -615,7 +656,7 @@ async function linkPickedSticker(plates: string[]): Promise<{ text: string; ok:
615
656
  const code = qrPick.value;
616
657
  const plate = plates[0];
617
658
  if (!code || !plate) return { text: "", ok: true };
618
- const label = blankPickLabel(qrPicks.value.find((p) => p.code === code) ?? { token: code, code });
659
+ const label = blankPickLabel(qrPicked.value?.code === code ? qrPicked.value : qrPicks.value.find((p) => p.code === code) ?? { token: code, code });
619
660
  try {
620
661
  const found = await checkExistingPlates({ site: prop.site, plateNumbers: [plate] });
621
662
  const key = (v: unknown) => String(v ?? "").replace(/[^A-Za-z0-9]/g, "").toUpperCase();
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.705",
5
+ "version": "4.97.1-staging.707",
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.",