@7365admin1/layer-common 4.97.1-staging.610 → 4.97.1-staging.612

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.
@@ -45,9 +45,7 @@
45
45
  @refresh="reload"
46
46
  @update:page="page = $event"
47
47
  >
48
- <!-- The action swaps with the tab, as it did in the old top bar. -->
49
- <!-- Contacts are reader objects, so adding one is the readers right.
50
- The web call is a member level call and stays for everyone. -->
48
+ <!-- Contacts are reader objects, so adding one is the readers right. -->
51
49
  <template #actions>
52
50
  <AppButton
53
51
  v-if="activeTab === 'contacts' && canManageHidReaders"
@@ -56,15 +54,6 @@
56
54
  >
57
55
  Add Contacts
58
56
  </AppButton>
59
- <AppButton
60
- v-else-if="activeTab !== 'contacts'"
61
- icon="mdi-phone-in-talk-outline"
62
- class="web-call-button"
63
- :class="webPhoneButtonClass"
64
- @click="openWebPhoneDialog()"
65
- >
66
- {{ webPhone.callState.value === 'incoming' ? 'Incoming Call' : 'Web Call' }}
67
- </AppButton>
68
57
  </template>
69
58
 
70
59
  <!-- Was `v-tabs`/`v-tab`, whose selected state is drawn from Vuetify's
@@ -588,13 +577,13 @@
588
577
  <v-card class="form-dialog contact-dialog" rounded="lg">
589
578
  <v-card-title class="dialog-title">{{ contactForm.id ? 'Edit Contact' : 'Add Contact' }}</v-card-title>
590
579
  <v-card-text class="dialog-body">
591
- <FieldLabel text="HID Reader" required />
580
+ <div class="field-label">HID Reader <span>*</span></div>
592
581
  <AppSelect
593
582
  v-model="contactForm.readerId"
594
583
  :items="readerOptions"
595
584
  :disabled="Boolean(contactForm.id)"
596
585
  />
597
- <FieldLabel text="Name" required />
586
+ <div class="field-label">Name <span>*</span></div>
598
587
  <!-- The name is picked from the site's SIP accounts (`hid-sip-accounts`)
599
588
  rather than typed, so a contact always names a person who holds an
600
589
  extension. The model stays the plain name string the reader stores,
@@ -617,7 +606,7 @@
617
606
  <p v-else-if="!sipAccountsLoading && !sipAccounts.length" class="field-hint">
618
607
  No SIP accounts on this site yet. An account is created the first time a user opens Web Call.
619
608
  </p>
620
- <FieldLabel text="Address" required />
609
+ <div class="field-label">Address <span>*</span></div>
621
610
  <!-- Always read-only: it shows the extension of the chosen SIP account
622
611
  and is never typed into. -->
623
612
  <AppField
@@ -626,6 +615,7 @@
626
615
  disabled
627
616
  />
628
617
  <p class="field-hint">{{ contactAddressHint }}</p>
618
+ <p v-if="contactError" class="field-hint field-hint--error contact-error" role="alert">{{ contactError }}</p>
629
619
  </v-card-text>
630
620
  <v-card-actions class="dialog-actions pa-0">
631
621
  <v-btn class="text-none action-cancel" variant="flat" height="44" @click="contactDialog = false">Cancel</v-btn>
@@ -787,6 +777,8 @@ const contactsLoaded = ref(false);
787
777
  const loading = ref(false);
788
778
  const saving = ref(false);
789
779
  const contactsSaving = ref(false);
780
+ /** Shown inside the contact dialog: a page message would sit behind its overlay. */
781
+ const contactError = ref("");
790
782
  const calling = ref(false);
791
783
  const hangingUp = ref(false);
792
784
  const search = ref("");
@@ -1055,12 +1047,6 @@ const visiblePageRows = computed(() =>
1055
1047
  : paginatedContacts.value
1056
1048
  );
1057
1049
 
1058
- /** The web-call button turns green when registered and amber on an incoming
1059
- call - the same two states the old `.web-call-button` modifiers drew. */
1060
- const webPhoneButtonClass = computed(() => ({
1061
- "is-connected": webPhone.isRegistered.value,
1062
- "has-incoming-call": webPhone.callState.value === "incoming",
1063
- }));
1064
1050
  const isPeerToPeerMode = computed(() => sipForm.operatingMode === "peer-to-peer");
1065
1051
 
