Finished coding the AssetTypes part of the Admin page. Tested adding assets. Did not implement removing them or updating them. Added the start for a page to manage assets.
This commit is contained in:
@@ -22,13 +22,7 @@ const AssetTypesSchema = new SimpleSchema({
|
||||
label: "Description",
|
||||
optional: true,
|
||||
trim: true,
|
||||
defaultValue: ""
|
||||
},
|
||||
hasSerial: {
|
||||
type: Boolean,
|
||||
label: "Is a serial number available for all instances?",
|
||||
optional: false,
|
||||
defaultValue: false
|
||||
defaultValue: "",
|
||||
},
|
||||
});
|
||||
|
||||
@@ -37,9 +31,9 @@ AssetTypes.attachSchema(AssetTypesSchema);
|
||||
|
||||
if (Meteor.isServer) {
|
||||
// Drop any old indexes we no longer will use. Create indexes we need.
|
||||
try {AssetTypes._dropIndex("name")} catch(e) {}
|
||||
try {AssetTypes._dropIndex("External ID")} catch(e) {}
|
||||
//AssetTypes.createIndex({name: "text"}, {name: "name", unique: false});
|
||||
AssetTypes.createIndex({id: 1}, {name: "External ID", unique: true});
|
||||
//AssetTypes.createIndex({id: 1}, {name: "External ID", unique: true});
|
||||
|
||||
//Debug: Show all indexes.
|
||||
// AssetTypes.rawCollection().indexes((err, indexes) => {
|
||||
@@ -52,20 +46,28 @@ if (Meteor.isServer) {
|
||||
});
|
||||
}
|
||||
Meteor.methods({
|
||||
'assetTypes.add'(name, description, hasSerial) {
|
||||
'assetTypes.add'(name, description) {
|
||||
check(name, String);
|
||||
check(description, String);
|
||||
check(hasSerial, Boolean);
|
||||
|
||||
if(Roles.userIsInRole(Meteor.userId(), "admin", {anyScope:true})) {
|
||||
AssetTypes.insert({name, description, hasSerial});
|
||||
AssetTypes.insert({name, description});
|
||||
}
|
||||
},
|
||||
'assetTypes.update'(_id, name, description) {
|
||||
check(_id, String);
|
||||
check(name, String);
|
||||
check(description, String);
|
||||
|
||||
if(Roles.userIsInRole(Meteor.userId(), "admin", {anyScope:true})) {
|
||||
AssetTypes.update({_id}, {$set: {name, description}});
|
||||
}
|
||||
},
|
||||
'assetTypes.remove'(_id) {
|
||||
check(_id, String);
|
||||
|
||||
if(Roles.userIsInRole(Meteor.userId(), "admin", {anyScope:true})) {
|
||||
//TODO: Need to first verify there are no checked out assets to the staff member.
|
||||
//TODO: Need to either remove all assets of this type, or change their type.
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user