Fixed all known bugs; Modified the menu to hide; Fixed the tables to scroll with a fixed header.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user