@7365admin1/layer-common 4.4.1 → 4.4.2-staging.291

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.
@@ -482,6 +482,55 @@
482
482
  </draggable>
483
483
  </section>
484
484
 
485
+ <!-- RESIDENT CHECKLISTS -->
486
+ <v-col cols="12" class="mt-4 border-t">
487
+ <v-row align="center" no-gutters class="pt-5">
488
+ <v-col cols="9" class="d-flex align-center text-body-2">
489
+ <v-row no-gutters>
490
+ <v-col cols="12" class="header-style">
491
+ Resident Checklists
492
+ </v-col>
493
+ <v-col cols="12" class="text-body-2 text-medium-emphasis">
494
+ Allow residents to view and complete assigned checklists. Each
495
+ checklist requires a photo upload before submission.
496
+ </v-col>
497
+ </v-row>
498
+ </v-col>
499
+ <v-col cols="3" class="d-flex align-center justify-end">
500
+ <v-switch
501
+ v-model="facility.isResidentChecklistEnabled"
502
+ class="d-flex align-center"
503
+ color="accent"
504
+ hide-details
505
+ @update:model-value="onToggleResidentChecklist"
506
+ />
507
+ </v-col>
508
+ </v-row>
509
+
510
+ <!-- SECURITY CHECKLISTS -->
511
+ <v-row align="center" no-gutters class="border-t pt-5 mt-5">
512
+ <v-col cols="9" class="d-flex align-center text-body-2">
513
+ <v-row no-gutters>
514
+ <v-col cols="12" class="header-style">
515
+ Security Checklists
516
+ </v-col>
517
+ <v-col cols="12" class="text-body-2 text-medium-emphasis">
518
+ Allow Security to view and complete assigned checklists
519
+ </v-col>
520
+ </v-row>
521
+ </v-col>
522
+ <v-col cols="3" class="d-flex align-center justify-end">
523
+ <v-switch
524
+ v-model="facility.isSecurityChecklistEnabled"
525
+ class="d-flex align-center"
526
+ color="accent"
527
+ hide-details
528
+ @update:model-value="onToggleSecurityChecklist"
529
+ />
530
+ </v-col>
531
+ </v-row>
532
+ </v-col>
533
+
485
534
  <v-col cols="12" class="mt-10">
486
535
  <p class="header-style font-weight-bold mb-5 mt-md-0 ml-md-4">
487
536
  Other Settings
@@ -1020,6 +1069,20 @@ watchEffect(() => {
1020
1069
  }
1021
1070
  });
1022
1071
 
