Upgraded to Meteor 1.6.0.1 and NodeJS 8.9.3. Added weekly/daily property to venues to support graphing and tracking of actual income from farmers markets (they don't usually match with expected income). Added workers objects to help illustrate who did what work (who was at the market on a specific week for example, or who prep'd and who canned a batch of jam). Fixed some bugs in the venue page. Re-design of the menu to allow for more menu options.
This commit is contained in:
@@ -3,6 +3,9 @@ import { Mongo } from 'meteor/mongo';
|
||||
import { check } from 'meteor/check';
|
||||
import {SimpleSchema} from 'meteor/aldeed:simple-schema';
|
||||
|
||||
const TYPES = ['Retail', "Farmer's Market", "Restaurant", "Mail"];
|
||||
const FREQUENCIES = ['Daily', 'Weekly'];
|
||||
|
||||
Venues = new Mongo.Collection('Venues');
|
||||
let VenuesSchema = new SimpleSchema({
|
||||
name: {
|
||||
@@ -17,7 +20,15 @@ let VenuesSchema = new SimpleSchema({
|
||||
type: String,
|
||||
label: "Type",
|
||||
optional: false,
|
||||
trim: true
|
||||
trim: true,
|
||||
allowedValues: TYPES //If you change these values, also change Venues.js for the editor to include the new list when setting up the combo.
|
||||
},
|
||||
frequency: { // How often the market is run. The exact day or week is not important, just that it is daily, weekly, bi-weekly, monthly, etc... Currently only supporting Daily and Weekly since all markets fit into these categories.
|
||||
type: String,
|
||||
label: "Frequency",
|
||||
optional: false,
|
||||
defaultValue: 'Daily',
|
||||
allowedValues: FREQUENCIES //If you change these values, also change Venues.js for the editor to include the new list when setting up the combo.
|
||||
},
|
||||
createdAt: {
|
||||
type: Date,
|
||||
@@ -40,6 +51,7 @@ let VenuesSchema = new SimpleSchema({
|
||||
optional: true
|
||||
}
|
||||
});
|
||||
VenuesSchema.constants = {types: TYPES, frequencies: FREQUENCIES};
|
||||
Venues.attachSchema(VenuesSchema);
|
||||
|
||||
if(Meteor.isServer) Meteor.publish('venues', function() {
|
||||
@@ -58,12 +70,30 @@ if(Meteor.isServer) {
|
||||
//});
|
||||
|
||||
Meteor.methods({
|
||||
createVenue: function(name, type) {
|
||||
createVenue: function(name, type, frequency) {
|
||||
check(name, String);
|
||||
check(type, String);
|
||||
check(frequency, String);
|
||||
|
||||
if(Roles.userIsInRole(this.userId, [Meteor.UserRoles.ROLE_UPDATE])) {
|
||||
Venues.insert({name, type, createdAt: new Date()});
|
||||
Venues.insert({name, type, frequency, createdAt: new Date()});
|
||||
}
|
||||
else throw new Meteor.Error(403, "Not authorized.");
|
||||
},
|
||||
//deleteVenue: function(id) {
|
||||
// if(Roles.userIsInRole(this.userId, [Meteor.UserRoles.ROLE_UPDATE])) {
|
||||
// Venues.remove(id); //TODO: If this is ever allowed, we should either remove or replace references to the deleted venue in the rest of the database.
|
||||
// }
|
||||
// else throw new Meteor.Error(403, "Not authorized.");
|
||||
//},
|
||||
updateVenue: function(id, name, type, frequency) {
|
||||
check(id, String);
|
||||
check(name, String);
|
||||
check(type, String);
|
||||
check(frequency, String);
|
||||
|
||||
if(Roles.userIsInRole(this.userId, [Meteor.UserRoles.ROLE_UPDATE])) {
|
||||
Venues.update(id, {$set: {name, type, frequency, updatedAt: new Date()}});
|
||||
}
|
||||
else throw new Meteor.Error(403, "Not authorized.");
|
||||
},
|
||||
@@ -92,22 +122,6 @@ if(Meteor.isServer) {
|
||||
Venues.update(id, {$set: {hidden: false}}, {bypassCollection2: true});
|
||||
}
|
||||
else throw new Meteor.Error(403, "Not authorized.");
|
||||
},
|
||||
//deleteVenue: function(id) {
|
||||
// if(Roles.userIsInRole(this.userId, [Meteor.UserRoles.ROLE_UPDATE])) {
|
||||
// Venues.remove(id); //TODO: If this is ever allowed, we should either remove or replace references to the deleted venue in the rest of the database.
|
||||
// }
|
||||
// else throw new Meteor.Error(403, "Not authorized.");
|
||||
//},
|
||||
updateVenue: function(id, name, type) {
|
||||
check(id, String);
|
||||
check(name, String);
|
||||
check(type, String);
|
||||
|
||||
if(Roles.userIsInRole(this.userId, [Meteor.UserRoles.ROLE_UPDATE])) {
|
||||
Venues.update(id, {$set: {name, type, updatedAt: new Date()}});
|
||||
}
|
||||
else throw new Meteor.Error(403, "Not authorized.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user