mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +00:00
Lots of changes and additions to the project. Still early, and not usable.
This commit is contained in:
parent
8636f8cf9b
commit
266dbd0856
41 changed files with 836 additions and 67 deletions
107
client/AdminMgmt/ProductMgmt/prodMgmtForm.js
Normal file
107
client/AdminMgmt/ProductMgmt/prodMgmtForm.js
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
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");
|
||||
this.subscribe("storeInfo");
|
||||
this.subscribe("myCategories");
|
||||
this.subscribe("myLocations");
|
||||
});
|
||||
|
||||
Template.prodMgmtForm.onRendered(function() {
|
||||
Meteor.setTimeout(function() {
|
||||
$('select').formSelect();
|
||||
}, 200);
|
||||
$('select').formSelect();
|
||||
$('.modal').modal();
|
||||
});
|
||||
|
||||
Template.prodMgmtForm.helpers({
|
||||
stores: function() {
|
||||
return Stores.find({});
|
||||
},
|
||||
prodNameErr: function() {
|
||||
return Session.get("prodNameRed");
|
||||
},
|
||||
category: function() {
|
||||
return Categories.find({});
|
||||
},
|
||||
locations: function() {
|
||||
return Locations.find({});
|
||||
},
|
||||
});
|
||||
|
||||
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 = "";
|
||||
}
|
||||
|
||||
if (name == "" || name == null) {
|
||||
Session.set("prodNameRed", true);
|
||||
return;
|
||||
} 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.");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
'click .cancelProdMgmt' (event) {
|
||||
event.preventDefault();
|
||||
$("#prodName").val("");
|
||||
$("#prodCategory").val("");
|
||||
$("#prodStore").val("");
|
||||
$("#prodLocation").val("")
|
||||
},
|
||||
'change #prodStore' (event) {
|
||||
event.preventDefault();
|
||||
let val = $("#prodStore").val();
|
||||
|
||||
if (val == "addNewStore") {
|
||||
$("#prodStore").val("");
|
||||
// open a modal to enter store information.
|
||||
$('#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 == "addNewCategory") {
|
||||
$("#prodCategory").val("");
|
||||
// open a modal to enter store information.
|
||||
$('#modalCategory').modal('open');
|
||||
}
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue