Initial cut - untested.

This commit is contained in:
2025-09-25 09:31:02 -07:00
parent 7a0666cc6c
commit 3775522265
33 changed files with 351 additions and 346 deletions

View File

@@ -59,17 +59,17 @@ const AssignmentsByAsset = () => {
const [assetIdInput, setAssetIdInput] = useState(undefined)
const {foundAsset} = useTracker(() => {
const {foundAsset} = useTracker(async () => {
let foundAsset = null;
if(assetId) {
foundAsset = Assets.findOne({assetId: assetId});
foundAsset = await Assets.findOneAsync({assetId: assetId});
if(foundAsset) {
foundAsset.assetType = AssetTypes.findOne({_id: foundAsset.assetTypeId})
foundAsset.assetType = await AssetTypes.findOneAsync({_id: foundAsset.assetTypeId})
if(foundAsset.assigneeId)
foundAsset.assignee = foundAsset.assigneeType === "Student" ? Students.findOne({_id: foundAsset.assigneeId}) : Staff.findOne({_id: foundAsset.assigneeId})
foundAsset.assignee = foundAsset.assigneeType === "Student" ? await Students.findOneAsync({_id: foundAsset.assigneeId}) : await Staff.findOneAsync({_id: foundAsset.assigneeId})
}
}
@@ -99,7 +99,7 @@ const AssignmentsByAsset = () => {
const [assignmentData, setAssignmentData] = useState([])
// Collect the usage and assignment data when the selected person changes.
useEffect(() => {
useEffect(async () => {
try {
if(foundAsset) {
let query = {assetId: foundAsset.assetId}
@@ -107,11 +107,11 @@ const AssignmentsByAsset = () => {
console.log("Requesting asset historical data")
console.log(query)
Meteor.call('DataCollection.chromebookData', query, (err, result) => {
await Meteor.callAsync('DataCollection.chromebookData', query, (err, result) => {
if (err) console.error(err)
else setUsageData(result)
})
Meteor.call('AssetAssignmentHistory.get', query, (err, result) => {
await Meteor.callAsync('AssetAssignmentHistory.get', query, (err, result) => {
if (err) console.error(err)
else setAssignmentData(result)
})
@@ -149,19 +149,19 @@ const AssignmentsByAsset = () => {
setUnassignConditionDetails(foundAsset.conditionDetails || "")
setOpenUnassignDialog(true);
}
const unassignDialogClosed = (unassign) => {
const unassignDialogClosed = async (unassign) => {
setOpenUnassignDialog(false)
if(unassign === true) {
if(unassignDialogEditConditionOnly) {
Meteor.call('assets.updateCondition', foundAsset._id, unassignCondition, unassignConditionDetails, (err, result) => {
await Meteor.callAsync('assets.updateCondition', foundAsset._id, unassignCondition, unassignConditionDetails, (err, result) => {
if(err) console.error(err)
else if(assetIdInput) assetIdInput.focus()
})
}
else {
// Call assets.unassign(assetId, comment, condition, conditionDetails, date)
Meteor.call('assets.unassign', foundAsset.assetId, unassignComment, unassignCondition, unassignConditionDetails, (err, result) => {
await Meteor.callAsync('assets.unassign', foundAsset.assetId, unassignComment, unassignCondition, unassignConditionDetails, (err, result) => {
if (err) console.error(err)
else if (assetIdInput) assetIdInput.focus()
})