diff --git a/imports/api/assets.js b/imports/api/assets.js index f80c2dd..0ea3c84 100644 --- a/imports/api/assets.js +++ b/imports/api/assets.js @@ -114,8 +114,9 @@ Meteor.methods({ } else throw new Meteor.Error("User Permission Error"); }, - 'assets.update'(_id, assetId, serial, condition, conditionDetails) { + 'assets.update'(_id, assetTypeId, assetId, serial, condition, conditionDetails) { check(_id, String); + check(assetTypeId, String); check(assetId, String); if(serial) check(serial, String); check(condition, String); @@ -129,7 +130,7 @@ Meteor.methods({ if(Roles.userIsInRole(Meteor.userId(), "admin", {anyScope:true})) { //TODO: Need to first verify there are no checked out assets to the staff member. - Assets.update({_id}, {$set: {assetId, serial, condition, conditionDetail}}); + Assets.update({_id}, {$set: {assetTypeId, assetId, serial, condition, conditionDetails}}); } else throw new Meteor.Error("User Permission Error"); }, diff --git a/imports/ui/Assets/AssetList.svelte b/imports/ui/Assets/AssetList.svelte index 4079fb9..8f52366 100644 --- a/imports/ui/Assets/AssetList.svelte +++ b/imports/ui/Assets/AssetList.svelte @@ -17,6 +17,7 @@ }); let assetTypes; $: assetTypes = AssetTypes.find({}, {sort: {year: -1}}); + let assetTypeNameMap; $: assetTypeNameMap = derived(assetTypes, $assetTypes => $assetTypes.reduce((map, obj) => { map[obj._id] = obj.name; return map; @@ -40,6 +41,13 @@ minWidth: 100, weight: 1, cls: "serial", + }, { + key: "condition", + title: "Condition", + value: v => v.condition ? v.condition : "-", + minWidth: 100, + weight: 1, + cls: "condition", }, { key: "asset", title: "Asset Type", @@ -75,7 +83,7 @@ // Copy the edited site when ever it changes, set some defaults for a new site object (to make the view happy). editedAsset.subscribe(site => { if(site) { - dirtyAsset = Object.assign({serial: "", assetId: "", assetTypeId: ""}, site); + dirtyAsset = Object.assign({serial: "", assetId: "", assetTypeId: "", condition: "", conditionDetails: ""}, site); //document.getElementsByClassName('select').focus(); } else dirtyAsset = null; @@ -84,9 +92,9 @@ let assets = Assets.find({}); const applyAssetChanges = () => { if(dirtyAsset._id) - Meteor.call("assets.update", dirtyAsset._id, dirtyAsset.assetId, dirtyAsset.serial); + Meteor.call("assets.update", dirtyAsset._id, dirtyAsset.assetTypeId, dirtyAsset.assetId, dirtyAsset.serial, dirtyAsset.condition, dirtyAsset.conditionDetails); else - Meteor.call("assets.add", dirtyAsset.assetTypeId, dirtyAsset.assetId, dirtyAsset.serial); + Meteor.call("assets.add", dirtyAsset.assetTypeId, dirtyAsset.assetId, dirtyAsset.serial, dirtyAsset.condition, dirtyAsset.conditionDetails); editedAsset.set(null); } const rejectAssetChanges = () => { @@ -135,7 +143,7 @@ {/each}
- +