Many chcanges, but version 0.1.0 is ready to be cut.

This commit is contained in:
Brian McGonagill 2022-08-23 13:41:21 -05:00
parent 42643a37f5
commit 6e37ae8c74
46 changed files with 1038 additions and 273 deletions

View file

@ -30,4 +30,3 @@ raix:handlebar-helpers
kadira:flow-router
kadira:blaze-layout
accounts-password@2.3.1
# mizzao:autocomplete # for the @mentions functionality

View file

@ -1,6 +1,8 @@
<template name="catMgmt">
<h4>Category Management</h4>
{{> catMgmtForm}}
<hr>
{{> catMgmtTbl}}
<div class="container">
<h4>Category Management</h4>
{{> catMgmtForm}}
<hr>
{{> catMgmtTbl}}
</div>
</template>

View file

@ -1,16 +1,22 @@
<template name="catMgmtForm">
<div class="row">
<div class="col s12 m6 l6 input-field">
<input type="text" class="catNameInp" id="catNameInp" style="{{#if $eq catNameErr true}}border: 2px solid red;{{/if}}" />
<label for="catNameInp">Name*</label>
<form action="submit" id="catInputForm">
<div class="row">
<div class="col s12 m6 l6 input-field">
<input type="text" class="catNameInp" id="catNameInp" style="{{#if $eq catNameErr true}}border: 2px solid red;{{/if}}" />
<label for="catNameInp">Name*</label>
</div>
</div>
</div>
<div class="row">
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn cancelCatMgmt orange">Cancel</a>
<div class="row">
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn cancelCatMgmt orange">Cancel</a>
</div>
<div class="col s6 m6 l6">
{{#if $eq catEditMode false}}
<a class="waves-effect waves-light btn saveCatMgmt green right">Add</a>
{{else}}
<a class="waves-effect waves-light btn editCatMgmt blue right">Rename</a>
{{/if}}
</div>
</div>
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn saveCatMgmt green right">Add</a>
</div>
</div>
</form>
</template>

View file

@ -6,12 +6,16 @@ Template.catMgmtForm.onCreated(function() {
Template.catMgmtForm.onRendered(function() {
Session.set("catNameMiss", false);
Session.set("catEditMode", false);
});
Template.catMgmtForm.helpers({
catNameErr: function() {
return Session.get("catNameMiss");
},
catEditMode: function() {
return Session.get("catEditMode");
}
});
Template.catMgmtForm.events({
@ -32,8 +36,60 @@ Template.catMgmtForm.events({
});
}
},
'click .editCatMgmt' (event) {
event.preventDefault();
let catName = $("#catNameInp").val();
let catId = this._id;
if (catName == null || catName == "") {
Session.set("catNameMiss", true);
return;
} else {
let catId = Session.get("categoryEditId");
Meteor.call('edit.category', catId, catName, function(err, result) {
if (err) {
// console.log(" ERROR: Can't edit category: " + err);
} else {
// console.log(" SUCCESS editing category.");
$("#catNameInp").val("");
Session.set("catEditMode", false);
}
});
}
},
'submit #catInputForm' (event) {
event.preventDefault();
let catName = $("#catNameInp").val();
let editMode = Session.get("catEditMode");
if (catName == null || catName == "") {
Session.set("catNameMiss", true);
return;
} else {
if (editMode == false) {
Meteor.call('add.category', catName, function(err, result) {
if (err) {
// console.log(" ERROR: Can't add category: " + err);
} else {
// console.log(" SUCCESS adding category.");
$("#catNameInp").val("");
}
});
} else {
let catId = Session.get("categoryEditId");
Meteor.call('edit.category', catId, catName, function(err, result) {
if (err) {
// console.log(" ERROR: Can't edit category: " + err);
} else {
// console.log(" SUCCESS editing category.");
$("#catNameInp").val("");
Session.set("catEditMode", false);
}
});
}
}
},
'click .cancelCatMgmt' (event) {
event.preventDefault();
$("#catNameInp").val("");
Session.set("catEditMode", false);
}
});

View file

@ -5,8 +5,8 @@
{{#each cats}}
<li class="collection-item">
{{categoryName}}
<i class="material-icons clickable deleteCategory right">delete</i>
<i class="material-icons clickable editCategory right">edit</i>
<i class="material-icons clickable deleteCategory right tooltipped" data-position="top" data-tooltip="Delete Category">delete</i>
<i class="material-icons clickable editCategory right tooltipped" data-position="top" data-tooltip="Edit Category">edit</i>
</li>
{{/each}}
</ul>

View file

@ -5,7 +5,9 @@ Template.catMgmtTbl.onCreated(function() {
});
Template.catMgmtTbl.onRendered(function() {
Meteor.setTimeout(function() {
$('.tooltipped').tooltip();
}, 150);
});
Template.catMgmtTbl.helpers({
@ -15,5 +17,21 @@ Template.catMgmtTbl.helpers({
});
Template.catMgmtTbl.events({
'click .deleteCategory' (event) {
event.preventDefault();
Meteor.call('delete.category', this._id, function(err, result) {
if (err) {
console.log(" ERROR deleting category: " + err);
} else {
console.log(" SUCCESS deleting the category.");
}
});
},
'click .editCategory' (event) {
event.preventDefault();
Session.set("categoryEditId", this._id);
Session.set("catEditMode", true);
let catInfo = Categories.findOne({ _id: this._id });
$("#catNameInp").val(catInfo.categoryName);
}
});

View file

@ -6,7 +6,17 @@
<input type="text" class="listNameInp" style="{{#if $eq listNameErr true}}border: 2px solid red{{/if}}" id="listNameInp" />
<label for="listNameInp">List Name</label>
</div>
<div class="col s4 m4 l2">
<div class="col s4 m4 l2 input-field">
<p>
<label>
<input type="checkbox" id="isShared"/>
<span>Shared</span>
</label>
</p>
</div>
</div>
<div class="row">
<div class="col s12 m12 l12">
{{#if $eq editMode false}}
<a class="waves-effect waves-light btn saveListMgmt green right">Add</a>
{{else}}

View file

@ -22,17 +22,19 @@ Template.listMgmtForm.events({
'click .saveListMgmt' (event) {
event.preventDefault();
let listName = $("#listNameInp").val();
let shared = $("#isShared").prop('checked');
if (listName == null || listName == "") {
Session.set("listNameMiss", true);
return;
} else {
Meteor.call('add.list', listName, function(err, result) {
Meteor.call('add.list', listName, shared, function(err, result) {
if (err) {
console.log(" ERROR adding list name: " + err);
} else {
console.log(" SUCCESS adding list name.");
$("#listNameInp").val("");
$("#isShared").prop("checked", false);
}
});
}
@ -40,18 +42,20 @@ Template.listMgmtForm.events({
'click .renameListMgmt' (event) {
event.preventDefault();
let listName = $("#listNameInp").val();
let shared = $("#isShared").prop('checked');
let listId = Session.get("listItemId");
if (listName == null || listName == "") {
Session.set("listNameMiss", true);
return;
} else {
Meteor.call('edit.list', listId, listName, function(err, result) {
Meteor.call('edit.list', listId, listName, shared, function(err, result) {
if (err) {
console.log(" ERROR editing list name: " + err);
} else {
console.log(" SUCCESS editing list name.");
$("#listNameInp").val("");
$("#isShared").prop("checked", false);
Session.set("listNameEditMode", false);
}
});
@ -60,6 +64,7 @@ Template.listMgmtForm.events({
'submit .listAdd' (event) {
event.preventDefault();
let editMode = Session.get("listNameEditMode");
let shared = $("#isShared").prop("checked");
let listName = $("#listNameInp").val();
let listId = Session.get("listItemId");
@ -68,21 +73,23 @@ Template.listMgmtForm.events({
return;
} else {
if (editMode == false) {
Meteor.call('add.list', listName, function(err, result) {
Meteor.call('add.list', listName, shared, function(err, result) {
if (err) {
console.log(" ERROR adding list name: " + err);
} else {
console.log(" SUCCESS adding list name.");
$("#listNameInp").val("");
$("#isShared").prop("checked", false);
}
});
} else {
Meteor.call('edit.list', listId, listName, function(err, result) {
Meteor.call('edit.list', listId, listName, shared, function(err, result) {
if (err) {
console.log(" ERROR editing list name: " + err);
} else {
console.log(" SUCCESS editing list name.");
$("#listNameInp").val("");
$("#isShared").prop("checked", false);
Session.set("listNameEditMode", false);
}
});

View file

@ -4,7 +4,7 @@
<ul class="collection">
{{#each lists}}
<li class="collection-item">
{{listName}}
<span class="{{#if $eq listShared true}}green-text{{/if}}">{{listName}}</span>
<i class="material-icons clickable deleteListName tooltipped right" data-position="top" data-tooltip="Delete This List">delete</i>
<i class="material-icons clickable editListName tooltipped right" data-position="top" data-tooltip="Edit This List">edit</i>
<i class="material-icons clickable markListComplete tooltipped right" data-position="top" data-tooltip="Mark Complete">check</i>

View file

@ -5,7 +5,9 @@ Template.listMgmtTbl.onCreated(function() {
});
Template.listMgmtTbl.onRendered(function() {
$('.tooltipped').tooltip();
Meteor.setTimeout(function() {
$('.tooltipped').tooltip();
}, 150);
});
Template.listMgmtTbl.helpers({
@ -28,8 +30,15 @@ Template.listMgmtTbl.events({
},
'click .editListName' (event) {
event.preventDefault();
let listName = Lists.findOne({ _id: this._id }).listName;
let listInfo = Lists.findOne({ _id: this._id });
let listName = listInfo.listName;
let listShared = listInfo.listShared;
$("#listNameInp").val(listName);
if (listShared == true) {
$("#isShared").prop("checked", true);
} else {
$("#isShared").prop("checked", false);
}
Session.set("listNameEditMode", true);
Session.set("listItemId", this._id);
},

View file

@ -1,5 +1,8 @@
<template name="locMgmt">
{{> locMgmtForm}}
<hr>
{{> locMgmtTbl}}
<div class="container">
<h4>Location Management</h4>
{{> locMgmtForm}}
<hr>
{{> locMgmtTbl}}
</div>
</template>

View file

@ -1,16 +1,22 @@
<template name="locMgmtForm">
<div class="row">
<div class="col s12 m6 l6 input-field">
<input type="text" class="locNameInp" id="locNameInp" style="{{#if $eq locNameErr true}}border: 2px solid red;{{/if}}" />
<label for="locNameInp">Name*</label>
<form action="" id="locInputForm">
<div class="row">
<div class="col s12 m6 l6 input-field">
<input type="text" class="locNameInp" id="locNameInp" style="{{#if $eq locNameErr true}}border: 2px solid red;{{/if}}" />
<label for="locNameInp">Name*</label>
</div>
</div>
</div>
<div class="row">
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn cancelLocMgmt orange">Cancel</a>
<div class="row">
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn cancelLocMgmt orange">Cancel</a>
</div>
<div class="col s6 m6 l6">
{{#if $eq locEditMode false}}
<a class="waves-effect waves-light btn saveLocMgmt green right">Add</a>
{{else}}
<a class="waves-effect waves-light btn editLocMgmt blue right">Rename</a>
{{/if}}
</div>
</div>
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn saveLocMgmt green right">Add</a>
</div>
</div>
</form>
</template>

View file

@ -6,12 +6,16 @@ Template.locMgmtForm.onCreated(function() {
Template.locMgmtForm.onRendered(function() {
Session.set("locNameMiss", false);
Session.set("locEditMode", false);
});
Template.locMgmtForm.helpers({
locNameErr: function() {
return Session.get("locNameMiss");
},
locEditMode: function() {
return Session.get("locEditMode");
}
});
Template.locMgmtForm.events({
@ -32,8 +36,60 @@ Template.locMgmtForm.events({
});
}
},
'click .editLocMgmt' (event) {
event.preventDefault();
let locName = $("#locNameInp").val();
let locEditMode = Session.get("locEditMode");
let locId = Session.get("locEditId");
if (locName == null || locName == "") {
Session.set("locNameMiss", true);
return;
} else {
Meteor.call('edit.location', locId, locName, function(err, result) {
if (err) {
// console.log(" ERROR: Can't edit category: " + err);
} else {
// console.log(" SUCCESS editing category.");
$("#locNameInp").val("");
Session.set("locEditMode", false);
}
});
}
},
'submit #locInputForm' (event) {
event.preventDefault();
let locName = $("#locNameInp").val();
let locEditMode = Session.get("locEditMode");
let locId = Session.get("locEditId");
if (locName == null || locName == "") {
Session.set("locNameMiss", true);
return;
} else {
if (locEditMode == false) {
Meteor.call('add.location', locName, function(err, result) {
if (err) {
// console.log(" ERROR: Can't add category: " + err);
} else {
// console.log(" SUCCESS adding category.");
$("#locNameInp").val("");
}
});
} else {
Meteor.call('edit.location', locId, locName, function(err, result) {
if (err) {
// console.log(" ERROR: Can't edit category: " + err);
} else {
// console.log(" SUCCESS editing category.");
$("#locNameInp").val("");
Session.set("locEditMode", false);
}
});
}
}
},
'click .cancelLocMgmt' (event) {
event.preventDefault();
$("#locNameInp").val("");
Session.set("locEditMode", false);
}
});

View file

@ -1,21 +1,15 @@
<template name="locMgmtTbl">
<table class="highlight striped responsive-table">
<thead>
<tr>
<th>Name</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{{#each locs}}
<tr>
<td>{{locationName}}</td>
<td>
<i class="material-icons clickable deleteCategory">delete</i>
<i class="material-icons clickable editCategory">edit</i>
</td>
</tr>
{{/each}}
</tbody>
</table>
<div class="row">
<div class="col s12">
<ul class="collection">
{{#each locs}}
<li class="collection-item">
{{locationName}}
<i class="material-icons clickable deleteLocation right tooltipped" data-position="top" data-tooltip="Delete Location">delete</i>
<i class="material-icons clickable editLocation right tooltipped" data-position="top" data-tooltip="Edit Location">edit</i>
</li>
{{/each}}
</ul>
</div>
</div>
</template>

View file

@ -5,7 +5,9 @@ Template.locMgmtTbl.onCreated(function() {
});
Template.locMgmtTbl.onRendered(function() {
Meteor.setTimeout(function() {
$('.tooltipped').tooltip();
}, 150);
});
Template.locMgmtTbl.helpers({
@ -14,6 +16,22 @@ Template.locMgmtTbl.helpers({
}
});
Template.locMgmtTbl.events([
]);
Template.locMgmtTbl.events({
'click .deleteLocation' (event) {
event.preventDefault();
Meteor.call('delete.location', this._id, function(err, result) {
if (err) {
console.log(" ERROR deleting location: " + err);
} else {
console.log(" SUCCESS deleting the location.");
}
});
},
'click .editLocation' (event) {
event.preventDefault();
Session.set("locEditMode", true);
Session.set("locEditId", this._id);
let locInfo = Locations.findOne({ _id: this._id });
$("#locNameInp").val(locInfo.locationName);
},
});

View file

@ -4,16 +4,13 @@
<ul class="collection with-header">
<li class="collection-header"><h4>Management</h4></li>
{{#if isInRole "systemadmin"}}
<li><a href="#!" id="userMgmt" class="collection-item">User Management</a></li>
<li class="collection-item" id="userMgmt">Users</li>
{{/if}}
<li><a href="#!" id="manageLists" class="collection-item">List</a></li>
<li><a href="#!" id="manageCategory" class="collection-item">Category</a></li>
<li><a href="#!" id="manageProduct" class="collection-item">Product</a></li>
<li><a href="#!" id="manageLocation" class="collection-item">Location</a></li>
<li><a href="#!" id="manageStore" class="collection-item">Store</a></li>
<li><a href="#!" id="manageCabinet" class="collection-item">Cabinet</a></li>
<li><a href="#!" id="manageShelf" class="collection-item">Shelf</a></li>
<li><a href="#!" id="manageBin" class="collection-item">Bin</a></li>
<li id="manageLists" class="collection-item">Lists</li>
<li id="manageProduct" class="collection-item">Product</li>
<li id="manageCategory" class="collection-item">Category</li>
<li id="manageLocation" class="collection-item">Location</li>
<li id="manageStore" class="collection-item">Store</li>
</ul>
</div>
</div>

View file

@ -1,51 +1,57 @@
<template name="prodMgmtForm">
<h4>Product Management</h4>
<div class="row">
<div class="col s12 m6 l6 input-field">
<input type="text" class="prodName" style="{{#if $eq prodNameErr true}}border: 2px solid red;{{/if}}" id="prodName" />
<label for="prodName">Name*</label>
<form action="submit" class="prodInputForm">
<div class="row">
<div class="col s12 m6 l6 input-field">
<input type="text" class="prodName" style="{{#if $eq prodNameErr true}}border: 2px solid red;{{/if}}" id="prodName" />
<label for="prodName">Name*</label>
</div>
<div class="col s12 m6 l6 input-field">
<select name="prodCategory" id="prodCategory" class="prodCategory">
<option value="" disabled selected></option>
{{#each category}}
<option value="{{categoryName}}">{{categoryName}}</option>
{{/each}}
<option id="addNewCategory" value="addNewCat">Add New Category</option>
</select>
<label for="prodCategory">Category</label>
</div>
</div>
<div class="col s12 m6 l6 input-field">
<select name="prodCategory" id="prodCategory" class="prodCategory">
<option value="" disabled selected></option>
{{#each category}}
<option value="{{categoryName}}">{{categoryName}}</option>
{{/each}}
<option id="addNewCategory" value="addNewCat">Add New Category</option>
</select>
<label for="prodCategory">Category</label>
<div class="row">
<div class="col s12 m6 l6 input-field">
<select name="prodStore" id="prodStore" class="prodStore">
<option value="" disabled selected></option>
{{#each stores}}
<option value="{{storeName}}">{{storeName}}</option>
{{/each}}
<option id="addNewStore" value="addNewStore">Add New Store</option>
</select>
<label for="prodStore">Store</label>
</div>
<div class="col s12 m6 l6 input-field">
<select name="prodLocation" id="prodLocation" class="prodLocation {{#if $eq darkmode true}}dark-mode{{/if}}">
<option value="" disabled selected></option>
{{#each locations}}
<option value="{{locationName}}">{{locationName}}</option>
{{/each}}
<option id="addNewLocation" value="addNewLocation">Add New Location</option>
</select>
<label for="prodLocation">Location</label>
</div>
</div>
</div>
<div class="row">
<div class="col s12 m6 l6 input-field">
<select name="prodStore" id="prodStore" class="prodStore">
<option value="" disabled selected></option>
{{#each stores}}
<option value="{{storeName}}">{{storeName}}</option>
{{/each}}
<option id="addNewStore" value="addNewStore">Add New Store</option>
</select>
<label for="prodStore">Store</label>
<div class="row">
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn cancelProdMgmt orange">Cancel</a>
</div>
<div class="col s6 m6 l6">
{{#if $eq prodEditMode false}}
<a class="waves-effect waves-light btn saveProdMgmt green right">Add</a>
{{else}}
<a class="waves-effect waves-light btn editProdMgmt blue right">Save Edits</a>
{{/if}}
</div>
</div>
<div class="col s12 m6 l6 input-field">
<select name="prodLocation" id="prodLocation" class="prodLocation {{#if $eq darkmode true}}dark-mode{{/if}}">
<option value="" disabled selected></option>
{{#each locations}}
<option value="{{locationName}}">{{locationName}}</option>
{{/each}}
<option id="addNewLocation" value="addNewLocation">Add New Location</option>
</select>
<label for="prodLocation">Location</label>
</div>
</div>
<div class="row">
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn cancelProdMgmt orange">Cancel</a>
</div>
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn saveProdMgmt green right">Add</a>
</div>
</div>
</form>
<!-- Store Modal Structure -->
<div id="modalStore" class="modal">

View file

@ -16,6 +16,7 @@ Template.prodMgmtForm.onRendered(function() {
}, 200);
$('select').formSelect();
$('.modal').modal();
Session.set("prodEditMode", false);
});
Template.prodMgmtForm.helpers({
@ -31,12 +32,15 @@ Template.prodMgmtForm.helpers({
locations: function() {
return Locations.find({});
},
prodEditMode: function() {
return Session.get("prodEditMode");
},
});
Template.prodMgmtForm.events({
'click .saveProdMgmt' (event) {
event.preventDefault();
let name=$("#prodName").val();
let name = $("#prodName").val();
let cat = $("#prodCategory").val();
let store = $("#prodStore").val();
let location = $("#prodLocation").val();
@ -66,16 +70,112 @@ Template.prodMgmtForm.events({
$("#prodCategory").val("");
$("#prodStore").val("");
$("#prodLocation").val("");
$('select').formSelect();
}
});
}
},
'click .editProdMgmt' (event) {
event.preventDefault();
let name = $("#prodName").val();
let cat = $("#prodCategory").val();
let store = $("#prodStore").val();
let location = $("#prodLocation").val();
let prodId = Session.get("prodEditId");
if (cat == null) {
cat = "";
}
if (location == null) {
location = "";
}
if (store == null) {
store = "";
}
if (name == "" || name == null) {
Session.set("prodNameRed", true);
return;
} else {
Meteor.call('edit.product', prodId, name, cat, store, location, function(err, result) {
if (err) {
// console.log(" ERROR: can't add product: " + err);
} else {
// console.log(" SUCCESS adding product.");
$("#prodName").val("");
$("#prodCategory").val("");
$("#prodStore").val("");
$("#prodLocation").val("");
$('select').formSelect();
}
});
}
},
'keypress form.prodInputForm' (event) {
// event.preventDefault();
if (event.which === 13) {
let name = $("#prodName").val();
let cat = $("#prodCategory").val();
let store = $("#prodStore").val();
let location = $("#prodLocation").val();
let prodId = Session.get("prodEditId");
let prodEditMode = Session.get("prodEditMode");
console.log(" ---- got the submit event for products.");
if (cat == null) {
cat = "";
}
if (location == null) {
location = "";
}
if (store == null) {
store = "";
}
if (name == "" || name == null) {
Session.set("prodNameRed", true);
return;
} else {
if (prodEditMode == true) {
Meteor.call('edit.product', prodId, name, cat, store, location, function(err, result) {
if (err) {
// console.log(" ERROR: can't add product: " + err);
} else {
// console.log(" SUCCESS adding product.");
$("#prodName").val("");
$("#prodCategory").val("");
$("#prodStore").val("");
$("#prodLocation").val("");
$('select').formSelect();
}
});
} else {
Meteor.call('add.product', name, cat, store, location, function(err, result) {
if (err) {
// console.log(" ERROR: can't add product: " + err);
} else {
// console.log(" SUCCESS adding product.");
$("#prodName").val("");
$("#prodCategory").val("");
$("#prodStore").val("");
$("#prodLocation").val("");
$('select').formSelect();
}
});
}
}
}
},
'click .cancelProdMgmt' (event) {
event.preventDefault();
$("#prodName").val("");
$("#prodCategory").val("");
$("#prodStore").val("");
$("#prodLocation").val("");
$('select').formSelect();
},
'change #prodStore' (event) {
event.preventDefault();

View file

@ -19,8 +19,8 @@
<td>{{prodStore}}</td>
<td>{{prodLocation}}</td>
<td>
<i class="material-icons clickable deleteProduct">delete</i>
<i class="material-icons clickable editProduct">edit</i>
<i class="material-icons clickable deleteProduct tooltipped" data-position="top" data-tooltip="Delete Product">delete</i>
<i class="material-icons clickable editProduct tooltipped" data-position="top" data-tooltip="Edit Product">edit</i>
</td>
</tr>
{{/each}}

View file

@ -5,7 +5,9 @@ Template.prodMgmtTbl.onCreated(function() {
});
Template.prodMgmtTbl.onRendered(function() {
Meteor.setTimeout(function() {
$('.tooltipped').tooltip();
}, 150);
});
Template.prodMgmtTbl.helpers({
@ -15,5 +17,25 @@ Template.prodMgmtTbl.helpers({
});
Template.prodMgmtTbl.events({
'click .deleteProduct' (event) {
event.preventDefault();
Meteor.call('delete.product', this._id, function(err, result) {
if (err) {
console.log(" ERROR deleting product: " + err);
} else {
console.log(" SUCCESS deleting the product.");
}
});
},
'click .editProduct' (event) {
event.preventDefault();
Session.set("prodEditMode", true);
Session.set("prodEditId", this._id);
let prodInfo = Products.findOne({ _id: this._id });
$("#prodName").val(prodInfo.prodName);
$("#prodCategory").val(prodInfo.prodCategory);
$("#prodLocation").val(prodInfo.prodLocation);
$("#prodStore").val(prodInfo.prodStore);
$('select').formSelect();
}
});

View file

@ -1,11 +1,8 @@
<template name="storeMgmt">
<!-- Store Management Entry / Edit -->
<h4>Store Management</h4>
<p>Add Stores you commonly make lists for here.</p>
{{> storeMgmtForm}}
<!-- Store Management Table List -->
<hr>
{{> storeMgmtTbl}}
<div class="container">
<h4>Store Management</h4>
{{> storeMgmtForm}}
<hr>
{{> storeMgmtTbl}}
</div>
</template>

View file

@ -1,20 +1,22 @@
<template name="storeMgmtForm">
<div class="row">
<div class="col s12 m6 l6 input-field">
<input type="text" class="storeName" id="storeName" />
<label for="storeName">Name</label>
<form id="storeForm" action="submit">
<div class="row">
<div class="col s12 input-field">
<input type="text" class="storeName" id="storeName" />
<label for="storeName">Name</label>
</div>
</div>
<div class="col s12 m6 l6 input-field">
<input type="text" class="storeType" id="storeType" />
<label for="storeType">Type</label>
<div class="row">
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn cancelStoreMgmt orange">Cancel</a>
</div>
<div class="col s6 m6 l6">
{{#if $eq editModeStore false}}
<a class="waves-effect waves-light btn saveStoreMgmt green right">Add</a>
{{else}}
<a class="waves-effect waves-light btn editStoreMgmt blue right">Rename</a>
{{/if}}
</div>
</div>
</div>
<div class="row">
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn cancelStoreMgmt orange">Cancel</a>
</div>
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn saveStoreMgmt green right">Add</a>
</div>
</div>
</form>
</template>

View file

@ -6,28 +6,83 @@ Template.storeMgmtForm.onCreated(function() {
Template.storeMgmtForm.onRendered(function() {
Session.set("borderRed", false);
Session.set("editModeStore", false);
});
Template.storeMgmtForm.helpers({
editModeStore: function() {
return Session.get("editModeStore");
}
});
Template.storeMgmtForm.events({
'click .saveStoreMgmt' (event) {
event.preventDefault();
let storeName = $("#storeName").val();
let storeType = $("#storeType").val();
if (storeName == "" || storeName == null) {
Session.set("borderRed", true);
return;
} else {
Meteor.call("add.store", storeName, storeType, function(err, result) {
Meteor.call("add.store", storeName, function(err, result) {
if (err) {
// console.log("ERROR: Store add failed: " + err);
} else {
// console.log("Success adding store!");
$("#storeName").val("");
$("#storeType").val("");
}
});
}
},
'click .cancelStoreMgmt' (event) {
event.preventDefault();
$("#storeName").val("");
Session.set("editModeStore", false);
},
'submit #storeForm' (event) {
event.preventDefault();
let editMode = Session.get("editModeStore");
let storeName = $("#storeName").val();
if (storeName == "" || storeName == null) {
Session.set("borderRed", true);
return;
} else {
if (editMode == false) {
Meteor.call("add.store", storeName, function(err, result) {
if (err) {
// console.log("ERROR: Store add failed: " + err);
} else {
// console.log("Success adding store!");
$("#storeName").val("");
}
});
} else {
let storeId = Session.get("storeIdEdit");
Meteor.call("edit.store", storeId, storeName, function(err, result) {
if (err) {
// console.log("ERROR: Store add failed: " + err);
} else {
// console.log("Success adding store!");
$("#storeName").val("");
Session.set("editModeStore", false);
}
});
}
}
},
'click .editStoreMgmt' (event) {
let storeName = $("#storeName").val();
let storeId = Session.get("storeIdEdit");
if (storeName == "" || storeName == null) {
Session.set("borderRed", true);
return;
} else {
Meteor.call("edit.store", storeId, storeName, function(err, result) {
if (err) {
// console.log("ERROR: Store add failed: " + err);
} else {
// console.log("Success adding store!");
$("#storeName").val("");
Session.set("editModeStore", false);
}
});
}

View file

@ -1,27 +1,15 @@
<template name="storeMgmtTbl">
<table class="highlight striped responsive-table">
<thead>
<tr>
<th>Store Name</th>
<th>Type</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{{#each mgmtStoreInfo}}
<tr>
<td>
<div class="row">
<div class="col s12">
<ul class="collection">
{{#each mgmtStoreInfo}}
<li class="collection-item">
{{storeName}}
</td>
<td>
{{storeType}}
</td>
<td>
<i class="material-icons clickable deleteStore">delete</i>
<i class="material-icons clickable editStore">edit</i>
</td>
</tr>
{{/each}}
</tbody>
</table>
<i class="material-icons clickable deleteStore right tooltipped" data-position="top" data-tooltip="Delete Store">delete</i>
<i class="material-icons clickable editStore right tooltipped" data-position="top" data-tooltip="Edit Store Name">edit</i>
</li>
{{/each}}
</ul>
</div>
</div>
</template>

View file

@ -5,7 +5,9 @@ Template.storeMgmtTbl.onCreated(function() {
});
Template.storeMgmtTbl.onRendered(function() {
Meteor.setTimeout(function() {
$('.tooltipped').tooltip();
}, 150);
});
Template.storeMgmtTbl.helpers({
@ -17,10 +19,19 @@ Template.storeMgmtTbl.helpers({
Template.storeMgmtTbl.events({
'click .deleteStore' (event) {
event.preventDefault();
// console.log("Delete Store Clicked");
Meteor.call('delete.store', this._id, function(err, result) {
if (err) {
console.log(" ERROR deleting store: " + err);
} else {
console.log(" SUCCESS deleting the store.");
}
});
},
'click .editStore' (event) {
event.preventDefault();
// console.log("Edit Store Clicked");
Session.set("storeIdEdit", this._id);
let storeInfo = Stores.findOne({ _id: this._id });
$("#storeName").val(storeInfo.storeName);
Session.set("editModeStore", true);
},
});

View file

@ -3,7 +3,7 @@
<div class="row">
{{#if isInRole 'systemadmin'}}
<div class="col s12 m6 l4">
<div class="card blue-grey darken-1">
<div class="card blue-grey darken-1" id="userInfoCard">
<div class="card-content white-text">
<span class="card-title"><h4>Users</h4></span>
<div class="row">
@ -12,13 +12,13 @@
</div>
</div>
<div class="card-action">
<a href="#" id="usermgmtlink">User Management</a>
<a href="#" class="cardLink" id="userMgmtLink">User Management</a>
</div>
</div>
</div>
{{/if}}
<div class="col s12 m6 l4">
<div class="card blue-grey darken-1">
<div class="card blue-grey darken-1" id="listInfoCard">
<div class="card-content white-text">
<span class="card-title"><h4>My Lists</h4></span>
<div class="row">
@ -26,15 +26,13 @@
<div class="col s4"><h2>{{listCount}}</h2></div>
</div>
</div>
{{#if isInRole 'systemadmin'}}
<div class="card-action">
<a href="#" id="usermgmtlink">List Management</a>
<a href="#" class="cardLink" id="listMgmtLink">List Management</a>
</div>
{{/if}}
</div>
</div>
<div class="col s12 m6 l4">
<div class="card blue-grey darken-1">
<div class="card blue-grey darken-1" id="prodInfoCard">
<div class="card-content white-text">
<span class="card-title"><h4>My Products</h4></span>
<div class="row">
@ -42,15 +40,13 @@
<div class="col s4"><h2>{{productCount}}</h2></div>
</div>
</div>
{{#if isInRole 'systemadmin'}}
<div class="card-action">
<a href="#" id="usermgmtlink">Product Management</a>
<a href="#" class="cardLink" id="prodMgmtLink">Product Management</a>
</div>
{{/if}}
</div>
</div>
<div class="col s12 m6 l4">
<div class="card blue-grey darken-1">
<div class="card blue-grey darken-1" id="storeInfoCard">
<div class="card-content white-text">
<span class="card-title"><h4>My Stores</h4></span>
<div class="row">
@ -58,15 +54,13 @@
<div class="col s4"><h2>{{storeCount}}</h2></div>
</div>
</div>
{{#if isInRole 'systemadmin'}}
<div class="card-action">
<a href="#" id="usermgmtlink">Store Management</a>
<a href="#" class="cardLink" id="storeMgmtLink">Store Management</a>
</div>
{{/if}}
</div>
</div>
<div class="col s12 m6 l4">
<div class="card blue-grey darken-1">
<div class="card blue-grey darken-1" id="catInfoCard">
<div class="card-content white-text">
<span class="card-title"><h4>My Categories</h4></span>
<div class="row">
@ -74,11 +68,23 @@
<div class="col s4"><h2>{{catCount}}</h2></div>
</div>
</div>
{{#if isInRole 'systemadmin'}}
<div class="card-action">
<a href="#" id="usermgmtlink">Category Management</a>
<a href="#" class="cardLink" id="catMgmtLink">Category Management</a>
</div>
</div>
</div>
<div class="col s12 m6 l4">
<div class="card blue-grey darken-1" id="locInfoCard">
<div class="card-content white-text">
<span class="card-title"><h4>My Locations</h4></span>
<div class="row">
<div class="col s8"><i class="medium material-icons">map</i></div>
<div class="col s4"><h2>{{locCount}}</h2></div>
</div>
</div>
<div class="card-action">
<a href="#" class="cardLink" id="locationMgmtLink">Location Management</a>
</div>
{{/if}}
</div>
</div>
</div>

View file

@ -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;
}
}
});

View file

@ -0,0 +1,34 @@
<template name="listItemsForm">
<div class="row">
<div class="col s6">
<h4>{{selListName}}</h4>
</div>
<div class="col s6">
<p>
<label>
<input type="checkbox" id="showReceivedItems" />
<span>Show Recv'd</span>
</label>
</p>
</div>
</div>
<div class="row">
<div class="col s9 m10 l10">
<input list="listItemsData" name="listItems" id="listItems">
<datalist id="listItemsData">
{{#each itemProdName}}
<option value="{{prodName}}">{{prodName}}</option>
{{/each}}
</datalist>
</div>
<div class="col s3 m2 l2">
{{#if $eq editMode false}}
<a class="waves-effect waves-light btn saveListItem green right">Add</a>
{{else}}
<a class="waves-effect waves-light btn renameListItem blue right">Rename</a>
{{/if}}
</div>
</div>
</template>

View file

@ -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);
}
}
});

View file

@ -0,0 +1,5 @@
<template name="listItemsMain">
{{> listItemsForm}}
<hr>
{{> listItemsTbl}}
</template>

View file

@ -0,0 +1,15 @@
Template.listItemsMain.onCreated(function() {
});
Template.listItemsMain.onRendered(function() {
});
Template.listItemsMain.helpers({
});
Template.listItemsMain.events({
});

View file

@ -0,0 +1,21 @@
<template name="listItemsTbl">
<div class="row">
<div class="col s12">
<ul class="collection">
{{#each thisListItems}}
<li class="collection-item">
<span>
{{#if $eq itemOrdered true}}
<strike>{{itemName}}</strike>
{{else}}
{{itemName}}
{{/if}}
</span>
<i class="material-icons clickable deleteListItem right">delete</i>
<i class="material-icons clickable markListItemReceived right">check</i>
</li>
{{/each}}
</ul>
</div>
</div>
</template>

View file

@ -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.");
}
});
}
});

View file

@ -0,0 +1,4 @@
<template name="listsMain">
<h4>My Lists</h4>
{{> listsTbl}}
</template>

16
client/Lists/listsMain.js Normal file
View file

@ -0,0 +1,16 @@
Template.listsMain.onCreated(function() {
});
Template.listsMain.onRendered(function() {
});
Template.listsMain.helpers({
});
Template.listsMain.events({
});

View file

@ -0,0 +1,26 @@
<template name="listsTbl">
<div class="row">
<div class="col s12">
<ul class="collection">
{{#each mylists}}
<li class="collection-item clickable" id="{{this._id}}">
<span class="{{#if $eq listShared true}}green-text{{/if}}">{{listName}}</span>
<i class="material-icons clickable markAsComplete right" id="check_{{this._id}}">check</i>
</li>
{{/each}}
<li class="collection-item clickable addNew" id="addList"> + Add New List</li>
</ul>
</div>
</div>
<!-- Modal for the Add List Option -->
<div id="modalList" class="modal">
<div class="modal-content">
<h4>Add New List</h4>
{{> listMgmtForm}}
</div>
<div class="modal-footer">
<a href="#!" class="modal-close waves-effect waves-green btn-flat">Done</a>
</div>
</div>
{{> snackbar}}
</template>

57
client/Lists/listsTbl.js Normal file
View file

@ -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");
}
});
}
}
});

View file

@ -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;
}

View file

@ -6,8 +6,11 @@
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="./lib/assets/materialize.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://kraaden.github.io/autocomplete/autocomplete.css">
<script type="text/javascript" src="./lib/assets/materialize.js"></script>
<script src="https://kraaden.github.io/autocomplete/autocomplete.js"></script>
</head>
<body>

View file

@ -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 });
}
});

View file

@ -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()
}
});;
}
});

View file

@ -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!");

View file

@ -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,
}
});
},

View file

@ -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' });
}
});

View file

@ -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});
});

View file

@ -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);
}
});