1072
+ /**
1073
+ * One checklist, one owner, and always one. A facility is completed either by
1074
+ * its residents or by Security, so the two switches are each other's inverse:
1075
+ * turning either off turns the other on. There is no state where a facility
1076
+ * has no checklist owner.
1077
+ */
1078
+ function onToggleResidentChecklist(enabled: boolean | null) {
1079
+ facility.value.isSecurityChecklistEnabled = !enabled;
1080
+ }
1081
+
1082
+ function onToggleSecurityChecklist(enabled: boolean | null) {
1083
+ facility.value.isResidentChecklistEnabled = !enabled;
1084
+ }
1085
+
1023
1086
  function onToggleBookingUnitLimit(val: any) {
1024
1087
  if (val) {
1025
1088
  isBookingUnitLimitEnabled.value = true;
@@ -132,15 +132,18 @@
132
132
  </template>
133
133
 
134
134
  <template #[`item.contactStatus`]="{ item }">
135
- <v-btn
136
- size="small"
137
- variant="outlined"
138
- class="text-none"
139
- :loading="testingContactReaderId === item.readerId"
140
- @click="testContactSipStatus(item)"
141
- >
142
- {{ getContactReaderStatus(item) }}
143
- </v-btn>
135
+ <span class="contact-status-cell">
136
+ <StatusChip :status="getContactReaderStatus(item)" />
137
+ <v-btn
138
+ icon="mdi-refresh"
139
+ size="x-small"
140
+ variant="text"
141
+ class="contact-status-refresh"
142
+ aria-label="Check reader SIP status"
143
+ :loading="testingContactReaderId === item.readerId"
144
+ @click="testContactSipStatus(item)"
145
+ />
146
+ </span>
144
147
  </template>
145
148
 
146
149
  <template #[`item.action-table`]="{ item }">
@@ -148,24 +151,26 @@
148
151
  <template #activator="{ props: menuProps }">
149
152
  <AppButton v-bind="menuProps" variant="row" icon="mdi-dots-vertical" />
150
153
  </template>
151
- <v-list v-if="activeTab === 'intercom'" density="compact" class="row-menu">
152
- <v-list-item title="View" @click="openViewDialog(item)" />
154
+ <v-list v-if="activeTab === 'intercom'" density="compact" class="screen-menu">
155
+ <v-list-item class="screen-menu__item" title="View" prepend-icon="mdi-eye" @click="openViewDialog(item)" />
153
156
  <v-list-item
157
+ class="screen-menu__item"
154
158
  title="Test Connection with SIP"
159
+ prepend-icon="mdi-lan-check"
155
160
  :disabled="testingSipReaderId === item.reader._id"
156
161
  @click="testSipConnection(item)"
157
162
  />
158
- <v-list-item title="Call Settings" @click="openCallDialog(item)" />
159
- <v-list-item title="Dial Code" @click="openDialCodeDialog(item)" />
160
- <v-list-item title="Make a call" @click="openMakeCallDialog(item)" />
161
- <v-list-item title="Web call" @click="openWebPhoneDialog(item)" />
163
+ <v-list-item class="screen-menu__item" title="Call Settings" prepend-icon="mdi-cog" @click="openCallDialog(item)" />
164
+ <v-list-item class="screen-menu__item" title="Dial Code" prepend-icon="mdi-dialpad" @click="openDialCodeDialog(item)" />
165
+ <v-list-item class="screen-menu__item" title="Make a call" prepend-icon="mdi-phone" @click="openMakeCallDialog(item)" />
166
+ <v-list-item class="screen-menu__item" title="Web call" prepend-icon="mdi-headset" @click="openWebPhoneDialog(item)" />
162
167
  </v-list>
163
- <v-list v-else density="compact" class="row-menu">
164
- <v-list-item title="Call" prepend-icon="mdi-phone" @click="openContactCall(item)" />
165
- <v-list-item title="Check reader SIP status" prepend-icon="mdi-lan-check" @click="testContactSipStatus(item)" />
166
- <v-list-item title="View" @click="openContactView(item)" />
167
- <v-list-item title="Edit" @click="openContactDialog(item)" />
168
- <v-list-item title="Delete" @click="openDeleteContact(item)" />
168
+ <v-list v-else density="compact" class="screen-menu">
169
+ <v-list-item class="screen-menu__item" title="Call" prepend-icon="mdi-phone" @click="openContactCall(item)" />
170
+ <v-list-item class="screen-menu__item" title="Check reader SIP status" prepend-icon="mdi-lan-check" @click="testContactSipStatus(item)" />
171
+ <v-list-item class="screen-menu__item" title="View" prepend-icon="mdi-eye" @click="openContactView(item)" />
172
+ <v-list-item class="screen-menu__item" title="Edit" prepend-icon="mdi-pencil" @click="openContactDialog(item)" />
173
+ <v-list-item class="screen-menu__item screen-menu__item--danger" title="Delete" prepend-icon="mdi-delete-outline" @click="openDeleteContact(item)" />
169
174
  </v-list>
170
175
  </v-menu>
171
176
  </template>
@@ -574,7 +579,7 @@
574
579
  </v-dialog>
575
580
 
576
581
  <v-dialog v-model="contactDialog" max-width="360" persistent>
577
- <v-card class="form-dialog" rounded="lg">
582
+ <v-card class="form-dialog contact-dialog" rounded="lg">
578
583
  <v-card-title class="dialog-title">{{ contactForm.id ? 'Edit Contact' : 'Add Contact' }}</v-card-title>
579
584
  <v-card-text class="dialog-body">
580
585
  <FieldLabel text="HID Reader" required />
@@ -584,9 +589,10 @@
584
589
  :disabled="Boolean(contactForm.id)"
585
590
  />
586
591
  <FieldLabel text="Name" required />
587
- <AppField v-model="contactForm.name" placeholder="Enter name" />
588
- <FieldLabel text="SIP Number / Address" required />
589
- <AppField v-model="contactForm.serverAddress" placeholder="7100 or user@example.com" />
592
+ <AppField v-model="contactForm.name" placeholder="Name shown on calls" class="my-3" />
593
+ <FieldLabel text="Address" required />
594
+ <AppField v-model="contactForm.serverAddress" :placeholder="contactAddressPlaceholder" />
595
+ <p class="field-hint">{{ contactAddressHint }}</p>
590
596
  </v-card-text>
591
597
  <v-card-actions class="dialog-actions pa-0">
592
598
  <v-btn class="text-none action-cancel" variant="flat" height="44" @click="contactDialog = false">Cancel</v-btn>
@@ -958,6 +964,26 @@ const webPhoneButtonClass = computed(() => ({
958
964
  "has-incoming-call": webPhone.callState.value === "incoming",
959
965
  }));
960
966
  const isPeerToPeerMode = computed(() => sipForm.operatingMode === "peer-to-peer");
967
+
968
+ /**
969
+ * The user guide (6.3 Intercom contacts) gives a contact ONE address field
970
+ * whose meaning follows the reader's operating mode: an extension number in
971
+ * SIP Client mode, a local IP address in Peer-to-Peer mode. The reader chosen
972
+ * in the contact dialog decides which one the field asks for.
973
+ */
974
+ const contactReaderRow = computed(() =>
975
+ intercomRows.value.find((row) => row.reader._id === contactForm.readerId)
976
+ );
977
+ const isContactReaderPeerToPeer = computed(() => contactReaderRow.value?.operatingMode === "Peer-to-Peer");
978
+ const contactAddressPlaceholder = computed(() => (isContactReaderPeerToPeer.value ? "192.168.0.129" : "7100"));
979
+ const contactAddressHint = computed(() => {
980
+ if (!contactReaderRow.value) {
981
+ return "Extension number (SIP Client) or local IP address (Peer-to-Peer), depending on the reader's operating mode.";
982
+ }
983
+ return isContactReaderPeerToPeer.value
984
+ ? "Peer-to-Peer mode: enter the contact's local IP address."
985
+ : "SIP Client mode: enter the contact's extension number.";
986
+ });
961
987
  const areSipCredentialFieldsDisabled = computed(() => !sipForm.enabled || isPeerToPeerMode.value);
962
988
  const intercomDetailSections = computed(() => {
963
989
  const row = selectedRow.value;
@@ -1466,7 +1492,14 @@ function toggleWebMute() {
1466
1492
  }
1467
1493
  }
1468
1494
 
1495
+ function hasReaderContactId(contact: ContactRow) {
1496
+ if (contact.id !== undefined) return true;
1497
+ showMessage("This contact has no identifier on the HID reader. Refresh the list and try again.", "error");
1498
+ return false;
1499
+ }
1500
+
1469
1501
  function openContactDialog(contact?: ContactRow) {
1502
+ if (contact && !hasReaderContactId(contact)) return;
1470
1503
  selectedContact.value = contact || null;
1471
1504
  contactForm.id = contact?.id;
1472
1505
  contactForm.readerId = contact?.readerId || selectedReaderId.value || readers.value[0]?._id || "";
@@ -1516,10 +1549,20 @@ function openContactCall(contact: ContactRow) {
1516
1549
  }
1517
1550
 
1518
1551
  function openDeleteContact(contact: ContactRow) {
1552
+ if (!hasReaderContactId(contact)) return;
1519
1553
  selectedContact.value = contact;
1520
1554
  deleteContactDialog.value = true;
1521
1555
  }
1522
1556
 
1557
+ /**
1558
+ * modify_objects and destroy_objects answer { changes: n } (API guide, Modify
1559
+ * Objects / Delete Objects). Zero means the where clause matched nothing on the
1560
+ * reader - typically a contact already removed from the touchscreen.
1561
+ */
1562
+ function readChanges(response: unknown) {
1563
+ return toNumber(toRecord(toRecord(response).data ?? response).changes, Number.NaN);
1564
+ }
1565
+
1523
1566
  async function saveSipSettings() {
1524
1567
  if (!selectedRow.value) return;
1525
1568
  const isPeerToPeer = sipForm.operatingMode === "peer-to-peer";
@@ -1620,6 +1663,17 @@ function isSipCallTarget(value = "") {
1620
1663
  return /^(?:sip:)?[A-Za-z0-9_.+-]+(?:@[A-Za-z0-9.-]+(?::\d{1,5})?)?$/.test(value.trim());
1621
1664
  }
1622
1665
 
1666
+ function isIpv4Address(value = "") {
1667
+ const [host, port, ...rest] = value.trim().split(":");
1668
+ if (rest.length || (port !== undefined && !/^\d{1,5}$/.test(port))) return false;
1669
+ const octets = host.split(".");
1670
+ return octets.length === 4 && octets.every((octet) => /^\d{1,3}$/.test(octet) && Number(octet) <= 255);
1671
+ }
1672
+
1673
+ function isContactAddress(value: string, peerToPeer: boolean) {
1674
+ return peerToPeer ? isIpv4Address(value) : isSipCallTarget(value);
1675
+ }
1676
+
1623
1677
  async function runHangupCall() {
1624
1678
  if (!selectedRow.value) return;
1625
1679
  hangingUp.value = true;
@@ -1708,15 +1762,20 @@ async function saveContact() {
1708
1762
  return;
1709
1763
  }
1710
1764
 
1711
- if (!isSipCallTarget(contactForm.serverAddress)) {
1712
- showMessage("Enter a valid extension, SIP address, or IPv4 address.", "warning");
1765
+ if (!isContactAddress(contactForm.serverAddress, isContactReaderPeerToPeer.value)) {
1766
+ showMessage(
1767
+ isContactReaderPeerToPeer.value
1768
+ ? "Enter the contact's local IPv4 address for a Peer-to-Peer reader."
1769
+ : "Enter a valid extension number or SIP address.",
1770
+ "warning",
1771
+ );
1713
1772
  return;
1714
1773
  }
1715
1774
 
1716
1775
  contactsSaving.value = true;
1717
1776
  try {
1718
- if (contactForm.id) {
1719
- await runObjectOperation(contactForm.readerId, {
1777
+ if (contactForm.id !== undefined) {
1778
+ const response = await runObjectOperation(contactForm.readerId, {
1720
1779
  operation: "modify",
1721
1780
  object: "contacts",
1722
1781
  values: {
@@ -1725,8 +1784,14 @@ async function saveContact() {
1725
1784
  },
1726
1785
  where: { contacts: { id: contactForm.id } },
1727
1786
  });
1787
+ if (readChanges(response) === 0) {
1788
+ contactDialog.value = false;
1789
+ await loadContacts();
1790
+ showMessage("The HID reader no longer has this contact. The list has been refreshed.", "warning");
1791
+ return;
1792
+ }
1728
1793
  } else {
1729
- await runObjectOperation(contactForm.readerId, {
1794
+ const response = await runObjectOperation(contactForm.readerId, {
1730
1795
  operation: "create",
1731
1796
  object: "contacts",
1732
1797
  values: [{
@@ -1734,6 +1799,15 @@ async function saveContact() {
1734
1799
  number: contactForm.serverAddress.trim(),
1735
1800
  }],
1736
1801
  });
1802
+ // create_objects answers { ids: [...] } with the id of each created
1803
+ // object. No id means the reader accepted the request but created nothing.
1804
+ const created = toRecord(response?.data ?? response).ids;
1805
+ if (!Array.isArray(created) || created.length === 0) {
1806
+ contactDialog.value = false;
1807
+ await loadContacts();
1808
+ showMessage("The HID reader did not confirm the new contact. Check the contact list.", "warning");
1809
+ return;
1810
+ }
1737
1811
  }
1738
1812
  contactDialog.value = false;
1739
1813
  await loadContacts();
@@ -1746,16 +1820,21 @@ async function saveContact() {
1746
1820
  }
1747
1821
 
1748
1822
  async function deleteContact() {
1749
- if (!selectedContact.value?.id) return;
1823
+ const contact = selectedContact.value;
1824
+ if (!contact || !hasReaderContactId(contact)) return;
1750
1825
  contactsSaving.value = true;
1751
1826
  try {
1752
- await runObjectOperation(selectedContact.value.readerId, {
1827
+ const response = await runObjectOperation(contact.readerId, {
1753
1828
  operation: "destroy",
1754
1829
  object: "contacts",
1755
- where: { contacts: { id: selectedContact.value.id } },
1830
+ where: { contacts: { id: contact.id } },
1756
1831
  });
1757
1832
  deleteContactDialog.value = false;
1758
1833
  await loadContacts();
1834
+ if (readChanges(response) === 0) {
1835
+ showMessage("The HID reader had already removed this contact. The list has been refreshed.", "warning");
1836
+ return;
1837
+ }
1759
1838
  showMessage("Intercom contact deleted.", "success");
1760
1839
  } catch (error: unknown) {
1761
1840
  showMessage(getErrorMessage(error), "error");
@@ -1943,9 +2022,14 @@ export default {
1943
2022
 
1944
2023
 
1945
2024
 
1946
- .row-menu {
1947
- min-width: 160px;
1948
- border-radius: 6px;
2025
+ .contact-status-cell {
2026
+ display: inline-flex;
2027
+ align-items: center;
2028
+ gap: 4px;
2029
+ }
2030
+
2031
+ .contact-status-refresh {
2032
+ color: var(--text2);
1949
2033
  }
1950
2034
 
1951
2035
  .link-text {
@@ -2005,10 +2089,27 @@ export default {
2005
2089
  color: var(--err);
2006
2090
  }
2007
2091
 
2092
+ .field-hint {
2093
+ margin: 6px 0 0;
2094
+ color: var(--text2);
2095
+ font-size: 11px;
2096
+ line-height: 1.4;
2097
+ }
2098
+
2008
2099
  .sip-settings-dialog .field-label {
2009
2100
  margin-top: 14px;
2010
2101
  }
2011
2102
 
2103
+ /* Room between the contact dialog's three inputs; the first label sits
2104
+ against the body padding. */
2105
+ .contact-dialog .field-label {
2106
+ margin-top: 18px;
2107
+ }
2108
+
2109
+ .contact-dialog .field-label:first-child {
2110
+ margin-top: 0;
2111
+ }
2112
+
2012
2113
  .sip-label {
2013
2114
  margin: 12px 0 6px;
2014
2115
  color: var(--text);
@@ -2706,14 +2807,18 @@ export default {
2706
2807
  margin-top: 0;
2707
2808
  }
2708
2809
 
2810
+ .detail-dialog .dialog-title {
2811
+ font-size: var(--fs-card-title);
2812
+ }
2813
+
2709
2814
  .detail-row {
2710
2815
  display: flex;
2711
2816
  align-items: center;
2712
2817
  justify-content: space-between;
2713
2818
  gap: 16px;
2714
- min-height: 26px;
2819
+ min-height: 32px;
2715
2820
  color: var(--muted);
2716
- font-size: 11px;
2821
+ font-size: var(--fs-cell);
2717
2822
  }
2718
2823
 
2719
2824
  .detail-row strong {
@@ -2725,13 +2830,11 @@ export default {
2725
2830
  .dialog-actions {
2726
2831
  display: grid;
2727
2832
  grid-template-columns: 1fr 1fr;
2833
+ gap: 0;
2834
+ min-height: 0;
2728
2835
  border-top: 1px solid var(--border);
2729
2836
  }
2730
2837
 
2731
- .sip-settings-dialog .dialog-actions {
2732
- min-height: 46px;
2733
- }
2734
-
2735
2838
  /* The split footer bar, as panels 2, 4 and 5 keep it: the SHAPE is the
2736
2839
  screen's own (the handoff draws no such bar); only the colours change. The
2737
2840
  navy was a fixed hex that sat on the dark card unchanged. */