Fixed all known bugs; Modified the menu to hide; Fixed the tables to scroll with a fixed header.

This commit is contained in:
Wynne Crisman
2017-10-20 14:54:58 -07:00
parent 83e8268375
commit f848ea9a8f
34 changed files with 1019 additions and 821 deletions

View File

@@ -8,7 +8,8 @@ import './Pricing.html';
* Because the structure of the Product object is so complicated, the normal checking that is done by the framework cannot be used.
*/
let QUERY_LIMIT = 20;
let QUERY_LIMIT = 100;
let QUERY_LIMIT_INCREMENT = 100;
let PREFIX = "Pricing.";
Meteor.subscribe("products");
@@ -24,14 +25,22 @@ Tracker.autorun(function() {
});
Template.Pricing.onCreated(function() {
Session.set(PREFIX + "queryLimit", QUERY_LIMIT);
});
Template.Pricing.onRendered(function() {
this.$('input[name="date"]').val(new Date().toDateInputValue());
// this>$('select[name="measures"]').val()
$(".tableContainer").mCustomScrollbar({
scrollButtons: {enable:true},
theme: "light-thick",
scrollbarPosition: "outside",
scrollEasing: "linear"
});
});
Template.Pricing.helpers({
measures: function() {
let measures = Meteor.collections.Measures.find({}, {sort: {order: 1}}).fetch();
let measures = Meteor.collections.Measures.find({$or: [{hidden: false}, {hidden: {$exists: false}}]}, {sort: {order: 1}}).fetch();
for(let i = 0; i < measures; i++) {
if(Meteor.collections.Products.find({measures: {$all: [measures[i]._id]}}, {sort: {name: 1}}).count() == 0)
@@ -46,18 +55,20 @@ Template.Pricing.helpers({
let dbQuery = {measures: {$all: [measureId]}, $or: [{hidden: false}, {hidden: {$exists:false}}]};
Session.set(PREFIX + 'productCount', Meteor.collections.Products.find(dbQuery).count()); //Always get a full count.
return Meteor.collections.Products.find(dbQuery, {limit: QUERY_LIMIT, skip: skipCount, sort: {name: 1}});
return Meteor.collections.Products.find(dbQuery, {limit: Session.get(PREFIX + "queryLimit"), skip: skipCount, sort: {name: 1}});
},
disablePrev: function() {
return (Session.get(PREFIX + 'skipCount') || 0) == 0;
},
disableNext: function() {
return Session.get(PREFIX + 'productCount') - (Session.get(PREFIX + 'skipCount') || 0) - QUERY_LIMIT <= 0;
disableLoadMore: function() {
return Session.get(PREFIX + 'productCount') - (Session.get(PREFIX + 'skipCount') || 0) - Session.get(PREFIX + "queryLimit") <= 0;
}
});
Template.Pricing.events({
'click .loadMoreLink': function(event, template) {
event.preventDefault();
Session.set(PREFIX + 'queryLimit', Session.get(PREFIX + "queryLimit") + QUERY_LIMIT_INCREMENT);
},
'change select[name="measures"]': function(event, template) {
Session.get(PREFIX + 'skipCount', 0);
Session.set(PREFIX + 'skipCount', 0);
Session.set(PREFIX + 'queryLimit', QUERY_LIMIT);
Session.set(PREFIX + "selectedMeasure", $(event.target).val());
},
'click .applyButton': function(event, template) {
@@ -95,14 +106,6 @@ Template.Pricing.events({
template.$('input.price').val(0);
template.$('input.date').val(new Date().toDateInputValue());
template.$('input[name="setPrevious"]').removeProp('checked');
},
'click .prevProducts': function(event, template) {
if(!$(event.target).hasClass('disabled'))
Session.set(PREFIX + 'skipCount', Math.max(0, (Session.get(PREFIX + 'skipCount') || 0) - QUERY_LIMIT));
},
'click .nextProducts': function(event, template) {
if(!$(event.target).hasClass('disabled'))
Session.set(PREFIX + 'skipCount', (Session.get(PREFIX + 'skipCount') || 0) + QUERY_LIMIT);
}
});