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

@@ -354,6 +354,40 @@ Template.SalesSheetEditorConfigurationRow.onCreated(function() {
template.$('.product .name').text(name);
template.$('.product .nameEditor, .product .name').removeClass('edit');
};
this.handleHeadingSort = function(event) {
let width = event.currentTarget.offsetWidth;
let x = event.pageX - event.currentTarget.offsetLeft;
let sortAlphabetical = x <= (width / 2);
let headingIndex = template.$(event.target).closest(".heading").index();
let firstIndex = headingIndex + 1;
let products = template.parentTemplate(1).salesSheet.products;
let length = 0;
while(firstIndex + length < products.length && products[firstIndex + length].productId) {
length++;
}
//Sort the part of the array that contains products under the sorted heading.
products.partialSort(firstIndex, length, function(a, b) {
return sortAlphabetical ? (a.name < b.name ? -1 : 1) : (a.name > b.name ? -1 : 1);
});
//Notify anything depending on the products list that they have been modified.
template.parentTemplate(1).productsDependency.changed();
};
});
Template.SalesSheetEditorConfigurationRow.onRendered(function() {
let template = this;
Tracker.autorun(function() {
let data = Blaze.getData(template.view);
template.parentTemplate(1).productsDependency.depend();
if(data) {
template.$('.heading .name, .product .name').text(data.name);
}
});
});
Template.SalesSheetEditorConfigurationRow.helpers({
measureName: function(measureId) {
@@ -436,24 +470,6 @@ Template.SalesSheetEditorConfigurationRow.events({
this.measureIds.add(measureId);
},
'click .heading .sort': function(event, template) {
let width = event.currentTarget.offsetWidth;
let x = event.pageX - event.currentTarget.offsetLeft;
let sortAlphabetical = x <= (width / 2);
let headingIndex = template.$(event.target).closest(".heading").index();
let firstIndex = headingIndex + 1;
let products = template.parentTemplate(1).salesSheet.products;
let length = 0;
while(firstIndex + length < products.length && products[firstIndex + length].productId) {
length++;
}
//Sort the part of the array that contains products under the sorted heading.
products.partialSort(firstIndex, length, function(a, b) {
return sortAlphabetical ? (a.name < b.name ? -1 : 1) : (a.name > b.name ? -1 : 1);
});
//Notify anything depending on the products list that they have been modified.
template.parentTemplate(1).productsDependency.changed();
template.handleHeadingSort(event);
}
});