Initial cut - untested.
This commit is contained in:
@@ -62,7 +62,7 @@ const AssignmentsByPerson = () => {
|
||||
|
||||
const [searchInput, setSearchInput] = useState(undefined)
|
||||
|
||||
const {people} = useTracker(() => {
|
||||
const {people} = useTracker(async () => {
|
||||
let people = [];
|
||||
|
||||
if(search && search.length > 1) {
|
||||
@@ -80,8 +80,8 @@ const AssignmentsByPerson = () => {
|
||||
// Look for students/staff that are active or whose active flag is not set.
|
||||
if(!includeInactive) query = {$and: [query, {$or: [{active: true}, {active: {$exists: false}}]}]}
|
||||
|
||||
const students = Students.find(query).fetch();
|
||||
const staff = Staff.find(query).fetch();
|
||||
const students = await Students.find(query).fetchAsync();
|
||||
const staff = await Staff.find(query).fetchAsync();
|
||||
|
||||
for(let next of students) next.type = "Student"
|
||||
for(let next of staff) next.type = "Staff"
|
||||
@@ -92,11 +92,11 @@ const AssignmentsByPerson = () => {
|
||||
return {people}
|
||||
}, [search]);
|
||||
|
||||
const {assets} = useTracker(() => {
|
||||
const {assets} = useTracker(async () => {
|
||||
let assets = [];
|
||||
|
||||
if(selectedPerson) {
|
||||
assets = Assets.find({assigneeId: selectedPerson._id}).fetch();
|
||||
assets = await Assets.find({assigneeId: selectedPerson._id}).fetchAsync();
|
||||
|
||||
for(let next of assets) {
|
||||
next.assetType = AssetTypes.findOne({_id: next.assetTypeId})
|
||||
@@ -106,17 +106,17 @@ const AssignmentsByPerson = () => {
|
||||
return {assets}
|
||||
}, [selectedPerson]);
|
||||
|
||||
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})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ const AssignmentsByPerson = () => {
|
||||
const [assignmentData, setAssignmentData] = useState([])
|
||||
|
||||
// Collect the usage and assignment data when the selected person changes.
|
||||
useEffect(() => {
|
||||
useEffect(async () => {
|
||||
try {
|
||||
if(selectedPerson) {
|
||||
let query = selectedPerson.type === "Student" ? {studentId: selectedPerson._id} : {staffId: selectedPerson._id}
|
||||
@@ -135,11 +135,11 @@ const AssignmentsByPerson = () => {
|
||||
console.log("Collecting person history")
|
||||
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)
|
||||
})
|
||||
@@ -161,12 +161,12 @@ const AssignmentsByPerson = () => {
|
||||
setOpenAssignDialog(true)
|
||||
}
|
||||
}
|
||||
const assignDialogClosed = (assign) => {
|
||||
const assignDialogClosed = async (assign) => {
|
||||
setOpenAssignDialog(false)
|
||||
|
||||
if(assign === true) {
|
||||
// Call assets.assign
|
||||
Meteor.call('assets.assign', foundAsset.assetId, selectedPerson.type, selectedPerson._id, assignCondition, assignConditionDetails, (err, result) => {
|
||||
await Meteor.callAsync('assets.assign', foundAsset.assetId, selectedPerson.type, selectedPerson._id, assignCondition, assignConditionDetails, (err, result) => {
|
||||
if(err) console.error(err)
|
||||
else {
|
||||
// Clear the asset id field and set focus to it.
|
||||
@@ -193,19 +193,19 @@ const AssignmentsByPerson = () => {
|
||||
setUnassignConditionDetails(asset.conditionDetails || "")
|
||||
setOpenUnassignDialog(true);
|
||||
}
|
||||
const unassignDialogClosed = (unassign) => {
|
||||
const unassignDialogClosed = async (unassign) => {
|
||||
setOpenUnassignDialog(false)
|
||||
|
||||
if(unassign === true) {
|
||||
if(unassignDialogEditConditionOnly) {
|
||||
Meteor.call('assets.updateCondition', unassignAsset._id, unassignCondition, unassignConditionDetails, (err, result) => {
|
||||
await Meteor.callAsync('assets.updateCondition', unassignAsset._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', unassignAsset.assetId, unassignComment, unassignCondition, unassignConditionDetails, (err, result) => {
|
||||
await Meteor.callAsync('assets.unassign', unassignAsset.assetId, unassignComment, unassignCondition, unassignConditionDetails, (err, result) => {
|
||||
if(err) console.error(err)
|
||||
else if(assetIdInput) assetIdInput.focus()
|
||||
})
|
||||
@@ -322,7 +322,7 @@ const AssignmentsByPerson = () => {
|
||||
})}
|
||||
</TextField>
|
||||
</div>
|
||||
<TextField style={{marginTop: '1rem',minWidth: '30rem'}} multiline rows={4} variant="outlined" label="Condition Details" value={assignConditionDetails} onChange={(e) => {setAssignConditionDetails(e.target.value)}}/>
|
||||
<TextField style={{marginTop: '1rem',minWidth: '30rem'}} multiline rows={4} variant="outlined" label="Condition Details" value={assignConditionDetails} onChange={(e,v) => {setAssignConditionDetails(v)}}/>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={() => assignDialogClosed(true)}>Assign</Button>
|
||||
|
||||
Reference in New Issue
Block a user