@7365admin1/layer-common 4.97.1-staging.744 → 4.97.1-staging.745
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.
|
@@ -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.745",
|
|
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
|
+
}
|