Fixed bugs.

This commit is contained in:
2022-09-15 09:13:30 -07:00
parent 6fe980ae6e
commit d7319e340c
5 changed files with 40 additions and 35 deletions

View File

@@ -119,7 +119,7 @@ if (Meteor.isServer) {
} }
if(next.asset) { if(next.asset) {
next.assetType = AssetTypes.findOne({_id: next.asset.assetType}) next.assetType = AssetTypes.findOne({_id: next.asset.assetTypeId})
} }
if(next.assigneeId) { if(next.assigneeId) {

View File

@@ -118,7 +118,7 @@ if (Meteor.isServer) {
} }
if (next.asset) { if (next.asset) {
next.assetType = AssetTypes.findOne({_id: next.asset.assetType}) next.assetType = AssetTypes.findOne({_id: next.asset.assetTypeId})
if (next.asset.assigneeId) { if (next.asset.assigneeId) {
next.assignedTo = next.asset.assigneeType === "Student" ? Students.findOne({_id: next.asset.assigneeId}) : Staff.findOne({_id: next.asset.assigneeId}) next.assignedTo = next.asset.assigneeType === "Student" ? Students.findOne({_id: next.asset.assigneeId}) : Staff.findOne({_id: next.asset.assigneeId})

View File

@@ -65,9 +65,10 @@ const AssignmentsByAsset = () => {
return {foundAsset} return {foundAsset}
}); });
useEffect(() => { //This works too well. The field always gets focus anytime anything is typed anywhere.
if(assetIdInput) assetIdInput.focus() // useEffect(() => {
}) // if(assetIdInput) assetIdInput.focus()
// })
const unassign = () => { const unassign = () => {
// Open the dialog to get condition and comment. // Open the dialog to get condition and comment.
@@ -81,7 +82,10 @@ const AssignmentsByAsset = () => {
if(unassign === true) { if(unassign === true) {
// Call assets.unassign(assetId, comment, condition, conditionDetails, date) // 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()
})
} }
} }

View File

@@ -124,19 +124,23 @@ const AssignmentsByPerson = () => {
if(assign === true) { if(assign === true) {
// Call assets.assign // Call assets.assign
Meteor.call('assets.assign', foundAsset.assetId, selectedPerson.type, selectedPerson._id, assignCondition, assignConditionDetails) 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("") setAssetId("")
// Set the focus back to the asset id text field if(assetIdInput) assetIdInput.focus()
// document.getElementById('assetIdInput').focus() }
// useEffect(() => { })
// if(assetIdInput) assetIdInput.focus()
// }) //document.getElementById('assetIdInput').focus()
} }
} }
useEffect(() => { //This works too well. The field always gets focus anytime anything is typed anywhere.
if(assetIdInput) assetIdInput.focus() // useEffect(() => {
}) // if(assetIdInput) assetIdInput.focus()
// })
const unassign = (asset) => { const unassign = (asset) => {
// Open the dialog to get condition and comment. // Open the dialog to get condition and comment.
@@ -151,7 +155,10 @@ const AssignmentsByPerson = () => {
if(unassign === true) { if(unassign === true) {
// Call assets.unassign(assetId, comment, condition, conditionDetails, date) // 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 = () => {
<div style={{display: 'flex', flexDirection: 'column', margin: '1rem 0 0 .5rem'}}> <div style={{display: 'flex', flexDirection: 'column', margin: '1rem 0 0 .5rem'}}>
{selectedPerson && ( {selectedPerson && (
<div style={cssAssetTile}> <div style={cssAssetTile}>
<div style={{marginBottom: '1rem'}}><TextField id='assetIdInput' inputRef={input=>setAssetIdInput(input)} style={cssEditorField} variant="standard" label="Asset ID" value={assetId} onChange={(e) => {setAssetId(e.target.value)}}/></div> <div style={{marginBottom: '1rem'}}><TextField id='assetIdInput' inputRef={input=>setAssetIdInput(input)} style={cssEditorField} variant="standard" label="Asset ID" value={assetId} onChange={(e) => {setAssetId(e.target.value.toUpperCase())}}/></div>
<div>{foundAsset && foundAsset.assetType.name}</div> <div>{foundAsset && foundAsset.assetType.name}</div>
<div>{foundAsset && foundAsset.serial}</div> <div>{foundAsset && foundAsset.serial}</div>
{foundAsset && foundAsset.assignee && ( {foundAsset && foundAsset.assignee && (

View File

@@ -18,23 +18,17 @@ const RenderUsage = ({data}) => {
User: {next.person.firstName} {next.person.lastName} {next.person.grade ? "~ " + next.person.grade : ""} (<Link to={"/search?email=" + encodeURIComponent(next.email)}>{next.email}</Link>)<br/> User: {next.person.firstName} {next.person.lastName} {next.person.grade ? "~ " + next.person.grade : ""} (<Link to={"/search?email=" + encodeURIComponent(next.email)}>{next.email}</Link>)<br/>
</> </>
)} )}
Device ID: <Link to={"/search?deviceId=" + encodeURIComponent(next.deviceId)}>{next.deviceId}</Link><br/> {/*Device ID: <Link to={"/search?deviceId=" + encodeURIComponent(next.deviceId)}>{next.deviceId}</Link><br/>*/}
{next.assetType && (
<>Asset Type: {next.assetType.name}<br/></>
)}
Serial: <Link to={"/search?serial=" + encodeURIComponent(next.serial)}>{next.serial}</Link><br/> Serial: <Link to={"/search?serial=" + encodeURIComponent(next.serial)}>{next.serial}</Link><br/>
{next.asset && ( {next.asset && (
<> <>Asset ID: <Link to={"/search?assetId=" + encodeURIComponent(next.asset.assetId)}>{next.asset.assetId}</Link><br/></>
Asset ID: <Link to={"/search?assetId=" + encodeURIComponent(next.asset.assetId)}>{next.asset.assetId}</Link><br/>
</>
)}
{new Date(next.startTime).toLocaleDateString("en-US") + "-" + new Date(next.endTime).toLocaleDateString("en-US")}
{next.assetType && (
<>
<br/>Asset Type: {next.assetType.name}
</>
)} )}
{new Date(next.startTime).toLocaleDateString("en-US") + "-" + new Date(next.endTime).toLocaleDateString("en-US")}<br/>
{next.assignedTo && ( {next.assignedTo && (
<> <>Currently assigned to: {next.assignedTo.firstName} {next.assignedTo.lastName} {next.assignedTo.grade ? "~ " + next.assignedTo.grade : ""} ({next.assignedTo.email})</>
<br/>Currently assigned to: {next.assignedTo.firstName} {next.assignedTo.lastName} {next.assignedTo.grade ? "~ " + next.assignedTo.grade : ""} ({next.assignedTo.email})
</>
)} )}
</li> </li>
))} ))}
@@ -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")}<br/> {new Date(next.startDate).toLocaleDateString("en-US") + (next.endDate ? "-" + new Date(next.endDate).toLocaleDateString("en-US") : " - Still Assigned")}<br/>
{next.endDate && ( {next.comment && (
<>Comment: {next.comment}<br/></> <>Comment: {next.comment}<br/></>
)} )}
Start Condition: {next.startCondition}<br/> Start Condition: {next.startCondition}<br/>
Details: {next.startConditionDetails}<br/> {next.startConditionDetails && <>Details: {next.startConditionDetails}<br/></>}
{next.endDate && ( {next.endDate && (
<> <>
End Condition: {next.endCondition}<br/> End Condition: {next.endCondition}<br/>
Details: {next.endConditionDetails}<br/> {next.endConditionDetails && <>Details: {next.endConditionDetails}<br/></>}
</> </>
)} )}
</li> </li>