mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +00:00
Many chcanges, but version 0.1.0 is ready to be cut.
This commit is contained in:
parent
42643a37f5
commit
6e37ae8c74
46 changed files with 1038 additions and 273 deletions
|
|
@ -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">
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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}}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue