Initial cut - untested.
This commit is contained in:
@@ -38,13 +38,13 @@ const AssetTypeEditor = ({value, close}) => {
|
||||
const [name, setName] = useState(value.name || "")
|
||||
const [description, setDescription] = useState(value.description || "")
|
||||
|
||||
const applyChanges = () => {
|
||||
const applyChanges = async () => {
|
||||
close()
|
||||
//TODO Should invert this and only close if there was success on the server.
|
||||
if(value._id)
|
||||
Meteor.call("assetTypes.update", value._id, name, description, year);
|
||||
await Meteor.callAsync("assetTypes.update", value._id, name, description, year);
|
||||
else
|
||||
Meteor.call("assetTypes.add", name, description, year);
|
||||
await Meteor.callAsync("assetTypes.add", name, description, year);
|
||||
}
|
||||
const rejectChanges = () => {
|
||||
close()
|
||||
@@ -69,8 +69,8 @@ const AssetTypeEditor = ({value, close}) => {
|
||||
export default () => {
|
||||
Meteor.subscribe('assetTypes');
|
||||
|
||||
const {assetTypes} = useTracker(() => {
|
||||
let assetTypes = AssetTypes.find().fetch();
|
||||
const {assetTypes} = useTracker(async () => {
|
||||
let assetTypes = await AssetTypes.find().fetchAsync();
|
||||
|
||||
return {assetTypes}
|
||||
});
|
||||
|
||||
@@ -30,13 +30,13 @@ const SiteEditor = ({value, close}) => {
|
||||
const [name, setName] = useState(value.name || "")
|
||||
const [externalId, setExternalId] = useState(value.externalId || "")
|
||||
|
||||
const applyChanges = () => {
|
||||
const applyChanges = async () => {
|
||||
close()
|
||||
//TODO Should invert this and only close if there was success on the server.
|
||||
if(value._id)
|
||||
Meteor.call("sites.update", value._id, name, externalId);
|
||||
await Meteor.callAsync("sites.update", value._id, name, externalId);
|
||||
else
|
||||
Meteor.call("sites.add", name, externalId);
|
||||
await Meteor.callAsync("sites.add", name, externalId);
|
||||
}
|
||||
const rejectChanges = () => {
|
||||
close()
|
||||
@@ -58,8 +58,8 @@ const SiteEditor = ({value, close}) => {
|
||||
export default () => {
|
||||
Meteor.subscribe('sites');
|
||||
|
||||
const {sites} = useTracker(() => {
|
||||
const sites = Sites.find({}).fetch();
|
||||
const {sites} = useTracker(async () => {
|
||||
const sites = await Sites.find({}).fetchAsync();
|
||||
return {
|
||||
sites
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ const StaffEditor = ({value, close, defaultSiteId}) => {
|
||||
const [lastName, setLastName] = useState(value.lastName || "")
|
||||
const [siteId, setSiteId] = useState(value.siteId ? value.siteId : defaultSiteId)
|
||||
|
||||
const {sites} = useTracker(() => {
|
||||
let sites = Sites.find({}).fetch();
|
||||
const {sites} = useTracker(async () => {
|
||||
let sites = await Sites.find({}).fetchAsync();
|
||||
|
||||
return {sites}
|
||||
});
|
||||
@@ -52,13 +52,13 @@ const StaffEditor = ({value, close, defaultSiteId}) => {
|
||||
setSiteId(sites[0]._id)
|
||||
}
|
||||
|
||||
const applyChanges = () => {
|
||||
const applyChanges = async () => {
|
||||
close()
|
||||
//TODO Should invert this and only close if there was success on the server.
|
||||
if(value._id)
|
||||
Meteor.call("staff.update", value._id, id, firstName, lastName, email, siteId);
|
||||
await Meteor.callAsync("staff.update", value._id, id, firstName, lastName, email, siteId);
|
||||
else
|
||||
Meteor.call("staff.add", id, firstName, lastName, email, siteId);
|
||||
await Meteor.callAsync("staff.add", id, firstName, lastName, email, siteId);
|
||||
}
|
||||
const rejectChanges = () => {
|
||||
close()
|
||||
@@ -94,17 +94,17 @@ export default () => {
|
||||
Meteor.subscribe('sites');
|
||||
Meteor.subscribe('staff');
|
||||
|
||||
const {sites} = useTracker(() => {
|
||||
const sites = Sites.find({}).fetch();
|
||||
const {sites} = useTracker(async () => {
|
||||
const sites = await Sites.find({}).fetchAsync();
|
||||
|
||||
sites.push(siteAll);
|
||||
|
||||
return {sites}
|
||||
});
|
||||
|
||||
const {staff} = useTracker(() => {
|
||||
const {staff} = useTracker(async () => {
|
||||
const staffQuery = site === siteAll._id ? {} : {siteId: site}
|
||||
let staff = Staff.find(staffQuery).fetch();
|
||||
let staff = await Staff.find(staffQuery).fetchAsync();
|
||||
|
||||
return {staff}
|
||||
});
|
||||
|
||||
@@ -56,8 +56,8 @@ const StudentEditor = ({value, close, defaultSiteId}) => {
|
||||
const [active, setActive] = useState(value.active)
|
||||
const [siteId, setSiteId] = useState(value.siteId ? value.siteId : defaultSiteId)
|
||||
|
||||
const {sites} = useTracker(() => {
|
||||
let sites = Sites.find({}).fetch();
|
||||
const {sites} = useTracker(async () => {
|
||||
let sites = await Sites.find({}).fetch();
|
||||
|
||||
return {sites}
|
||||
});
|
||||
@@ -66,13 +66,13 @@ const StudentEditor = ({value, close, defaultSiteId}) => {
|
||||
setSiteId(sites[0]._id)
|
||||
}
|
||||
|
||||
const applyChanges = () => {
|
||||
const applyChanges = async () => {
|
||||
close()
|
||||
//TODO Should invert this and only close if there was success on the server.
|
||||
if(value._id)
|
||||
Meteor.call("students.update", value._id, id, firstName, firstNameAlias, lastName, email, siteId, grade, active);
|
||||
await Meteor.callAsync("students.update", value._id, id, firstName, firstNameAlias, lastName, email, siteId, grade, active);
|
||||
else
|
||||
Meteor.call("students.add", id, firstName, firstNameAlias, lastName, email, siteId, grade, active);
|
||||
await Meteor.callAsync("students.add", id, firstName, firstNameAlias, lastName, email, siteId, grade, active);
|
||||
}
|
||||
const rejectChanges = () => {
|
||||
close()
|
||||
@@ -110,8 +110,8 @@ export default () => {
|
||||
Meteor.subscribe('sites');
|
||||
Meteor.subscribe('students');
|
||||
|
||||
const {sites} = useTracker(() => {
|
||||
const sites = Sites.find({}).fetch();
|
||||
const {sites} = useTracker(async () => {
|
||||
const sites = await Sites.find({}).fetchAsync();
|
||||
|
||||
sites.push(siteAll);
|
||||
|
||||
@@ -124,7 +124,7 @@ export default () => {
|
||||
const [active, setActive] = useState(ACTIVE_BOTH)
|
||||
const [nameSearch, setNameSearch] = useState("")
|
||||
|
||||
const {students} = useTracker(() => {
|
||||
const {students} = useTracker(async () => {
|
||||
const studentQuery = site === siteAll._id ? {} : {siteId: site}
|
||||
|
||||
if(active !== ACTIVE_BOTH) {
|
||||
@@ -135,7 +135,7 @@ export default () => {
|
||||
studentQuery["$or"] = [{firstName: {$regex: nameSearch, $options: 'i'}}, {firstNameAlias: {$regex: nameSearch, $options: 'i'}}, {lastName: {$regex: nameSearch, $options: 'i'}}]
|
||||
}
|
||||
|
||||
let students = Students.find(studentQuery).fetch();
|
||||
let students = await Students.find(studentQuery).fetchAsync();
|
||||
|
||||
return {students}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user