@7365admin1/layer-common 4.97.1-staging.744 → 4.97.1-staging.746
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.
|
@@ -159,18 +159,35 @@
|
|
|
159
159
|
<!-- Entry content -->
|
|
160
160
|
<div class="d-flex flex-column ga-1 pb-4 flex-grow-1">
|
|
161
161
|
<div class="d-flex align-center justify-space-between">
|
|
162
|
-
<StatusChip
|
|
162
|
+
<StatusChip
|
|
163
|
+
:status="historyEntryKind(entry).label"
|
|
164
|
+
:tone="isChangeEntry(entry) ? historyEntryKind(entry).tone : ''"
|
|
165
|
+
>
|
|
163
166
|
<v-icon
|
|
164
167
|
size="13"
|
|
165
168
|
class="mr-1"
|
|
166
|
-
:icon="
|
|
167
|
-
/>{{
|
|
169
|
+
:icon="historyEntryKind(entry).icon"
|
|
170
|
+
/>{{ historyEntryKind(entry).label }}
|
|
168
171
|
</StatusChip>
|
|
169
172
|
<span class="card-details__label">{{ formatDate(entry.createdAt) }}</span>
|
|
170
173
|
</div>
|
|
171
174
|
|
|
175
|
+
<!-- Replace / Delete entry (DV-2277): who, the other card, remarks -->
|
|
176
|
+
<template v-if="isChangeEntry(entry)">
|
|
177
|
+
<div class="card-details__sub">
|
|
178
|
+
By {{ entry.performedByName || "Not recorded" }}
|
|
179
|
+
</div>
|
|
180
|
+
<div v-if="entry.relatedCardNo" class="card-details__sub">
|
|
181
|
+
{{ historyEntryKind(entry).kind === "replaced" ? "Replaced by" : "Replaces" }}
|
|
182
|
+
card {{ entry.relatedCardNo }}
|
|
183
|
+
</div>
|
|
184
|
+
<div v-if="entry.remarks" class="card-details__sub">
|
|
185
|
+
Remarks: {{ entry.remarks }}
|
|
186
|
+
</div>
|
|
187
|
+
</template>
|
|
188
|
+
|
|
172
189
|
<!-- Assignment entry -->
|
|
173
|
-
<template v-if="entry.type === 'assigned' || entry.visitorId">
|
|
190
|
+
<template v-else-if="entry.type === 'assigned' || entry.visitorId">
|
|
174
191
|
<div class="card-details__value">{{ entry.name ?? "N/A" }}</div>
|
|
175
192
|
<div class="card-details__sub">
|
|
176
193
|
<span v-if="entry.nric">NRIC: {{ maskNRIC(entry.nric) }}</span>
|
|
@@ -204,6 +221,7 @@
|
|
|
204
221
|
</template>
|
|
205
222
|
|
|
206
223
|
<script setup lang="ts">
|
|
224
|
+
import { historyEntryKind } from "../utils/card-history-entry";
|
|
207
225
|
const { maskNRIC } = useUtils();
|
|
208
226
|
const props = defineProps({
|
|
209
227
|
modelValue: {
|
|
@@ -309,6 +327,12 @@ function isAssignment(entry: Record<string, any>) {
|
|
|
309
327
|
return entry.type === "assigned" || Boolean(entry.visitorId);
|
|
310
328
|
}
|
|
311
329
|
|
|
330
|
+
/** A Replace or Delete entry (DV-2277), shown with who did it and the remarks. */
|
|
331
|
+
function isChangeEntry(entry: Record<string, any>) {
|
|
332
|
+
const kind = historyEntryKind(entry).kind;
|
|
333
|
+
return kind === "replaced" || kind === "replacement" || kind === "deleted";
|
|
334
|
+
}
|
|
335
|
+
|
|
312
336
|
function formatDate(date: string) {
|
|
313
337
|
if (!date) return "N/A";
|
|
314
338
|
return new Intl.DateTimeFormat("en-GB", {
|
|
@@ -391,7 +391,7 @@
|
|
|
391
391
|
@click="emit('delete')"
|
|
392
392
|
class="text-error"
|
|
393
393
|
:disabled="!isSelectedCardDeletable"
|
|
394
|
-
v-if="canDeleteAccessCard"
|
|
394
|
+
v-if="canDeleteAccessCard && !isSelectedCardInactive"
|
|
395
395
|
>
|
|
396
396
|
<v-list-item-title class="text-subtitle-2">
|
|
397
397
|
Delete Card
|
|
@@ -405,6 +405,7 @@
|
|
|
405
405
|
</template>
|
|
406
406
|
|
|
407
407
|
<script setup lang="ts">
|
|
408
|
+
import { cardStateInUnit, isInactiveCardState } from "../utils/access-card-state";
|
|
408
409
|
const props = defineProps({
|
|
409
410
|
modelValue: {
|
|
410
411
|
type: Boolean,
|
|
@@ -593,6 +594,12 @@ const isSelectedCardAvailable = computed(() => {
|
|
|
593
594
|
].some((c) => c._id === id);
|
|
594
595
|
});
|
|
595
596
|
|
|
597
|
+
// A deleted or replaced card is already deactivated: Delete Card is not shown
|
|
598
|
+
// for it at all (DV-2278), rather than shown greyed out.
|
|
599
|
+
const isSelectedCardInactive = computed(() =>
|
|
600
|
+
isInactiveCardState(cardStateInUnit(props.unit, props.selectedCardInUnit?._id))
|
|
601
|
+
);
|
|
602
|
+
|
|
596
603
|
const isSelectedCardDeletable = computed(() => {
|
|
597
604
|
if (!props.selectedCardInUnit?._id) return false;
|
|
598
605
|
const id = props.selectedCardInUnit._id;
|
|
@@ -401,7 +401,7 @@ async function handleDeleteCard(remarks: string) {
|
|
|
401
401
|
previewDialog.value = false;
|
|
402
402
|
showMessage("Access card deleted successfully!", "success");
|
|
403
403
|
} catch (error: any) {
|
|
404
|
-
const msg = error?.response?._data?.message || "Failed to delete card";
|
|
404
|
+
const msg = error?.response?._data?.message || error?.data?.message || "Failed to delete card";
|
|
405
405
|
deleteError.value = msg;
|
|
406
406
|
showMessage(msg, "error");
|
|
407
407
|
} finally {
|
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.
|
|
5
|
+
"version": "4.97.1-staging.746",
|
|
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.",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which of a unit's card lists a card is in, as the Cards preview dialog shows
|
|
3
|
+
* them. A deleted or replaced card is already deactivated, so the dialog does
|
|
4
|
+
* not offer Delete Card for it (DV-2278).
|
|
5
|
+
*/
|
|
6
|
+
export type CardState = "available" | "assigned" | "replaced" | "deleted";
|
|
7
|
+
|
|
8
|
+
const STATES: CardState[] = ["available", "assigned", "replaced", "deleted"];
|
|
9
|
+
|
|
10
|
+
export function cardStateInUnit(
|
|
11
|
+
unit: Record<string, any> | null | undefined,
|
|
12
|
+
cardId: string | null | undefined,
|
|
13
|
+
): CardState | null {
|
|
14
|
+
if (!unit || !cardId) return null;
|
|
15
|
+
for (const state of STATES) {
|
|
16
|
+
const lists = unit[state];
|
|
17
|
+
const cards = [...(lists?.physical ?? []), ...(lists?.non_physical ?? [])];
|
|
18
|
+
if (cards.some((c: any) => c?._id === cardId)) return state;
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function isInactiveCardState(state: CardState | null): boolean {
|
|
24
|
+
return state === "deleted" || state === "replaced";
|
|
25
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a Card Details > History entry is, for its chip and icon.
|
|
3
|
+
*
|
|
4
|
+
* Assign and visitor issue have always written history; a return/checkout is
|
|
5
|
+
* the other old kind. Replace and Delete add three more (DV-2277), written by
|
|
6
|
+
* core as `type: "replaced" | "replacement" | "deleted"`.
|
|
7
|
+
*/
|
|
8
|
+
export type HistoryKind = "assigned" | "replaced" | "replacement" | "deleted" | "returned";
|
|
9
|
+
|
|
10
|
+
export type HistoryKindInfo = {
|
|
11
|
+
kind: HistoryKind;
|
|
12
|
+
label: string;
|
|
13
|
+
tone: "ok" | "warn" | "err" | "info" | "neutral";
|
|
14
|
+
icon: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const KINDS: Record<Exclude<HistoryKind, "returned" | "assigned">, HistoryKindInfo> = {
|
|
18
|
+
replaced: { kind: "replaced", label: "Replaced", tone: "warn", icon: "mdi-swap-horizontal" },
|
|
19
|
+
replacement: { kind: "replacement", label: "Issued as replacement", tone: "info", icon: "mdi-card-plus-outline" },
|
|
20
|
+
deleted: { kind: "deleted", label: "Deleted", tone: "err", icon: "mdi-delete-outline" },
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function historyEntryKind(entry: Record<string, any> | null | undefined): HistoryKindInfo {
|
|
24
|
+
const type = entry?.type;
|
|
25
|
+
if (type === "assigned" || entry?.visitorId) {
|
|
26
|
+
return { kind: "assigned", label: "Assigned", tone: "ok", icon: "mdi-account-arrow-right" };
|
|
27
|
+
}
|
|
28
|
+
if (type === "replaced" || type === "replacement" || type === "deleted") return KINDS[type];
|
|
29
|
+
return { kind: "returned", label: "Returned", tone: "neutral", icon: "mdi-arrow-u-left-top" };
|
|
30
|
+
}
|