1066
1052
  /**
@@ -1179,6 +1165,11 @@ watch([activeTab, search, statusFilter], () => {
1179
1165
  page.value = 1;
1180
1166
  });
1181
1167
 
1168
+ // A contact dialog error is about the values that were saved; changing them clears it.
1169
+ watch(() => [contactForm.readerId, contactForm.name], () => {
1170
+ contactError.value = "";
1171
+ });
1172
+
1182
1173
  watch(pages, () => {
1183
1174
  if (page.value > pages.value) page.value = pages.value;
1184
1175
  });
@@ -1682,6 +1673,7 @@ function openContactDialog(contact?: ContactRow) {
1682
1673
  const selectedReader = readers.value.find((reader) => reader._id === contactForm.readerId);
1683
1674
  contactForm.location = contact?.location === "N/A" ? "" : contact?.location || selectedReader?.location || "";
1684
1675
  contactForm.serverAddress = contact?.serverAddress === "N/A" ? "" : contact?.serverAddress || "";
1676
+ contactError.value = "";
1685
1677
  contactDialog.value = true;
1686
1678
  // Fetched on every open, not cached: an account is provisioned the first
1687
1679
  // time a user opens Web Call, so the list can grow between two dialogs.
@@ -1935,18 +1927,30 @@ async function savePjsip(readerId: string, payload: Record<string, string>, opti
1935
1927
  }
1936
1928
 
1937
1929
  async function saveContact() {
1930
+ contactError.value = "";
1938
1931
  if (!contactForm.readerId || !contactForm.name.trim() || !contactForm.serverAddress.trim()) {
1939
- showMessage("Please complete the required contact fields.", "warning");
1932
+ contactError.value = "Please complete the required contact fields.";
1940
1933
  return;
1941
1934
  }
1942
1935
 
1943
1936
  if (!isContactAddress(contactForm.serverAddress, isContactReaderPeerToPeer.value)) {
1944
- showMessage(
1945
- isContactReaderPeerToPeer.value
1946
- ? "Enter the contact's local IPv4 address for a Peer-to-Peer reader."
1947
- : "Enter a valid extension number or SIP address.",
1948
- "warning",
1949
- );
1937
+ contactError.value = isContactReaderPeerToPeer.value
1938
+ ? "Enter the contact's local IPv4 address for a Peer-to-Peer reader."
1939
+ : "Enter a valid extension number or SIP address.";
1940
+ return;
1941
+ }
1942
+
1943
+ // The reader accepts duplicates, so the same person or extension could be
1944
+ // listed twice on one reader. Edits skip the contact being edited.
1945
+ const name = contactForm.name.trim().toLowerCase();
1946
+ const number = contactForm.serverAddress.trim();
1947
+ const duplicate = contacts.value.find((contact) =>
1948
+ contact.readerId === contactForm.readerId
1949
+ && contact.id !== contactForm.id
1950
+ && (contact.name.trim().toLowerCase() === name || contact.serverAddress.trim() === number),
1951
+ );
1952
+ if (duplicate) {
1953
+ contactError.value = `${duplicate.name} is already a contact on this HID reader.`;
1950
1954
  return;
1951
1955
  }
1952
1956
 
@@ -1991,7 +1995,7 @@ async function saveContact() {
1991
1995
  await loadContacts();
1992
1996
  showMessage("Intercom contact saved.", "success");
1993
1997
  } catch (error: unknown) {
1994
- showMessage(getErrorMessage(error), "error");
1998
+ contactError.value = getErrorMessage(error);
1995
1999
  } finally {
1996
2000
  contactsSaving.value = false;
1997
2001
  }
@@ -2097,40 +2101,6 @@ function toNumber(value: unknown, fallback?: number) {
2097
2101
  }
2098
2102
  </script>
2099
2103
 
2100
- <script lang="ts">
2101
- export default {
2102
- components: {
2103
- FieldLabel: {
2104
- props: {
2105
- text: String,
2106
- required: Boolean,
2107
- },
2108
- template: `
2109
- <div class="field-label">{{ text }} <span v-if="required">*</span></div>
2110
- `,
2111
- },
2112
- ToggleField: {
2113
- props: {
2114
- modelValue: Boolean,
2115
- label: String,
2116
- },
2117
- emits: ["update:modelValue"],
2118
- template: `
2119
- <div class="toggle-field">
2120
- <span>{{ label }}</span>
2121
- <v-switch
2122
- :model-value="modelValue"
2123
- class="app-switch"
2124
- density="compact"
2125
- hide-details
2126
- @update:model-value="$emit('update:modelValue', $event)"
2127
- />
2128
- </div>
2129
- `,
2130
- },
2131
- },
2132
- };
2133
- </script>
2134
2104
 
2135
2105
  <style scoped>
2136
2106
  .hid-intercom-management {
@@ -2166,26 +2136,6 @@ export default {
2166
2136
  max-width: 320px;
2167
2137
  }
2168
2138
 
2169
- /*
2170
- The web-call button is the card's PRIMARY action, so its resting state is
2171
- `AppButton`'s own accent - it was a flat `#e5e7eb` grey, which read as
2172
- disabled next to every other screen's primary. Only the two STATE colours
2173
- are the screen's own, because the handoff draws no such states.
2174
- */
2175
- .web-call-button {
2176
- min-width: 160px;
2177
- }
2178
-
2179
- .web-call-button.is-connected {
2180
- background: var(--ok);
2181
- color: var(--on-accent-strong);
2182
- }
2183
-
2184
- .web-call-button.has-incoming-call {
2185
- background: var(--warn);
2186
- color: var(--on-accent-strong);
2187
- }
2188
-
2189
2139
 
