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

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