Removed Categories and Locations

This commit is contained in:
Brian McGonagill 2024-07-06 11:13:35 -05:00
parent c916c278a2
commit 2b1022f513
23 changed files with 4 additions and 637 deletions

View file

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

View file

@ -1,17 +0,0 @@
import { Categories } from '../../../imports/api/category.js';
Template.catMgmt.onCreated(function() {
this.subscribe("myCategories");
});
Template.catMgmt.onRendered(function() {
});
Template.catMgmt.helpers({
});
Template.catMgmt.events({
});

View file

@ -1,17 +0,0 @@
<template name="catMgmtForm">
<form action="submit" id="catInputForm">
<div class="row">
<div class="col s8 m10 l10 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 class="col s4 m2 l2 input-field">
{{#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>
</form>
</template>

View file

@ -1,95 +0,0 @@
import { Categories } from '../../../imports/api/category.js';
Template.catMgmtForm.onCreated(function() {
this.subscribe("myCategories");
});
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({
'click .saveCatMgmt' (event) {
event.preventDefault();
let catName = $("#catNameInp").val();
if (catName == null || catName == "") {
Session.set("catNameMiss", true);
return;
} else {
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("");
}
});
}
},
'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

@ -1,16 +0,0 @@
<template name="catMgmtTbl">
<div class="row">
<div class="col s12">
<ul class="collection">
{{#each cats}}
<li class="collection-item">
{{categoryName}}
<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>
</div>
</div>
{{> deleteConfirmationModal}}
</template>

View file

@ -1,35 +0,0 @@
import { Categories } from '../../../imports/api/category.js';
Template.catMgmtTbl.onCreated(function() {
this.subscribe("myCategories");
});
Template.catMgmtTbl.onRendered(function() {
Meteor.setTimeout(function() {
$('.tooltipped').tooltip();
}, 150);
});
Template.catMgmtTbl.helpers({
cats: function() {
return Categories.find({});
}
});
Template.catMgmtTbl.events({
'click .deleteCategory' (event) {
event.preventDefault();
Session.set("deleteId", this._id);
Session.set("method", "delete.category");
Session.set("item", this.categoryName);
Session.set("view", "Categories");
$('#modalDelete').modal('open');
},
'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

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

View file

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

View file

@ -1,17 +0,0 @@
<template name="locMgmtForm">
<form action="" id="locInputForm">
<div class="row">
<div class="col s8 m10 l10 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 class="col s4 m2 l2 input-field">
{{#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>
</form>
</template>

View file

@ -1,95 +0,0 @@
import { Locations } from '../../../imports/api/location.js';
Template.locMgmtForm.onCreated(function() {
this.subscribe("myLocations");
});
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({
'click .saveLocMgmt' (event) {
event.preventDefault();
let locName = $("#locNameInp").val();
if (locName == null || locName == "") {
Session.set("locNameMiss", true);
return;
} else {
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("");
}
});
}
},
'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,16 +0,0 @@
<template name="locMgmtTbl">
<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>
{{> deleteConfirmationModal}}
</template>

View file

@ -1,35 +0,0 @@
import { Locations } from '../../../imports/api/location.js';
Template.locMgmtTbl.onCreated(function() {
this.subscribe("myLocations");
});
Template.locMgmtTbl.onRendered(function() {
Meteor.setTimeout(function() {
$('.tooltipped').tooltip();
}, 150);
});
Template.locMgmtTbl.helpers({
locs: function() {
return Locations.find({});
}
});
Template.locMgmtTbl.events({
'click .deleteLocation' (event) {
event.preventDefault();
Session.set("deleteId", this._id);
Session.set("method", "delete.location");
Session.set("item", this.locationName);
Session.set("view", "Locations");
$('#modalDelete').modal('open');
},
'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

@ -6,18 +6,6 @@
<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="row">
<div class="col s12 m6 l6 input-field">
<select name="prodStore" id="prodStore" class="prodStore">
<option value="" disabled selected></option>
@ -28,16 +16,6 @@
</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 class="row">
<div class="col s6 m6 l6">
@ -63,26 +41,4 @@
<a href="#!" class="modal-close waves-effect waves-green btn-flat">Done</a>
</div>
</div>
<!-- Location Modal Structure -->
<div id="modalLocation" class="modal">
<div class="modal-content">
<h4>Add New Location</h4>
{{> locMgmtForm}}
</div>
<div class="modal-footer">
<a href="#!" class="modal-close waves-effect waves-green btn-flat">Done</a>
</div>
</div>
<!-- Category Modal Structure -->
<div id="modalCategory" class="modal">
<div class="modal-content">
<h4>Add New Category</h4>
{{> catMgmtForm}}
</div>
<div class="modal-footer">
<a href="#!" class="modal-close waves-effect waves-green btn-flat">Done</a>
</div>
</div>
</template>

View file

@ -1,7 +1,5 @@
import { Products } from '../../../imports/api/products.js';
import { Stores } from '../../../imports/api/stores.js';
import { Categories } from '../../../imports/api/category.js';
import { Locations } from '../../../imports/api/location.js';
Template.prodMgmtForm.onCreated(function() {
this.subscribe("myProducts");
@ -26,12 +24,6 @@ Template.prodMgmtForm.helpers({
prodNameErr: function() {
return Session.get("prodNameRed");
},
category: function() {
return Categories.find({});
},
locations: function() {
return Locations.find({});
},
prodEditMode: function() {
return Session.get("prodEditMode");
},
@ -41,17 +33,7 @@ Template.prodMgmtForm.events({
'click .saveProdMgmt' (event) {
event.preventDefault();
let name = $("#prodName").val();
let cat = $("#prodCategory").val();
let store = $("#prodStore").val();
let location = $("#prodLocation").val();
if (cat == null) {
cat = "";
}
if (location == null) {
location = "";
}
if (store == null) {
store = "";
@ -61,15 +43,13 @@ Template.prodMgmtForm.events({
Session.set("prodNameRed", true);
return;
} else {
Meteor.call('add.product', name, cat, store, location, function(err, result) {
Meteor.call('add.product', name, store, 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();
}
});
@ -78,8 +58,7 @@ Template.prodMgmtForm.events({
'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");
@ -105,9 +84,7 @@ Template.prodMgmtForm.events({
} else {
// console.log(" SUCCESS adding product.");
$("#prodName").val("");
$("#prodCategory").val("");
$("#prodStore").val("");
$("#prodLocation").val("");
$('select').formSelect();
Session.set("prodEditMode", false);
}
@ -118,9 +95,7 @@ Template.prodMgmtForm.events({
// 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.");
@ -147,9 +122,7 @@ Template.prodMgmtForm.events({
} else {
// console.log(" SUCCESS adding product.");
$("#prodName").val("");
$("#prodCategory").val("");
$("#prodStore").val("");
$("#prodLocation").val("");
$('select').formSelect();
}
});
@ -160,9 +133,7 @@ Template.prodMgmtForm.events({
} else {
// console.log(" SUCCESS adding product.");
$("#prodName").val("");
$("#prodCategory").val("");
$("#prodStore").val("");
$("#prodLocation").val("");
$('select').formSelect();
}
});
@ -173,9 +144,7 @@ Template.prodMgmtForm.events({
'click .cancelProdMgmt' (event) {
event.preventDefault();
$("#prodName").val("");
$("#prodCategory").val("");
$("#prodStore").val("");
$("#prodLocation").val("");
$('select').formSelect();
},
'change #prodStore' (event) {
@ -188,26 +157,6 @@ Template.prodMgmtForm.events({
$('#modalStore').modal('open');
}
},
'change #prodLocation' (event) {
event.preventDefault();
let val = $("#prodLocation").val();
if (val == "addNewLocation") {
$("#prodLocation").val("");
// open a modal to enter store information.
$('#modalLocation').modal('open');
}
},
'change #prodCategory' (event) {
event.preventDefault();
let val = $("#prodCategory").val();
if (val == "addNewCat") {
$("#prodCategory").val("");
// open a modal to enter store information.
$('#modalCategory').modal('open');
}
},
'click .modal-close' (event) {
$('select').formSelect();
}

View file

@ -13,9 +13,7 @@
</div>
{{/if}}
</th>
<th>Category</th>
<th>Store</th>
<th>Location</th>
<th>Actions</th>
</tr>
</thead>
@ -23,9 +21,7 @@
{{#each products}}
<tr>
<td>{{prodName}} </td>
<td>{{prodCategory}}</td>
<td>{{prodStore}}</td>
<td>{{prodLocation}}</td>
<td>
<i class="material-icons clickable deleteProduct">delete</i>
<i class="material-icons clickable editProduct">edit</i>

View file

@ -40,8 +40,6 @@ Template.prodMgmtTbl.events({
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();
},