@7365admin1/layer-common 4.190.2 → 4.190.3

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @iservice365/layer-common
2
2
 
3
+ ## 4.190.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 09f3969: DV-2279 to DV-2282: a Guest or Walk-In's picked NFC or QR pass is now issued, and a pass that is not issued says why on the visitor list; Replace and Delete Card show "Select a replacement card" and "Remarks is required" instead of the backend's text or nothing; the delete question names the card; an empty NFC card list says how to add one.
8
+
3
9
  ## 4.190.2
4
10
 
5
11
  ### Patch Changes
@@ -4188,11 +4194,11 @@ Monthly report: a month that had patrols opens the list of that month's patrol r
4188
4194
  `utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
4189
4195
  own rule from two endpoints the console already calls, unprojected:
4190
4196
 
4191
- GET /api/members/user/:user/app/admin the Seven365 staff membership
4192
- GET /api/roles/id/:role that membership's role document
4197
+ GET /api/members/user/:user/app/admin the Seven365 staff membership
4198
+ GET /api/roles/id/:role that membership's role document
4193
4199
 
4194
- owner = member.type === "admin" && role.type === "admin" && role.default === true
4195
- staff = member.type === "admin" && role.type === "admin"
4200
+ owner = member.type === "admin" && role.type === "admin" && role.default === true
4201
+ staff = member.type === "admin" && role.type === "admin"
4196
4202
 
4197
4203
  `role.default` is the marker because it is the only property of a platform
4198
4204
  staff role no API caller can set - `role.controller.ts` validates create and
@@ -9,15 +9,15 @@
9
9
  <v-card-title>Delete Card</v-card-title>
10
10
 
11
11
  <v-card-text class="screen-modal__body">
12
- <p class="text-center mb-4">
13
- Are you sure you want to delete this card? This action cannot be
14
- undone.
12
+ <!-- Names the card, so the operator can see which one goes (DV-2281). -->
13
+ <p class="text-center mb-4" data-test="delete-card-question">
14
+ {{ question }}
15
15
  </p>
16
16
 
17
- <v-form v-model="validForm" :disabled="loading">
17
+ <v-form ref="formRef" :disabled="loading">
18
18
  <InputLabel class="text-capitalize font-weight-bold" title="Remarks" required />
19
- <!-- Still a `v-textarea`, not an `AppField`: Delete Card is gated on
20
- `validForm`, which only exists because this `:rules` runs.
19
+ <!-- Still a `v-textarea`, not an `AppField`: Delete Card checks
20
+ this `:rules` on click, so an empty Remarks says so (DV-2280).
21
21
  `.filter-field` gives it the design's 10px corner and 13.5px
22
22
  type without taking the validation away. -->
23
23
  <v-textarea
@@ -28,7 +28,7 @@
28
28
  rows="3"
29
29
  auto-grow
30
30
  hide-details="auto"
31
- :rules="[requiredRule]"
31
+ :rules="[remarksRule]"
32
32
  />
33
33
  </v-form>
34
34
 
@@ -57,7 +57,7 @@
57
57
  variant="flat"
58
58
  class="screen-btn-primary"
59
59
  :loading="loading"
60
- :disabled="!validForm || loading"
60
+ :disabled="loading"
61
61
  @click="handleConfirm"
62
62
  >
63
63
  Delete Card
@@ -81,6 +81,11 @@ const props = defineProps({
81
81
  type: String,
82
82
  default: "",
83
83
  },
84
+ /** The number of the card being deleted, shown in the question. */
85
+ cardNo: {
86
+ type: String,
87
+ default: "",
88
+ },
84
89
  });
85
90
 
86
91
  const emit = defineEmits<{
@@ -88,15 +93,28 @@ const emit = defineEmits<{
88
93
  confirm: [remarks: string];
89
94
  }>();
90
95
 
91
- const { requiredRule } = useUtils();
92
-
93
- const validForm = ref(false);
96
+ // Delete Card stays clickable and checks Remarks itself: a button that only
97
+ // greyed out did nothing visible when clicked (DV-2280).
98
+ const formRef = ref<{
99
+ validate: () => Promise<{ valid: boolean }>;
100
+ resetValidation: () => void;
101
+ } | null>(null);
102
+ const remarksRule = (v: string) => !!(v && v.trim()) || "Remarks is required";
94
103
  const remarks = ref("");
95
104
 
105
+ const question = computed(() =>
106
+ props.cardNo
107
+ ? `Are you sure you want to delete card ${props.cardNo}? This action cannot be undone.`
108
+ : "Are you sure you want to delete this card? This action cannot be undone.",
109
+ );
110
+
96
111
  watch(
97
112
  () => props.modelValue,
98
113
  (val) => {
99
- if (val) remarks.value = "";
114
+ if (val) {
115
+ remarks.value = "";
116
+ formRef.value?.resetValidation();
117
+ }
100
118
  }
101
119
  );
102
120
 
@@ -104,8 +122,9 @@ function handleClose() {
104
122
  emit("update:modelValue", false);
105
123
  }
106
124
 
107
- function handleConfirm() {
108
- if (!validForm.value) return;
125
+ async function handleConfirm() {
126
+ const { valid } = (await formRef.value?.validate()) ?? { valid: false };
127
+ if (!valid || !remarks.value.trim()) return;
109
128
  emit("confirm", remarks.value.trim());
110
129
  }
111
130
  </script>
@@ -3,7 +3,7 @@
3
3
  <v-card-title>Replace Access Card</v-card-title>
4
4
 
5
5
  <v-card-text class="screen-modal__body pa-0">
6
- <v-form v-model="validForm" :disabled="loading">
6
+ <v-form ref="formRef" :disabled="loading">
7
7
  <v-row no-gutters class="px-6 pt-4 pb-6">
8
8
  <!-- Card being replaced -->
9
9
  <v-col cols="12" class="px-1 mb-4">
@@ -26,9 +26,10 @@
26
26
  title="Replacement Card"
27
27
  required
28
28
  />
29
- <!-- Both inputs keep their `:rules`: Replace is gated on
30
- `validForm`. `.filter-field` gives them the design's shape
31
- without touching the validation. -->
29
+ <!-- Both inputs keep their `:rules`, and Replace checks them on
30
+ click so an empty field says what is missing (DV-2280).
31
+ `.filter-field` gives them the design's shape without
32
+ touching the validation. -->
32
33
  <v-autocomplete
33
34
  v-model="form.replacementCardId"
34
35
  class="filter-field"
@@ -39,7 +40,7 @@
39
40
  item-value="_id"
40
41
  placeholder="Select replacement card..."
41
42
  persistent-placeholder
42
- :rules="[requiredRule]"
43
+ :rules="[replacementRule]"
43
44
  :no-data-text="noDataText"
44
45
  />
45
46
  </v-col>
@@ -60,7 +61,7 @@
60
61
  persistent-placeholder
61
62
  rows="3"
62
63
  auto-grow
63
- :rules="[requiredRule]"
64
+ :rules="[remarksRule]"
64
65
  />
65
66
  </v-col>
66
67
  </v-row>
@@ -88,7 +89,7 @@
88
89
  block
89
90
  variant="flat"
90
91
  class="text-none screen-btn-primary"
91
- :disabled="!validForm || loading"
92
+ :disabled="loading"
92
93
  :loading="loading"
93
94
  @click="submit"
94
95
  >
@@ -116,9 +117,12 @@ const props = defineProps({
116
117
  });
117
118
  const emit = defineEmits(["cancel", "success", "error"]);
118
119
 
119
- const { requiredRule } = useUtils();
120
-
121
- const validForm = ref(false);
120
+ // Replace stays clickable and checks the fields itself: a button that only
121
+ // greyed out showed no message, and an empty card once reached the API as
122
+ // `"issuedCardId" must be a string` (DV-2280).
123
+ const formRef = ref<{ validate: () => Promise<{ valid: boolean }> } | null>(null);
124
+ const replacementRule = (v: string | null) => !!v || "Select a replacement card";
125
+ const remarksRule = (v: string) => !!(v && v.trim()) || "Remarks is required";
122
126
  const loading = ref(false);
123
127
 
124
128
  const form = ref({
@@ -157,6 +161,8 @@ function cancel() {
157
161
  }
158
162
 
159
163
  async function submit() {
164
+ const { valid } = (await formRef.value?.validate()) ?? { valid: false };
165
+ if (!valid || !form.value.replacementCardId || !form.value.remarks.trim()) return;
160
166
  loading.value = true;
161
167
  try {
162
168
  const { replaceCard } = useCard();
@@ -164,9 +170,9 @@ async function submit() {
164
170
  // @TODO: userId should be the ID of the unit owner, not the current user
165
171
  await replaceCard({
166
172
  cardId: props.card._id,
167
- issuedCardId: form.value.replacementCardId!,
173
+ issuedCardId: form.value.replacementCardId,
168
174
  unitId: props.unit._id,
169
- remarks: form.value.remarks,
175
+ remarks: form.value.remarks.trim(),
170
176
  userId: currentUser.value?._id ?? "",
171
177
  });
172
178
  emit("success");
@@ -132,6 +132,7 @@
132
132
  v-model="confirmDialog"
133
133
  :loading="deleteLoading"
134
134
  :error="deleteError"
135
+ :card-no="selectedCardInUnit?.cardNo ?? ''"
135
136
  @confirm="handleDeleteCard"
136
137
  />
137
138
 
@@ -111,6 +111,7 @@
111
111
  :items="filteredCardItems"
112
112
  :loading="cardsLoading"
113
113
  :hide-no-data="false"
114
+ :no-data-text="nfcNoDataText"
114
115
  item-title="cardNo"
115
116
  item-value="_id"
116
117
  density="comfortable"
@@ -415,6 +416,18 @@ const cardsLoadingMore = ref(false);
415
416
  // Typed text in the card picker. Reset after each pick so the next search
416
417
  // starts from the full list instead of staying narrowed to the last term.
417
418
  const cardSearch = ref("");
419
+
420
+ // What an empty card list means, said the way the QR Pass hint does: it was
421
+ // a bare "No data available" (DV-2282).
422
+ const nfcNoDataText = computed(() => {
423
+ if (cardsLoading.value) return "Loading cards...";
424
+ const term = (cardSearch.value ?? "").trim();
425
+ if (term) return `No cards match "${term}".`;
426
+ if (cardItems.value.length > 0) {
427
+ return "Every available NFC card is already picked for this visit.";
428
+ }
429
+ return "No NFC cards available. Add a physical card to this unit in Access Management.";
430
+ });
418
431
  const CARD_PAGE_SIZE = 100;
419
432
  const cardPage = ref(1);
420
433
  const cardHasMore = ref(false);
@@ -992,9 +992,13 @@ const saveResult = ref<{
992
992
  barrier?: TBarrierOutcome;
993
993
  /** The camera the barrier is at, "Entry Gate 1". */
994
994
  barrierCamera?: string;
995
+ /** Why the entry pass (QR or NFC) was not issued; unset when it was. */
996
+ passError?: string;
995
997
  }>({
996
998
  action: "add",
997
999
  });
1000
+ const ENTRY_PASS_NOT_ISSUED =
1001
+ "Visitor saved, but the entry pass was not issued and no card is assigned.";
998
1002
  const hidQrPreview = reactive({
999
1003
  imageUrl: "",
1000
1004
  issuedAt: "",
@@ -3123,8 +3127,10 @@ async function submit(options: { skipNonCheckedOutCheck?: boolean } = {}) {
3123
3127
  return;
3124
3128
  }
3125
3129
 
3126
- // The entry pass (isecure365 `onSubmit`), messages verbatim.
3127
- if (prop.type === "contractor" && showEntryPassInformation.value) {
3130
+ // The entry pass (isecure365 `onSubmit`), messages verbatim. Every visitor
3131
+ // type the section is shown to: a Guest or Walk-In can pick QR or NFC too
3132
+ // (DV-2279), and the checks only run for the pass type picked.
3133
+ if (showEntryPassInformation.value) {
3128
3134
  if (passType.value === "NFC" && passCards.value.length === 0) {
3129
3135
  errorMessage.value = "Please select at least one NFC card before proceeding.";
3130
3136
  return;
@@ -3225,10 +3231,11 @@ async function submit(options: { skipNonCheckedOutCheck?: boolean } = {}) {
3225
3231
  return;
3226
3232
  }
3227
3233
 
3228
- // The contractor's entry pass, issued once the visitor exists - for a
3229
- // register too, against the record being registered.
3234
+ // The entry pass, issued once the visitor exists - for a register too,
3235
+ // against the record being registered. Any visitor type the section was
3236
+ // shown to: a Guest or Walk-In whose NFC card was picked had it dropped
3237
+ // here before (DV-2279).
3230
3238
  if (
3231
- prop.type === "contractor" &&
3232
3239
  showEntryPassInformation.value &&
3233
3240
  (passType.value === "QR" || passType.value === "NFC")
3234
3241
  ) {
@@ -3251,9 +3258,17 @@ async function submit(options: { skipNonCheckedOutCheck?: boolean } = {}) {
3251
3258
  }
3252
3259
  }
3253
3260
 
3254
- /** Never fails the save: the visitor is already saved. */
3261
+ /**
3262
+ * Never fails the save: the visitor is already saved. A pass that is not
3263
+ * issued goes into `saveResult.passError`, which the list shows once this
3264
+ * dialog has closed. A snackbar here closed with the dialog, so nobody saw
3265
+ * why the card stayed unassigned (DV-2279).
3266
+ */
3255
3267
  async function issueEntryPass(visitorId: string, payload: Record<string, unknown>) {
3256
- if (!visitorId) return;
3268
+ if (!visitorId) {
3269
+ saveResult.value = { ...saveResult.value, passError: ENTRY_PASS_NOT_ISSUED };
3270
+ return;
3271
+ }
3257
3272
  try {
3258
3273
  const rawUrl = entryPassSettings.value?.data?.settings?.url;
3259
3274
  const { encrypted: acmUrl } = await $fetch<{ encrypted: string }>(
@@ -3317,10 +3332,11 @@ async function issueEntryPass(visitorId: string, payload: Record<string, unknown
3317
3332
  }
3318
3333
  }
3319
3334
  } catch (error: any) {
3320
- showSnackbar(
3321
- `Visitor saved, pass not issued. The visitor was registered, but the entry pass could not be issued. ${error?.data?.message ?? error?.message ?? ""}`.trim(),
3322
- "error"
3323
- );
3335
+ const reason = String(error?.data?.message ?? error?.message ?? "").trim();
3336
+ saveResult.value = {
3337
+ ...saveResult.value,
3338
+ passError: reason ? `${ENTRY_PASS_NOT_ISSUED} ${reason}` : ENTRY_PASS_NOT_ISSUED,
3339
+ };
3324
3340
  }
3325
3341
  }
3326
3342
 
@@ -3578,6 +3578,8 @@ type TVisitorFormResult = {
3578
3578
  barrier?: "opened" | "failed";
3579
3579
  /** The camera the barrier is at, "Entry Gate 1". */
3580
3580
  barrierCamera?: string;
3581
+ /** Why the entry pass was not issued (DV-2279); unset when it was. */
3582
+ passError?: string;
3581
3583
  };
3582
3584
 
3583
3585
  function visitorSavedMessage(result?: TVisitorFormResult) {
@@ -3586,15 +3588,29 @@ function visitorSavedMessage(result?: TVisitorFormResult) {
3586
3588
  return VISITOR_SAVED_MESSAGE;
3587
3589
  }
3588
3590
 
3589
- function handleVisitorFormDone(result?: TVisitorFormResult) {
3591
+ /**
3592
+ * The save message, then the entry pass failure in red under it. The form has
3593
+ * closed by now, so this toast is the only place the reason can be read.
3594
+ */
3595
+ function showVisitorSaved(result?: TVisitorFormResult) {
3590
3596
  showMessage(visitorSavedMessage(result), "success", result?.barrier, result?.barrierCamera);
3597
+ if (!result?.passError) return;
3598
+ const barrierText = messageDetail.value.text;
3599
+ messageDetail.value = {
3600
+ text: barrierText ? `${barrierText} ${result.passError}` : result.passError,
3601
+ tone: "error",
3602
+ };
3603
+ }
3604
+
3605
+ function handleVisitorFormDone(result?: TVisitorFormResult) {
3606
+ showVisitorSaved(result);
3591
3607
  getVisitorRefresh();
3592
3608
  dialog.showSelection = false;
3593
3609
  dialog.showForm = false;
3594
3610
  }
3595
3611
 
3596
3612
  function handleVisitorFormCreateMore(result?: TVisitorFormResult) {
3597
- showMessage(visitorSavedMessage(result), "success", result?.barrier, result?.barrierCamera);
3613
+ showVisitorSaved(result);
3598
3614
  getVisitorRefresh();
3599
3615
  dialog.showSelection = true;
3600
3616
  dialog.showForm = false;
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.190.2",
5
+ "version": "4.190.3",
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.",