@7365admin1/layer-common 4.2.4 → 4.2.5-staging.270
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.
|
@@ -193,7 +193,6 @@ const today = computed(() => {
|
|
|
193
193
|
const yyyy = d.getFullYear();
|
|
194
194
|
const mm = String(d.getMonth() + 1).padStart(2, "0");
|
|
195
195
|
const dd = String(d.getDate()).padStart(2, "0");
|
|
196
|
-
console.log("${yyyy}-${mm}-${dd}", `${yyyy}-${mm}-${dd}`);
|
|
197
196
|
return `${yyyy}-${mm}-${dd}`;
|
|
198
197
|
});
|
|
199
198
|
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
<InputLabel class="text-capitalize" title="Block" required />
|
|
59
59
|
<v-autocomplete
|
|
60
60
|
v-model="vehicle.block"
|
|
61
|
-
:items="
|
|
61
|
+
:items="blockItems"
|
|
62
62
|
autocomplete="off"
|
|
63
63
|
:key="
|
|
64
64
|
blockListDataPending ? 'block-list-pending' : 'block-list-ready'
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
<InputLabel class="text-capitalize" title="Level" required />
|
|
77
77
|
<v-autocomplete
|
|
78
78
|
v-model="vehicle.level"
|
|
79
|
-
:items="
|
|
79
|
+
:items="levelItems"
|
|
80
80
|
autocomplete="off"
|
|
81
81
|
:key="
|
|
82
82
|
levelListDataPending ? 'level-list-pending' : 'level-list-ready'
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
<InputLabel class="text-capitalize" title="Unit" required />
|
|
94
94
|
<v-autocomplete
|
|
95
95
|
v-model="vehicle.unit"
|
|
96
|
-
:items="
|
|
96
|
+
:items="unitItems"
|
|
97
97
|
autocomplete="off"
|
|
98
98
|
:key="
|
|
99
99
|
unitListDataPending ? 'unit-list-pending' : 'unit-list-ready'
|
|
@@ -532,10 +532,78 @@ const shouldShowField = (fieldKey: string): boolean => {
|
|
|
532
532
|
return visibleFields?.includes(fieldKey);
|
|
533
533
|
};
|
|
534
534
|
|
|
535
|
+
/**
|
|
536
|
+
* Block / Level / Unit are ids bound to autocompletes whose `:items` come from
|
|
537
|
+
* the site's own lists. Vuetify renders the RAW model value when it is not in
|
|
538
|
+
* that list, which is how the Season Pass edit dialog came to show
|
|
539
|
+
* `6a31fd37917fb18ef1a21a0a` in all three fields instead of names.
|
|
540
|
+
*
|
|
541
|
+
* Two different causes end in the same place, and neither is fixable in the
|
|
542
|
+
* repository: the site list has simply not arrived yet, and - measured on
|
|
543
|
+
* staging - a stored unit id that points at a building unit which has since
|
|
544
|
+
* been DELETED, so it can NEVER appear in the list however the row is fetched.
|
|
545
|
+
*
|
|
546
|
+
* So the fix is here, at the display layer: an id with no name gets an explicit
|
|
547
|
+
* item saying why there is no name. A Mongo id is not a name, and a blank field
|
|
548
|
+
* with no explanation is not better than one.
|
|
549
|
+
*
|
|
550
|
+
* The stored value is left untouched - the field still submits the same id, so
|
|
551
|
+
* saving an unrelated edit does not silently rewrite someone's unit.
|
|
552
|
+
*/
|
|
553
|
+
function withUnresolved(
|
|
554
|
+
items: TDefaultOptionObj[],
|
|
555
|
+
value: unknown,
|
|
556
|
+
pending: boolean,
|
|
557
|
+
noun: string
|
|
558
|
+
): TDefaultOptionObj[] {
|
|
559
|
+
const id =
|
|
560
|
+
typeof value === "string" ? value : ((value as any)?._id ?? "");
|
|
561
|
+
if (!id || items.some((item) => item.value === id)) return items;
|
|
562
|
+
|
|
563
|
+
return [
|
|
564
|
+
{
|
|
565
|
+
title: pending
|
|
566
|
+
? `Loading ${noun}…`
|
|
567
|
+
: `This ${noun} is no longer on the site list (${id})`,
|
|
568
|
+
value: id,
|
|
569
|
+
},
|
|
570
|
+
...items,
|
|
571
|
+
];
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
const blockItems = computed(() =>
|
|
575
|
+
withUnresolved(
|
|
576
|
+
blocksArray.value,
|
|
577
|
+
vehicle.block,
|
|
578
|
+
blockListDataPending.value,
|
|
579
|
+
"block"
|
|
580
|
+
)
|
|
581
|
+
);
|
|
582
|
+
|
|
583
|
+
const levelItems = computed(() =>
|
|
584
|
+
withUnresolved(
|
|
585
|
+
levelsArray.value,
|
|
586
|
+
vehicle.level,
|
|
587
|
+
levelListDataPending.value,
|
|
588
|
+
"level"
|
|
589
|
+
)
|
|
590
|
+
);
|
|
591
|
+
|
|
592
|
+
const unitItems = computed(() =>
|
|
593
|
+
withUnresolved(
|
|
594
|
+
unitsArray.value,
|
|
595
|
+
vehicle.unit,
|
|
596
|
+
unitListDataPending.value,
|
|
597
|
+
"unit"
|
|
598
|
+
)
|
|
599
|
+
);
|
|
600
|
+
|
|
535
601
|
const searchUnitName = computed(() => {
|
|
602
|
+
// Same rule as the fields: never put a raw id in front of a person. The
|
|
603
|
+
// dialog title used to fall through to `vehicle.unit`, so a deleted unit
|
|
604
|
+
// titled the panel with its ObjectId.
|
|
536
605
|
return (
|
|
537
|
-
unitsArray.value.find((u) => u.value === vehicle.unit)?.title ||
|
|
538
|
-
vehicle.unit
|
|
606
|
+
unitsArray.value.find((u) => u.value === vehicle.unit)?.title || "-"
|
|
539
607
|
);
|
|
540
608
|
});
|
|
541
609
|
|
|
@@ -1047,10 +1115,12 @@ const resetVehicleDetails = () => {
|
|
|
1047
1115
|
};
|
|
1048
1116
|
|
|
1049
1117
|
function handleCloseMatchDialog() {
|
|
1118
|
+
// Close only. This used to null `vehicle.unit` whenever the panel had found
|
|
1119
|
+
// matches, so backing out of the picker with the header X wiped a Unit the
|
|
1120
|
+
// user had chosen BEFORE opening it and painted the field required-in-red.
|
|
1121
|
+
// The panel's own close button never did that; the two now agree. Backing out
|
|
1122
|
+
// of a picker is not a decision to discard what you already had.
|
|
1050
1123
|
showMatchingPeopleDialog.value = false;
|
|
1051
|
-
if (matchingPeople.value.length > 0) {
|
|
1052
|
-
vehicle.unit = null;
|
|
1053
|
-
}
|
|
1054
1124
|
}
|
|
1055
1125
|
|
|
1056
1126
|
onMounted(() => {
|
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.2.
|
|
5
|
+
"version": "4.2.5-staging.270",
|
|
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.",
|