Initial cut - untested.
This commit is contained in:
@@ -53,9 +53,9 @@ const AddAssets = ({assetTypes}) => {
|
||||
backgroundColor: selectedAssetType === assetType ? '#EECFA6' : 'white'
|
||||
}
|
||||
}
|
||||
const addAsset = () => {
|
||||
const addAsset = async () => {
|
||||
//TODO: Check the inputs.
|
||||
Meteor.call("assets.add", selectedAssetType._id, assetId, serial, condition, conditionDetails);
|
||||
await Meteor.callAsync("assets.add", selectedAssetType._id, assetId, serial, condition, conditionDetails);
|
||||
setAssetId("")
|
||||
setSerial("")
|
||||
}
|
||||
@@ -122,8 +122,8 @@ const AddAssets = ({assetTypes}) => {
|
||||
export default () => {
|
||||
Meteor.subscribe('assetTypes');
|
||||
|
||||
const {assetTypes} = useTracker(() => {
|
||||
const assetTypes = AssetTypes.find({}, {sort: {year: -1}}).fetch();
|
||||
const {assetTypes} = useTracker(async () => {
|
||||
const assetTypes = await AssetTypes.find({}, {sort: {year: -1}}).fetchAsync();
|
||||
|
||||
return {
|
||||
assetTypes
|
||||
|
||||
@@ -44,13 +44,13 @@ const AssetEditor = ({value, close}) => {
|
||||
const [assetTypeId, setAssetTypeId] = useState(value.assetTypeId || "")
|
||||
const assetTypes = AssetTypes.find({}, {sort: {year: -1}});
|
||||
|
||||
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("assets.update", value._id, assetTypeId, assetId, serial, condition, conditionDetails);
|
||||
await Meteor.callAsync("assets.update", value._id, assetTypeId, assetId, serial, condition, conditionDetails);
|
||||
else
|
||||
Meteor.call("assets.add", assetTypeId, assetId, serial, condition, conditionDetails);
|
||||
await Meteor.callAsync("assets.add", assetTypeId, assetId, serial, condition, conditionDetails);
|
||||
}
|
||||
const rejectChanges = () => {
|
||||
close()
|
||||
@@ -93,15 +93,15 @@ export default () => {
|
||||
const assetTypes = [{name: "All", _id: 0}, ...AssetTypes.find({}, {sort: {year: -1}}).fetch()]
|
||||
|
||||
|
||||
const {assets} = useTracker(() => {
|
||||
const {assets} = useTracker(async () => {
|
||||
let query = {}
|
||||
|
||||
if(assetId) query.assetId = {$regex: assetId, $options: 'i'}
|
||||
if(serial) query.serial = {$regex: serial, $options: 'i'}
|
||||
if(assetTypeId) query.assetTypeId = assetTypeId
|
||||
|
||||
const assets = Assets.find(query).fetch();
|
||||
const assetTypes = AssetTypes.find({}, {sort: {year: -1}}).fetch();
|
||||
const assets = await Assets.find(query).fetchAsync();
|
||||
const assetTypes = await AssetTypes.find({}, {sort: {year: -1}}).fetchAsync();
|
||||
const assetTypeNameMap = assetTypes.reduce((map, obj) => {
|
||||
map[obj._id] = obj;
|
||||
return map;
|
||||
@@ -170,8 +170,8 @@ export default () => {
|
||||
maxHeight: '40rem'
|
||||
}
|
||||
|
||||
const removeAsset = (asset) => {
|
||||
Meteor.call("assets.remove", asset._id);
|
||||
const removeAsset = async (asset) => {
|
||||
await Meteor.callAsync("assets.remove", asset._id);
|
||||
setRemoveRow(undefined)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user