-
+
My Stores
@@ -58,15 +54,13 @@
{{storeCount}}
- {{#if isInRole 'systemadmin'}}
- {{/if}}
-
+
My Categories
@@ -74,11 +68,23 @@
{{catCount}}
- {{#if isInRole 'systemadmin'}}
+
+
+
diff --git a/client/Dashboard/dashboard.js b/client/Dashboard/dashboard.js
index d0d339e..4aa7ad9 100644
--- a/client/Dashboard/dashboard.js
+++ b/client/Dashboard/dashboard.js
@@ -1,5 +1,6 @@
import { Categories } from "../../imports/api/category";
import { Lists } from "../../imports/api/lists";
+import { Locations } from "../../imports/api/location";
import { Products } from "../../imports/api/products";
import { Stores } from "../../imports/api/stores";
@@ -10,6 +11,7 @@ Template.dashboard.onCreated(function() {
this.subscribe("myCategories");
this.subscribe("storeInfo");
this.subscribe("myProducts");
+ this.subscribe("myLocations");
});
Template.dashboard.onRendered(function() {
@@ -31,12 +33,64 @@ Template.dashboard.helpers({
},
catCount: function() {
return Categories.find().count();
+ },
+ locCount: function() {
+ return Locations.find().count();
}
});
Template.dashboard.events({
- "click #usermgmtlink" (event) {
+ "click .cardLink" (event) {
event.preventDefault();
- FlowRouter.go('/userMgmt');
+ let link = event.currentTarget.id;
+ switch(link) {
+ case "userMgmtLink":
+ FlowRouter.go('/userMgmt');
+ break;
+ case "listMgmtLink":
+ FlowRouter.go('/manageLists');
+ break;
+ case "storeMgmtLink":
+ FlowRouter.go('/manageStore');
+ break;
+ case "prodMgmtLink":
+ FlowRouter.go('/manageProduct');
+ break;
+ case "catMgmtLink":
+ FlowRouter.go('/manageCategory');
+ break;
+ case "locationMgmtLink":
+ FlowRouter.go('/manageLocation');
+ break;
+ default:
+ break;
+ }
},
+ 'click .card' (event) {
+ event.preventDefault();
+ let cardId = event.currentTarget.id;
+
+ switch(cardId) {
+ case "userInfoCard":
+ FlowRouter.go('/userMgmt');
+ break;
+ case "listInfoCard":
+ FlowRouter.go("/mylists");
+ break;
+ case "storeInfoCard":
+ FlowRouter.go('/manageStore');
+ break;
+ case "catInfoCard":
+ FlowRouter.go('/manageCategory');
+ break;
+ case "locInfoCard":
+ FlowRouter.go('/manageLocation');
+ break;
+ case "prodInfoCard":
+ FlowRouter.go("/manageProduct");
+ break;
+ default:
+ break;
+ }
+ }
});
\ No newline at end of file
diff --git a/client/ListItems/listItemsForm.html b/client/ListItems/listItemsForm.html
new file mode 100644
index 0000000..d28a12c
--- /dev/null
+++ b/client/ListItems/listItemsForm.html
@@ -0,0 +1,34 @@
+
+
+
+
{{selListName}}
+
+
+
+
+
+ Show Recv'd
+
+
+
+
+
+
+
+
+
+ {{#each itemProdName}}
+ {{prodName}}
+ {{/each}}
+
+
+
+ {{#if $eq editMode false}}
+
Add
+ {{else}}
+
Rename
+ {{/if}}
+
+
+
+
\ No newline at end of file
diff --git a/client/ListItems/listItemsForm.js b/client/ListItems/listItemsForm.js
new file mode 100644
index 0000000..331d886
--- /dev/null
+++ b/client/ListItems/listItemsForm.js
@@ -0,0 +1,68 @@
+import { ListItems } from '../../imports/api/listItems.js'
+import { Lists } from '../../imports/api/lists.js';
+import { Products } from '../../imports/api/products.js';
+
+Template.listItemsForm.onCreated(function() {
+ this.subscribe("myListItems", Session.get("listId"));
+ this.subscribe("myLists");
+ this.subscribe("myProducts");
+});
+
+Template.listItemsForm.onRendered(function() {
+ Meteor.setTimeout(function() {
+ $('select').formSelect();
+ }, 100);
+ $('select').formSelect();
+ Session.set("listItemEditMode", false);
+ Session.set("itemReqErr", false);
+ Session.set("showReceivedItems", false);
+});
+
+Template.listItemsForm.helpers({
+ selListName: function() {
+ let selListId = Session.get("listId");
+ console.log("List ID in Helper is: " + selListId);
+ let listInfo = Lists.findOne({ _id: selListId });
+ return listInfo.listName;
+ },
+ itemProdName: function() {
+ return Products.find({});
+ },
+ editMode: function() {
+ return Session.get("listItemEditMode");
+ }
+});
+
+Template.listItemsForm.events({
+ 'click .saveListItem' (event) {
+ event.preventDefault();
+ let item = $("#listItems").val();
+ let listId = Session.get("listId");
+ if (item == null || item == "") {
+ Session.set("itemReqErr", true);
+ } else {
+ Meteor.call("add.listItem", item, listId, function(err, result) {
+ if (err) {
+ console.log(" ERROR adding item to list: " + err);
+ } else {
+ console.log(" SUCCESS adding item to list.");
+ $("#listItems").val("");
+ }
+ });
+ }
+ },
+ 'keypress #listItemInput' (event) {
+ event.preventDefault();
+
+ },
+ 'click .editListItem' (event) {
+ event.preventDefault();
+ },
+ 'click #showReceivedItems' (event) {
+ if ($("#showReceivedItems").prop('checked') == true) {
+ Session.set("showReceivedItems", true);
+ } else {
+ Session.set("showReceivedItems", false);
+ }
+ }
+});
\ No newline at end of file
diff --git a/client/ListItems/listItemsMain.html b/client/ListItems/listItemsMain.html
new file mode 100644
index 0000000..198c755
--- /dev/null
+++ b/client/ListItems/listItemsMain.html
@@ -0,0 +1,5 @@
+
+ {{> listItemsForm}}
+
+ {{> listItemsTbl}}
+
\ No newline at end of file
diff --git a/client/ListItems/listItemsMain.js b/client/ListItems/listItemsMain.js
new file mode 100644
index 0000000..fe9e509
--- /dev/null
+++ b/client/ListItems/listItemsMain.js
@@ -0,0 +1,15 @@
+Template.listItemsMain.onCreated(function() {
+
+});
+
+Template.listItemsMain.onRendered(function() {
+
+});
+
+Template.listItemsMain.helpers({
+
+});
+
+Template.listItemsMain.events({
+
+});
\ No newline at end of file
diff --git a/client/ListItems/listItemsTbl.html b/client/ListItems/listItemsTbl.html
new file mode 100644
index 0000000..5c8780f
--- /dev/null
+++ b/client/ListItems/listItemsTbl.html
@@ -0,0 +1,21 @@
+
+
+
+
+ {{#each thisListItems}}
+
+
+ {{#if $eq itemOrdered true}}
+ {{itemName}}
+ {{else}}
+ {{itemName}}
+ {{/if}}
+
+ delete
+ check
+
+ {{/each}}
+
+
+
+
\ No newline at end of file
diff --git a/client/ListItems/listItemsTbl.js b/client/ListItems/listItemsTbl.js
new file mode 100644
index 0000000..e3f11c9
--- /dev/null
+++ b/client/ListItems/listItemsTbl.js
@@ -0,0 +1,67 @@
+import { ListItems } from '../../imports/api/listItems.js';
+
+Template.listItemsTbl.onCreated(function() {
+ this.autorun( () => {
+ this.subscribe("myListItems", Session.get("listId"));
+ });
+});
+
+Template.listItemsTbl.onRendered(function() {
+ Session.set("showReceivedItems", false);
+});
+
+Template.listItemsTbl.helpers({
+ 'thisListItems': function() {
+ let showRecvd = Session.get("showReceivedItems");
+ console.log("Show Received is: " + showRecvd);
+ if (showRecvd == false) {
+ return ListItems.find({ itemReceived: false });
+ } else {
+ return ListItems.find({});
+ }
+ },
+});
+
+Template.listItemsTbl.events({
+ 'click li' (event) {
+ event.preventDefault();
+ let itemInfo = ListItems.findOne({ _id: this._id });
+ if (itemInfo.itemOrdered == true) {
+ Meteor.call('setNotOrdered.listItem', this._id, function(err, result) {
+ if (err) {
+ console.log(" ERROR setting this item as NOT ordered: " + err);
+ } else {
+ console.log(" SUCCESS setting this item as NOT ordered.");
+ }
+ });
+ } else {
+ Meteor.call('setOrdered.listItem', this._id, function(err, result) {
+ if (err) {
+ console.log(" ERROR marking item ordered: " + err);
+ } else {
+ console.log(" SUCCESS marking this item ordered.");
+ }
+ });
+ }
+ },
+ 'click .markListItemReceived' (event) {
+ event.preventDefault();
+ Meteor.call('setReceived.listItem', this._id, function(err, result) {
+ if (err) {
+ console.log(" ERROR setting item as received: " + err);
+ } else {
+ console.log(" SUCCESS setting item received.");
+ }
+ });
+ },
+ 'click .deleteListItem' (event) {
+ event.preventDefault();
+ Meteor.call('delete.listItem', this._id, function(err, result) {
+ if (err) {
+ console.log(" ERROR deleting the list item: " + err);
+ } else {
+ console.log(" SUCCESS deleting the list item.");
+ }
+ });
+ }
+});
\ No newline at end of file
diff --git a/client/Lists/listsMain.html b/client/Lists/listsMain.html
new file mode 100644
index 0000000..20bee39
--- /dev/null
+++ b/client/Lists/listsMain.html
@@ -0,0 +1,4 @@
+
+ My Lists
+ {{> listsTbl}}
+
\ No newline at end of file
diff --git a/client/Lists/listsMain.js b/client/Lists/listsMain.js
new file mode 100644
index 0000000..7c27634
--- /dev/null
+++ b/client/Lists/listsMain.js
@@ -0,0 +1,16 @@
+
+Template.listsMain.onCreated(function() {
+
+});
+
+Template.listsMain.onRendered(function() {
+
+});
+
+Template.listsMain.helpers({
+
+});
+
+Template.listsMain.events({
+
+});
\ No newline at end of file
diff --git a/client/Lists/listsTbl.html b/client/Lists/listsTbl.html
new file mode 100644
index 0000000..951bf17
--- /dev/null
+++ b/client/Lists/listsTbl.html
@@ -0,0 +1,26 @@
+
+
+
+
+ {{#each mylists}}
+
+ {{listName}}
+ check
+
+ {{/each}}
+ + Add New List
+
+
+
+
+
+
+
Add New List
+ {{> listMgmtForm}}
+
+
+
+ {{> snackbar}}
+
\ No newline at end of file
diff --git a/client/Lists/listsTbl.js b/client/Lists/listsTbl.js
new file mode 100644
index 0000000..a3ee4db
--- /dev/null
+++ b/client/Lists/listsTbl.js
@@ -0,0 +1,57 @@
+import { Lists } from '../../imports/api/lists.js';
+
+Template.listsTbl.onCreated(function() {
+ this.subscribe("myLists");
+});
+
+Template.listsTbl.onRendered(function() {
+ $('.modal').modal();
+});
+
+Template.listsTbl.helpers({
+ mylists: function() {
+ return Lists.find({});
+ },
+});
+
+Template.listsTbl.events({
+ 'click li.collection-item' (event) {
+ event.preventDefault();
+ let sender = event.target;
+ // console.log("Sender origination from: ");
+ // console.log(sender.localName);
+ if (sender.localName == "li") {
+ let listId = event.currentTarget.id;
+ if (listId == "addList") {
+ $('#modalList').modal('open');
+ } else {
+ console.log("listId is: " + listId);
+ Session.set("listId", listId);
+ Meteor.setTimeout(function() {
+ FlowRouter.go('/listitems');
+ }, 100);
+ }
+ }
+ },
+ 'click i.markAsComplete' (event) {
+ event.preventDefault();
+ let sender = event.target;
+ // console.log("Sender origination from: " );
+ // console.log(sender.localName);
+ if (sender.localName == "i") {
+ let listFullId = event.currentTarget.id;
+ let splitList = listFullId.split("_");
+ let listId = splitList[1];
+ // console.log("listId is " + listId);
+ Meteor.call("mark.complete", listId, function(err, result){
+ if (err) {
+ console.log(" ERROR marking list complete! " + err);
+ showSnackbar("ERROR! List Not Makred Complete!", "red");
+ } else {
+ console.log(" SUCCESS marking list complete.");
+ showSnackbar("List Marked Complete!", "green");
+ }
+ });
+ }
+ }
+});
\ No newline at end of file
diff --git a/client/main.css b/client/main.css
index 1f3c654..2d0bb33 100644
--- a/client/main.css
+++ b/client/main.css
@@ -22,5 +22,20 @@ select.dark-mode {
}
li.collection-item {
- font-size: 24px;
+ font-size: 20px;
+
+}
+
+li.collection-item.addNew {
+ background-color: rgb(218, 218, 218);
+ color: #343434;
+}
+
+li.collection-item:active {
+ background-color: #bebebe;
+}
+
+strike {
+ text-decoration-thickness: 3px;
+ text-decoration-color: red;
}
\ No newline at end of file
diff --git a/client/main.html b/client/main.html
index 8a2f5d0..df85d40 100644
--- a/client/main.html
+++ b/client/main.html
@@ -6,8 +6,11 @@
+
+
+
diff --git a/imports/api/listItems.js b/imports/api/listItems.js
index da6c2b6..383c299 100644
--- a/imports/api/listItems.js
+++ b/imports/api/listItems.js
@@ -14,35 +14,53 @@ ListItems.allow({
});
Meteor.methods({
- 'add.listItem' (itemName, prodId, itemQty, shopListId) {
+ 'add.listItem' (itemName, listId) {
check(itemName, String);
- check(prodId, String);
- check(itemQty, String);
- check(shopListId, String);
+ check(listId, 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.');
}
// look up the item from the Products collection
- let prodInfo = Products.findOne({ _id: prodId });
+ let prodInfo = Products.findOne({ prodName: itemName });
+ if (typeof prodInfo == "undefined") {
+ Meteor.call("add.product", itemName, "", "", "", function(err, result) {
+ if (err) {
+ console.log(" ERROR adding item to products: " + err);
+ } else {
+ console.log(" SUCCESS adding item to Products.");
+ return ListItems.insert({
+ itemName: itemName,
+ listId: listId,
+ prodId: result,
+ addedBy: this.userId,
+ itemCategory: "",
+ itemStore: "",
+ itemLocation: "",
+ itemOrdered: false,
+ itemReceived: false,
+ dateAddedToList: new Date(),
+ });
+ }
+ });
+ } else {
+ return ListItems.insert({
+ itemName: itemName,
+ listId: listId,
+ prodId: prodInfo._id,
+ addedBy: this.userId,
+ itemCategory: prodInfo.prodCategory,
+ itemStore: prodInfo.prodStore,
+ itemLocation: prodInfo.prodLocation,
+ itemOrdered: false,
+ itemReceived: false,
+ dateAddedToList: new Date(),
+ });
+ }
- // look up the shopList by shopListId
- let shopListInfo = ShopLists.findOne({ _id: shopListId });
- return ListItems.insert({
- itemName: itemName,
- prodId: prodId,
- itemQty: itemQty,
- itemOwner: shopListInfo.ownerId,
- addedBy: this.userId,
- itemCategory: prodInfo.prodCategory,
- itemStore: prodInfo.prodStore,
- itemLocation: prodInfo.prodLocation,
- itemOrdered: false,
- itemReceived: false,
- dateAddedToList: new Date(),
- });
+
},
'setOrdered.listItem' (itemId) {
check(itemId, String);
@@ -109,33 +127,17 @@ Meteor.methods({
// set all items that are not already listed as received to received on this list
},
- 'edit.listItem' (itemId, itemName, prodId, itemQty, shopListId) {
+ 'edit.listItem' (itemId, itemName) {
check(itemId, String);
check(itemName, String);
- check(prodId, String);
- check(itemQty, String);
- check(shopListId, 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.');
}
- // look up the item from the Products collection
- let prodInfo = Products.findOne({ _id: prodId });
-
- // look up the shopList by shopListId
- let shopListInfo = ShopLists.findOne({ _id: shopListId });
-
return ListItems.update({ _id: itemId }, {
$set: {
itemName: itemName,
- prodId: prodId,
- itemQty: itemQty,
- itemOwner: shopListInfo.ownerId,
- editedBy: this.userId,
- itemCategory: prodInfo.prodCategory,
- itemStore: prodInfo.prodStore,
- itemLocation: prodInfo.prodLocation,
}
});
},
@@ -146,13 +148,6 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to delete list items. Make sure you are logged in with valid user credentials.');
}
- let itemInfo = ListItems.findOne({ _id: itemId });
- let myId = this.userId;
- if (myId == itemInfo.owner) {
- return ListItems.remove({ _id: itemId });
- } else {
- console.log("User not allowed to delete this list item. Not the owner!");
- return("Not Allowed!");
- }
+ return ListItems.remove({ _id: itemId });
}
});
\ No newline at end of file
diff --git a/imports/api/lists.js b/imports/api/lists.js
index e95e330..7521bb8 100644
--- a/imports/api/lists.js
+++ b/imports/api/lists.js
@@ -12,8 +12,9 @@ Lists.allow({
});
Meteor.methods({
- 'add.list' (listName) {
+ 'add.list' (listName, isShared) {
check(listName, String);
+ check(isShared, Boolean);
if (!this.userId) {
throw new Meteor.Error('You are not allowed to add lists. Make sure you are logged in with valid user credentials.');
@@ -21,13 +22,15 @@ Meteor.methods({
return Lists.insert({
listName: listName,
+ listShared: isShared,
listOwner: this.userId,
listComplete: false,
});
},
- 'edit.list' (listId, listName) {
+ 'edit.list' (listId, listName, isShared) {
check(listId, String);
check(listName, String);
+ check(isShared, Boolean);
if (!this.userId) {
throw new Meteor.Error('You are not allowed to edit lists. Make sure you are logged in with valid user credentials.');
@@ -36,6 +39,7 @@ Meteor.methods({
return Lists.update({ _id: listId }, {
$set: {
listName: listName,
+ listShared: isShared,
}
});
},
@@ -62,18 +66,11 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to mark lists complete. Make sure you are logged in with valid user credentials.');
}
- let listInfo = Lists.findOne({ _id: listId });
- let myId = this.userId;
- if (myId == listInfo.listOwner) {
- return Lists.update({ _id: listId }, {
- $set: {
- listComplete: true,
- completedOn: new Date()
- }
- });
- } else {
- console.log("User not allowed to mark lists complete. Not a member of the list!");
- return("Not Allowed!");
- }
+ return Lists.update({ _id: listId }, {
+ $set: {
+ listComplete: true,
+ completedOn: new Date()
+ }
+ });;
}
});
\ No newline at end of file
diff --git a/imports/api/products.js b/imports/api/products.js
index 90b1a44..f6bf5ab 100644
--- a/imports/api/products.js
+++ b/imports/api/products.js
@@ -41,7 +41,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to edit products. Make sure you are logged in with valid user credentials.');
}
- return Products.update({ _id: itemId }, {
+ return Products.update({ _id: prodId }, {
$set: {
prodName: prodName,
prodCategory: prodCategory,
@@ -59,7 +59,7 @@ Meteor.methods({
let prodInfo = Products.findOne({ _id: prodId });
let myId = this.userId;
- if (myId == prodInfo.owner) {
+ if (myId == prodInfo.prodOwner) {
return Products.remove({ _id: prodId });
} else {
console.log("User not allowed to delete this product. Not the owner!");
diff --git a/imports/api/stores.js b/imports/api/stores.js
index 888b835..175ba5e 100644
--- a/imports/api/stores.js
+++ b/imports/api/stores.js
@@ -12,26 +12,21 @@ Stores.allow({
});
Meteor.methods({
- 'add.store' (storeName, storeType) {
+ 'add.store' (storeName) {
check(storeName, String);
- check(storeType, String);
if (!this.userId) {
throw new Meteor.Error('You are not allowed to add stores. Make sure you are logged in with valid user credentials.');
}
- console.log(" ---- userid: " + Meteor.user()._id);
-
return Stores.insert({
storeName: storeName,
- storeType: storeType,
- owner: Meteor.user()._id,
+ owner: this.userId,
});
},
- 'edit.store' (storeId, storeName, storeType) {
+ 'edit.store' (storeId, storeName) {
check(storeId, String);
check(storeName, String);
- check(storeType, String);
if (!this.userId) {
throw new Meteor.Error('You are not allowed to edit stores. Make sure you are logged in with valid user credentials.');
@@ -40,7 +35,6 @@ Meteor.methods({
return Stores.update({ _id: storeId }, {
$set: {
storeName: storeName,
- storeType: storeType,
}
});
},
diff --git a/lib/routes.js b/lib/routes.js
index 33c5bb1..51fc7ce 100644
--- a/lib/routes.js
+++ b/lib/routes.js
@@ -80,4 +80,18 @@ FlowRouter.route('/manageLists', {
action() {
BlazeLayout.render('MainLayout', { main: 'listMgmt' });
}
+});
+
+FlowRouter.route('/mylists', {
+ name: 'mylists',
+ action() {
+ BlazeLayout.render('MainLayout', { main: 'listsMain' });
+ }
+});
+
+FlowRouter.route('/listItems', {
+ name: 'listItems',
+ action() {
+ BlazeLayout.render('MainLayout', { main: 'listItemsMain' });
+ }
});
\ No newline at end of file
diff --git a/server/main.js b/server/main.js
index ad5e056..0054da2 100644
--- a/server/main.js
+++ b/server/main.js
@@ -3,6 +3,8 @@ import { Meteor } from 'meteor/meteor';
Meteor.startup(() => {
// code to run on server at startup
Roles.createRole("user", {unlessExists: true});
+ Roles.createRole("groupLeader", {unlessExists: true});
+ Roles.createRole("groupMember", {unlessExists: true});
Roles.createRole("admin", {unlessExists: true});
Roles.createRole("systemadmin", {unlessExists: true});
});
diff --git a/server/publish.js b/server/publish.js
index 40a6dbd..3917c76 100644
--- a/server/publish.js
+++ b/server/publish.js
@@ -5,6 +5,7 @@ import { Products } from '../imports/api/products.js';
import { Categories } from '../imports/api/category.js';
import { Locations } from '../imports/api/location.js';
import { Lists } from '../imports/api/lists.js';
+import { ListItems } from '../imports/api/listItems.js';
Meteor.publish("SystemConfig", function() {
try {
@@ -52,8 +53,17 @@ Meteor.publish("myLocations", function() {
Meteor.publish("myLists", function() {
try {
- return Lists.find({ listOwner: this.userId, listComplete: false });
+ return Lists.find( { $or: [ { listOwner: this.userId, listComplete: false }, { listShared: true, listComplete: false } ] } );
} catch (error) {
console.log(" ERROR pulling list data: " + error);
}
+});
+
+Meteor.publish("myListItems", function(listId) {
+ try {
+ console.log("List Id is: " + listId);
+ return ListItems.find({ listId: listId });
+ } catch (error) {
+ console.log(" ERROR pulling list items for this list: " + error);
+ }
});
\ No newline at end of file