Finished the first cut of adding asset assignments; Added a page to display asset assignments (need to allow removing them).

This commit is contained in:
2022-08-02 12:02:56 -07:00
parent bd88818428
commit 4560d7203d
7 changed files with 316 additions and 160 deletions

View File

@@ -23,12 +23,12 @@ const AssetAssignmentsSchema = new SimpleSchema({
label: "Assignee ID",
optional: false,
},
assigneeType: {
assigneeType: { // 0: Student, 1: Staff
type: SimpleSchema.Integer,
label: "Assignee Type",
optional: false,
min: 1,
max: 2,
min: 0,
max: 1,
exclusiveMin: false,
exclusiveMax: false,
},
@@ -49,15 +49,26 @@ if (Meteor.isServer) {
});
}
Meteor.methods({
'assetAssignments.add'(assetId) {
// check(assetTypeId, String);
// check(assetId, String);
/**
* Assigns the asset to the assignee. The assignee should either be a Student or Staff member.
* @param assetId The Mongo ID of the asset (asset._id).
* @param assigneeType One of: 'Student', 'Staff'
* @param assigneeId The Mongo ID of the Student or Staff (person._id).
*/
'AssetAssignments.add'(assetId, assigneeType, assigneeId) {
check(assigneeId, String);
check(assigneeType, String);
check(assetId, String);
if(Roles.userIsInRole(Meteor.userId(), "admin", {anyScope:true})) {
// Assets.insert({assetTypeId, assetId});
if(assigneeType !== 'Student' || assigneeType !== 'Staff') {
// Should never happen.
console.error("Error: Received incorrect assignee type in adding an assignment.");
}
else if(Roles.userIsInRole(Meteor.userId(), "admin", {anyScope:true})) {
AssetAssignments.insert({assetId, assigneeType: assigneeType === "Student" ? 0 : 1, assigneeId});
}
},
'assetAssignments.remove'(_id) {
'AssetAssignments.remove'(_id) {
check(_id, String);
if(Roles.userIsInRole(Meteor.userId(), "admin", {anyScope:true})) {