2190
2140
 
2191
2141
 
@@ -2278,6 +2228,11 @@ export default {
2278
2228
  color: var(--err);
2279
2229
  }
2280
2230
 
2231
+ /* Set apart from the address hint above it, so it reads as the form's error. */
2232
+ .contact-error {
2233
+ margin-top: 12px;
2234
+ }
2235
+
2281
2236
  .sip-settings-dialog .field-label {
2282
2237
  margin-top: 14px;
2283
2238
  }
@@ -3043,10 +2998,6 @@ export default {
3043
2998
  max-width: none;
3044
2999
  }
3045
3000
 
3046
- .web-call-button {
3047
- width: 100%;
3048
- }
3049
-
3050
3001
  .web-phone-body {
3051
3002
  grid-template-columns: minmax(0, 1fr);
3052
3003
  min-height: 0;
@@ -61,6 +61,7 @@
61
61
  <v-chip size="small" variant="tonal" :color="qrStickerSummary(rowPlates(item)).color" data-test="vehicle-qr-cell">
62
62
  {{ qrStickerSummary(rowPlates(item)).label }}
63
63
  </v-chip>
64
+ <div v-for="n in qrStickerNumbers(rowPlates(item))" :key="n" class="text-caption" data-test="vehicle-qr-number">{{ n }}</div>
64
65
  <div v-for="plate in rowPlates(item).filter((p: any) => p.qrCode)" :key="plate._id ?? plate.plateNumber">
65
66
  <VehicleStickerCode :code="plate.qrCode" :label="rowPlates(item).length > 1 ? plate.plateNumber : ''" />
66
67
  </div>
@@ -484,7 +485,7 @@ import {
484
485
  // `error.message` put ofetch's own developer string in the delete dialog:
485
486
  // `[PUT] "/api/vehicles/6a9691f25648d7633171c9e3": 502`.
486
487
  import { errorConverter } from '../utils/data';
487
- import { BLANK_LIST_NOTE, UNDO_REISSUE_NOTE, blankSummaryText, qrStickerSummary, stickerCodeHint, type BlankSummary } from '../utils/vehicle-qr-blank';
488
+ import { BLANK_LIST_NOTE, UNDO_REISSUE_NOTE, blankSummaryText, qrStickerNumbers, qrStickerSummary, stickerCodeHint, type BlankSummary } from '../utils/vehicle-qr-blank';
488
489
  import { isPermissionRefusalError } from '../utils/permission-refusal';
489
490
 
490
491
 
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.610",
5
+ "version": "4.97.1-staging.612",
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.",
package/types/people.d.ts CHANGED
@@ -48,7 +48,7 @@ declare type TOccupancyRoleOption = {
48
48
  description: string;
49
49
  };
50
50
 
51
- declare type TPlateNumber = { plateNumber: string, recNo?: string, _id?: string, status: TVehicleStatus, type: TVehicleType, anprCameras?: TVehicleAnprCamera[], hasQrSticker?: boolean };
51
+ declare type TPlateNumber = { plateNumber: string, recNo?: string, _id?: string, status: TVehicleStatus, type: TVehicleType, anprCameras?: TVehicleAnprCamera[], hasQrSticker?: boolean, qrSerial?: number };
52
52
 
53
53
 
54
54
  // `""` is the FORM's "nothing picked yet" - it is stripped from the payload
@@ -94,6 +94,14 @@ export function qrStickerSummary(plates: Array<{ hasQrSticker?: boolean }>): { l
94
94
  return { label: `${linked} of ${total}`, color: "warning" };
95
95
  }
96
96
 
97
+ /** The list's sticker numbers for one row ("No. 5", or "SBA123A: No. 5" when the row has several plates). */
98
+ export function qrStickerNumbers(plates: Array<{ hasQrSticker?: boolean; qrSerial?: number; plateNumber?: string }>): string[] {
99
+ const many = plates.length > 1;
100
+ return plates
101
+ .filter((p) => p?.hasQrSticker === true && Number.isInteger(p.qrSerial) && Number(p.qrSerial) > 0)
102
+ .map((p) => (many ? `${p.plateNumber}: No. ${p.qrSerial}` : `No. ${p.qrSerial}`));
103
+ }
104
+
97
105
  export type BlankSummary = { printed: number; linked: number; available: number };
98
106
 
99
107
  /** "12 blank stickers available to link (20 printed, 8 linked)" - or what to do when none were printed yet. */