Reorganized assignment UI. Added searching by person.

This commit is contained in:
2022-08-16 07:39:15 -07:00
parent 571f3da1d6
commit 1501a36801
9 changed files with 3816 additions and 198 deletions

View File

@@ -3,6 +3,9 @@ import { Mongo } from 'meteor/mongo';
import { check } from 'meteor/check';
import { MongoClient } from 'mongodb';
import {Assets} from "/imports/api/assets";
import {Students} from "/imports/api/students";
import {Staff} from "/imports/api/staff";
import {AssetTypes} from "/imports/api/asset-types";
//import {Roles} from 'alanning/roles';
// console.log("Setting Up Data Collection...")
@@ -81,13 +84,34 @@ if (Meteor.isServer) {
}
if(query) {
console.log("Collecting Chromebook Data: ");
console.log(query);
// console.log("Collecting Chromebook Data: ");
// console.log(query);
//Sort by the last time the record was updated from most to least recent.
let result = Meteor.Records.find(query, {sort: {endTime: -1}}).fetch();
// console.log("Found: ");
// console.log(result);
//Add some additional data to the records.
for (let next of result) {
if (next.serial) {
next.asset = Assets.findOne({serial: next.serial});
}
if (next.email) {
next.person = Students.findOne({email: next.email});
if (!next.person) next.person = Staff.findOne({email: next.email});
}
if (next.asset) {
next.assetType = AssetTypes.findOne({_id: next.asset.assetType})
if (next.asset.assigneeId) {
next.assignedTo = next.asset.assigneeType === "Student" ? Students.findOne({_id: next.asset.assigneeId}) : Staff.findOne({_id: next.asset.assigneeId})
}
}
}
return result;
} else return null;

View File

@@ -12,7 +12,8 @@ export const Staff = new Mongo.Collection('staff');
if (Meteor.isServer) {
// This code only runs on the server
Meteor.publish('staff', function(siteId) {
return Staff.find({siteId});
if(siteId) check(siteId, String);
return siteId ? Staff.find({siteId}) : Staff.find({});
});
}
Meteor.methods({

View File

@@ -14,7 +14,8 @@ if (Meteor.isServer) {
// This code only runs on the server
Meteor.publish('students', function(siteId) {
return Students.find({siteId});
if(siteId) check(siteId, String);
return siteId ? Students.find({siteId}) : Students.find({});
});
Meteor.methods({