@@ -175,11 +206,45 @@ export default {
CharacteristicMass: createComputedSetterForItemField("characteristic_mass"),
Collections: createComputedSetterForItemField("collections"),
Status: createComputedSetterForItemField("status"),
+ TheoreticalCapacity: createComputedSetterForItemField("theoretical_capacity"),
+ NominalCapacityUnit: createComputedSetterForItemField("nominal_capacity_unit"),
schema() {
return this.$store.state.schemas[this.item?.type];
},
possibleItemStatuses() {
- return this.schema?.attributes?.schema?.definitions?.CellStatus?.enum;
+ return this.schema?.attributes?.schema?.["$defs"]?.CellStatus?.enum;
+ },
+ // Recomputed live from the store on every render — no save round-trip needed.
+ NominalCapacity() {
+ const nominalCapacityToMah = { mAh: 1, Ah: 1e3 };
+
+ // theoretical_capacity is always mAh/g.
+ const theoreticalCapacity = Number(this.TheoreticalCapacity);
+ const characteristicMass = Number(this.CharacteristicMass);
+ if (!Number.isFinite(theoreticalCapacity) || !Number.isFinite(characteristicMass)) {
+ return null;
+ }
+
+ const nominalCapacityUnit = this.NominalCapacityUnit || "mAh";
+
+ // characteristic_mass is stored in mg; divide by 1000 to get grams.
+ const mAh = (theoreticalCapacity * characteristicMass) / 1000;
+ return mAh / nominalCapacityToMah[nominalCapacityUnit];
+ },
+ NominalCapacityDisplay() {
+ return this.NominalCapacity === null ? "—" : this.NominalCapacity.toFixed(4);
+ },
+ },
+ watch: {
+ // Persist the live-computed value too, so it's saved without relying on a
+ // server round-trip (the backend validator recomputes it again on save).
+ NominalCapacity(value) {
+ if (value !== null && value !== this.item?.nominal_capacity) {
+ this.$store.commit("updateItemData", {
+ item_id: this.item_id,
+ item_data: { nominal_capacity: value },
+ });
+ }
},
},
};
diff --git a/webapp/src/components/EquipmentInformation.vue b/webapp/src/components/EquipmentInformation.vue
index 66401d1a6..7668b3201 100644
--- a/webapp/src/components/EquipmentInformation.vue
+++ b/webapp/src/components/EquipmentInformation.vue
@@ -135,7 +135,7 @@ export default {
return this.$store.state.schemas[this.item?.type];
},
possibleItemStatuses() {
- return this.schema?.attributes?.schema?.definitions?.EquipmentStatus?.enum;
+ return this.schema?.attributes?.schema?.["$defs"]?.EquipmentStatus?.enum;
},
uniqueLocations() {
return [
diff --git a/webapp/src/components/SampleInformation.vue b/webapp/src/components/SampleInformation.vue
index d47c8b8f1..29f2fcded 100644
--- a/webapp/src/components/SampleInformation.vue
+++ b/webapp/src/components/SampleInformation.vue
@@ -126,7 +126,7 @@ export default {
return this.$store.state.schemas[this.item?.type];
},
possibleItemStatuses() {
- return this.schema?.attributes?.schema?.definitions?.ItemStatus?.enum;
+ return this.schema?.attributes?.schema?.["$defs"]?.ItemStatus?.enum;
},
},
};
diff --git a/webapp/src/components/StartingMaterialInformation.vue b/webapp/src/components/StartingMaterialInformation.vue
index 26a78494f..7bb2bdc3f 100644
--- a/webapp/src/components/StartingMaterialInformation.vue
+++ b/webapp/src/components/StartingMaterialInformation.vue
@@ -184,7 +184,7 @@ export default {
return this.$store.state.schemas[this.item?.type];
},
possibleItemStatuses() {
- return this.schema?.attributes?.schema?.definitions?.StartingMaterialsStatus?.enum;
+ return this.schema?.attributes?.schema?.["$defs"]?.StartingMaterialsStatus?.enum;
},
Barcode: createComputedSetterForItemField("barcode"),
uniqueSuppliers() {