mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +00:00
Updated product management to use newer materialize libraries
This commit is contained in:
parent
df3eb4ff08
commit
27b3c82faf
7 changed files with 65 additions and 83 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { Products } from '../../../imports/api/products.js';
|
||||
import { Stores } from '../../../imports/api/stores.js';
|
||||
import { M } from '../../lib/assets/materialize.js';
|
||||
|
||||
Template.prodMgmtForm.onCreated(function() {
|
||||
this.subscribe("myProducts");
|
||||
|
|
@ -7,11 +8,14 @@ Template.prodMgmtForm.onCreated(function() {
|
|||
});
|
||||
|
||||
Template.prodMgmtForm.onRendered(function() {
|
||||
Meteor.setTimeout(function() {
|
||||
$('select').formSelect();
|
||||
setTimeout(function() {
|
||||
var elems = document.querySelectorAll('select');
|
||||
var instances = M.FormSelect.init(elems, {});
|
||||
}, 200);
|
||||
$('select').formSelect();
|
||||
$('.modal').modal();
|
||||
|
||||
var elemm = document.querySelectorAll('.modal');
|
||||
var instancem = M.Modal.init(elemm, {});
|
||||
|
||||
Session.set("prodEditMode", false);
|
||||
});
|
||||
|
||||
|
|
@ -43,12 +47,12 @@ Template.prodMgmtForm.events({
|
|||
} else {
|
||||
Meteor.call('add.product', name, store, function(err, result) {
|
||||
if (err) {
|
||||
// console.log(" ERROR: can't add product: " + err);
|
||||
console.log(" ERROR: can't add product: " + err);
|
||||
} else {
|
||||
// console.log(" SUCCESS adding product.");
|
||||
$("#prodName").val("");
|
||||
$("#prodStore").val("");
|
||||
$('select').formSelect();
|
||||
let elemse = document.querySelectorAll('select');
|
||||
let instancese = M.FormSelect.init(elemse, {});
|
||||
showSnackbar("Succesffuly Added Product!", "green");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -71,11 +75,9 @@ Template.prodMgmtForm.events({
|
|||
if (err) {
|
||||
// console.log(" ERROR: can't add product: " + err);
|
||||
} else {
|
||||
// console.log(" SUCCESS adding product.");
|
||||
$("#prodName").val("");
|
||||
$("#prodStore").val("");
|
||||
$('select').formSelect();
|
||||
Session.set("prodEditMode", false);
|
||||
showSnackbar("Product Edited Successfully!", "green");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -87,7 +89,7 @@ Template.prodMgmtForm.events({
|
|||
let store = $("#prodStore").val();
|
||||
let prodId = Session.get("prodEditId");
|
||||
let prodEditMode = Session.get("prodEditMode");
|
||||
console.log(" ---- got the submit event for products.");
|
||||
// console.log(" ---- got the submit event for products.");
|
||||
|
||||
if (store == null) {
|
||||
store = "";
|
||||
|
|
@ -100,46 +102,38 @@ Template.prodMgmtForm.events({
|
|||
if (prodEditMode == true) {
|
||||
Meteor.call('edit.product', prodId, name, store, function(err, result) {
|
||||
if (err) {
|
||||
// console.log(" ERROR: can't add product: " + err);
|
||||
console.log(" ERROR: can't add product: " + err);
|
||||
} else {
|
||||
// console.log(" SUCCESS adding product.");
|
||||
$("#prodName").val("");
|
||||
$("#prodStore").val("");
|
||||
$('select').formSelect();
|
||||
showSnackbar("Successfully Edited Product!", "green");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Meteor.call('add.product', name, store, function(err, result) {
|
||||
if (err) {
|
||||
// console.log(" ERROR: can't add product: " + err);
|
||||
console.log(" ERROR: can't add product: " + err);
|
||||
} else {
|
||||
// console.log(" SUCCESS adding product.");
|
||||
$("#prodName").val("");
|
||||
$("#prodStore").val("");
|
||||
$('select').formSelect();
|
||||
showSnackbar("Product Added Succssfully!", "green");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'click .cancelProdMgmt' (event) {
|
||||
event.preventDefault();
|
||||
$("#prodName").val("");
|
||||
$("#prodStore").val("");
|
||||
$('select').formSelect();
|
||||
},
|
||||
'change #prodStore' (event) {
|
||||
event.preventDefault();
|
||||
// event.preventDefault();
|
||||
console.log("detected event");
|
||||
let val = $("#prodStore").val();
|
||||
console.log("Value detected: " + val);
|
||||
|
||||
if (val == "addNewStore") {
|
||||
console.log("got the request for modal.");
|
||||
$("#prodStore").val("");
|
||||
// open a modal to enter store information.
|
||||
$('#modalStore').modal('open');
|
||||
// open modal to add a new store
|
||||
let elemmm = document.getElementById('modalStore');
|
||||
let storeModal = M.Modal.getInstance(elemmm);
|
||||
storeModal.open();
|
||||
}
|
||||
},
|
||||
'click .modal-close' (event) {
|
||||
$('select').formSelect();
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue