Updated the models.
This commit is contained in:
68
imports/api/asset-assignments.js
Normal file
68
imports/api/asset-assignments.js
Normal file
@@ -0,0 +1,68 @@
|
||||
import {Mongo} from "meteor/mongo";
|
||||
import {Meteor} from "meteor/meteor";
|
||||
import { check } from 'meteor/check';
|
||||
import { Roles } from 'meteor/alanning:roles';
|
||||
import SimpleSchema from "simpl-schema";
|
||||
import {AssetTypes} from "./asset-types";
|
||||
|
||||
export const AssetAssignments = new Mongo.Collection('assetAssignments');
|
||||
/*
|
||||
const TYPE_STUDENT = 1;
|
||||
const TYPE_STAFF = 2;
|
||||
|
||||
const AssetAssignmentsSchema = new SimpleSchema({
|
||||
assetId: {
|
||||
type: String,
|
||||
label: "Asset ID",
|
||||
optional: false,
|
||||
index: 1,
|
||||
unique: false
|
||||
},
|
||||
assigneeId: {
|
||||
type: String,
|
||||
label: "Assignee ID",
|
||||
optional: false,
|
||||
},
|
||||
assigneeType: {
|
||||
type: SimpleSchema.Integer,
|
||||
label: "Assignee Type",
|
||||
optional: false,
|
||||
min: 1,
|
||||
max: 2,
|
||||
exclusiveMin: false,
|
||||
exclusiveMax: false,
|
||||
},
|
||||
});
|
||||
|
||||
AssetAssignments.attachSchema(AssetAssignmentsSchema);
|
||||
*/
|
||||
|
||||
if (Meteor.isServer) {
|
||||
// Drop any old indexes we no longer will use. Create indexes we need.
|
||||
//try {AssetTypes._dropIndex("name")} catch(e) {}
|
||||
//AssetTypes.createIndex({name: "text"}, {name: "name", unique: false});
|
||||
AssetTypes.createIndex({assetId: 1}, {name: "AssetID", unique: false});
|
||||
|
||||
// This code only runs on the server
|
||||
Meteor.publish('assetAssignments', function() {
|
||||
return AssetAssignments.find({});
|
||||
});
|
||||
}
|
||||
Meteor.methods({
|
||||
'assetAssignments.add'(assetId) {
|
||||
// check(assetTypeId, String);
|
||||
// check(assetId, String);
|
||||
|
||||
if(Roles.userIsInRole(Meteor.userId(), "admin", {anyScope:true})) {
|
||||
// Assets.insert({assetTypeId, assetId});
|
||||
}
|
||||
},
|
||||
'assetAssignments.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.
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user