Added custom scroll bars and separated the table header from the tables for Sales and the Graphs tables.

This commit is contained in:
Wynne Crisman
2017-10-08 08:56:15 -07:00
parent 210517a5c2
commit b5ac9fd249
44 changed files with 4939 additions and 245 deletions

View File

@@ -72,6 +72,7 @@ Template.Products.events({
else {
Session.set(PREFIX + 'displayNewProduct', true);
Session.set(PREFIX + "editedProduct", undefined); //Clear the edited product so that only one editor is open at a time.
Session.set(PREFIX + "convertedProduct", undefined); //Clear the converted product so that only one editor is open at a time.
}
template.$('.newProductButton').toggleClass('active');
},
@@ -166,6 +167,11 @@ Template.Product.helpers({
return editedProduct == this._id;
},
converting: function() {
let convertedProduct = Session.get(PREFIX + "convertedProduct");
return convertedProduct == this._id;
},
getRowClass: function() {
return this.hidden ? "hidden" : this.deactivated ? "deactivated" : "";
}
@@ -174,9 +180,10 @@ Template.Product.events({
"click .actionEdit": function(event, template) {
Session.set(PREFIX + "editedProduct", this._id);
Session.set(PREFIX + 'displayNewProduct', false); //Ensure the new product editor is closed.
Session.set(PREFIX + "convertedProduct", undefined); //Clear the converted product so that only one editor is open at a time.
template.$('.newProductButton').removeClass('active');
},
"click .actionRemove": function(event, template) {
"click .actionDeactivate": function(event, template) {
Meteor.call('deactivateProduct', this._id, function(error, result) {
if(error) sAlert.error(error);
else sAlert.success("Product Deactivated");
@@ -194,6 +201,12 @@ Template.Product.events({
else sAlert.success("Product Visibility Enabled");
});
},
"click .actionConvert": function(event, template) {
Session.set(PREFIX + "convertedProduct", this._id);
Session.set(PREFIX + 'displayNewProduct', false); //Ensure the new product editor is closed.
Session.set(PREFIX + "editedProduct", undefined); //Clear the edited product so that only one editor is open at a time.
template.$('.newProductButton').removeClass('active');
},
'click .actionHide': function(event, template) {
Meteor.call('hideProduct', this._id, function(error, result) {
if(error) sAlert.error(error);
@@ -268,4 +281,35 @@ Template.ProductEditor.events({
});
}
}
});
Template.ConvertProduct.onCreated(function() {
this.selectedProduct = new ReactiveVar();
});
Template.ConvertProduct.onRendered(function() {
this.$('[name="product"]').buildCombo({cursor: Meteor.collections.Products.find({$or: [{hidden: false}, {hidden: {$exists:false}}]}), selection: this.selectedProduct, textAttr: 'name', listClass: 'comboList', getClasses: function(data) {
return (data && data.deactivated) ? "deactivated" : "";
}});
});
Template.ConvertProduct.events({
"click .editorCancel": function(event, template) {
Session.set(PREFIX + "editedProduct", undefined);
Session.set(PREFIX + "convertedProduct", undefined);
Session.set(PREFIX + 'displayNewProduct', false);
template.parentTemplate().$('.newProductButton').removeClass('active');
},
"click .editorApply": function(event, template) {
let productId = template.selectedProduct.get()._id;
Meteor.call("convertProduct", this._id, productId, function(error, result) {
if(error) sAlert.error(error);
else {
sAlert.success("Sales of this product were converted.");
Session.set(PREFIX + "editedProduct", undefined);
Session.set(PREFIX + "convertedProduct", undefined);
Session.set(PREFIX + 'displayNewProduct', false);
template.parentTemplate().$('.newProductButton').removeClass('active');
}
});
}
});