diff --git a/imports/api/asset-assignment-history.js b/imports/api/asset-assignment-history.js index 4ea20d3..3a7af45 100644 --- a/imports/api/asset-assignment-history.js +++ b/imports/api/asset-assignment-history.js @@ -119,14 +119,14 @@ if (Meteor.isServer) { } if(next.asset) { - next.assetType = AssetTypes.findOne({_id: next.asset.assetType}) + next.assetType = AssetTypes.findOne({_id: next.asset.assetTypeId}) } if(next.assigneeId) { next.assignee = next.asset.assigneeType === "Student" ? Students.findOne({_id: next.assigneeId}) : Staff.findOne({_id: next.assigneeId}) } } - + return result; } else return null; } diff --git a/imports/api/data-collection.js b/imports/api/data-collection.js index 34265ea..04031ce 100644 --- a/imports/api/data-collection.js +++ b/imports/api/data-collection.js @@ -118,7 +118,7 @@ if (Meteor.isServer) { } if (next.asset) { - next.assetType = AssetTypes.findOne({_id: next.asset.assetType}) + next.assetType = AssetTypes.findOne({_id: next.asset.assetTypeId}) if (next.asset.assigneeId) { next.assignedTo = next.asset.assigneeType === "Student" ? Students.findOne({_id: next.asset.assigneeId}) : Staff.findOne({_id: next.asset.assigneeId}) diff --git a/imports/ui/pages/Assignments/ByAsset.jsx b/imports/ui/pages/Assignments/ByAsset.jsx index 1b629e5..3e19695 100644 --- a/imports/ui/pages/Assignments/ByAsset.jsx +++ b/imports/ui/pages/Assignments/ByAsset.jsx @@ -65,9 +65,10 @@ const AssignmentsByAsset = () => { return {foundAsset} }); - useEffect(() => { - if(assetIdInput) assetIdInput.focus() - }) + //This works too well. The field always gets focus anytime anything is typed anywhere. + // useEffect(() => { + // if(assetIdInput) assetIdInput.focus() + // }) const unassign = () => { // Open the dialog to get condition and comment. @@ -81,7 +82,10 @@ const AssignmentsByAsset = () => { if(unassign === true) { // Call assets.unassign(assetId, comment, condition, conditionDetails, date) - Meteor.call('assets.unassign', foundAsset.assetId, unassignComment, unassignCondition, unassignConditionDetails) + Meteor.call('assets.unassign', foundAsset.assetId, unassignComment, unassignCondition, unassignConditionDetails, (err, result) => { + if(err) console.error(err) + else if(assetIdInput) assetIdInput.focus() + }) } } diff --git a/imports/ui/pages/Assignments/ByPerson.jsx b/imports/ui/pages/Assignments/ByPerson.jsx index d1a920c..6cefba6 100644 --- a/imports/ui/pages/Assignments/ByPerson.jsx +++ b/imports/ui/pages/Assignments/ByPerson.jsx @@ -124,19 +124,23 @@ const AssignmentsByPerson = () => { if(assign === true) { // Call assets.assign - Meteor.call('assets.assign', foundAsset.assetId, selectedPerson.type, selectedPerson._id, assignCondition, assignConditionDetails) - setAssetId("") - // Set the focus back to the asset id text field - // document.getElementById('assetIdInput').focus() - // useEffect(() => { - // if(assetIdInput) assetIdInput.focus() - // }) + Meteor.call('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. + setAssetId("") + if(assetIdInput) assetIdInput.focus() + } + }) + + //document.getElementById('assetIdInput').focus() } } - useEffect(() => { - if(assetIdInput) assetIdInput.focus() - }) + //This works too well. The field always gets focus anytime anything is typed anywhere. + // useEffect(() => { + // if(assetIdInput) assetIdInput.focus() + // }) const unassign = (asset) => { // Open the dialog to get condition and comment. @@ -151,7 +155,10 @@ const AssignmentsByPerson = () => { if(unassign === true) { // Call assets.unassign(assetId, comment, condition, conditionDetails, date) - Meteor.call('assets.unassign', unassignAsset.assetId, unassignComment, unassignCondition, unassignConditionDetails) + Meteor.call('assets.unassign', unassignAsset.assetId, unassignComment, unassignCondition, unassignConditionDetails, (err, result) => { + if(err) console.error(err) + else if(assetIdInput) assetIdInput.focus() + }) } } @@ -226,7 +233,7 @@ const AssignmentsByPerson = () => {
{selectedPerson && (
-
setAssetIdInput(input)} style={cssEditorField} variant="standard" label="Asset ID" value={assetId} onChange={(e) => {setAssetId(e.target.value)}}/>
+
setAssetIdInput(input)} style={cssEditorField} variant="standard" label="Asset ID" value={assetId} onChange={(e) => {setAssetId(e.target.value.toUpperCase())}}/>
{foundAsset && foundAsset.assetType.name}
{foundAsset && foundAsset.serial}
{foundAsset && foundAsset.assignee && ( diff --git a/imports/ui/pages/Search.jsx b/imports/ui/pages/Search.jsx index 6d1c785..6b1ff14 100644 --- a/imports/ui/pages/Search.jsx +++ b/imports/ui/pages/Search.jsx @@ -18,23 +18,17 @@ const RenderUsage = ({data}) => { User: {next.person.firstName} {next.person.lastName} {next.person.grade ? "~ " + next.person.grade : ""} ({next.email})
)} - Device ID: {next.deviceId}
+ {/*Device ID: {next.deviceId}
*/} + {next.assetType && ( + <>Asset Type: {next.assetType.name}
+ )} Serial: {next.serial}
{next.asset && ( - <> - Asset ID: {next.asset.assetId}
- - )} - {new Date(next.startTime).toLocaleDateString("en-US") + "-" + new Date(next.endTime).toLocaleDateString("en-US")} - {next.assetType && ( - <> -
Asset Type: {next.assetType.name} - + <>Asset ID: {next.asset.assetId}
)} + {new Date(next.startTime).toLocaleDateString("en-US") + "-" + new Date(next.endTime).toLocaleDateString("en-US")}
{next.assignedTo && ( - <> -
Currently assigned to: {next.assignedTo.firstName} {next.assignedTo.lastName} {next.assignedTo.grade ? "~ " + next.assignedTo.grade : ""} ({next.assignedTo.email}) - + <>Currently assigned to: {next.assignedTo.firstName} {next.assignedTo.lastName} {next.assignedTo.grade ? "~ " + next.assignedTo.grade : ""} ({next.assignedTo.email}) )} ))} @@ -66,15 +60,15 @@ const RenderAssignments = ({data}) => { )} {new Date(next.startDate).toLocaleDateString("en-US") + (next.endDate ? "-" + new Date(next.endDate).toLocaleDateString("en-US") : " - Still Assigned")}
- {next.endDate && ( + {next.comment && ( <>Comment: {next.comment}
)} Start Condition: {next.startCondition}
- Details: {next.startConditionDetails}
+ {next.startConditionDetails && <>Details: {next.startConditionDetails}
} {next.endDate && ( <> End Condition: {next.endCondition}
- Details: {next.endConditionDetails}
+ {next.endConditionDetails && <>Details: {next.endConditionDetails}
} )}