mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +00:00
Lots of changes made (almost a refactor <--- four letter word to me... - Menu Items collection is now the "permanent" storage location for menu item for any day. So, if i set Green Chile Chicken Enchiladas, Beans, and Rice as an item for a day, it will be stored as a Menu Item for later use. - Linking menu items to items that can be added to a shopping list - This has been updated to be more reusable. So as you re-choose a menu item that's already got list items linked, it just shows up for you to use to build a shopping list as needed. - Deleting menu items from a menu - changed to delete them only from the menu, and not from the database. - Dashboard updated to pull today's menu item from the menu, and not the menu item list.
84 lines
2.4 KiB
JavaScript
84 lines
2.4 KiB
JavaScript
import { Meteor } from 'meteor/meteor';
|
|
import { Mongo } from 'meteor/mongo';
|
|
import { check } from 'meteor/check';
|
|
|
|
export const MenuItems = new Mongo.Collection('menuitems');
|
|
|
|
MenuItems.allow({
|
|
insert: function(userId, doc){
|
|
// if use id exists, allow insert
|
|
return !!userId;
|
|
},
|
|
});
|
|
|
|
Meteor.methods({
|
|
'add.menuItem' (itemName) {
|
|
check(itemName, String);
|
|
|
|
if (!this.userId) {
|
|
throw new Meteor.Error('You are not allowed to add items. Make sure you are logged in with valid user credentials.');
|
|
}
|
|
|
|
serveDateActual = new Date(serveDate);
|
|
|
|
return MenuItems.insert({
|
|
itemName: itemName,
|
|
addedBy: this.userId,
|
|
dateAddedtoMenu: new Date(),
|
|
isLinked: false,
|
|
});
|
|
},
|
|
'update.menuItemLinked' (itemId, isLinked) {
|
|
check(itemId, String);
|
|
check(isLinked, Boolean);
|
|
|
|
if (!this.userId) {
|
|
throw new Meteor.Error('You are not allowed to set this menu item as linked to products. Make sure you are logged in with valid user credentials.');
|
|
}
|
|
|
|
return MenuItems.update({ _id: itemId }, {
|
|
$set: {
|
|
isLinked: isLinked,
|
|
}
|
|
});
|
|
},
|
|
'edit.madeItem' (itemId, itemName, serveDate) {
|
|
check(itemId, String);
|
|
check(itemName, String);
|
|
check(serveDate, String);
|
|
|
|
if (!this.userId) {
|
|
throw new Meteor.Error('You are not allowed to edit menu items. Make sure you are logged in with valid user credentials.');
|
|
}
|
|
|
|
return MenuItems.update({ _id: itemId }, {
|
|
$set: {
|
|
itemName: itemName,
|
|
serveDate: serveDate,
|
|
}
|
|
});
|
|
},
|
|
'delete.menuItem' (itemId) {
|
|
check(itemId, String);
|
|
|
|
if (!this.userId) {
|
|
throw new Meteor.Error('You are not allowed to delete menu items. Make sure you are logged in with valid user credentials.');
|
|
}
|
|
|
|
return MenuItems.remove({ _id: itemId });
|
|
},
|
|
'shiftDate' (itemId, momentAddDay) {
|
|
check(itemId, String);
|
|
check(momentAddDay, String);
|
|
|
|
if (!this.userId) {
|
|
throw new Meteor.Error('You are not allowed to shift menu item dates. Make sure you are logged in with valid user credentials.');
|
|
}
|
|
|
|
return MenuItems.update({ _id: itemId }, {
|
|
$set: {
|
|
serveDate: momentAddDay,
|
|
}
|
|
});
|
|
}
|
|
});
|