Added a Sales Sheet page along with other changes.

This commit is contained in:
Wynne Crisman
2017-05-09 13:51:26 -07:00
parent 184ce1133f
commit e1b0b19589
39 changed files with 3581 additions and 5610 deletions

View File

@@ -199,11 +199,31 @@
if(this.$hidden && _this.$hidden.val()) {
hiddenInputChanged();
}
//TODO: Should probably check to ensure comparator is a function? Not that it will help much if the function is not written correctly. Stupid Javascript!
if(this.options.selection && this.options.comparator) {
Tracker.autorun(function() {
let selectedData = this.options.selection.get();
if(selectedData) {
let listItems = this.$list.children();
let found = false;
for(let i = 0; !found && i < listItems.length; i++) {
if(this.options.comparator($(listItems[i]).data('model'), selectedData)) {
found = true;
this.select($(listItems[i]));
}
}
}
}.bind(this));
}
};
Combo.DEFAULTS = {
cursor: undefined, //A meteor Cursor.
selection: undefined, //A meteor ReactiveVar whose value will be set to the current selection.
comparator: undefined, //A function that takes two collection objects and compares them for equality. If the combo shows users for example, this comparator would compare one user id to another. Required for the combo to set the selection if the view changes it externally relative to this combo.
textAttr: 'text', //The attribute of the data elements to use for the name. This can also be a function that takes the data object and returns the text.
idAttr: 'id', //The attribute of the data elements to use for the ID. This can also be a function that takes the data obejct and returns the ID.
// groupFunctions: The object containing three functions: 'groupParent', 'parentText', 'children'.
@@ -222,7 +242,7 @@
Combo.prototype.select = function($li) {
if($li.length == 0) {
if(this.$input.val() != '') {
this.$input.val("")
this.$input.val("");
if(this.$hidden) this.$hidden.val(undefined).change();
this.filter();
//Note: Don't trigger the select event - for some reason it causes the dropdown to reopen and the control to retain focus when clicking out of the widget.
@@ -242,13 +262,17 @@
this.filter();
//this.trigger('select', $li);
//Set the reactive var for the selection if one is provided.
if(this.options.selection) {
//Set the reactive var for the selection if one is provided and the selection has changed relative to the model.
if(this.options.selection && this.options.selection.get() != $li.data('model')) {
this.options.selection.set($li.data('model'));
}
}
}
};
Combo.prototype.escapeRegex = function(s) {
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
};
//Filters the list items by marking those that match the text in the text field as having the class 'visible'.
Combo.prototype.filter = function() {
@@ -273,7 +297,7 @@
if(searches) {
for(let i = 0; i < searches.length; i++) {
regexs.push(new RegExp("\\b" + searches[i]));
regexs.push(new RegExp("\\b" + this.escapeRegex(searches[i])));
}
}