@7365admin1/layer-common 4.97.1-staging.747 → 4.97.1-staging.749

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.
@@ -101,6 +101,7 @@
101
101
  </v-card>
102
102
  </template>
103
103
  <script setup lang="ts">
104
+ import { replacementHolderId } from "../utils/card-replacement";
104
105
  const props = defineProps({
105
106
  card: {
106
107
  type: Object as PropType<Record<string, any>>,
@@ -166,14 +167,13 @@ async function submit() {
166
167
  loading.value = true;
167
168
  try {
168
169
  const { replaceCard } = useCard();
169
- const { currentUser } = useLocalAuth();
170
- // @TODO: userId should be the ID of the unit owner, not the current user
170
+ // The new card goes to whoever held the old one, not the signed-in admin (DV-2276).
171
171
  await replaceCard({
172
172
  cardId: props.card._id,
173
173
  issuedCardId: form.value.replacementCardId,
174
174
  unitId: props.unit._id,
175
175
  remarks: form.value.remarks.trim(),
176
- userId: currentUser.value?._id ?? "",
176
+ userId: replacementHolderId(props.card),
177
177
  });
178
178
  emit("success");
179
179
  } catch (error: any) {
@@ -31,42 +31,6 @@
31
31
  </v-radio-group>
32
32
  </v-col>
33
33
 
34
- <!-- Brand decides which protocol every later field is used with, so
35
- it is asked first. Picked once on Add and READ-ONLY on Edit
36
- (owner, 2026-11-25): swapping a saved camera to another brand
37
- would strand its plates on the old unit, so that is a delete and
38
- re-add, not an edit. -->
39
- <v-col v-if="isANPR" cols="12">
40
- <InputLabel class="text-capitalize" title="Brand" :required="!isEdit" />
41
-
42
- <v-select
43
- v-if="!isEdit"
44
- v-model="camera.brand"
45
- :items="brandOptions"
46
- class="filter-field"
47
- density="comfortable"
48
- placeholder="Select brand"
49
- :rules="[requiredRule]"
50
- data-test="camera-brand"
51
- />
52
-
53
- <template v-else>
54
- <v-text-field
55
- :model-value="brandLabel"
56
- class="filter-field"
57
- density="comfortable"
58
- readonly
59
- variant="solo-filled"
60
- flat
61
- prepend-inner-icon="mdi-lock-outline"
62
- data-test="camera-brand"
63
- />
64
- <div class="text-caption text-medium-emphasis mb-2">
65
- To change the brand, delete this camera and add it again.
66
- </div>
67
- </template>
68
- </v-col>
69
-
70
34
  <template v-if="showRecorderFields">
71
35
  <v-col cols="12">
72
36
  <InputLabel
@@ -119,8 +83,6 @@
119
83
  density="comfortable"
120
84
  :rules="[requiredRule, hostRule]"
121
85
  placeholder="Enter camera URL"
122
- :hint="addressHint"
123
- :persistent-hint="!!addressHint"
124
86
  />
125
87
  </v-col>
126
88
 
@@ -463,9 +425,6 @@ const camera = ref<TSiteCamera>({
463
425
  username: "",
464
426
  password: "",
465
427
  type: "ip",
466
- // Deliberately unset: on Add the person picks, because a camera saved with
467
- // the wrong brand never talks to its device and the failure is silent.
468
- brand: undefined,
469
428
  category: "standard",
470
429
  direction: "both",
471
430
  name: "",
@@ -506,35 +465,6 @@ const message = ref("");
506
465
  const isANPR = computed(() => prop.type === "anpr");
507
466
  const isCCTV = computed(() => prop.type === "ip");
508
467
 
509
- /** The ANPR brands the server will accept (DV-2436). */
510
- const brandOptions = [
511
- { title: "Dahua", value: "dahua" },
512
- { title: "Hikvision", value: "hikvision" },
513
- ];
514
-
515
- /**
516
- * What an edited camera's brand is called on screen. A camera saved before the
517
- * field existed has none stored, and the server reads that as Dahua, so that
518
- * is what is shown rather than a blank box.
519
- */
520
- const brandLabel = computed(
521
- () =>
522
- brandOptions.find((option) => option.value === camera.value.brand)?.title ??
523
- "Dahua",
524
- );
525
-
526
- /** Per-brand wording for the address field; nothing for CCTV. */
527
- const addressHint = computed(() => {
528
- if (!isANPR.value) return "";
529
- if (camera.value.brand === "hikvision") {
530
- return "The camera's own address, reachable from the internet - e.g. http://site.dyndns.org:7020";
531
- }
532
- if (camera.value.brand === "dahua") {
533
- return "The camera's own address, reachable from the internet - e.g. http://site.dyndns.org:8080";
534
- }
535
- return "";
536
- });
537
-
538
468
  const { addCamera, updateSiteCamera, testSiteCamera, getAllSiteCameras } = useSiteSettings();
539
469
 
540
470
  /**
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.747",
5
+ "version": "4.97.1-staging.749",
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/camera.d.ts CHANGED
@@ -24,12 +24,6 @@ declare type TSiteCamera = {
24
24
  username: string;
25
25
  password: string;
26
26
  type: "ip" | "anpr";
27
- /**
28
- * ANPR cameras: which vendor's protocol the camera speaks (DV-2436). Absent
29
- * on every camera stored before the field existed, which the server reads as
30
- * Dahua. Picked once when the camera is added and never editable after.
31
- */
32
- brand?: "dahua" | "hikvision";
33
27
  category: "standard" | "resident" | "visitor";
34
28
  direction: "entry" | "exit" | "both" | "none";
35
29
  name?: string;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The holder id Replace Card sends with `card-replacement` (DV-2276).
3
+ *
4
+ * It used to send the signed-in admin, so the new card was assigned to them.
5
+ * The replacement belongs to whoever held the old card. Core now reads the
6
+ * holder from the old card itself and ignores this field; it is still sent,
7
+ * as the old card's holder, so a core without that fix also gets it right.
8
+ */
9
+ export function replacementHolderId(card: Record<string, any> | null | undefined): string {
10
+ const id = card?.userId;
11
+ return id ? String(id) : "";
12
+ }