mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +00:00
Removed Categories and Locations
This commit is contained in:
parent
c916c278a2
commit
2b1022f513
23 changed files with 4 additions and 637 deletions
|
|
@ -1,50 +0,0 @@
|
|||
import { Meteor } from 'meteor/meteor';
|
||||
import { Mongo } from 'meteor/mongo';
|
||||
import { check } from 'meteor/check';
|
||||
|
||||
export const Categories = new Mongo.Collection('categories');
|
||||
|
||||
Categories.allow({
|
||||
insert: function(userId, doc){
|
||||
// if use id exists, allow insert
|
||||
return !!userId;
|
||||
},
|
||||
});
|
||||
|
||||
Meteor.methods({
|
||||
'add.category' (categoryName) {
|
||||
check(categoryName, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to add categories. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Categories.insert({
|
||||
categoryName: categoryName,
|
||||
categoryOwner: this.userId,
|
||||
});
|
||||
},
|
||||
'edit.category' (categoryId, categoryName,) {
|
||||
check(categoryId, String);
|
||||
check(categoryName, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to edit categories. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Categories.update({ _id: categoryId }, {
|
||||
$set: {
|
||||
categoryName: categoryName,
|
||||
}
|
||||
});
|
||||
},
|
||||
'delete.category' (categoryId) {
|
||||
check(categoryId, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to delete categories. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Categories.remove({ _id: categoryId });
|
||||
},
|
||||
});
|
||||
|
|
@ -35,9 +35,7 @@ Meteor.methods({
|
|||
listId: listId,
|
||||
prodId: result,
|
||||
addedBy: this.userId,
|
||||
itemCategory: "",
|
||||
itemStore: "",
|
||||
itemLocation: "",
|
||||
itemOrdered: false,
|
||||
itemReceived: false,
|
||||
dateAddedToList: new Date(),
|
||||
|
|
@ -50,9 +48,7 @@ Meteor.methods({
|
|||
listId: listId,
|
||||
prodId: prodInfo._id,
|
||||
addedBy: this.userId,
|
||||
itemCategory: prodInfo.prodCategory,
|
||||
itemStore: prodInfo.prodStore,
|
||||
itemLocation: prodInfo.prodLocation,
|
||||
itemOrdered: false,
|
||||
itemReceived: false,
|
||||
dateAddedToList: new Date(),
|
||||
|
|
|
|||
|
|
@ -1,50 +0,0 @@
|
|||
import { Meteor } from 'meteor/meteor';
|
||||
import { Mongo } from 'meteor/mongo';
|
||||
import { check } from 'meteor/check';
|
||||
|
||||
export const Locations = new Mongo.Collection('locations');
|
||||
|
||||
Locations.allow({
|
||||
insert: function(userId, doc){
|
||||
// if use id exists, allow insert
|
||||
return !!userId;
|
||||
},
|
||||
});
|
||||
|
||||
Meteor.methods({
|
||||
'add.location' (name) {
|
||||
check(name, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to add locations. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Locations.insert({
|
||||
locationName: name,
|
||||
owner: this.userId,
|
||||
});
|
||||
},
|
||||
'edit.location' (locationId, locationName) {
|
||||
check(locationId, String);
|
||||
check(locationName, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to edit locations. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Locations.update({ _id: locationId }, {
|
||||
$set: {
|
||||
locationName: locationName,
|
||||
}
|
||||
});
|
||||
},
|
||||
'delete.location' (locationId) {
|
||||
check(locationId, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to delete locations. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Locations.remove({ _id: locationId });
|
||||
},
|
||||
});
|
||||
|
|
@ -12,11 +12,9 @@ Products.allow({
|
|||
});
|
||||
|
||||
Meteor.methods({
|
||||
'add.product' (prodName, prodCategory, prodStore, prodLocation) {
|
||||
'add.product' (prodName, prodStore) {
|
||||
check(prodName, String);
|
||||
check(prodCategory, String);
|
||||
check(prodStore, String);
|
||||
check(prodLocation, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to add products. Make sure you are logged in with valid user credentials.');
|
||||
|
|
@ -25,17 +23,13 @@ Meteor.methods({
|
|||
return Products.insert({
|
||||
prodName: prodName,
|
||||
prodOwner: this.userId,
|
||||
prodCategory: prodCategory,
|
||||
prodStore: prodStore,
|
||||
prodLocation: prodLocation,
|
||||
});
|
||||
},
|
||||
'edit.product' (prodId, prodName, prodCategory, prodStore, prodLocation) {
|
||||
'edit.product' (prodId, prodName, prodStore) {
|
||||
check(prodId, String);
|
||||
check(prodName, String);
|
||||
check(prodCategory, String);
|
||||
check(prodStore, String);
|
||||
check(prodLocation, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to edit products. Make sure you are logged in with valid user credentials.');
|
||||
|
|
@ -44,9 +38,7 @@ Meteor.methods({
|
|||
return Products.update({ _id: prodId }, {
|
||||
$set: {
|
||||
prodName: prodName,
|
||||
prodCategory: prodCategory,
|
||||
prodStore: prodStore,
|
||||
prodLocation: prodLocation,
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue