mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +00:00
dev work on menu to prod link
This commit is contained in:
parent
01ae220674
commit
9abb198e82
7 changed files with 163 additions and 3 deletions
51
client/MenuItems/modalLinkProducts.js
Normal file
51
client/MenuItems/modalLinkProducts.js
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import { M } from '../lib/assets/materialize.js';
|
||||
import { Products } from '../../imports/api/products.js';
|
||||
import { MenuItems } from '../../imports/api/menuItems';
|
||||
import { MenuProdLinks } from '../../imports/api/menuProdLinks.js';
|
||||
|
||||
Template.modalLinkProducts.onCreated(function() {
|
||||
this.subscribe("myMenuItems");
|
||||
this.subscribe("myProducts");
|
||||
this.subscribe("menuProdLinkData");
|
||||
});
|
||||
|
||||
Template.modalLinkProducts.onRendered(function() {
|
||||
var elems = document.querySelectorAll('.modal');
|
||||
var instances = M.Modal.init(elems, {});
|
||||
|
||||
var elemse = document.querySelectorAll('select');
|
||||
var instancese = M.FormSelect.init(elemse, {
|
||||
dropdownOptions: 4,
|
||||
});
|
||||
|
||||
setTimeout(function() {
|
||||
var instances = M.Modal.init(elems, {});
|
||||
var instancese = M.FormSelect.init(elemse, {
|
||||
dropdownOptions: 4,
|
||||
});
|
||||
}, 250);
|
||||
});
|
||||
|
||||
Template.modalLinkProducts.helpers({
|
||||
products: function() {
|
||||
return Products.find({});
|
||||
}
|
||||
});
|
||||
|
||||
Template.modalLinkProducts.events({
|
||||
'click #saveLink' (event) {
|
||||
event.preventDefault();
|
||||
let menuItemId = Session.get("menuItemId");
|
||||
let linkSelect = document.getElementById('prodForMenu');
|
||||
let links = M.FormSelect.getInstance(linkSelect).getSelectedValues();
|
||||
if (typeof links != undefined && links != [] && links != null) {
|
||||
Meteor.call("add.menuProdLinks", menuItemId, links, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR adding product links to this menu item: " + err);
|
||||
} else {
|
||||
showSnackbar("Products added to Menu Item successfully!", "green");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue